Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc |
| 4 | * |
| 5 | * (C) Copyright 2012 |
| 6 | * Pavel Herrmann <morpheus.ibis@gmail.com> |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _DM_LISTS_H_ |
| 10 | #define _DM_LISTS_H_ |
| 11 | |
Simon Glass | f5b5719 | 2017-05-18 20:09:06 -0600 | [diff] [blame] | 12 | #include <dm/ofnode.h> |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 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 |
Simon Glass | caa4daa | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 19 | * for binding a driver given its name and plat. |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 20 | * |
| 21 | * @name: Name of driver to look up |
Patrick Delaunay | cbb14ac | 2022-01-12 10:53:44 +0100 | [diff] [blame] | 22 | * Return: pointer to driver, or NULL if not found |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 23 | */ |
| 24 | struct driver *lists_driver_lookup_name(const char *name); |
| 25 | |
| 26 | /** |
| 27 | * lists_uclass_lookup() - Return uclass_driver based on ID of the class |
Patrick Delaunay | cbb14ac | 2022-01-12 10:53:44 +0100 | [diff] [blame] | 28 | * |
| 29 | * @id: ID of the class |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 30 | * |
| 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 | */ |
| 34 | struct uclass_driver *lists_uclass_lookup(enum uclass_id id); |
| 35 | |
Simon Glass | f2bc6fc | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 36 | /** |
| 37 | * lists_bind_drivers() - search for and bind all drivers to parent |
| 38 | * |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 39 | * This searches the U_BOOT_DRVINFO() structures and creates new devices for |
Simon Glass | f2bc6fc | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 40 | * each one. The devices will have @parent as their parent. |
| 41 | * |
Masahiro Yamada | 81b4e75 | 2014-09-28 22:52:24 +0900 | [diff] [blame] | 42 | * @parent: parent device (root) |
Bin Meng | 6244fc6 | 2018-10-10 22:06:59 -0700 | [diff] [blame] | 43 | * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag. |
| 44 | * If false bind all drivers. |
Simon Glass | f2bc6fc | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 45 | */ |
Simon Glass | 00606d7 | 2014-07-23 06:55:03 -0600 | [diff] [blame] | 46 | int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only); |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 47 | |
Simon Glass | f2bc6fc | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 48 | /** |
| 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 Yamada | 81b4e75 | 2014-09-28 22:52:24 +0900 | [diff] [blame] | 54 | * @parent: parent device (root) |
Simon Glass | f5b5719 | 2017-05-18 20:09:06 -0600 | [diff] [blame] | 55 | * @node: device tree node to bind |
Simon Glass | 1f359e3 | 2014-09-04 16:27:25 -0600 | [diff] [blame] | 56 | * @devp: if non-NULL, returns a pointer to the bound device |
Patrice Chotard | 38f7d3b | 2021-09-10 16:16:20 +0200 | [diff] [blame] | 57 | * @drv: if non-NULL, force this driver to be bound |
Bin Meng | 8d773c4 | 2018-10-10 22:06:58 -0700 | [diff] [blame] | 58 | * @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 Delaunay | cbb14ac | 2022-01-12 10:53:44 +0100 | [diff] [blame] | 60 | * |
| 61 | * Return: 0 if device was bound, -EINVAL if the device tree is invalid, |
Simon Glass | 1f359e3 | 2014-09-04 16:27:25 -0600 | [diff] [blame] | 62 | * other -ve value on error |
Simon Glass | f2bc6fc | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 63 | */ |
Bin Meng | 8d773c4 | 2018-10-10 22:06:58 -0700 | [diff] [blame] | 64 | int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, |
Patrice Chotard | 38f7d3b | 2021-09-10 16:16:20 +0200 | [diff] [blame] | 65 | struct driver *drv, bool pre_reloc_only); |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 66 | |
Simon Glass | e33dc22 | 2014-11-11 10:46:21 -0700 | [diff] [blame] | 67 | /** |
| 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 Yamada | e6cabe4 | 2015-08-27 12:44:28 +0900 | [diff] [blame] | 75 | * @devp: If non-NULL, returns the newly bound device |
Simon Glass | e33dc22 | 2014-11-11 10:46:21 -0700 | [diff] [blame] | 76 | */ |
| 77 | int device_bind_driver(struct udevice *parent, const char *drv_name, |
| 78 | const char *dev_name, struct udevice **devp); |
| 79 | |
Simon Glass | 5b9000d | 2015-04-28 20:25:04 -0600 | [diff] [blame] | 80 | /** |
| 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 Yamada | e6cabe4 | 2015-08-27 12:44:28 +0900 | [diff] [blame] | 90 | * @devp: If non-NULL, returns the newly bound device |
Simon Glass | 5b9000d | 2015-04-28 20:25:04 -0600 | [diff] [blame] | 91 | */ |
| 92 | int device_bind_driver_to_node(struct udevice *parent, const char *drv_name, |
Simon Glass | 45a2686 | 2017-05-18 20:09:07 -0600 | [diff] [blame] | 93 | const char *dev_name, ofnode node, |
Simon Glass | 5b9000d | 2015-04-28 20:25:04 -0600 | [diff] [blame] | 94 | struct udevice **devp); |
| 95 | |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 96 | #endif |