Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Simon Glass | 802b2c6 | 2017-05-18 20:09:06 -0600 | [diff] [blame] | 13 | #include <dm/ofnode.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 14 | #include <dm/uclass-id.h> |
| 15 | |
| 16 | /** |
| 17 | * lists_driver_lookup_name() - Return u_boot_driver corresponding to name |
| 18 | * |
| 19 | * This function returns a pointer to a driver given its name. This is used |
| 20 | * for binding a driver given its name and platdata. |
| 21 | * |
| 22 | * @name: Name of driver to look up |
| 23 | * @return pointer to driver, or NULL if not found |
| 24 | */ |
| 25 | struct driver *lists_driver_lookup_name(const char *name); |
| 26 | |
| 27 | /** |
| 28 | * lists_uclass_lookup() - Return uclass_driver based on ID of the class |
| 29 | * id: ID of the class |
| 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 | 4dbb5cf | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 36 | /** |
| 37 | * lists_bind_drivers() - search for and bind all drivers to parent |
| 38 | * |
| 39 | * This searches the U_BOOT_DEVICE() structures and creates new devices for |
| 40 | * each one. The devices will have @parent as their parent. |
| 41 | * |
Masahiro Yamada | 191fa3b | 2014-09-28 22:52:24 +0900 | [diff] [blame] | 42 | * @parent: parent device (root) |
Simon Glass | 4dbb5cf | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 43 | * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false |
| 44 | * bind all drivers. |
| 45 | */ |
Simon Glass | fef72b7 | 2014-07-23 06:55:03 -0600 | [diff] [blame] | 46 | int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only); |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 47 | |
Simon Glass | 4dbb5cf | 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 | 191fa3b | 2014-09-28 22:52:24 +0900 | [diff] [blame] | 54 | * @parent: parent device (root) |
Simon Glass | 802b2c6 | 2017-05-18 20:09:06 -0600 | [diff] [blame] | 55 | * @node: device tree node to bind |
Simon Glass | 439bc84 | 2014-09-04 16:27:25 -0600 | [diff] [blame] | 56 | * @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 Glass | 4dbb5cf | 2014-06-11 23:29:54 -0600 | [diff] [blame] | 59 | */ |
Simon Glass | 802b2c6 | 2017-05-18 20:09:06 -0600 | [diff] [blame] | 60 | int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp); |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 61 | |
Simon Glass | 54f79a0 | 2014-11-11 10:46:21 -0700 | [diff] [blame] | 62 | /** |
| 63 | * device_bind_driver() - bind a device to a driver |
| 64 | * |
| 65 | * This binds a new device to a driver. |
| 66 | * |
| 67 | * @parent: Parent device |
| 68 | * @drv_name: Name of driver to attach to this parent |
| 69 | * @dev_name: Name of the new device thus created |
Masahiro Yamada | e1cc1f0 | 2015-08-27 12:44:28 +0900 | [diff] [blame] | 70 | * @devp: If non-NULL, returns the newly bound device |
Simon Glass | 54f79a0 | 2014-11-11 10:46:21 -0700 | [diff] [blame] | 71 | */ |
| 72 | int device_bind_driver(struct udevice *parent, const char *drv_name, |
| 73 | const char *dev_name, struct udevice **devp); |
| 74 | |
Simon Glass | 3d217f6 | 2015-04-28 20:25:04 -0600 | [diff] [blame] | 75 | /** |
| 76 | * device_bind_driver_to_node() - bind a device to a driver for a node |
| 77 | * |
| 78 | * This binds a new device to a driver for a given device tree node. This |
| 79 | * should only be needed if the node lacks a compatible strings. |
| 80 | * |
| 81 | * @parent: Parent device |
| 82 | * @drv_name: Name of driver to attach to this parent |
| 83 | * @dev_name: Name of the new device thus created |
| 84 | * @node: Device tree node |
Masahiro Yamada | e1cc1f0 | 2015-08-27 12:44:28 +0900 | [diff] [blame] | 85 | * @devp: If non-NULL, returns the newly bound device |
Simon Glass | 3d217f6 | 2015-04-28 20:25:04 -0600 | [diff] [blame] | 86 | */ |
| 87 | int device_bind_driver_to_node(struct udevice *parent, const char *drv_name, |
Simon Glass | e6dd8da | 2017-05-18 20:09:07 -0600 | [diff] [blame^] | 88 | const char *dev_name, ofnode node, |
Simon Glass | 3d217f6 | 2015-04-28 20:25:04 -0600 | [diff] [blame] | 89 | struct udevice **devp); |
| 90 | |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 91 | #endif |