root.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_init_and_scan() - Initialise Driver Model structures and scan for devices
  59. *
  60. * This function initialises the roots of the driver tree and uclass trees,
  61. * then scans and binds available devices from platform data and the FDT.
  62. * This calls dm_init() to set up Driver Model structures.
  63. *
  64. * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
  65. * flag. If false bind all drivers.
  66. * @return 0 if OK, -ve on error
  67. */
  68. int dm_init_and_scan(bool pre_reloc_only);
  69. /**
  70. * dm_init() - Initialise Driver Model structures
  71. *
  72. * This function will initialize roots of driver tree and class tree.
  73. * This needs to be called before anything uses the DM
  74. *
  75. * @return 0 if OK, -ve on error
  76. */
  77. int dm_init(void);
  78. /**
  79. * dm_uninit - Uninitialise Driver Model structures
  80. *
  81. * All devices will be removed and unbound
  82. * @return 0 if OK, -ve on error
  83. */
  84. int dm_uninit(void);
  85. #endif