es7210_config.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * ALSA SoC ES7210 adc driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.^M
  7. *
  8. * Notes:
  9. * ES7210 is a 4-ch ADC of Everest
  10. * This is user configuration document.
  11. * You can update this file according to your application
  12. */
  13. #define ENABLE 1
  14. #define DISABLE 0
  15. #define MIC_CHN_16 16
  16. #define MIC_CHN_14 14
  17. #define MIC_CHN_12 12
  18. #define MIC_CHN_10 10
  19. #define MIC_CHN_8 8
  20. #define MIC_CHN_6 6
  21. #define MIC_CHN_4 4
  22. #define MIC_CHN_2 2
  23. #define ES7210_TDM_ENABLE ENABLE
  24. #define ES7210_CHANNELS_MAX MIC_CHN_2
  25. #if ES7210_CHANNELS_MAX == MIC_CHN_2
  26. #define ADC_DEV_MAXNUM 1
  27. #endif
  28. #if ES7210_CHANNELS_MAX == MIC_CHN_4
  29. #define ADC_DEV_MAXNUM 1
  30. #endif
  31. #if ES7210_CHANNELS_MAX == MIC_CHN_6
  32. #define ADC_DEV_MAXNUM 2
  33. #endif
  34. #if ES7210_CHANNELS_MAX == MIC_CHN_8
  35. #define ADC_DEV_MAXNUM 2
  36. #endif
  37. #if ES7210_CHANNELS_MAX == MIC_CHN_10
  38. #define ADC_DEV_MAXNUM 3
  39. #endif
  40. #if ES7210_CHANNELS_MAX == MIC_CHN_12
  41. #define ADC_DEV_MAXNUM 3
  42. #endif
  43. #if ES7210_CHANNELS_MAX == MIC_CHN_14
  44. #define ADC_DEV_MAXNUM 4
  45. #endif
  46. #if ES7210_CHANNELS_MAX == MIC_CHN_16
  47. #define ADC_DEV_MAXNUM 4
  48. #endif
  49. #define ES7210_TDM_1LRCK_DSPA 0
  50. #define ES7210_TDM_1LRCK_DSPB 1
  51. #define ES7210_TDM_1LRCK_I2S 2
  52. #define ES7210_TDM_1LRCK_LJ 3
  53. #define ES7210_TDM_NLRCK_DSPA 4
  54. #define ES7210_TDM_NLRCK_DSPB 5
  55. #define ES7210_TDM_NLRCK_I2S 6
  56. #define ES7210_TDM_NLRCK_LJ 7
  57. #define ES7210_NORMAL_I2S 8
  58. #define ES7210_NORMAL_LJ 9
  59. #define ES7210_NORMAL_DSPA 10
  60. #define ES7210_NORMAL_DSPB 11
  61. #define ES7210_WORK_MODE ES7210_NORMAL_I2S
  62. #define RATIO_MCLK_LRCK_64 64
  63. #define RATIO_MCLK_LRCK_128 128
  64. #define RATIO_MCLK_LRCK_192 192
  65. #define RATIO_MCLK_LRCK_256 256
  66. #define RATIO_MCLK_LRCK_384 384
  67. #define RATIO_MCLK_LRCK_512 512
  68. #define RATIO_MCLK_LRCK_768 768
  69. #define RATIO_MCLK_LRCK_896 896
  70. #define RATIO_MCLK_LRCK_1024 1024
  71. #define RATIO_MCLK_LRCK_1152 1152
  72. #define RATIO_MCLK_LRCK_1280 1280
  73. #define RATIO_MCLK_LRCK_1408 1408
  74. #define RAITO_MCLK_LRCK_1536 1536
  75. #define RATIO_MCLK_LRCK_1664 1664
  76. #define RATIO_MCLK_LRCK_1792 1792
  77. #define RATIO_MCLK_LRCK_1920 1920
  78. #define RATIO_MCLK_LRCK_2048 2048
  79. #define RATIO_MCLK_LRCK_3072 3072
  80. #define RATIO_MCLK_LRCK_4096 4096
  81. #define RATIO_MCLK_LRCK RATIO_MCLK_LRCK_64
  82. #define ES7210_I2C_BUS_NUM 1
  83. #define ES7210_CODEC_RW_TEST_EN 0
  84. #define ES7210_IDLE_RESET_EN 1 //reset ES7210 when in idle time
  85. #define ES7210_MATCH_DTS_EN 1 //ES7210 match method select: 0: i2c_detect, 1:of_device_id
  86. struct i2c_client *i2c_clt1[ADC_DEV_MAXNUM];
  87. struct snd_soc_component *tron_codec1[ADC_DEV_MAXNUM];
  88. int es7210_init_reg = 0;
  89. static int es7210_codec_num = 0;
  90. struct es7210_reg_config {
  91. unsigned char reg_addr;
  92. unsigned char reg_v;
  93. };
  94. static const struct es7210_reg_config es7210_tdm_reg_common_cfg1[] = {
  95. {0x00, 0xFF},
  96. {0x00, 0x32},
  97. {0x09, 0x30},
  98. {0x0A, 0x30},
  99. {0x23, 0x2a},
  100. {0x22, 0x0a},
  101. {0x21, 0x2a},
  102. {0x20, 0x0a},
  103. };
  104. static const struct es7210_reg_config es7210_tdm_reg_fmt_cfg[] = {
  105. {0x11, 0x63},
  106. {0x12, 0x01},
  107. };
  108. static const struct es7210_reg_config es7210_tdm_reg_common_cfg2[] = {
  109. {0x40, 0xC7},
  110. {0x41, 0x70},
  111. {0x42, 0x70},
  112. {0x43, 0x10},
  113. {0x44, 0x10},
  114. {0x45, 0x10},
  115. {0x46, 0x10},
  116. {0x47, 0x08},
  117. {0x48, 0x08},
  118. {0x49, 0x08},
  119. {0x4A, 0x08},
  120. {0x07, 0x20},
  121. };
  122. static const struct es7210_reg_config es7210_tdm_reg_mclk_cfg[] = {
  123. {0x02, 0xC1},
  124. };
  125. static const struct es7210_reg_config es7210_tdm_reg_common_cfg3[] = {
  126. {0x06, 0x00},
  127. {0x4B, 0x0F},
  128. {0x4C, 0x0F},
  129. {0x00, 0x71},
  130. {0x00, 0x41},
  131. };
  132. struct es7210_mclklrck_ratio_config {
  133. int ratio;
  134. unsigned char nfs;
  135. unsigned char channels;
  136. unsigned char reg02_v;
  137. unsigned char reg06_v;
  138. };
  139. static const struct es7210_mclklrck_ratio_config es7210_1fs_ratio_cfg[] = {
  140. //ratio, nfs, channels, reg02_v, reg06_v
  141. {64, 0, 0, 0x41, 0x00},
  142. {128, 0, 0, 0x01, 0x00},
  143. {192, 0, 0, 0x43, 0x00},
  144. {256, 0, 0, 0xc1, 0x04},
  145. {384, 0, 0, 0x03, 0x00},
  146. {512, 0, 0, 0x81, 0x04},
  147. {768, 0, 0, 0xc3, 0x04},
  148. {896, 0, 0, 0x07, 0x00},
  149. {1024, 0, 0, 0x82, 0x04},
  150. {1152, 0, 0, 0x09, 0x00},
  151. {1280, 0, 0, 0x0a, 0x00},
  152. {1408, 0, 0, 0x0b, 0x00},
  153. {1536, 0, 0, 0xc6, 0x04},
  154. {1664, 0, 0, 0x0d, 0x00},
  155. {1792, 0, 0, 0xc7, 0x04},
  156. {1920, 0, 0, 0x0f, 0x00},
  157. {2048, 0, 0, 0x84, 0x04},
  158. {3072, 0, 0, 0x86, 0x04},
  159. {4096, 0, 0, 0x88, 0x04},
  160. };
  161. static const struct es7210_mclklrck_ratio_config es7210_nfs_ratio_cfg[] = {
  162. //ratio, nfs, channels, reg02_v, reg06_v
  163. {32, 1, 4, 0x41, 0x00},
  164. {32, 1, 8, 0x01, 0x00},
  165. {32, 1, 12, 0x43, 0x00},
  166. {32, 1, 16, 0xC1, 0x04},
  167. {64, 1, 4, 0x01, 0x00},
  168. {64, 1, 6, 0x43, 0x00},
  169. {64, 1, 8, 0xC1, 0x04},
  170. {64, 1, 10, 0x45, 0x00},
  171. {64, 1, 12, 0x03, 0x00},
  172. {64, 1, 14, 0x47, 0x00},
  173. {64, 1, 16, 0x81, 0x04},
  174. {96, 1, 4, 0x43, 0x00},
  175. {96, 1, 8, 0x03, 0x00},
  176. {96, 1, 12, 0x49, 0x00},
  177. {96, 1, 16, 0xc3, 0x04},
  178. {128, 1, 4, 0xc1, 0x04},
  179. {128, 1, 6, 0x03, 0x00},
  180. {128, 1, 8, 0x81, 0x04},
  181. {128, 1, 10, 0x05, 0x00},
  182. {128, 1, 12, 0xc3, 0x04},
  183. {128, 1, 14, 0x07, 0x00},
  184. {128, 1, 16, 0x82, 0x04},
  185. {192, 1, 4, 0x03, 0x00},
  186. {192, 1, 6, 0x49, 0x00},
  187. {192, 1, 8, 0xc3, 0x04},
  188. {192, 1, 10, 0x4f, 0x00},
  189. {192, 1, 12, 0x09, 0x00},
  190. {192, 1, 14, 0x55, 0x00},
  191. {192, 1, 16, 0x83, 0x04},
  192. {256, 1, 4, 0x81, 0x04},
  193. {256, 1, 6, 0xc3, 0x04},
  194. {256, 1, 8, 0x82, 0x04},
  195. {256, 1, 10, 0xc5, 0x04},
  196. {256, 1, 12, 0x83, 0x04},
  197. {256, 1, 14, 0xc7, 0x04},
  198. {256, 1, 16, 0x84, 0x04},
  199. {384, 1, 4, 0xc3, 0x04},
  200. {384, 1, 6, 0x09, 0x00},
  201. {384, 1, 8, 0x83, 0x04},
  202. {384, 1, 10, 0x0f, 0x00},
  203. {384, 1, 12, 0xc9, 0x04},
  204. {384, 1, 14, 0x15, 0x00},
  205. {384, 1, 16, 0x86, 0x04},
  206. {512, 1, 4, 0x82, 0x04},
  207. {512, 1, 6, 0x83, 0x04},
  208. {512, 1, 8, 0x84, 0x04},
  209. {512, 1, 10, 0x85, 0x04},
  210. {512, 1, 12, 0x86, 0x04},
  211. {512, 1, 14, 0x87, 0x04},
  212. {512, 1, 16, 0x88, 0x04},
  213. {768, 1, 4, 0x83, 0x04},
  214. {768, 1, 6, 0xC9, 0x04},
  215. {768, 1, 8, 0x86, 0x04},
  216. {768, 1, 10, 0xCf, 0x04},
  217. {768, 1, 12, 0x89, 0x04},
  218. {768, 1, 14, 0xD5, 0x04},
  219. {768, 1, 16, 0x8C, 0x04},
  220. {1024, 1, 4, 0x84, 0x04},
  221. {1024, 1, 6, 0x86, 0x04},
  222. {1024, 1, 8, 0x88, 0x04},
  223. {1024, 1, 10, 0x8a, 0x04},
  224. {1024, 1, 12, 0x8c, 0x04},
  225. {1024, 1, 14, 0x8e, 0x04},
  226. {1024, 1, 16, 0x90, 0x04},
  227. };