uclass-internal.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_bind_device() - Associate device with a uclass
  45. *
  46. * Connect the device into uclass's list of devices.
  47. *
  48. * @dev: Pointer to the device
  49. * #return 0 on success, -ve on error
  50. */
  51. int uclass_bind_device(struct udevice *dev);
  52. /**
  53. * uclass_unbind_device() - Deassociate device with a uclass
  54. *
  55. * Disconnect the device from uclass's list of devices.
  56. *
  57. * @dev: Pointer to the device
  58. * #return 0 on success, -ve on error
  59. */
  60. int uclass_unbind_device(struct udevice *dev);
  61. /**
  62. * uclass_pre_probe_device() - Deal with a device that is about to be probed
  63. *
  64. * Perform any pre-processing that is needed by the uclass before it can be
  65. * probed. This includes the uclass' pre-probe() method and the parent
  66. * uclass' child_pre_probe() method.
  67. *
  68. * @dev: Pointer to the device
  69. * #return 0 on success, -ve on error
  70. */
  71. int uclass_pre_probe_device(struct udevice *dev);
  72. /**
  73. * uclass_post_probe_device() - Deal with a device that has just been probed
  74. *
  75. * Perform any post-processing of a probed device that is needed by the
  76. * uclass.
  77. *
  78. * @dev: Pointer to the device
  79. * #return 0 on success, -ve on error
  80. */
  81. int uclass_post_probe_device(struct udevice *dev);
  82. /**
  83. * uclass_pre_remove_device() - Handle a device which is about to be removed
  84. *
  85. * Perform any pre-processing of a device that is about to be removed.
  86. *
  87. * @dev: Pointer to the device
  88. * #return 0 on success, -ve on error
  89. */
  90. int uclass_pre_remove_device(struct udevice *dev);
  91. /**
  92. * uclass_find() - Find uclass by its id
  93. *
  94. * @id: Id to serach for
  95. * @return pointer to uclass, or NULL if not found
  96. */
  97. struct uclass *uclass_find(enum uclass_id key);
  98. /**
  99. * uclass_destroy() - Destroy a uclass
  100. *
  101. * Destroy a uclass and all its devices
  102. *
  103. * @uc: uclass to destroy
  104. * @return 0 on success, -ve on error
  105. */
  106. int uclass_destroy(struct uclass *uc);
  107. /**
  108. * uclass_find_device_by_seq() - Find uclass device based on ID and sequence
  109. *
  110. * This searches for a device with the given seq or req_seq.
  111. *
  112. * For seq, if an active device has this sequence it will be returned.
  113. * If there is no such device then this will return -ENODEV.
  114. *
  115. * For req_seq, if a device (whether activated or not) has this req_seq
  116. * value, that device will be returned. This is a strong indication that
  117. * the device will receive that sequence when activated.
  118. *
  119. * The device is NOT probed, it is merely returned.
  120. *
  121. * @id: ID to look up
  122. * @seq_or_req_seq: Sequence number to find (0=first)
  123. * @find_req_seq: true to find req_seq, false to find seq
  124. * @devp: Returns pointer to device (there is only one per for each seq)
  125. * @return 0 if OK, -ve on error
  126. */
  127. int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
  128. bool find_req_seq, struct udevice **devp);
  129. #endif