新手上路
- 积分
- 45
- 金钱
- 45
- 注册时间
- 2017-10-25
- 在线时间
- 16 小时
|
发表于 2021-3-2 15:30:05
|
显示全部楼层
本帖最后由 副国级 于 2021-3-2 15:32 编辑
static int really_probe(struct device *dev, struct device_driver *drv)
{
int ret = -EPROBE_DEFER;
int local_trigger_count = atomic_read(&deferred_trigger_count);
bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
!drv->suppress_bind_attrs;
if (defer_all_probes) {
/*
* Value of defer_all_probes can be set only by
* device_block_probing() which, in turn, will call
* wait_for_device_probe() right after that to avoid any races.
*/
dev_dbg(dev, "Driver %s force probe deferral\n", drv->name);
driver_deferred_probe_add(dev);
return ret;
}
ret = device_links_check_suppliers(dev);
if (ret == -EPROBE_DEFER)
driver_deferred_probe_add_trigger(dev, local_trigger_count);
if (ret)
return ret;
atomic_inc(&probe_count);
pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
drv->bus->name, __func__, drv->name, dev_name(dev));
if (!list_empty(&dev->devres_head)) {
dev_crit(dev, "Resources present before probing\n");
ret = -EBUSY;
goto done;
}
re_probe:
dev->driver = drv;
/* If using pinctrl, bind pins now before probing */
ret = pinctrl_bind_pins(dev);//这里对pin进行配置
.................
}
int pinctrl_bind_pins(struct device *dev)
{
int ret;
if (dev->of_node_reused)
return 0;
dev->pins = devm_kzalloc(dev, sizeof(*(dev->pins)), GFP_KERNEL);//创建叫pins的dev_info结构体
//struct dev_pin_info {
// struct pinctrl *p;
// struct pinctrl_state *default_state;
// struct pinctrl_state *init_state;
//#ifdef CONFIG_PM
// struct pinctrl_state *sleep_state;
// struct pinctrl_state *idle_state;
//#endif
//};
dev->pins->p = devm_pinctrl_get(dev);//每个节点自己的pinctrl创建
//struct pinctrl *devm_pinctrl_get(struct device *dev)
//{
// struct pinctrl **ptr, *p;
// ptr = devres_alloc(devm_pinctrl_release, sizeof(*ptr), GFP_KERNEL);
// if (!ptr)
// return ERR_PTR(-ENOMEM);
// p = pinctrl_get(dev);
//.....
//}
if (IS_ERR(dev->pins->p)) {
dev_dbg(dev, "no pinctrl handle\n");
ret = PTR_ERR(dev->pins->p);
goto cleanup_alloc;
}
//下面就是寻找对应的"default“这些配置去设置了
dev->pins->default_state = pinctrl_lookup_state(dev->pins->p,
PINCTRL_STATE_DEFAULT);
if (IS_ERR(dev->pins->default_state)) {
dev_dbg(dev, "no default pinctrl state\n");
ret = 0;
goto cleanup_get;
}
dev->pins->init_state = pinctrl_lookup_state(dev->pins->p,
PINCTRL_STATE_INIT);
if (IS_ERR(dev->pins->init_state)) {
/* Not supplying this state is perfectly legal */
dev_dbg(dev, "no init pinctrl state\n");
ret = pinctrl_select_state(dev->pins->p,
dev->pins->default_state);
} else {
ret = pinctrl_select_state(dev->pins->p, dev->pins->init_state);
}
if (ret) {
dev_dbg(dev, "failed to activate initial pinctrl state\n");
goto cleanup_get;
}
|
|