dp_hpd.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DP_HPD_H_
  6. #define _DP_HPD_H_
  7. #include <linux/types.h>
  8. #include "dp_parser.h"
  9. #include "dp_catalog.h"
  10. #include "dp_aux_bridge.h"
  11. struct device;
  12. /**
  13. * enum dp_hpd_plug_orientation - plug orientation
  14. * @ORIENTATION_NONE: Undefined or unspecified
  15. * @ORIENTATION_CC1: CC1
  16. * @ORIENTATION_CC2: CC2
  17. */
  18. enum dp_hpd_plug_orientation {
  19. ORIENTATION_NONE,
  20. ORIENTATION_CC1,
  21. ORIENTATION_CC2,
  22. };
  23. /**
  24. * enum dp_hpd_type - dp hpd type
  25. * @DP_HPD_ALTMODE: AltMode over G-Link based HPD
  26. * @DP_HPD_USBPD: USB type-c based HPD
  27. * @DP_HPD_GPIO: GPIO based HPD
  28. * @DP_HPD_LPHW: LPHW based HPD
  29. * @DP_HPD_BRIDGE: External bridge HPD
  30. */
  31. enum dp_hpd_type {
  32. DP_HPD_ALTMODE,
  33. DP_HPD_USBPD,
  34. DP_HPD_GPIO,
  35. DP_HPD_LPHW,
  36. DP_HPD_BRIDGE,
  37. };
  38. /**
  39. * struct dp_hpd_cb - callback functions provided by the client
  40. *
  41. * @configure: called when dp connection is ready.
  42. * @disconnect: notify the cable disconnect event.
  43. * @attention: notify any attention message event.
  44. */
  45. struct dp_hpd_cb {
  46. int (*configure)(struct device *dev);
  47. int (*disconnect)(struct device *dev);
  48. int (*attention)(struct device *dev);
  49. };
  50. /**
  51. * struct dp_hpd - DisplayPort HPD status
  52. *
  53. * @type: type of HPD
  54. * @orientation: plug orientation configuration, USBPD type only.
  55. * @hpd_high: Hot Plug Detect signal is high.
  56. * @hpd_irq: Change in the status since last message
  57. * @alt_mode_cfg_done: bool to specify alt mode status
  58. * @multi_func: multi-function preferred, USBPD type only
  59. * @peer_usb_com: downstream supports usb data communication
  60. * @force_multi_func: force multi-function preferred
  61. * @isr: event interrupt, BUILTIN and LPHW type only
  62. * @register_hpd: register hardware callback
  63. * @host_init: source or host side setup for hpd
  64. * @host_deinit: source or host side de-initializations
  65. * @simulate_connect: simulate disconnect or connect for debug mode
  66. * @simulate_attention: simulate attention messages for debug mode
  67. * @wakeup_phy: wakeup USBPD phy layer
  68. */
  69. struct dp_hpd {
  70. enum dp_hpd_type type;
  71. u32 orientation;
  72. bool hpd_high;
  73. bool hpd_irq;
  74. bool alt_mode_cfg_done;
  75. bool multi_func;
  76. bool peer_usb_comm;
  77. bool force_multi_func;
  78. void (*isr)(struct dp_hpd *dp_hpd);
  79. int (*register_hpd)(struct dp_hpd *dp_hpd);
  80. void (*host_init)(struct dp_hpd *hpd, struct dp_catalog_hpd *catalog);
  81. void (*host_deinit)(struct dp_hpd *hpd, struct dp_catalog_hpd *catalog);
  82. int (*simulate_connect)(struct dp_hpd *dp_hpd, bool hpd);
  83. int (*simulate_attention)(struct dp_hpd *dp_hpd, int vdo);
  84. void (*wakeup_phy)(struct dp_hpd *dp_hpd, bool wakeup);
  85. };
  86. /**
  87. * dp_hpd_get() - configure and get the DisplayPlot HPD module data
  88. *
  89. * @dev: device instance of the caller
  90. * @parser: pointer to DP parser module
  91. * @catalog: pointer to DP catalog module
  92. * @aux_bridge: handle for aux_bridge driver data
  93. * @cb: callback function for HPD response
  94. * return: pointer to allocated hpd module data
  95. *
  96. * This function sets up the hpd module
  97. */
  98. struct dp_hpd *dp_hpd_get(struct device *dev, struct dp_parser *parser,
  99. struct dp_catalog_hpd *catalog,
  100. struct dp_aux_bridge *aux_bridge,
  101. struct dp_hpd_cb *cb);
  102. /**
  103. * dp_hpd_put()
  104. *
  105. * Cleans up dp_hpd instance
  106. *
  107. * @dp_hpd: instance of dp_hpd
  108. */
  109. void dp_hpd_put(struct dp_hpd *dp_hpd);
  110. #endif /* _DP_HPD_H_ */