blob: fc3b4ae58500c5cc857b0ea9f6743a7b7b9affed [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass6494d702014-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 Glass6494d702014-02-26 15:59:18 -07007 */
8
9#ifndef _DM_LISTS_H_
10#define _DM_LISTS_H_
11
Simon Glassf5b57192017-05-18 20:09:06 -060012#include <dm/ofnode.h>
Simon Glass6494d702014-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
Simon Glasscaa4daa2020-12-03 16:55:18 -070019 * for binding a driver given its name and plat.
Simon Glass6494d702014-02-26 15:59:18 -070020 *
21 * @name: Name of driver to look up
Patrick Delaunaycbb14ac2022-01-12 10:53:44 +010022 * Return: pointer to driver, or NULL if not found
Simon Glass6494d702014-02-26 15:59:18 -070023 */
24struct driver *lists_driver_lookup_name(const char *name);
25
26/**
27 * lists_uclass_lookup() - Return uclass_driver based on ID of the class
Patrick Delaunaycbb14ac2022-01-12 10:53:44 +010028 *
29 * @id: ID of the class
Simon Glass6494d702014-02-26 15:59:18 -070030 *
31 * This function returns the pointer to uclass_driver, which is the class's
32 * base structure based on the ID of the class. Returns NULL on error.
33 */
34struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
35
Simon Glassf2bc6fc2014-06-11 23:29:54 -060036/**
37 * lists_bind_drivers() - search for and bind all drivers to parent
38 *
Simon Glass20e442a2020-12-28 20:34:54 -070039 * This searches the U_BOOT_DRVINFO() structures and creates new devices for
Simon Glassf2bc6fc2014-06-11 23:29:54 -060040 * each one. The devices will have @parent as their parent.
41 *
Masahiro Yamada81b4e752014-09-28 22:52:24 +090042 * @parent: parent device (root)
Bin Meng6244fc62018-10-10 22:06:59 -070043 * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag.
44 * If false bind all drivers.
Simon Glassf2bc6fc2014-06-11 23:29:54 -060045 */
Simon Glass00606d72014-07-23 06:55:03 -060046int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
Simon Glass6494d702014-02-26 15:59:18 -070047
Simon Glassf2bc6fc2014-06-11 23:29:54 -060048/**
49 * lists_bind_fdt() - bind a device tree node
50 *
51 * This creates a new device bound to the given device tree node, with
52 * @parent as its parent.
53 *
Masahiro Yamada81b4e752014-09-28 22:52:24 +090054 * @parent: parent device (root)
Simon Glassf5b57192017-05-18 20:09:06 -060055 * @node: device tree node to bind
Simon Glass1f359e32014-09-04 16:27:25 -060056 * @devp: if non-NULL, returns a pointer to the bound device
Patrice Chotard38f7d3b2021-09-10 16:16:20 +020057 * @drv: if non-NULL, force this driver to be bound
Bin Meng8d773c42018-10-10 22:06:58 -070058 * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
59 * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
Patrick Delaunaycbb14ac2022-01-12 10:53:44 +010060 *
61 * Return: 0 if device was bound, -EINVAL if the device tree is invalid,
Simon Glass1f359e32014-09-04 16:27:25 -060062 * other -ve value on error
Simon Glassf2bc6fc2014-06-11 23:29:54 -060063 */
Bin Meng8d773c42018-10-10 22:06:58 -070064int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
Patrice Chotard38f7d3b2021-09-10 16:16:20 +020065 struct driver *drv, bool pre_reloc_only);
Simon Glass6494d702014-02-26 15:59:18 -070066
Simon Glasse33dc222014-11-11 10:46:21 -070067/**
68 * device_bind_driver() - bind a device to a driver
69 *
70 * This binds a new device to a driver.
71 *
72 * @parent: Parent device
73 * @drv_name: Name of driver to attach to this parent
74 * @dev_name: Name of the new device thus created
Masahiro Yamadae6cabe42015-08-27 12:44:28 +090075 * @devp: If non-NULL, returns the newly bound device
Simon Glasse33dc222014-11-11 10:46:21 -070076 */
77int device_bind_driver(struct udevice *parent, const char *drv_name,
78 const char *dev_name, struct udevice **devp);
79
Simon Glass5b9000d2015-04-28 20:25:04 -060080/**
81 * device_bind_driver_to_node() - bind a device to a driver for a node
82 *
83 * This binds a new device to a driver for a given device tree node. This
84 * should only be needed if the node lacks a compatible strings.
85 *
86 * @parent: Parent device
87 * @drv_name: Name of driver to attach to this parent
88 * @dev_name: Name of the new device thus created
89 * @node: Device tree node
Masahiro Yamadae6cabe42015-08-27 12:44:28 +090090 * @devp: If non-NULL, returns the newly bound device
Simon Glass5b9000d2015-04-28 20:25:04 -060091 */
92int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
Simon Glass45a26862017-05-18 20:09:07 -060093 const char *dev_name, ofnode node,
Simon Glass5b9000d2015-04-28 20:25:04 -060094 struct udevice **devp);
95
Simon Glass6494d702014-02-26 15:59:18 -070096#endif