lists.h 3.0 KB

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