root.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_ROOT_H_
  10. #define _DM_ROOT_H_
  11. struct udevice;
  12. /**
  13. * dm_root() - Return pointer to the top of the driver tree
  14. *
  15. * This function returns pointer to the root node of the driver tree,
  16. *
  17. * @return pointer to root device, or NULL if not inited yet
  18. */
  19. struct udevice *dm_root(void);
  20. struct global_data;
  21. /**
  22. * dm_fixup_for_gd_move() - Handle global_data moving to a new place
  23. *
  24. * The uclass list is part of global_data. Due to the way lists work, moving
  25. * the list will cause it to become invalid. This function fixes that up so
  26. * that the uclass list will work correctly.
  27. */
  28. void dm_fixup_for_gd_move(struct global_data *new_gd);
  29. /**
  30. * dm_scan_platdata() - Scan all platform data and bind drivers
  31. *
  32. * This scans all available platdata and creates drivers for each
  33. *
  34. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  35. * flag. If false bind all drivers.
  36. * @return 0 if OK, -ve on error
  37. */
  38. int dm_scan_platdata(bool pre_reloc_only);
  39. /**
  40. * dm_scan_fdt() - Scan the device tree and bind drivers
  41. *
  42. * This scans the device tree and creates a driver for each node. Only
  43. * the top-level subnodes are examined.
  44. *
  45. * @blob: Pointer to device tree blob
  46. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  47. * flag. If false bind all drivers.
  48. * @return 0 if OK, -ve on error
  49. */
  50. int dm_scan_fdt(const void *blob, bool pre_reloc_only);
  51. /**
  52. * dm_extended_scan_fdt() - Scan the device tree and bind drivers
  53. *
  54. * This calls dm_scna_dft() which scans the device tree and creates a driver
  55. * for each node. the top-level subnodes are examined and also all sub-nodes
  56. * of "clocks" node.
  57. *
  58. * @blob: Pointer to device tree blob
  59. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  60. * flag. If false bind all drivers.
  61. * @return 0 if OK, -ve on error
  62. */
  63. int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only);
  64. /**
  65. * dm_scan_other() - Scan for other devices
  66. *
  67. * Some devices may not be visible to Driver Model. This weak function can
  68. * be provided by boards which wish to create their own devices
  69. * programmaticaly. They should do this by calling device_bind() on each
  70. * device.
  71. *
  72. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  73. * flag. If false bind all drivers.
  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 drivers with the DM_FLAG_PRE_RELOC
  84. * 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