pcm512x.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * Driver for the PCM512x CODECs
  3. *
  4. * Author: Mark Brown <broonie@linaro.org>
  5. * Copyright 2014 Linaro Ltd
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. */
  16. #ifndef _SND_SOC_PCM512X
  17. #define _SND_SOC_PCM512X
  18. #include <linux/pm.h>
  19. #include <linux/regmap.h>
  20. #define PCM512x_VIRT_BASE 0x100
  21. #define PCM512x_PAGE_LEN 0x100
  22. #define PCM512x_PAGE_BASE(n) (PCM512x_VIRT_BASE + (PCM512x_PAGE_LEN * n))
  23. #define PCM512x_PAGE 0
  24. #define PCM512x_RESET (PCM512x_PAGE_BASE(0) + 1)
  25. #define PCM512x_POWER (PCM512x_PAGE_BASE(0) + 2)
  26. #define PCM512x_MUTE (PCM512x_PAGE_BASE(0) + 3)
  27. #define PCM512x_PLL_EN (PCM512x_PAGE_BASE(0) + 4)
  28. #define PCM512x_SPI_MISO_FUNCTION (PCM512x_PAGE_BASE(0) + 6)
  29. #define PCM512x_DSP (PCM512x_PAGE_BASE(0) + 7)
  30. #define PCM512x_GPIO_EN (PCM512x_PAGE_BASE(0) + 8)
  31. #define PCM512x_BCLK_LRCLK_CFG (PCM512x_PAGE_BASE(0) + 9)
  32. #define PCM512x_DSP_GPIO_INPUT (PCM512x_PAGE_BASE(0) + 10)
  33. #define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12)
  34. #define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13)
  35. #define PCM512x_DAC_REF (PCM512x_PAGE_BASE(0) + 14)
  36. #define PCM512x_GPIO_DACIN (PCM512x_PAGE_BASE(0) + 16)
  37. #define PCM512x_GPIO_PLLIN (PCM512x_PAGE_BASE(0) + 18)
  38. #define PCM512x_SYNCHRONIZE (PCM512x_PAGE_BASE(0) + 19)
  39. #define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20)
  40. #define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_BASE(0) + 21)
  41. #define PCM512x_PLL_COEFF_2 (PCM512x_PAGE_BASE(0) + 22)
  42. #define PCM512x_PLL_COEFF_3 (PCM512x_PAGE_BASE(0) + 23)
  43. #define PCM512x_PLL_COEFF_4 (PCM512x_PAGE_BASE(0) + 24)
  44. #define PCM512x_DSP_CLKDIV (PCM512x_PAGE_BASE(0) + 27)
  45. #define PCM512x_DAC_CLKDIV (PCM512x_PAGE_BASE(0) + 28)
  46. #define PCM512x_NCP_CLKDIV (PCM512x_PAGE_BASE(0) + 29)
  47. #define PCM512x_OSR_CLKDIV (PCM512x_PAGE_BASE(0) + 30)
  48. #define PCM512x_MASTER_CLKDIV_1 (PCM512x_PAGE_BASE(0) + 32)
  49. #define PCM512x_MASTER_CLKDIV_2 (PCM512x_PAGE_BASE(0) + 33)
  50. #define PCM512x_FS_SPEED_MODE (PCM512x_PAGE_BASE(0) + 34)
  51. #define PCM512x_IDAC_1 (PCM512x_PAGE_BASE(0) + 35)
  52. #define PCM512x_IDAC_2 (PCM512x_PAGE_BASE(0) + 36)
  53. #define PCM512x_ERROR_DETECT (PCM512x_PAGE_BASE(0) + 37)
  54. #define PCM512x_I2S_1 (PCM512x_PAGE_BASE(0) + 40)
  55. #define PCM512x_I2S_2 (PCM512x_PAGE_BASE(0) + 41)
  56. #define PCM512x_DAC_ROUTING (PCM512x_PAGE_BASE(0) + 42)
  57. #define PCM512x_DSP_PROGRAM (PCM512x_PAGE_BASE(0) + 43)
  58. #define PCM512x_CLKDET (PCM512x_PAGE_BASE(0) + 44)
  59. #define PCM512x_AUTO_MUTE (PCM512x_PAGE_BASE(0) + 59)
  60. #define PCM512x_DIGITAL_VOLUME_1 (PCM512x_PAGE_BASE(0) + 60)
  61. #define PCM512x_DIGITAL_VOLUME_2 (PCM512x_PAGE_BASE(0) + 61)
  62. #define PCM512x_DIGITAL_VOLUME_3 (PCM512x_PAGE_BASE(0) + 62)
  63. #define PCM512x_DIGITAL_MUTE_1 (PCM512x_PAGE_BASE(0) + 63)
  64. #define PCM512x_DIGITAL_MUTE_2 (PCM512x_PAGE_BASE(0) + 64)
  65. #define PCM512x_DIGITAL_MUTE_3 (PCM512x_PAGE_BASE(0) + 65)
  66. #define PCM512x_GPIO_OUTPUT_1 (PCM512x_PAGE_BASE(0) + 80)
  67. #define PCM512x_GPIO_OUTPUT_2 (PCM512x_PAGE_BASE(0) + 81)
  68. #define PCM512x_GPIO_OUTPUT_3 (PCM512x_PAGE_BASE(0) + 82)
  69. #define PCM512x_GPIO_OUTPUT_4 (PCM512x_PAGE_BASE(0) + 83)
  70. #define PCM512x_GPIO_OUTPUT_5 (PCM512x_PAGE_BASE(0) + 84)
  71. #define PCM512x_GPIO_OUTPUT_6 (PCM512x_PAGE_BASE(0) + 85)
  72. #define PCM512x_GPIO_CONTROL_1 (PCM512x_PAGE_BASE(0) + 86)
  73. #define PCM512x_GPIO_CONTROL_2 (PCM512x_PAGE_BASE(0) + 87)
  74. #define PCM512x_OVERFLOW (PCM512x_PAGE_BASE(0) + 90)
  75. #define PCM512x_RATE_DET_1 (PCM512x_PAGE_BASE(0) + 91)
  76. #define PCM512x_RATE_DET_2 (PCM512x_PAGE_BASE(0) + 92)
  77. #define PCM512x_RATE_DET_3 (PCM512x_PAGE_BASE(0) + 93)
  78. #define PCM512x_RATE_DET_4 (PCM512x_PAGE_BASE(0) + 94)
  79. #define PCM512x_CLOCK_STATUS (PCM512x_PAGE_BASE(0) + 95)
  80. #define PCM512x_ANALOG_MUTE_DET (PCM512x_PAGE_BASE(0) + 108)
  81. #define PCM512x_GPIN (PCM512x_PAGE_BASE(0) + 119)
  82. #define PCM512x_DIGITAL_MUTE_DET (PCM512x_PAGE_BASE(0) + 120)
  83. #define PCM512x_OUTPUT_AMPLITUDE (PCM512x_PAGE_BASE(1) + 1)
  84. #define PCM512x_ANALOG_GAIN_CTRL (PCM512x_PAGE_BASE(1) + 2)
  85. #define PCM512x_UNDERVOLTAGE_PROT (PCM512x_PAGE_BASE(1) + 5)
  86. #define PCM512x_ANALOG_MUTE_CTRL (PCM512x_PAGE_BASE(1) + 6)
  87. #define PCM512x_ANALOG_GAIN_BOOST (PCM512x_PAGE_BASE(1) + 7)
  88. #define PCM512x_VCOM_CTRL_1 (PCM512x_PAGE_BASE(1) + 8)
  89. #define PCM512x_VCOM_CTRL_2 (PCM512x_PAGE_BASE(1) + 9)
  90. #define PCM512x_CRAM_CTRL (PCM512x_PAGE_BASE(44) + 1)
  91. #define PCM512x_FLEX_A (PCM512x_PAGE_BASE(253) + 63)
  92. #define PCM512x_FLEX_B (PCM512x_PAGE_BASE(253) + 64)
  93. #define PCM512x_MAX_REGISTER (PCM512x_PAGE_BASE(253) + 64)
  94. /* Page 0, Register 1 - reset */
  95. #define PCM512x_RSTR (1 << 0)
  96. #define PCM512x_RSTM (1 << 4)
  97. /* Page 0, Register 2 - power */
  98. #define PCM512x_RQPD (1 << 0)
  99. #define PCM512x_RQPD_SHIFT 0
  100. #define PCM512x_RQST (1 << 4)
  101. #define PCM512x_RQST_SHIFT 4
  102. /* Page 0, Register 3 - mute */
  103. #define PCM512x_RQMR_SHIFT 0
  104. #define PCM512x_RQML_SHIFT 4
  105. /* Page 0, Register 4 - PLL */
  106. #define PCM512x_PLLE (1 << 0)
  107. #define PCM512x_PLLE_SHIFT 0
  108. #define PCM512x_PLCK (1 << 4)
  109. #define PCM512x_PLCK_SHIFT 4
  110. /* Page 0, Register 7 - DSP */
  111. #define PCM512x_SDSL (1 << 0)
  112. #define PCM512x_SDSL_SHIFT 0
  113. #define PCM512x_DEMP (1 << 4)
  114. #define PCM512x_DEMP_SHIFT 4
  115. /* Page 0, Register 8 - GPIO output enable */
  116. #define PCM512x_G1OE (1 << 0)
  117. #define PCM512x_G2OE (1 << 1)
  118. #define PCM512x_G3OE (1 << 2)
  119. #define PCM512x_G4OE (1 << 3)
  120. #define PCM512x_G5OE (1 << 4)
  121. #define PCM512x_G6OE (1 << 5)
  122. /* Page 0, Register 9 - BCK, LRCLK configuration */
  123. #define PCM512x_LRKO (1 << 0)
  124. #define PCM512x_LRKO_SHIFT 0
  125. #define PCM512x_BCKO (1 << 4)
  126. #define PCM512x_BCKO_SHIFT 4
  127. #define PCM512x_BCKP (1 << 5)
  128. #define PCM512x_BCKP_SHIFT 5
  129. /* Page 0, Register 12 - Master mode BCK, LRCLK reset */
  130. #define PCM512x_RLRK (1 << 0)
  131. #define PCM512x_RLRK_SHIFT 0
  132. #define PCM512x_RBCK (1 << 1)
  133. #define PCM512x_RBCK_SHIFT 1
  134. /* Page 0, Register 13 - PLL reference */
  135. #define PCM512x_SREF (7 << 4)
  136. #define PCM512x_SREF_SHIFT 4
  137. #define PCM512x_SREF_SCK (0 << 4)
  138. #define PCM512x_SREF_BCK (1 << 4)
  139. #define PCM512x_SREF_GPIO (3 << 4)
  140. /* Page 0, Register 14 - DAC reference */
  141. #define PCM512x_SDAC (7 << 4)
  142. #define PCM512x_SDAC_SHIFT 4
  143. #define PCM512x_SDAC_MCK (0 << 4)
  144. #define PCM512x_SDAC_PLL (1 << 4)
  145. #define PCM512x_SDAC_SCK (3 << 4)
  146. #define PCM512x_SDAC_BCK (4 << 4)
  147. #define PCM512x_SDAC_GPIO (5 << 4)
  148. /* Page 0, Register 16, 18 - GPIO source for DAC, PLL */
  149. #define PCM512x_GREF (7 << 0)
  150. #define PCM512x_GREF_SHIFT 0
  151. #define PCM512x_GREF_GPIO1 (0 << 0)
  152. #define PCM512x_GREF_GPIO2 (1 << 0)
  153. #define PCM512x_GREF_GPIO3 (2 << 0)
  154. #define PCM512x_GREF_GPIO4 (3 << 0)
  155. #define PCM512x_GREF_GPIO5 (4 << 0)
  156. #define PCM512x_GREF_GPIO6 (5 << 0)
  157. /* Page 0, Register 19 - synchronize */
  158. #define PCM512x_RQSY (1 << 0)
  159. #define PCM512x_RQSY_RESUME (0 << 0)
  160. #define PCM512x_RQSY_HALT (1 << 0)
  161. /* Page 0, Register 34 - fs speed mode */
  162. #define PCM512x_FSSP (3 << 0)
  163. #define PCM512x_FSSP_SHIFT 0
  164. #define PCM512x_FSSP_48KHZ (0 << 0)
  165. #define PCM512x_FSSP_96KHZ (1 << 0)
  166. #define PCM512x_FSSP_192KHZ (2 << 0)
  167. #define PCM512x_FSSP_384KHZ (3 << 0)
  168. /* Page 0, Register 37 - Error detection */
  169. #define PCM512x_IPLK (1 << 0)
  170. #define PCM512x_DCAS (1 << 1)
  171. #define PCM512x_IDCM (1 << 2)
  172. #define PCM512x_IDCH (1 << 3)
  173. #define PCM512x_IDSK (1 << 4)
  174. #define PCM512x_IDBK (1 << 5)
  175. #define PCM512x_IDFS (1 << 6)
  176. /* Page 0, Register 40 - I2S configuration */
  177. #define PCM512x_ALEN (3 << 0)
  178. #define PCM512x_ALEN_SHIFT 0
  179. #define PCM512x_ALEN_16 (0 << 0)
  180. #define PCM512x_ALEN_20 (1 << 0)
  181. #define PCM512x_ALEN_24 (2 << 0)
  182. #define PCM512x_ALEN_32 (3 << 0)
  183. #define PCM512x_AFMT (3 << 4)
  184. #define PCM512x_AFMT_SHIFT 4
  185. #define PCM512x_AFMT_I2S (0 << 4)
  186. #define PCM512x_AFMT_DSP (1 << 4)
  187. #define PCM512x_AFMT_RTJ (2 << 4)
  188. #define PCM512x_AFMT_LTJ (3 << 4)
  189. /* Page 0, Register 42 - DAC routing */
  190. #define PCM512x_AUPR_SHIFT 0
  191. #define PCM512x_AUPL_SHIFT 4
  192. /* Page 0, Register 59 - auto mute */
  193. #define PCM512x_ATMR_SHIFT 0
  194. #define PCM512x_ATML_SHIFT 4
  195. /* Page 0, Register 63 - ramp rates */
  196. #define PCM512x_VNDF_SHIFT 6
  197. #define PCM512x_VNDS_SHIFT 4
  198. #define PCM512x_VNUF_SHIFT 2
  199. #define PCM512x_VNUS_SHIFT 0
  200. /* Page 0, Register 64 - emergency ramp rates */
  201. #define PCM512x_VEDF_SHIFT 6
  202. #define PCM512x_VEDS_SHIFT 4
  203. /* Page 0, Register 65 - Digital mute enables */
  204. #define PCM512x_ACTL_SHIFT 2
  205. #define PCM512x_AMLE_SHIFT 1
  206. #define PCM512x_AMRE_SHIFT 0
  207. /* Page 0, Register 80-85, GPIO output selection */
  208. #define PCM512x_GxSL (31 << 0)
  209. #define PCM512x_GxSL_SHIFT 0
  210. #define PCM512x_GxSL_OFF (0 << 0)
  211. #define PCM512x_GxSL_DSP (1 << 0)
  212. #define PCM512x_GxSL_REG (2 << 0)
  213. #define PCM512x_GxSL_AMUTB (3 << 0)
  214. #define PCM512x_GxSL_AMUTL (4 << 0)
  215. #define PCM512x_GxSL_AMUTR (5 << 0)
  216. #define PCM512x_GxSL_CLKI (6 << 0)
  217. #define PCM512x_GxSL_SDOUT (7 << 0)
  218. #define PCM512x_GxSL_ANMUL (8 << 0)
  219. #define PCM512x_GxSL_ANMUR (9 << 0)
  220. #define PCM512x_GxSL_PLLLK (10 << 0)
  221. #define PCM512x_GxSL_CPCLK (11 << 0)
  222. #define PCM512x_GxSL_UV0_7 (14 << 0)
  223. #define PCM512x_GxSL_UV0_3 (15 << 0)
  224. #define PCM512x_GxSL_PLLCK (16 << 0)
  225. /* Page 1, Register 2 - analog volume control */
  226. #define PCM512x_RAGN_SHIFT 0
  227. #define PCM512x_LAGN_SHIFT 4
  228. /* Page 1, Register 7 - analog boost control */
  229. #define PCM512x_AGBR_SHIFT 0
  230. #define PCM512x_AGBL_SHIFT 4
  231. extern const struct dev_pm_ops pcm512x_pm_ops;
  232. extern const struct regmap_config pcm512x_regmap;
  233. int pcm512x_probe(struct device *dev, struct regmap *regmap);
  234. void pcm512x_remove(struct device *dev);
  235. #endif