root.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. /**
  21. * dm_scan_platdata() - Scan all platform data and bind drivers
  22. *
  23. * This scans all available platdata and creates drivers for each
  24. *
  25. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  26. * flag. If false bind all drivers.
  27. * @return 0 if OK, -ve on error
  28. */
  29. int dm_scan_platdata(bool pre_reloc_only);
  30. /**
  31. * dm_scan_fdt() - Scan the device tree and bind drivers
  32. *
  33. * This scans the device tree and creates a driver for each node. Only
  34. * the top-level subnodes are examined.
  35. *
  36. * @blob: Pointer to device tree blob
  37. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  38. * flag. If false bind all drivers.
  39. * @return 0 if OK, -ve on error
  40. */
  41. int dm_scan_fdt(const void *blob, bool pre_reloc_only);
  42. /**
  43. * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
  44. *
  45. * This scans the subnodes of a device tree node and and creates a driver
  46. * for each one.
  47. *
  48. * @parent: Parent device for the devices that will be created
  49. * @blob: Pointer to device tree blob
  50. * @offset: Offset of node to scan
  51. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  52. * flag. If false bind all drivers.
  53. * @return 0 if OK, -ve on error
  54. */
  55. int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
  56. bool pre_reloc_only);
  57. /**
  58. * dm_scan_other() - Scan for other devices
  59. *
  60. * Some devices may not be visible to Driver Model. This weak function can
  61. * be provided by boards which wish to create their own devices
  62. * programmaticaly. They should do this by calling device_bind() on each
  63. * device.
  64. *
  65. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  66. * flag. If false bind all drivers.
  67. */
  68. int dm_scan_other(bool pre_reloc_only);
  69. /**
  70. * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
  71. *
  72. * This function initialises the roots of the driver tree and uclass trees,
  73. * then scans and binds available devices from platform data and the FDT.
  74. * This calls dm_init() to set up Driver Model structures.
  75. *
  76. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  77. * flag. If false bind all drivers.
  78. * @return 0 if OK, -ve on error
  79. */
  80. int dm_init_and_scan(bool pre_reloc_only);
  81. /**
  82. * dm_init() - Initialise Driver Model structures
  83. *
  84. * This function will initialize roots of driver tree and class tree.
  85. * This needs to be called before anything uses the DM
  86. *
  87. * @return 0 if OK, -ve on error
  88. */
  89. int dm_init(void);
  90. /**
  91. * dm_uninit - Uninitialise Driver Model structures
  92. *
  93. * All devices will be removed and unbound
  94. * @return 0 if OK, -ve on error
  95. */
  96. int dm_uninit(void);
  97. #endif