blob: 61610e69aa551532927f7875227c31f3c980784a [file] [log] [blame]
Simon Glass6494d702014-02-26 15:59:18 -07001/*
2 * Copyright (c) 2013 Google, Inc
3 *
4 * (C) Copyright 2012
5 * Pavel Herrmann <morpheus.ibis@gmail.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#ifndef _DM_LISTS_H_
11#define _DM_LISTS_H_
12
13#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 Glassf2bc6fc2014-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 Yamada81b4e752014-09-28 22:52:24 +090041 * @parent: parent device (root)
Simon Glassf2bc6fc2014-06-11 23:29:54 -060042 * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false
43 * bind all drivers.
44 */
Simon Glass00606d72014-07-23 06:55:03 -060045int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
Simon Glass6494d702014-02-26 15:59:18 -070046
Simon Glassf2bc6fc2014-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 Yamada81b4e752014-09-28 22:52:24 +090053 * @parent: parent device (root)
Simon Glassf2bc6fc2014-06-11 23:29:54 -060054 * @blob: device tree blob
55 * @offset: offset of this device tree node
Simon Glass1f359e32014-09-04 16:27:25 -060056 * @devp: if non-NULL, returns a pointer to the bound device
57 * @return 0 if device was bound, -EINVAL if the device tree is invalid,
58 * other -ve value on error
Simon Glassf2bc6fc2014-06-11 23:29:54 -060059 */
Simon Glass1f359e32014-09-04 16:27:25 -060060int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
61 struct udevice **devp);
Simon Glass6494d702014-02-26 15:59:18 -070062
Simon Glasse33dc222014-11-11 10:46:21 -070063/**
64 * device_bind_driver() - bind a device to a driver
65 *
66 * This binds a new device to a driver.
67 *
68 * @parent: Parent device
69 * @drv_name: Name of driver to attach to this parent
70 * @dev_name: Name of the new device thus created
71 * @devp: Returns the newly bound device
72 */
73int device_bind_driver(struct udevice *parent, const char *drv_name,
74 const char *dev_name, struct udevice **devp);
75
Simon Glass5b9000d2015-04-28 20:25:04 -060076/**
77 * device_bind_driver_to_node() - bind a device to a driver for a node
78 *
79 * This binds a new device to a driver for a given device tree node. This
80 * should only be needed if the node lacks a compatible strings.
81 *
82 * @parent: Parent device
83 * @drv_name: Name of driver to attach to this parent
84 * @dev_name: Name of the new device thus created
85 * @node: Device tree node
86 * @devp: Returns the newly bound device
87 */
88int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
89 const char *dev_name, int node,
90 struct udevice **devp);
91
Simon Glass6494d702014-02-26 15:59:18 -070092#endif