dp_usbpd.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DP_USBPD_H_
  6. #define _DP_USBPD_H_
  7. #include <linux/types.h>
  8. #include "dp_hpd.h"
  9. struct device;
  10. /**
  11. * enum dp_usbpd_port - usb/dp port type
  12. * @DP_USBPD_PORT_NONE: port not configured
  13. * @DP_USBPD_PORT_UFP_D: Upstream Facing Port - DisplayPort
  14. * @DP_USBPD_PORT_DFP_D: Downstream Facing Port - DisplayPort
  15. * @DP_USBPD_PORT_D_UFP_D: Both UFP & DFP - DisplayPort
  16. */
  17. enum dp_usbpd_port {
  18. DP_USBPD_PORT_NONE,
  19. DP_USBPD_PORT_UFP_D,
  20. DP_USBPD_PORT_DFP_D,
  21. DP_USBPD_PORT_D_UFP_D,
  22. };
  23. /**
  24. * struct dp_usbpd - DisplayPort status
  25. *
  26. * @port: port configured
  27. * @low_pow_st: low power state
  28. * @adaptor_dp_en: adaptor functionality enabled
  29. * @usb_config_req: request to switch to usb
  30. * @exit_dp_mode: request exit from displayport mode
  31. * @debug_en: bool to specify debug mode
  32. */
  33. struct dp_usbpd {
  34. struct dp_hpd base;
  35. enum dp_usbpd_port port;
  36. bool low_pow_st;
  37. bool adaptor_dp_en;
  38. bool usb_config_req;
  39. bool exit_dp_mode;
  40. bool debug_en;
  41. };
  42. #if IS_ENABLED(CONFIG_DRM_MSM_DP_USBPD_LEGACY)
  43. /**
  44. * dp_usbpd_get() - setup usbpd module
  45. *
  46. * @dev: device instance of the caller
  47. * @cb: struct containing callback function pointers.
  48. *
  49. * This function allows the client to initialize the usbpd
  50. * module. The module will communicate with usb driver and
  51. * handles the power delivery (PD) communication with the
  52. * sink/usb device. This module will notify the client using
  53. * the callback functions about the connection and status.
  54. */
  55. struct dp_hpd *dp_usbpd_get(struct device *dev, struct dp_hpd_cb *cb);
  56. void dp_usbpd_put(struct dp_hpd *pd);
  57. #else
  58. static inline struct dp_hpd *dp_usbpd_get(struct device *dev,
  59. struct dp_hpd_cb *cb)
  60. {
  61. return ERR_PTR(-ENODEV);
  62. }
  63. static inline void dp_usbpd_put(struct dp_hpd *pd)
  64. {
  65. }
  66. #endif /* CONFIG_DRM_MSM_DP_USBPD_LEGACY */
  67. #endif /* _DP_USBPD_H_ */