root.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_ROOT_H_
  9. #define _DM_ROOT_H_
  10. struct udevice;
  11. /**
  12. * dm_root() - Return pointer to the top of the driver tree
  13. *
  14. * This function returns pointer to the root node of the driver tree,
  15. *
  16. * @return pointer to root device, or NULL if not inited yet
  17. */
  18. struct udevice *dm_root(void);
  19. struct global_data;
  20. /**
  21. * dm_fixup_for_gd_move() - Handle global_data moving to a new place
  22. *
  23. * The uclass list is part of global_data. Due to the way lists work, moving
  24. * the list will cause it to become invalid. This function fixes that up so
  25. * that the uclass list will work correctly.
  26. */
  27. void dm_fixup_for_gd_move(struct global_data *new_gd);
  28. /**
  29. * dm_scan_platdata() - Scan all platform data and bind drivers
  30. *
  31. * This scans all available platdata and creates drivers for each
  32. *
  33. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  34. * flag. If false bind all drivers.
  35. * @return 0 if OK, -ve on error
  36. */
  37. int dm_scan_platdata(bool pre_reloc_only);
  38. /**
  39. * dm_scan_fdt() - Scan the device tree and bind drivers
  40. *
  41. * This scans the device tree and creates a driver for each node. Only
  42. * the top-level subnodes are examined.
  43. *
  44. * @blob: Pointer to device tree blob
  45. * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
  46. * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
  47. * @return 0 if OK, -ve on error
  48. */
  49. int dm_scan_fdt(const void *blob, bool pre_reloc_only);
  50. /**
  51. * dm_extended_scan_fdt() - Scan the device tree and bind drivers
  52. *
  53. * This calls dm_scna_dft() which scans the device tree and creates a driver
  54. * for each node. the top-level subnodes are examined and also all sub-nodes
  55. * of "clocks" node.
  56. *
  57. * @blob: Pointer to device tree blob
  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.
  60. * @return 0 if OK, -ve on error
  61. */
  62. int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only);
  63. /**
  64. * dm_scan_other() - Scan for other devices
  65. *
  66. * Some devices may not be visible to Driver Model. This weak function can
  67. * be provided by boards which wish to create their own devices
  68. * programmaticaly. They should do this by calling device_bind() on each
  69. * device.
  70. *
  71. * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
  72. * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
  73. * @return 0 if OK, -ve on error
  74. */
  75. int dm_scan_other(bool pre_reloc_only);
  76. /**
  77. * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
  78. *
  79. * This function initialises the roots of the driver tree and uclass trees,
  80. * then scans and binds available devices from platform data and the FDT.
  81. * This calls dm_init() to set up Driver Model structures.
  82. *
  83. * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
  84. * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
  85. * @return 0 if OK, -ve on error
  86. */
  87. int dm_init_and_scan(bool pre_reloc_only);
  88. /**
  89. * dm_init() - Initialise Driver Model structures
  90. *
  91. * This function will initialize roots of driver tree and class tree.
  92. * This needs to be called before anything uses the DM
  93. *
  94. * @of_live: Enable live device tree
  95. * @return 0 if OK, -ve on error
  96. */
  97. int dm_init(bool of_live);
  98. /**
  99. * dm_uninit - Uninitialise Driver Model structures
  100. *
  101. * All devices will be removed and unbound
  102. * @return 0 if OK, -ve on error
  103. */
  104. int dm_uninit(void);
  105. #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
  106. /**
  107. * dm_remove_devices_flags - Call remove function of all drivers with
  108. * specific removal flags set to selectively
  109. * remove drivers
  110. *
  111. * All devices with the matching flags set will be removed
  112. *
  113. * @flags: Flags for selective device removal
  114. * @return 0 if OK, -ve on error
  115. */
  116. int dm_remove_devices_flags(uint flags);
  117. #else
  118. static inline int dm_remove_devices_flags(uint flags) { return 0; }
  119. #endif
  120. #endif