uclass-internal.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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_UCLASS_INTERNAL_H
  10. #define _DM_UCLASS_INTERNAL_H
  11. /**
  12. * uclass_find_device() - Return n-th child of uclass
  13. * @id: Id number of the uclass
  14. * @index: Position of the child in uclass's list
  15. * #devp: Returns pointer to device, or NULL on error
  16. *
  17. * The device is not prepared for use - this is an internal function
  18. *
  19. * @return the uclass pointer of a child at the given index or
  20. * return NULL on error.
  21. */
  22. int uclass_find_device(enum uclass_id id, int index, struct udevice **devp);
  23. /**
  24. * uclass_find_first_device() - Return the first device in a uclass
  25. * @id: Id number of the uclass
  26. * #devp: Returns pointer to device, or NULL on error
  27. *
  28. * The device is not prepared for use - this is an internal function
  29. *
  30. * @return 0 if OK (found or not found), -1 on error
  31. */
  32. int uclass_find_first_device(enum uclass_id id, struct udevice **devp);
  33. /**
  34. * uclass_find_next_device() - Return the next device in a uclass
  35. * @devp: On entry, pointer to device to lookup. On exit, returns pointer
  36. * to the next device in the same uclass, or NULL if none
  37. *
  38. * The device is not prepared for use - this is an internal function
  39. *
  40. * @return 0 if OK (found or not found), -1 on error
  41. */
  42. int uclass_find_next_device(struct udevice **devp);
  43. /**
  44. * uclass_find_device_by_name() - Find uclass device based on ID and name
  45. *
  46. * This searches for a device with the given name.
  47. *
  48. * The device is NOT probed, it is merely returned.
  49. *
  50. * @id: ID to look up
  51. * @name: name of a device to find
  52. * @devp: Returns pointer to device (the first one with the name)
  53. * @return 0 if OK, -ve on error
  54. */
  55. int uclass_find_device_by_name(enum uclass_id id, const char *name,
  56. struct udevice **devp);
  57. /**
  58. * uclass_find_device_by_seq() - Find uclass device based on ID and sequence
  59. *
  60. * This searches for a device with the given seq or req_seq.
  61. *
  62. * For seq, if an active device has this sequence it will be returned.
  63. * If there is no such device then this will return -ENODEV.
  64. *
  65. * For req_seq, if a device (whether activated or not) has this req_seq
  66. * value, that device will be returned. This is a strong indication that
  67. * the device will receive that sequence when activated.
  68. *
  69. * The device is NOT probed, it is merely returned.
  70. *
  71. * @id: ID to look up
  72. * @seq_or_req_seq: Sequence number to find (0=first)
  73. * @find_req_seq: true to find req_seq, false to find seq
  74. * @devp: Returns pointer to device (there is only one per for each seq)
  75. * @return 0 if OK, -ve on error
  76. */
  77. int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
  78. bool find_req_seq, struct udevice **devp);
  79. /**
  80. * uclass_bind_device() - Associate device with a uclass
  81. *
  82. * Connect the device into uclass's list of devices.
  83. *
  84. * @dev: Pointer to the device
  85. * #return 0 on success, -ve on error
  86. */
  87. int uclass_bind_device(struct udevice *dev);
  88. /**
  89. * uclass_unbind_device() - Deassociate device with a uclass
  90. *
  91. * Disconnect the device from uclass's list of devices.
  92. *
  93. * @dev: Pointer to the device
  94. * #return 0 on success, -ve on error
  95. */
  96. int uclass_unbind_device(struct udevice *dev);
  97. /**
  98. * uclass_pre_probe_device() - Deal with a device that is about to be probed
  99. *
  100. * Perform any pre-processing that is needed by the uclass before it can be
  101. * probed. This includes the uclass' pre-probe() method and the parent
  102. * uclass' child_pre_probe() method.
  103. *
  104. * @dev: Pointer to the device
  105. * #return 0 on success, -ve on error
  106. */
  107. int uclass_pre_probe_device(struct udevice *dev);
  108. /**
  109. * uclass_post_probe_device() - Deal with a device that has just been probed
  110. *
  111. * Perform any post-processing of a probed device that is needed by the
  112. * uclass.
  113. *
  114. * @dev: Pointer to the device
  115. * #return 0 on success, -ve on error
  116. */
  117. int uclass_post_probe_device(struct udevice *dev);
  118. /**
  119. * uclass_pre_remove_device() - Handle a device which is about to be removed
  120. *
  121. * Perform any pre-processing of a device that is about to be removed.
  122. *
  123. * @dev: Pointer to the device
  124. * #return 0 on success, -ve on error
  125. */
  126. int uclass_pre_remove_device(struct udevice *dev);
  127. /**
  128. * uclass_find() - Find uclass by its id
  129. *
  130. * @id: Id to serach for
  131. * @return pointer to uclass, or NULL if not found
  132. */
  133. struct uclass *uclass_find(enum uclass_id key);
  134. /**
  135. * uclass_destroy() - Destroy a uclass
  136. *
  137. * Destroy a uclass and all its devices
  138. *
  139. * @uc: uclass to destroy
  140. * @return 0 on success, -ve on error
  141. */
  142. int uclass_destroy(struct uclass *uc);
  143. #endif