16494d708SSimon Glass /* 26494d708SSimon Glass * Copyright (c) 2013 Google, Inc 36494d708SSimon Glass * 46494d708SSimon Glass * (C) Copyright 2012 56494d708SSimon Glass * Pavel Herrmann <morpheus.ibis@gmail.com> 66494d708SSimon Glass * 76494d708SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 86494d708SSimon Glass */ 96494d708SSimon Glass 106494d708SSimon Glass #ifndef _DM_LISTS_H_ 116494d708SSimon Glass #define _DM_LISTS_H_ 126494d708SSimon Glass 13f5b5719cSSimon Glass #include <dm/ofnode.h> 146494d708SSimon Glass #include <dm/uclass-id.h> 156494d708SSimon Glass 166494d708SSimon Glass /** 176494d708SSimon Glass * lists_driver_lookup_name() - Return u_boot_driver corresponding to name 186494d708SSimon Glass * 196494d708SSimon Glass * This function returns a pointer to a driver given its name. This is used 206494d708SSimon Glass * for binding a driver given its name and platdata. 216494d708SSimon Glass * 226494d708SSimon Glass * @name: Name of driver to look up 236494d708SSimon Glass * @return pointer to driver, or NULL if not found 246494d708SSimon Glass */ 256494d708SSimon Glass struct driver *lists_driver_lookup_name(const char *name); 266494d708SSimon Glass 276494d708SSimon Glass /** 286494d708SSimon Glass * lists_uclass_lookup() - Return uclass_driver based on ID of the class 296494d708SSimon Glass * id: ID of the class 306494d708SSimon Glass * 316494d708SSimon Glass * This function returns the pointer to uclass_driver, which is the class's 326494d708SSimon Glass * base structure based on the ID of the class. Returns NULL on error. 336494d708SSimon Glass */ 346494d708SSimon Glass struct uclass_driver *lists_uclass_lookup(enum uclass_id id); 356494d708SSimon Glass 36f2bc6fc3SSimon Glass /** 37f2bc6fc3SSimon Glass * lists_bind_drivers() - search for and bind all drivers to parent 38f2bc6fc3SSimon Glass * 39f2bc6fc3SSimon Glass * This searches the U_BOOT_DEVICE() structures and creates new devices for 40f2bc6fc3SSimon Glass * each one. The devices will have @parent as their parent. 41f2bc6fc3SSimon Glass * 4281b4e751SMasahiro Yamada * @parent: parent device (root) 43f2bc6fc3SSimon Glass * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false 44f2bc6fc3SSimon Glass * bind all drivers. 45f2bc6fc3SSimon Glass */ 4600606d7eSSimon Glass int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only); 476494d708SSimon Glass 48f2bc6fc3SSimon Glass /** 49f2bc6fc3SSimon Glass * lists_bind_fdt() - bind a device tree node 50f2bc6fc3SSimon Glass * 51f2bc6fc3SSimon Glass * This creates a new device bound to the given device tree node, with 52f2bc6fc3SSimon Glass * @parent as its parent. 53f2bc6fc3SSimon Glass * 5481b4e751SMasahiro Yamada * @parent: parent device (root) 55f5b5719cSSimon Glass * @node: device tree node to bind 561f359e36SSimon Glass * @devp: if non-NULL, returns a pointer to the bound device 571f359e36SSimon Glass * @return 0 if device was bound, -EINVAL if the device tree is invalid, 581f359e36SSimon Glass * other -ve value on error 59f2bc6fc3SSimon Glass */ 60f5b5719cSSimon Glass int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp); 616494d708SSimon Glass 62e33dc221SSimon Glass /** 63e33dc221SSimon Glass * device_bind_driver() - bind a device to a driver 64e33dc221SSimon Glass * 65e33dc221SSimon Glass * This binds a new device to a driver. 66e33dc221SSimon Glass * 67e33dc221SSimon Glass * @parent: Parent device 68e33dc221SSimon Glass * @drv_name: Name of driver to attach to this parent 69e33dc221SSimon Glass * @dev_name: Name of the new device thus created 70e6cabe4aSMasahiro Yamada * @devp: If non-NULL, returns the newly bound device 71e33dc221SSimon Glass */ 72e33dc221SSimon Glass int device_bind_driver(struct udevice *parent, const char *drv_name, 73e33dc221SSimon Glass const char *dev_name, struct udevice **devp); 74e33dc221SSimon Glass 755b9000ddSSimon Glass /** 765b9000ddSSimon Glass * device_bind_driver_to_node() - bind a device to a driver for a node 775b9000ddSSimon Glass * 785b9000ddSSimon Glass * This binds a new device to a driver for a given device tree node. This 795b9000ddSSimon Glass * should only be needed if the node lacks a compatible strings. 805b9000ddSSimon Glass * 815b9000ddSSimon Glass * @parent: Parent device 825b9000ddSSimon Glass * @drv_name: Name of driver to attach to this parent 835b9000ddSSimon Glass * @dev_name: Name of the new device thus created 845b9000ddSSimon Glass * @node: Device tree node 85e6cabe4aSMasahiro Yamada * @devp: If non-NULL, returns the newly bound device 865b9000ddSSimon Glass */ 875b9000ddSSimon Glass int device_bind_driver_to_node(struct udevice *parent, const char *drv_name, 88*45a26867SSimon Glass const char *dev_name, ofnode node, 895b9000ddSSimon Glass struct udevice **devp); 905b9000ddSSimon Glass 916494d708SSimon Glass #endif 92