dp_hpd.h 3.1 KB

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