Lines Matching full:dev
37 struct udevice *dev; in device_bind_common() local
52 dev = calloc(1, sizeof(struct udevice)); in device_bind_common()
53 if (!dev) in device_bind_common()
56 INIT_LIST_HEAD(&dev->sibling_node); in device_bind_common()
57 INIT_LIST_HEAD(&dev->child_head); in device_bind_common()
58 INIT_LIST_HEAD(&dev->uclass_node); in device_bind_common()
60 INIT_LIST_HEAD(&dev->devres_head); in device_bind_common()
62 dev->platdata = platdata; in device_bind_common()
63 dev->driver_data = driver_data; in device_bind_common()
64 dev->name = name; in device_bind_common()
65 dev->node = node; in device_bind_common()
66 dev->parent = parent; in device_bind_common()
67 dev->driver = drv; in device_bind_common()
68 dev->uclass = uc; in device_bind_common()
70 dev->seq = -1; in device_bind_common()
71 dev->req_seq = -1; in device_bind_common()
82 dev_read_alias_seq(dev, &dev->req_seq); in device_bind_common()
92 dev->flags |= DM_FLAG_OF_PLATDATA; in device_bind_common()
99 dev->flags |= DM_FLAG_ALLOC_PDATA; in device_bind_common()
100 dev->platdata = calloc(1, in device_bind_common()
102 if (!dev->platdata) { in device_bind_common()
107 memcpy(dev->platdata, platdata, in device_bind_common()
115 dev->flags |= DM_FLAG_ALLOC_UCLASS_PDATA; in device_bind_common()
116 dev->uclass_platdata = calloc(1, size); in device_bind_common()
117 if (!dev->uclass_platdata) { in device_bind_common()
130 dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA; in device_bind_common()
131 dev->parent_platdata = calloc(1, size); in device_bind_common()
132 if (!dev->parent_platdata) { in device_bind_common()
139 /* put dev into parent's successor list */ in device_bind_common()
141 list_add_tail(&dev->sibling_node, &parent->child_head); in device_bind_common()
143 ret = uclass_bind_device(dev); in device_bind_common()
149 ret = drv->bind(dev); in device_bind_common()
154 ret = parent->driver->child_post_bind(dev); in device_bind_common()
159 ret = uc->uc_drv->post_bind(dev); in device_bind_common()
165 pr_debug("Bound device %s to %s\n", dev->name, parent->name); in device_bind_common()
167 *devp = dev; in device_bind_common()
169 dev->flags |= DM_FLAG_BOUND; in device_bind_common()
177 if (drv->unbind && drv->unbind(dev)) { in device_bind_common()
178 dm_warn("unbind() method failed on dev '%s' on error path\n", in device_bind_common()
179 dev->name); in device_bind_common()
185 if (uclass_unbind_device(dev)) { in device_bind_common()
186 dm_warn("Failed to unbind dev '%s' on error path\n", in device_bind_common()
187 dev->name); in device_bind_common()
192 list_del(&dev->sibling_node); in device_bind_common()
193 if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) { in device_bind_common()
194 free(dev->parent_platdata); in device_bind_common()
195 dev->parent_platdata = NULL; in device_bind_common()
199 if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) { in device_bind_common()
200 free(dev->uclass_platdata); in device_bind_common()
201 dev->uclass_platdata = NULL; in device_bind_common()
204 if (dev->flags & DM_FLAG_ALLOC_PDATA) { in device_bind_common()
205 free(dev->platdata); in device_bind_common()
206 dev->platdata = NULL; in device_bind_common()
209 devres_release_all(dev); in device_bind_common()
211 free(dev); in device_bind_common()
297 int device_probe(struct udevice *dev) in device_probe() argument
304 if (!dev) in device_probe()
307 if (dev->flags & DM_FLAG_ACTIVATED) in device_probe()
310 drv = dev->driver; in device_probe()
314 if (drv->priv_auto_alloc_size && !dev->priv) { in device_probe()
315 dev->priv = alloc_priv(drv->priv_auto_alloc_size, drv->flags); in device_probe()
316 if (!dev->priv) { in device_probe()
322 size = dev->uclass->uc_drv->per_device_auto_alloc_size; in device_probe()
323 if (size && !dev->uclass_priv) { in device_probe()
324 dev->uclass_priv = calloc(1, size); in device_probe()
325 if (!dev->uclass_priv) { in device_probe()
332 if (dev->parent) { in device_probe()
333 size = dev->parent->driver->per_child_auto_alloc_size; in device_probe()
335 size = dev->parent->uclass->uc_drv-> in device_probe()
338 if (size && !dev->parent_priv) { in device_probe()
339 dev->parent_priv = alloc_priv(size, drv->flags); in device_probe()
340 if (!dev->parent_priv) { in device_probe()
346 ret = device_probe(dev->parent); in device_probe()
356 if (dev->flags & DM_FLAG_ACTIVATED) in device_probe()
360 seq = uclass_resolve_seq(dev); in device_probe()
365 dev->seq = seq; in device_probe()
367 dev->flags |= DM_FLAG_ACTIVATED; in device_probe()
375 if (dev->parent && device_get_uclass_id(dev) != UCLASS_PINCTRL) in device_probe()
376 pinctrl_select_state(dev, "default"); in device_probe()
378 ret = uclass_pre_probe_device(dev); in device_probe()
382 if (dev->parent && dev->parent->driver->child_pre_probe) { in device_probe()
383 ret = dev->parent->driver->child_pre_probe(dev); in device_probe()
388 if (drv->ofdata_to_platdata && dev_has_of_node(dev)) { in device_probe()
389 ret = drv->ofdata_to_platdata(dev); in device_probe()
395 ret = clk_set_defaults(dev); in device_probe()
400 ret = drv->probe(dev); in device_probe()
402 dev->flags &= ~DM_FLAG_ACTIVATED; in device_probe()
407 ret = uclass_post_probe_device(dev); in device_probe()
411 if (dev->parent && device_get_uclass_id(dev) == UCLASS_PINCTRL) in device_probe()
412 pinctrl_select_state(dev, "default"); in device_probe()
416 if (device_remove(dev, DM_REMOVE_NORMAL)) { in device_probe()
418 __func__, dev->name); in device_probe()
421 dev->flags &= ~DM_FLAG_ACTIVATED; in device_probe()
423 dev->seq = -1; in device_probe()
424 device_free(dev); in device_probe()
429 void *dev_get_platdata(struct udevice *dev) in dev_get_platdata() argument
431 if (!dev) { in dev_get_platdata()
436 return dev->platdata; in dev_get_platdata()
439 void *dev_get_parent_platdata(struct udevice *dev) in dev_get_parent_platdata() argument
441 if (!dev) { in dev_get_parent_platdata()
446 return dev->parent_platdata; in dev_get_parent_platdata()
449 void *dev_get_uclass_platdata(struct udevice *dev) in dev_get_uclass_platdata() argument
451 if (!dev) { in dev_get_uclass_platdata()
456 return dev->uclass_platdata; in dev_get_uclass_platdata()
459 void *dev_get_priv(struct udevice *dev) in dev_get_priv() argument
461 if (!dev) { in dev_get_priv()
466 return dev->priv; in dev_get_priv()
469 void *dev_get_uclass_priv(struct udevice *dev) in dev_get_uclass_priv() argument
471 if (!dev) { in dev_get_uclass_priv()
476 return dev->uclass_priv; in dev_get_uclass_priv()
479 void *dev_get_parent_priv(struct udevice *dev) in dev_get_parent_priv() argument
481 if (!dev) { in dev_get_parent_priv()
486 return dev->parent_priv; in dev_get_parent_priv()
489 static int device_get_device_tail(struct udevice *dev, int ret, in device_get_device_tail() argument
495 ret = device_probe(dev); in device_get_device_tail()
499 *devp = dev; in device_get_device_tail()
506 struct udevice *dev; in device_get_child() local
508 list_for_each_entry(dev, &parent->child_head, sibling_node) { in device_get_child()
510 return device_get_device_tail(dev, 0, devp); in device_get_child()
519 struct udevice *dev; in device_find_child_by_seq() local
525 list_for_each_entry(dev, &parent->child_head, sibling_node) { in device_find_child_by_seq()
526 if ((find_req_seq ? dev->req_seq : dev->seq) == in device_find_child_by_seq()
528 *devp = dev; in device_find_child_by_seq()
539 struct udevice *dev; in device_get_child_by_seq() local
543 ret = device_find_child_by_seq(parent, seq, false, &dev); in device_get_child_by_seq()
549 ret = device_find_child_by_seq(parent, seq, true, &dev); in device_get_child_by_seq()
551 return device_get_device_tail(dev, ret, devp); in device_get_child_by_seq()
557 struct udevice *dev; in device_find_child_by_of_offset() local
561 list_for_each_entry(dev, &parent->child_head, sibling_node) { in device_find_child_by_of_offset()
562 if (dev_of_offset(dev) == of_offset) { in device_find_child_by_of_offset()
563 *devp = dev; in device_find_child_by_of_offset()
574 struct udevice *dev; in device_get_child_by_of_offset() local
578 ret = device_find_child_by_of_offset(parent, node, &dev); in device_get_child_by_of_offset()
579 return device_get_device_tail(dev, ret, devp); in device_get_child_by_of_offset()
585 struct udevice *dev, *found; in _device_find_global_by_of_offset() local
590 list_for_each_entry(dev, &parent->child_head, sibling_node) { in _device_find_global_by_of_offset()
591 found = _device_find_global_by_of_offset(dev, of_offset); in _device_find_global_by_of_offset()
601 struct udevice *dev; in device_get_global_by_of_offset() local
603 dev = _device_find_global_by_of_offset(gd->dm_root, of_offset); in device_get_global_by_of_offset()
604 return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp); in device_get_global_by_of_offset()
621 struct udevice *dev = *devp; in device_find_next_child() local
622 struct udevice *parent = dev->parent; in device_find_next_child()
624 if (list_is_last(&dev->sibling_node, &parent->child_head)) { in device_find_next_child()
627 *devp = list_entry(dev->sibling_node.next, struct udevice, in device_find_next_child()
639 ulong dev_get_driver_data(struct udevice *dev) in dev_get_driver_data() argument
641 return dev->driver_data; in dev_get_driver_data()
644 const void *dev_get_driver_ops(struct udevice *dev) in dev_get_driver_ops() argument
646 if (!dev || !dev->driver->ops) in dev_get_driver_ops()
649 return dev->driver->ops; in dev_get_driver_ops()
652 enum uclass_id device_get_uclass_id(struct udevice *dev) in device_get_uclass_id() argument
654 return dev->uclass->uc_drv->id; in device_get_uclass_id()
657 const char *dev_get_uclass_name(struct udevice *dev) in dev_get_uclass_name() argument
659 if (!dev) in dev_get_uclass_name()
662 return dev->uclass->uc_drv->name; in dev_get_uclass_name()
665 bool device_has_children(struct udevice *dev) in device_has_children() argument
667 return !list_empty(&dev->child_head); in device_has_children()
670 bool device_has_active_children(struct udevice *dev) in device_has_active_children() argument
674 for (device_find_first_child(dev, &child); in device_has_active_children()
684 bool device_is_last_sibling(struct udevice *dev) in device_is_last_sibling() argument
686 struct udevice *parent = dev->parent; in device_is_last_sibling()
690 return list_is_last(&dev->sibling_node, &parent->child_head); in device_is_last_sibling()
693 void device_set_name_alloced(struct udevice *dev) in device_set_name_alloced() argument
695 dev->flags |= DM_FLAG_NAME_ALLOCED; in device_set_name_alloced()
698 int device_set_name(struct udevice *dev, const char *name) in device_set_name() argument
703 dev->name = name; in device_set_name()
704 device_set_name_alloced(dev); in device_set_name()
709 bool device_is_compatible(struct udevice *dev, const char *compat) in device_is_compatible() argument
711 return ofnode_device_is_compatible(dev_ofnode(dev), compat); in device_is_compatible()