wcd939x-i2c.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef WCD939X_I2C_H
  6. #define WCD939X_I2C_H
  7. #include <linux/kernel.h>
  8. #include <linux/of.h>
  9. #include <linux/notifier.h>
  10. #include <linux/usb/typec.h>
  11. enum wcd_usbss_config_type {
  12. WCD_USBSS_CONFIG_TYPE_POWER_MODE,
  13. WCD_USBSS_CONFIG_TYPE_ZDET,
  14. };
  15. enum wcd_usbss_cable_types {
  16. WCD_USBSS_USB,
  17. WCD_USBSS_DP_AUX_CC1,
  18. WCD_USBSS_DP_AUX_CC2,
  19. WCD_USBSS_AATC,
  20. WCD_USBSS_GND_MIC_SWAP_AATC,
  21. WCD_USBSS_HSJ_CONNECT,
  22. WCD_USBSS_CHARGER,
  23. WCD_USBSS_GND_MIC_SWAP_HSJ,
  24. WCD_USBSS_CABLE_TYPE_MAX,
  25. };
  26. enum wcd_usbss_cable_status {
  27. WCD_USBSS_CABLE_DISCONNECT,
  28. WCD_USBSS_CABLE_CONNECT,
  29. };
  30. enum wcd_usbss_sbu_switch_orientation {
  31. /* SBU switch orientation other than the below orientations */
  32. INVALID_ORIENTATION,
  33. /* GSBU1 for the sense switches and MG2 for the mic switches */
  34. GND_SBU1_ORIENTATION_B,
  35. /* GSBU2 for the sense switches and MG1 for the mic switches */
  36. GND_SBU2_ORIENTATION_A,
  37. };
  38. enum wcd_usbss_switch_type {
  39. MIN_SWITCH_TYPE_NUM = 0,
  40. AGND_SWITCHES = 0,
  41. MIC_SWITCHES = 1,
  42. SENSE_SWITCHES = 2,
  43. DPR_SWITCHES = 3,
  44. DNL_SWITCHES = 4,
  45. DP_AUXM_TO_MGX_SWITCHES = 5,
  46. AP_AUXP_TO_MGX_SWITCHES = 6,
  47. DEVICE_ENABLE = 7,
  48. MAX_SWITCH_TYPE_NUM = 7,
  49. };
  50. enum wcd_usbss_switch_state {
  51. USBSS_SWITCH_DISABLE,
  52. USBSS_SWITCH_ENABLE,
  53. };
  54. enum linearizer_rdac_cal_code_select {
  55. LINEARIZER_SOURCE_HW,
  56. LINEARIZER_SOURCE_SW,
  57. };
  58. enum wcd_usbss_notifier_events {
  59. WCD_USBSS_SURGE_RESET_EVENT = TYPEC_MAX_ACCESSORY,
  60. };
  61. #if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
  62. int wcd_usbss_update_default_trim(void);
  63. int wcd_usbss_switch_update(enum wcd_usbss_cable_types ctype,
  64. enum wcd_usbss_cable_status status);
  65. int wcd_usbss_reg_notifier(struct notifier_block *nb,
  66. struct device_node *node);
  67. int wcd_usbss_unreg_notifier(struct notifier_block *nb,
  68. struct device_node *node);
  69. int wcd_usbss_dpdm_switch_update(bool enable, bool eq_en);
  70. int wcd_usbss_audio_config(bool enable, enum wcd_usbss_config_type config_type,
  71. unsigned int power_mode);
  72. enum wcd_usbss_sbu_switch_orientation wcd_usbss_get_sbu_switch_orientation(void);
  73. int wcd_usbss_set_switch_settings_enable(enum wcd_usbss_switch_type switch_type,
  74. enum wcd_usbss_switch_state switch_state);
  75. int wcd_usbss_linearizer_rdac_cal_code_select(enum linearizer_rdac_cal_code_select source);
  76. int wcd_usbss_set_linearizer_sw_tap(uint32_t aud_tap, uint32_t gnd_tap);
  77. int wcd_usbss_register_update(uint32_t reg_arr[][2], bool write, size_t arr_size);
  78. #else
  79. static inline int wcd_usbss_switch_update(enum wcd_usbss_cable_types ctype,
  80. enum wcd_usbss_cable_status status)
  81. {
  82. return 0;
  83. }
  84. static inline int wcd_usbss_reg_notifier(struct notifier_block *nb,
  85. struct device_node *node)
  86. {
  87. return 0;
  88. }
  89. static inline int wcd_usbss_unreg_notifier(struct notifier_block *nb,
  90. struct device_node *node)
  91. {
  92. return 0;
  93. }
  94. static inline int wcd_usbss_dpdm_switch_update(bool enable, bool eq_en)
  95. {
  96. return 0;
  97. }
  98. int wcd_usbss_audio_config(bool enable, enum wcd_usbss_config_type config_type,
  99. unsigned int power_mode)
  100. {
  101. return 0;
  102. }
  103. int wcd_usbss_update_default_trim(void)
  104. {
  105. return 0;
  106. }
  107. enum wcd_usbss_sbu_switch_orientation wcd_usbss_get_sbu_switch_orientation(void)
  108. {
  109. return INVALID_ORIENTATION;
  110. }
  111. int wcd_usbss_set_switch_settings_enable(enum wcd_usbss_switch_type switch_type,
  112. enum wcd_usbss_switch_state switch_state)
  113. {
  114. return 0;
  115. }
  116. int wcd_usbss_linearizer_rdac_cal_code_select(enum linearizer_rdac_cal_code_select source)
  117. {
  118. return 0;
  119. }
  120. int wcd_usbss_set_linearizer_sw_tap(uint32_t aud_tap, uint32_t gnd_tap)
  121. {
  122. return 0;
  123. }
  124. int wcd_usbss_register_update(uint32_t reg_arr[][2], bool write, size_t arr_size)
  125. {
  126. return 0;
  127. }
  128. #endif /* CONFIG_QCOM_WCD_USBSS_I2C */
  129. #endif /* WCD939X_I2C_H */