root.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_fdt_node() - Scan the device tree and bind drivers for a node
  53. *
  54. * This scans the subnodes of a device tree node and and creates a driver
  55. * for each one.
  56. *
  57. * @parent: Parent device for the devices that will be created
  58. * @blob: Pointer to device tree blob
  59. * @offset: Offset of node to scan
  60. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  61. * flag. If false bind all drivers.
  62. * @return 0 if OK, -ve on error
  63. */
  64. int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
  65. bool pre_reloc_only);
  66. /**
  67. * dm_scan_other() - Scan for other devices
  68. *
  69. * Some devices may not be visible to Driver Model. This weak function can
  70. * be provided by boards which wish to create their own devices
  71. * programmaticaly. They should do this by calling device_bind() on each
  72. * device.
  73. *
  74. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  75. * flag. If false bind all drivers.
  76. */
  77. int dm_scan_other(bool pre_reloc_only);
  78. /**
  79. * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
  80. *
  81. * This function initialises the roots of the driver tree and uclass trees,
  82. * then scans and binds available devices from platform data and the FDT.
  83. * This calls dm_init() to set up Driver Model structures.
  84. *
  85. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  86. * flag. If false bind all drivers.
  87. * @return 0 if OK, -ve on error
  88. */
  89. int dm_init_and_scan(bool pre_reloc_only);
  90. /**
  91. * dm_init() - Initialise Driver Model structures
  92. *
  93. * This function will initialize roots of driver tree and class tree.
  94. * This needs to be called before anything uses the DM
  95. *
  96. * @return 0 if OK, -ve on error
  97. */
  98. int dm_init(void);
  99. /**
  100. * dm_uninit - Uninitialise Driver Model structures
  101. *
  102. * All devices will be removed and unbound
  103. * @return 0 if OK, -ve on error
  104. */
  105. int dm_uninit(void);
  106. #endif