lists.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #ifndef _DM_LISTS_H_
  10. #define _DM_LISTS_H_
  11. #include <dm/ofnode.h>
  12. #include <dm/uclass-id.h>
  13. /**
  14. * lists_driver_lookup_name() - Return u_boot_driver corresponding to name
  15. *
  16. * This function returns a pointer to a driver given its name. This is used
  17. * for binding a driver given its name and platdata.
  18. *
  19. * @name: Name of driver to look up
  20. * @return pointer to driver, or NULL if not found
  21. */
  22. struct driver *lists_driver_lookup_name(const char *name);
  23. /**
  24. * lists_uclass_lookup() - Return uclass_driver based on ID of the class
  25. * id: ID of the class
  26. *
  27. * This function returns the pointer to uclass_driver, which is the class's
  28. * base structure based on the ID of the class. Returns NULL on error.
  29. */
  30. struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
  31. /**
  32. * lists_bind_drivers() - search for and bind all drivers to parent
  33. *
  34. * This searches the U_BOOT_DEVICE() structures and creates new devices for
  35. * each one. The devices will have @parent as their parent.
  36. *
  37. * @parent: parent device (root)
  38. * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false
  39. * bind all drivers.
  40. */
  41. int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
  42. /**
  43. * lists_bind_fdt() - bind a device tree node
  44. *
  45. * This creates a new device bound to the given device tree node, with
  46. * @parent as its parent.
  47. *
  48. * @parent: parent device (root)
  49. * @node: device tree node to bind
  50. * @devp: if non-NULL, returns a pointer to the bound device
  51. * @return 0 if device was bound, -EINVAL if the device tree is invalid,
  52. * other -ve value on error
  53. */
  54. int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp);
  55. /**
  56. * device_bind_driver() - bind a device to a driver
  57. *
  58. * This binds a new device to a driver.
  59. *
  60. * @parent: Parent device
  61. * @drv_name: Name of driver to attach to this parent
  62. * @dev_name: Name of the new device thus created
  63. * @devp: If non-NULL, returns the newly bound device
  64. */
  65. int device_bind_driver(struct udevice *parent, const char *drv_name,
  66. const char *dev_name, struct udevice **devp);
  67. /**
  68. * device_bind_driver_to_node() - bind a device to a driver for a node
  69. *
  70. * This binds a new device to a driver for a given device tree node. This
  71. * should only be needed if the node lacks a compatible strings.
  72. *
  73. * @parent: Parent device
  74. * @drv_name: Name of driver to attach to this parent
  75. * @dev_name: Name of the new device thus created
  76. * @node: Device tree node
  77. * @devp: If non-NULL, returns the newly bound device
  78. */
  79. int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
  80. const char *dev_name, int node,
  81. struct udevice **devp);
  82. #endif