dp_hpd.h 2.6 KB

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