rt715-sdca.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * rt715-sdca.h -- RT715 ALSA SoC audio driver header
  4. *
  5. * Copyright(c) 2020 Realtek Semiconductor Corp.
  6. */
  7. #ifndef __RT715_SDCA_H__
  8. #define __RT715_SDCA_H__
  9. #include <linux/regmap.h>
  10. #include <linux/soundwire/sdw.h>
  11. #include <linux/soundwire/sdw_type.h>
  12. #include <sound/soc.h>
  13. #include <linux/workqueue.h>
  14. #include <linux/device.h>
  15. struct rt715_sdca_priv {
  16. struct regmap *regmap;
  17. struct regmap *mbq_regmap;
  18. struct snd_soc_codec *codec;
  19. struct sdw_slave *slave;
  20. struct delayed_work adc_mute_work;
  21. int dbg_nid;
  22. int dbg_vid;
  23. int dbg_payload;
  24. enum sdw_slave_status status;
  25. struct sdw_bus_params params;
  26. bool hw_init;
  27. bool first_hw_init;
  28. int l_is_unmute;
  29. int r_is_unmute;
  30. int hw_sdw_ver;
  31. int kctl_switch_orig[4];
  32. int kctl_2ch_orig[2];
  33. int kctl_4ch_orig[4];
  34. int kctl_8ch_orig[8];
  35. };
  36. struct rt715_sdw_stream_data {
  37. struct sdw_stream_runtime *sdw_stream;
  38. };
  39. struct rt715_sdca_kcontrol_private {
  40. unsigned int reg_base;
  41. unsigned int count;
  42. unsigned int max;
  43. unsigned int shift;
  44. unsigned int invert;
  45. };
  46. /* MIPI Register */
  47. #define RT715_INT_CTRL 0x005a
  48. #define RT715_INT_MASK 0x005e
  49. /* NID */
  50. #define RT715_AUDIO_FUNCTION_GROUP 0x01
  51. #define RT715_MIC_ADC 0x07
  52. #define RT715_LINE_ADC 0x08
  53. #define RT715_MIX_ADC 0x09
  54. #define RT715_DMIC1 0x12
  55. #define RT715_DMIC2 0x13
  56. #define RT715_MIC1 0x18
  57. #define RT715_MIC2 0x19
  58. #define RT715_LINE1 0x1a
  59. #define RT715_LINE2 0x1b
  60. #define RT715_DMIC3 0x1d
  61. #define RT715_DMIC4 0x29
  62. #define RT715_VENDOR_REG 0x20
  63. #define RT715_MUX_IN1 0x22
  64. #define RT715_MUX_IN2 0x23
  65. #define RT715_MUX_IN3 0x24
  66. #define RT715_MUX_IN4 0x25
  67. #define RT715_MIX_ADC2 0x27
  68. #define RT715_INLINE_CMD 0x55
  69. #define RT715_VENDOR_HDA_CTL 0x61
  70. /* Index (NID:20h) */
  71. #define RT715_PRODUCT_NUM 0x0
  72. #define RT715_IRQ_CTRL 0x2b
  73. #define RT715_AD_FUNC_EN 0x36
  74. #define RT715_REV_1 0x37
  75. #define RT715_SDW_INPUT_SEL 0x39
  76. #define RT715_DFLL_VAD 0x44
  77. #define RT715_EXT_DMIC_CLK_CTRL2 0x54
  78. /* Index (NID:61h) */
  79. #define RT715_HDA_LEGACY_MUX_CTL1 0x00
  80. /* SDCA (Function) */
  81. #define FUN_JACK_CODEC 0x01
  82. #define FUN_MIC_ARRAY 0x02
  83. #define FUN_HID 0x03
  84. /* SDCA (Entity) */
  85. #define RT715_SDCA_ST_EN 0x00
  86. #define RT715_SDCA_CS_FREQ_IND_EN 0x01
  87. #define RT715_SDCA_FU_ADC8_9_VOL 0x02
  88. #define RT715_SDCA_SMPU_TRIG_ST_EN 0x05
  89. #define RT715_SDCA_FU_ADC10_11_VOL 0x06
  90. #define RT715_SDCA_FU_ADC7_27_VOL 0x0a
  91. #define RT715_SDCA_FU_AMIC_GAIN_EN 0x0c
  92. #define RT715_SDCA_FU_DMIC_GAIN_EN 0x0e
  93. #define RT715_SDCA_CX_CLK_SEL_EN 0x10
  94. #define RT715_SDCA_CREQ_POW_EN 0x18
  95. /* SDCA (Control) */
  96. #define RT715_SDCA_ST_CTRL 0x00
  97. #define RT715_SDCA_CX_CLK_SEL_CTRL 0x01
  98. #define RT715_SDCA_REQ_POW_CTRL 0x01
  99. #define RT715_SDCA_FU_MUTE_CTRL 0x01
  100. #define RT715_SDCA_FU_VOL_CTRL 0x02
  101. #define RT715_SDCA_FU_DMIC_GAIN_CTRL 0x0b
  102. #define RT715_SDCA_FREQ_IND_CTRL 0x10
  103. #define RT715_SDCA_SMPU_TRIG_EN_CTRL 0x10
  104. #define RT715_SDCA_SMPU_TRIG_ST_CTRL 0x11
  105. /* SDCA (Channel) */
  106. #define CH_00 0x00
  107. #define CH_01 0x01
  108. #define CH_02 0x02
  109. #define CH_03 0x03
  110. #define CH_04 0x04
  111. #define CH_05 0x05
  112. #define CH_06 0x06
  113. #define CH_07 0x07
  114. #define CH_08 0x08
  115. #define RT715_SDCA_DB_STEP 375
  116. enum {
  117. RT715_AIF1,
  118. RT715_AIF2,
  119. };
  120. int rt715_sdca_io_init(struct device *dev, struct sdw_slave *slave);
  121. int rt715_sdca_init(struct device *dev, struct regmap *mbq_regmap,
  122. struct regmap *regmap, struct sdw_slave *slave);
  123. #endif /* __RT715_SDCA_H__ */