xref: /openbmc/u-boot/include/dm/lists.h (revision 1d6edcbfed2af33c748f2beb399810a0441888da)
183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
26494d708SSimon Glass /*
36494d708SSimon Glass  * Copyright (c) 2013 Google, Inc
46494d708SSimon Glass  *
56494d708SSimon Glass  * (C) Copyright 2012
66494d708SSimon Glass  * Pavel Herrmann <morpheus.ibis@gmail.com>
76494d708SSimon Glass  */
86494d708SSimon Glass 
96494d708SSimon Glass #ifndef _DM_LISTS_H_
106494d708SSimon Glass #define _DM_LISTS_H_
116494d708SSimon Glass 
12f5b5719cSSimon Glass #include <dm/ofnode.h>
136494d708SSimon Glass #include <dm/uclass-id.h>
146494d708SSimon Glass 
156494d708SSimon Glass /**
166494d708SSimon Glass  * lists_driver_lookup_name() - Return u_boot_driver corresponding to name
176494d708SSimon Glass  *
186494d708SSimon Glass  * This function returns a pointer to a driver given its name. This is used
196494d708SSimon Glass  * for binding a driver given its name and platdata.
206494d708SSimon Glass  *
216494d708SSimon Glass  * @name: Name of driver to look up
226494d708SSimon Glass  * @return pointer to driver, or NULL if not found
236494d708SSimon Glass  */
246494d708SSimon Glass struct driver *lists_driver_lookup_name(const char *name);
256494d708SSimon Glass 
266494d708SSimon Glass /**
276494d708SSimon Glass  * lists_uclass_lookup() - Return uclass_driver based on ID of the class
286494d708SSimon Glass  * id:		ID of the class
296494d708SSimon Glass  *
306494d708SSimon Glass  * This function returns the pointer to uclass_driver, which is the class's
316494d708SSimon Glass  * base structure based on the ID of the class. Returns NULL on error.
326494d708SSimon Glass  */
336494d708SSimon Glass struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
346494d708SSimon Glass 
35f2bc6fc3SSimon Glass /**
36f2bc6fc3SSimon Glass  * lists_bind_drivers() - search for and bind all drivers to parent
37f2bc6fc3SSimon Glass  *
38f2bc6fc3SSimon Glass  * This searches the U_BOOT_DEVICE() structures and creates new devices for
39f2bc6fc3SSimon Glass  * each one. The devices will have @parent as their parent.
40f2bc6fc3SSimon Glass  *
4181b4e751SMasahiro Yamada  * @parent: parent device (root)
42*6244fc64SBin Meng  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag.
43*6244fc64SBin Meng  * If false bind all drivers.
44f2bc6fc3SSimon Glass  */
4500606d7eSSimon Glass int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
466494d708SSimon Glass 
47f2bc6fc3SSimon Glass /**
48f2bc6fc3SSimon Glass  * lists_bind_fdt() - bind a device tree node
49f2bc6fc3SSimon Glass  *
50f2bc6fc3SSimon Glass  * This creates a new device bound to the given device tree node, with
51f2bc6fc3SSimon Glass  * @parent as its parent.
52f2bc6fc3SSimon Glass  *
5381b4e751SMasahiro Yamada  * @parent: parent device (root)
54f5b5719cSSimon Glass  * @node: device tree node to bind
551f359e36SSimon Glass  * @devp: if non-NULL, returns a pointer to the bound device
568d773c4aSBin Meng  * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
578d773c4aSBin Meng  * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
581f359e36SSimon Glass  * @return 0 if device was bound, -EINVAL if the device tree is invalid,
591f359e36SSimon Glass  * other -ve value on error
60f2bc6fc3SSimon Glass  */
618d773c4aSBin Meng int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
628d773c4aSBin Meng 		   bool pre_reloc_only);
636494d708SSimon Glass 
64e33dc221SSimon Glass /**
65e33dc221SSimon Glass  * device_bind_driver() - bind a device to a driver
66e33dc221SSimon Glass  *
67e33dc221SSimon Glass  * This binds a new device to a driver.
68e33dc221SSimon Glass  *
69e33dc221SSimon Glass  * @parent:	Parent device
70e33dc221SSimon Glass  * @drv_name:	Name of driver to attach to this parent
71e33dc221SSimon Glass  * @dev_name:	Name of the new device thus created
72e6cabe4aSMasahiro Yamada  * @devp:	If non-NULL, returns the newly bound device
73e33dc221SSimon Glass  */
74e33dc221SSimon Glass int device_bind_driver(struct udevice *parent, const char *drv_name,
75e33dc221SSimon Glass 		       const char *dev_name, struct udevice **devp);
76e33dc221SSimon Glass 
775b9000ddSSimon Glass /**
785b9000ddSSimon Glass  * device_bind_driver_to_node() - bind a device to a driver for a node
795b9000ddSSimon Glass  *
805b9000ddSSimon Glass  * This binds a new device to a driver for a given device tree node. This
815b9000ddSSimon Glass  * should only be needed if the node lacks a compatible strings.
825b9000ddSSimon Glass  *
835b9000ddSSimon Glass  * @parent:	Parent device
845b9000ddSSimon Glass  * @drv_name:	Name of driver to attach to this parent
855b9000ddSSimon Glass  * @dev_name:	Name of the new device thus created
865b9000ddSSimon Glass  * @node:	Device tree node
87e6cabe4aSMasahiro Yamada  * @devp:	If non-NULL, returns the newly bound device
885b9000ddSSimon Glass  */
895b9000ddSSimon Glass int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
9045a26867SSimon Glass 			       const char *dev_name, ofnode node,
915b9000ddSSimon Glass 			       struct udevice **devp);
925b9000ddSSimon Glass 
936494d708SSimon Glass #endif
94