root.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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_scan_other() - Scan for other devices
  53. *
  54. * Some devices may not be visible to Driver Model. This weak function can
  55. * be provided by boards which wish to create their own devices
  56. * programmaticaly. They should do this by calling device_bind() on each
  57. * device.
  58. *
  59. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  60. * flag. If false bind all drivers.
  61. */
  62. int dm_scan_other(bool pre_reloc_only);
  63. /**
  64. * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
  65. *
  66. * This function initialises the roots of the driver tree and uclass trees,
  67. * then scans and binds available devices from platform data and the FDT.
  68. * This calls dm_init() to set up Driver Model structures.
  69. *
  70. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  71. * flag. If false bind all drivers.
  72. * @return 0 if OK, -ve on error
  73. */
  74. int dm_init_and_scan(bool pre_reloc_only);
  75. /**
  76. * dm_init() - Initialise Driver Model structures
  77. *
  78. * This function will initialize roots of driver tree and class tree.
  79. * This needs to be called before anything uses the DM
  80. *
  81. * @of_live: Enable live device tree
  82. * @return 0 if OK, -ve on error
  83. */
  84. int dm_init(bool of_live);
  85. /**
  86. * dm_uninit - Uninitialise Driver Model structures
  87. *
  88. * All devices will be removed and unbound
  89. * @return 0 if OK, -ve on error
  90. */
  91. int dm_uninit(void);
  92. #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
  93. /**
  94. * dm_remove_devices_flags - Call remove function of all drivers with
  95. * specific removal flags set to selectively
  96. * remove drivers
  97. *
  98. * All devices with the matching flags set will be removed
  99. *
  100. * @flags: Flags for selective device removal
  101. * @return 0 if OK, -ve on error
  102. */
  103. int dm_remove_devices_flags(uint flags);
  104. #else
  105. static inline int dm_remove_devices_flags(uint flags) { return 0; }
  106. #endif
  107. #endif