blob: 810e244d9ef3d74a179373f516c040a75ab3f39f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassdd6ab882014-02-26 15:59:18 -07002/*
3 * Copyright (c) 2013 Google, Inc
4 *
5 * (C) Copyright 2012
6 * Pavel Herrmann <morpheus.ibis@gmail.com>
Simon Glassdd6ab882014-02-26 15:59:18 -07007 */
8
9#ifndef _DM_LISTS_H_
10#define _DM_LISTS_H_
11
Simon Glass802b2c62017-05-18 20:09:06 -060012#include <dm/ofnode.h>
Simon Glassdd6ab882014-02-26 15:59:18 -070013#include <dm/uclass-id.h>
14
15/**
16 * lists_driver_lookup_name() - Return u_boot_driver corresponding to name
17 *
18 * This function returns a pointer to a driver given its name. This is used
19 * for binding a driver given its name and platdata.
20 *
21 * @name: Name of driver to look up
22 * @return pointer to driver, or NULL if not found
23 */
24struct driver *lists_driver_lookup_name(const char *name);
25
26/**
27 * lists_uclass_lookup() - Return uclass_driver based on ID of the class
28 * id: ID of the class
29 *
30 * This function returns the pointer to uclass_driver, which is the class's
31 * base structure based on the ID of the class. Returns NULL on error.
32 */
33struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
34
Simon Glass4dbb5cf2014-06-11 23:29:54 -060035/**
36 * lists_bind_drivers() - search for and bind all drivers to parent
37 *
38 * This searches the U_BOOT_DEVICE() structures and creates new devices for
39 * each one. The devices will have @parent as their parent.
40 *
Masahiro Yamada191fa3b2014-09-28 22:52:24 +090041 * @parent: parent device (root)
Bin Meng004323a2018-10-10 22:06:59 -070042 * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag.
43 * If false bind all drivers.
Simon Glass4dbb5cf2014-06-11 23:29:54 -060044 */
Simon Glassfef72b72014-07-23 06:55:03 -060045int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
Simon Glassdd6ab882014-02-26 15:59:18 -070046
Simon Glass4dbb5cf2014-06-11 23:29:54 -060047/**
48 * lists_bind_fdt() - bind a device tree node
49 *
50 * This creates a new device bound to the given device tree node, with
51 * @parent as its parent.
52 *
Masahiro Yamada191fa3b2014-09-28 22:52:24 +090053 * @parent: parent device (root)
Simon Glass802b2c62017-05-18 20:09:06 -060054 * @node: device tree node to bind
Simon Glass439bc842014-09-04 16:27:25 -060055 * @devp: if non-NULL, returns a pointer to the bound device
Bin Meng9a9b0742018-10-10 22:06:58 -070056 * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
57 * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
Simon Glass439bc842014-09-04 16:27:25 -060058 * @return 0 if device was bound, -EINVAL if the device tree is invalid,
59 * other -ve value on error
Simon Glass4dbb5cf2014-06-11 23:29:54 -060060 */
Bin Meng9a9b0742018-10-10 22:06:58 -070061int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
62 bool pre_reloc_only);
Simon Glassdd6ab882014-02-26 15:59:18 -070063
Simon Glass54f79a02014-11-11 10:46:21 -070064/**
65 * device_bind_driver() - bind a device to a driver
66 *
67 * This binds a new device to a driver.
68 *
69 * @parent: Parent device
70 * @drv_name: Name of driver to attach to this parent
71 * @dev_name: Name of the new device thus created
Masahiro Yamadae1cc1f02015-08-27 12:44:28 +090072 * @devp: If non-NULL, returns the newly bound device
Simon Glass54f79a02014-11-11 10:46:21 -070073 */
74int device_bind_driver(struct udevice *parent, const char *drv_name,
75 const char *dev_name, struct udevice **devp);
76
Simon Glass3d217f62015-04-28 20:25:04 -060077/**
78 * device_bind_driver_to_node() - bind a device to a driver for a node
79 *
80 * This binds a new device to a driver for a given device tree node. This
81 * should only be needed if the node lacks a compatible strings.
82 *
83 * @parent: Parent device
84 * @drv_name: Name of driver to attach to this parent
85 * @dev_name: Name of the new device thus created
86 * @node: Device tree node
Masahiro Yamadae1cc1f02015-08-27 12:44:28 +090087 * @devp: If non-NULL, returns the newly bound device
Simon Glass3d217f62015-04-28 20:25:04 -060088 */
89int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
Simon Glasse6dd8da2017-05-18 20:09:07 -060090 const char *dev_name, ofnode node,
Simon Glass3d217f62015-04-28 20:25:04 -060091 struct udevice **devp);
92
Simon Glassdd6ab882014-02-26 15:59:18 -070093#endif