uclass-internal.h 2.9 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_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_bind_device() - Associate device with a uclass
  25. *
  26. * Connect the device into uclass's list of devices.
  27. *
  28. * @dev: Pointer to the device
  29. * #return 0 on success, -ve on error
  30. */
  31. int uclass_bind_device(struct udevice *dev);
  32. /**
  33. * uclass_unbind_device() - Deassociate device with a uclass
  34. *
  35. * Disconnect the device from uclass's list of devices.
  36. *
  37. * @dev: Pointer to the device
  38. * #return 0 on success, -ve on error
  39. */
  40. int uclass_unbind_device(struct udevice *dev);
  41. /**
  42. * uclass_post_probe_device() - Deal with a device that has just been probed
  43. *
  44. * Perform any post-processing of a probed device that is needed by the
  45. * uclass.
  46. *
  47. * @dev: Pointer to the device
  48. * #return 0 on success, -ve on error
  49. */
  50. int uclass_post_probe_device(struct udevice *dev);
  51. /**
  52. * uclass_pre_remove_device() - Handle a device which is about to be removed
  53. *
  54. * Perform any pre-processing of a device that is about to be removed.
  55. *
  56. * @dev: Pointer to the device
  57. * #return 0 on success, -ve on error
  58. */
  59. int uclass_pre_remove_device(struct udevice *dev);
  60. /**
  61. * uclass_find() - Find uclass by its id
  62. *
  63. * @id: Id to serach for
  64. * @return pointer to uclass, or NULL if not found
  65. */
  66. struct uclass *uclass_find(enum uclass_id key);
  67. /**
  68. * uclass_destroy() - Destroy a uclass
  69. *
  70. * Destroy a uclass and all its devices
  71. *
  72. * @uc: uclass to destroy
  73. * @return 0 on success, -ve on error
  74. */
  75. int uclass_destroy(struct uclass *uc);
  76. /**
  77. * uclass_find_device_by_seq() - Find uclass device based on ID and sequence
  78. *
  79. * This searches for a device with the given seq or req_seq.
  80. *
  81. * For seq, if an active device has this sequence it will be returned.
  82. * If there is no such device then this will return -ENODEV.
  83. *
  84. * For req_seq, if a device (whether activated or not) has this req_seq
  85. * value, that device will be returned. This is a strong indication that
  86. * the device will receive that sequence when activated.
  87. *
  88. * The device is NOT probed, it is merely returned.
  89. *
  90. * @id: ID to look up
  91. * @seq_or_req_seq: Sequence number to find (0=first)
  92. * @find_req_seq: true to find req_seq, false to find seq
  93. * @devp: Returns pointer to device (there is only one per for each seq)
  94. * @return 0 if OK, -ve on error
  95. */
  96. int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
  97. bool find_req_seq, struct udevice **devp);
  98. #endif