drm_dp_aux_bus.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2021 Google Inc.
  4. *
  5. * The DP AUX bus is used for devices that are connected over a DisplayPort
  6. * AUX bus. The devices on the far side of the bus are referred to as
  7. * endpoints in this code.
  8. */
  9. #ifndef _DP_AUX_BUS_H_
  10. #define _DP_AUX_BUS_H_
  11. #include <linux/device.h>
  12. #include <linux/mod_devicetable.h>
  13. /**
  14. * struct dp_aux_ep_device - Main dev structure for DP AUX endpoints
  15. *
  16. * This is used to instantiate devices that are connected via a DP AUX
  17. * bus. Usually the device is a panel, but conceivable other devices could
  18. * be hooked up there.
  19. */
  20. struct dp_aux_ep_device {
  21. /** @dev: The normal dev pointer */
  22. struct device dev;
  23. /** @aux: Pointer to the aux bus */
  24. struct drm_dp_aux *aux;
  25. };
  26. struct dp_aux_ep_driver {
  27. int (*probe)(struct dp_aux_ep_device *aux_ep);
  28. void (*remove)(struct dp_aux_ep_device *aux_ep);
  29. void (*shutdown)(struct dp_aux_ep_device *aux_ep);
  30. struct device_driver driver;
  31. };
  32. static inline struct dp_aux_ep_device *to_dp_aux_ep_dev(struct device *dev)
  33. {
  34. return container_of(dev, struct dp_aux_ep_device, dev);
  35. }
  36. static inline struct dp_aux_ep_driver *to_dp_aux_ep_drv(struct device_driver *drv)
  37. {
  38. return container_of(drv, struct dp_aux_ep_driver, driver);
  39. }
  40. int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
  41. int (*done_probing)(struct drm_dp_aux *aux));
  42. void of_dp_aux_depopulate_bus(struct drm_dp_aux *aux);
  43. int devm_of_dp_aux_populate_bus(struct drm_dp_aux *aux,
  44. int (*done_probing)(struct drm_dp_aux *aux));
  45. /* Deprecated versions of the above functions. To be removed when no callers. */
  46. static inline int of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
  47. {
  48. int ret;
  49. ret = of_dp_aux_populate_bus(aux, NULL);
  50. /* New API returns -ENODEV for no child case; adapt to old assumption */
  51. return (ret != -ENODEV) ? ret : 0;
  52. }
  53. static inline int devm_of_dp_aux_populate_ep_devices(struct drm_dp_aux *aux)
  54. {
  55. int ret;
  56. ret = devm_of_dp_aux_populate_bus(aux, NULL);
  57. /* New API returns -ENODEV for no child case; adapt to old assumption */
  58. return (ret != -ENODEV) ? ret : 0;
  59. }
  60. static inline void of_dp_aux_depopulate_ep_devices(struct drm_dp_aux *aux)
  61. {
  62. of_dp_aux_depopulate_bus(aux);
  63. }
  64. #define dp_aux_dp_driver_register(aux_ep_drv) \
  65. __dp_aux_dp_driver_register(aux_ep_drv, THIS_MODULE)
  66. int __dp_aux_dp_driver_register(struct dp_aux_ep_driver *aux_ep_drv,
  67. struct module *owner);
  68. void dp_aux_dp_driver_unregister(struct dp_aux_ep_driver *aux_ep_drv);
  69. #endif /* _DP_AUX_BUS_H_ */