rt700.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * rt700.h -- RT700 ALSA SoC audio driver header
  4. *
  5. * Copyright(c) 2019 Realtek Semiconductor Corp.
  6. */
  7. #ifndef __RT700_H__
  8. #define __RT700_H__
  9. extern const struct dev_pm_ops rt700_runtime_pm;
  10. struct rt700_priv {
  11. struct snd_soc_component *component;
  12. struct regmap *regmap;
  13. struct regmap *sdw_regmap;
  14. struct sdw_slave *slave;
  15. enum sdw_slave_status status;
  16. struct sdw_bus_params params;
  17. bool hw_init;
  18. bool first_hw_init;
  19. struct snd_soc_jack *hs_jack;
  20. struct delayed_work jack_detect_work;
  21. struct delayed_work jack_btn_check_work;
  22. int jack_type;
  23. struct mutex disable_irq_lock; /* imp-def irq lock protection */
  24. bool disable_irq;
  25. };
  26. struct sdw_stream_data {
  27. struct sdw_stream_runtime *sdw_stream;
  28. };
  29. /* NID */
  30. #define RT700_AUDIO_FUNCTION_GROUP 0x01
  31. #define RT700_DAC_OUT1 0x02
  32. #define RT700_DAC_OUT2 0x03
  33. #define RT700_ADC_IN1 0x09
  34. #define RT700_ADC_IN2 0x08
  35. #define RT700_DMIC1 0x12
  36. #define RT700_DMIC2 0x13
  37. #define RT700_SPK_OUT 0x14
  38. #define RT700_MIC2 0x19
  39. #define RT700_LINE1 0x1a
  40. #define RT700_LINE2 0x1b
  41. #define RT700_BEEP 0x1d
  42. #define RT700_SPDIF 0x1e
  43. #define RT700_VENDOR_REGISTERS 0x20
  44. #define RT700_HP_OUT 0x21
  45. #define RT700_MIXER_IN1 0x22
  46. #define RT700_MIXER_IN2 0x23
  47. #define RT700_INLINE_CMD 0x55
  48. /* Index (NID:20h) */
  49. #define RT700_DAC_DC_CALI_CTL1 0x00
  50. #define RT700_PARA_VERB_CTL 0x1a
  51. #define RT700_COMBO_JACK_AUTO_CTL1 0x45
  52. #define RT700_COMBO_JACK_AUTO_CTL2 0x46
  53. #define RT700_INLINE_CMD_CTL 0x48
  54. #define RT700_DIGITAL_MISC_CTRL4 0x4a
  55. #define RT700_VREFOUT_CTL 0x6b
  56. #define RT700_FSM_CTL 0x6f
  57. #define RT700_IRQ_FLAG_TABLE1 0x80
  58. #define RT700_IRQ_FLAG_TABLE2 0x81
  59. #define RT700_IRQ_FLAG_TABLE3 0x82
  60. /* Verb */
  61. #define RT700_VERB_SET_CONNECT_SEL 0x3100
  62. #define RT700_VERB_SET_EAPD_BTLENABLE 0x3c00
  63. #define RT700_VERB_GET_CONNECT_SEL 0xb100
  64. #define RT700_VERB_SET_POWER_STATE 0x3500
  65. #define RT700_VERB_SET_CHANNEL_STREAMID 0x3600
  66. #define RT700_VERB_SET_PIN_WIDGET_CONTROL 0x3700
  67. #define RT700_VERB_SET_UNSOLICITED_ENABLE 0x3800
  68. #define RT700_SET_AMP_GAIN_MUTE_H 0x7300
  69. #define RT700_SET_AMP_GAIN_MUTE_L 0x8380
  70. #define RT700_VERB_GET_PIN_SENSE 0xb900
  71. #define RT700_READ_HDA_3 0x2012
  72. #define RT700_READ_HDA_2 0x2013
  73. #define RT700_READ_HDA_1 0x2014
  74. #define RT700_READ_HDA_0 0x2015
  75. #define RT700_PRIV_INDEX_W_H 0x7520
  76. #define RT700_PRIV_INDEX_W_L 0x85a0
  77. #define RT700_PRIV_DATA_W_H 0x7420
  78. #define RT700_PRIV_DATA_W_L 0x84a0
  79. #define RT700_PRIV_INDEX_R_H 0x9d20
  80. #define RT700_PRIV_INDEX_R_L 0xada0
  81. #define RT700_PRIV_DATA_R_H 0x9c20
  82. #define RT700_PRIV_DATA_R_L 0xaca0
  83. #define RT700_DAC_FORMAT_H 0x7203
  84. #define RT700_DAC_FORMAT_L 0x8283
  85. #define RT700_ADC_FORMAT_H 0x7209
  86. #define RT700_ADC_FORMAT_L 0x8289
  87. #define RT700_SET_AUDIO_POWER_STATE\
  88. (RT700_VERB_SET_POWER_STATE | RT700_AUDIO_FUNCTION_GROUP)
  89. #define RT700_SET_PIN_DMIC1\
  90. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_DMIC1)
  91. #define RT700_SET_PIN_DMIC2\
  92. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_DMIC2)
  93. #define RT700_SET_PIN_SPK\
  94. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_SPK_OUT)
  95. #define RT700_SET_PIN_HP\
  96. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_HP_OUT)
  97. #define RT700_SET_PIN_MIC2\
  98. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_MIC2)
  99. #define RT700_SET_PIN_LINE1\
  100. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_LINE1)
  101. #define RT700_SET_PIN_LINE2\
  102. (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_LINE2)
  103. #define RT700_SET_MIC2_UNSOLICITED_ENABLE\
  104. (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_MIC2)
  105. #define RT700_SET_HP_UNSOLICITED_ENABLE\
  106. (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_HP_OUT)
  107. #define RT700_SET_INLINE_UNSOLICITED_ENABLE\
  108. (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_INLINE_CMD)
  109. #define RT700_SET_STREAMID_DAC1\
  110. (RT700_VERB_SET_CHANNEL_STREAMID | RT700_DAC_OUT1)
  111. #define RT700_SET_STREAMID_DAC2\
  112. (RT700_VERB_SET_CHANNEL_STREAMID | RT700_DAC_OUT2)
  113. #define RT700_SET_STREAMID_ADC1\
  114. (RT700_VERB_SET_CHANNEL_STREAMID | RT700_ADC_IN1)
  115. #define RT700_SET_STREAMID_ADC2\
  116. (RT700_VERB_SET_CHANNEL_STREAMID | RT700_ADC_IN2)
  117. #define RT700_SET_GAIN_DAC1_L\
  118. (RT700_SET_AMP_GAIN_MUTE_L | RT700_DAC_OUT1)
  119. #define RT700_SET_GAIN_DAC1_H\
  120. (RT700_SET_AMP_GAIN_MUTE_H | RT700_DAC_OUT1)
  121. #define RT700_SET_GAIN_ADC1_L\
  122. (RT700_SET_AMP_GAIN_MUTE_L | RT700_ADC_IN1)
  123. #define RT700_SET_GAIN_ADC1_H\
  124. (RT700_SET_AMP_GAIN_MUTE_H | RT700_ADC_IN1)
  125. #define RT700_SET_GAIN_ADC2_L\
  126. (RT700_SET_AMP_GAIN_MUTE_L | RT700_ADC_IN2)
  127. #define RT700_SET_GAIN_ADC2_H\
  128. (RT700_SET_AMP_GAIN_MUTE_H | RT700_ADC_IN2)
  129. #define RT700_SET_GAIN_AMIC_L\
  130. (RT700_SET_AMP_GAIN_MUTE_L | RT700_MIC2)
  131. #define RT700_SET_GAIN_AMIC_H\
  132. (RT700_SET_AMP_GAIN_MUTE_H | RT700_MIC2)
  133. #define RT700_SET_GAIN_HP_L\
  134. (RT700_SET_AMP_GAIN_MUTE_L | RT700_HP_OUT)
  135. #define RT700_SET_GAIN_HP_H\
  136. (RT700_SET_AMP_GAIN_MUTE_H | RT700_HP_OUT)
  137. #define RT700_SET_GAIN_SPK_L\
  138. (RT700_SET_AMP_GAIN_MUTE_L | RT700_SPK_OUT)
  139. #define RT700_SET_GAIN_SPK_H\
  140. (RT700_SET_AMP_GAIN_MUTE_H | RT700_SPK_OUT)
  141. #define RT700_SET_EAPD_SPK\
  142. (RT700_VERB_SET_EAPD_BTLENABLE | RT700_SPK_OUT)
  143. /* combo jack auto switch control 2 (0x46)(NID:20h) */
  144. #define RT700_COMBOJACK_AUTO_DET_STATUS (0x1 << 11)
  145. #define RT700_COMBOJACK_AUTO_DET_TRS (0x1 << 10)
  146. #define RT700_COMBOJACK_AUTO_DET_CTIA (0x1 << 9)
  147. #define RT700_COMBOJACK_AUTO_DET_OMTP (0x1 << 8)
  148. #define RT700_EAPD_HIGH 0x2
  149. #define RT700_EAPD_LOW 0x0
  150. #define RT700_MUTE_SFT 7
  151. #define RT700_DIR_IN_SFT 6
  152. #define RT700_DIR_OUT_SFT 7
  153. enum {
  154. RT700_AIF1,
  155. RT700_AIF2,
  156. RT700_AIFS,
  157. };
  158. int rt700_io_init(struct device *dev, struct sdw_slave *slave);
  159. int rt700_init(struct device *dev, struct regmap *sdw_regmap,
  160. struct regmap *regmap, struct sdw_slave *slave);
  161. int rt700_jack_detect(struct rt700_priv *rt700, bool *hp, bool *mic);
  162. int rt700_clock_config(struct device *dev);
  163. #endif /* __RT700_H__ */