1 /*
2 ** =============================================================================
3 ** Copyright (c) 2016 Texas Instruments Inc.
4 **
5 ** This program is free software; you can redistribute it and/or modify it under
6 ** the terms of the GNU General Public License as published by the Free Software
7 ** Foundation; version 2.
8 **
9 ** This program is distributed in the hope that it will be useful, but WITHOUT
10 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 ** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 **
13 ** File:
14 ** tas2557.h
15 **
16 ** Description:
17 ** definitions and data structures for TAS2557 Android Linux driver
18 **
19 ** =============================================================================
20 */
22 #ifndef _TAS2557_H
23 #define _TAS2557_H
25 #include <linux/regmap.h>
26 #include <linux/workqueue.h>
27 #include <linux/timer.h>
29 /* Page Control Register */
30 #define TAS2557_PAGECTL_REG 0
32 /* Book Control Register (available in page0 of each book) */
33 #define TAS2557_BOOKCTL_PAGE 0
34 #define TAS2557_BOOKCTL_REG 127
36 /* 0000 0000 0BBB BBBB BPPP PPPP PRRR RRRR */
38 #define TAS2557_REG(book, page, reg) ((((unsigned int)book * 256 * 128) + \
39 ((unsigned int)page * 128)) + reg)
41 #define TAS2557_BOOK_ID(reg) ((unsigned char)(reg / (256 * 128)))
42 #define TAS2557_PAGE_ID(reg) ((unsigned char)((reg % (256 * 128)) / 128))
43 #define TAS2557_BOOK_REG(reg) ((unsigned char)(reg % (256 * 128)))
44 #define TAS2557_PAGE_REG(reg) ((unsigned char)((reg % (256 * 128)) % 128))
46 /* Book0, Page0 registers */
47 #define TAS2557_SW_RESET_REG TAS2557_REG(0, 0, 1)
49 #define TAS2557_REV_PGID_REG TAS2557_REG(0, 0, 3)
50 #define TAS2557_PG_VERSION_1P0 0x80
51 #define TAS2557_PG_VERSION_2P0 0x90
52 #define TAS2557_PG_VERSION_2P1 0xa0
54 #define TAS2557_POWER_CTRL1_REG TAS2557_REG(0, 0, 4)
55 #define TAS2557_POWER_CTRL2_REG TAS2557_REG(0, 0, 5)
57 #define TAS2557_SPK_CTRL_REG TAS2557_REG(0, 0, 6)
58 /* B0P0R6 - TAS2557_SPK_CTRL_REG */
59 #define TAS2557_DAC_GAIN_MASK (0xf << 3)
60 #define TAS2557_DAC_GAIN_SHIFT 0x03
62 #define TAS2557_MUTE_REG TAS2557_REG(0, 0, 7)
63 #define TAS2557_SNS_CTRL_REG TAS2557_REG(0, 0, 8)
64 #define TAS2557_ADC_INPUT_SEL_REG TAS2557_REG(0, 0, 9)
65 #define TAS2557_DBOOST_CTL_REG TAS2557_REG(0, 0, 10)
66 #define TAS2557_NONAME11_REG TAS2557_REG(0, 0, 11)
67 #define TAS2557_NONAME12_REG TAS2557_REG(0, 0, 12)
68 #define TAS2557_NONAME13_REG TAS2557_REG(0, 0, 13)
69 #define TAS2557_NONAME14_REG TAS2557_REG(0, 0, 14)
70 #define TAS2557_NONAME15_REG TAS2557_REG(0, 0, 15)
71 #define TAS2557_NONAME16_REG TAS2557_REG(0, 0, 16)
72 #define TAS2557_NONAME17_REG TAS2557_REG(0, 0, 17)
73 #define TAS2557_NONAME18_REG TAS2557_REG(0, 0, 18)
74 #define TAS2557_SAR_SAMPLING_TIME_REG TAS2557_REG(0, 0, 19)
75 #define TAS2557_SAR_ADC1_REG TAS2557_REG(0, 0, 20)
76 #define TAS2557_SAR_ADC2_REG TAS2557_REG(0, 0, 21) /* B0_P0_R0x15*/
77 #define TAS2557_CRC_CHECKSUM_REG TAS2557_REG(0, 0, 32)
78 #define TAS2557_CRC_RESET_REG TAS2557_REG(0, 0, 33)
79 #define TAS2557_DSP_MODE_SELECT_REG TAS2557_REG(0, 0, 34)
80 #define TAS2557_SAFE_GUARD_REG TAS2557_REG(0, 0, 37)
81 #define TAS2557_ASI_CTL1_REG TAS2557_REG(0, 0, 42)
82 #define TAS2557_CLK_ERR_CTRL TAS2557_REG(0, 0, 44) /* B0_P0_R0x2c*/
83 #define TAS2557_CLK_ERR_CTRL2 TAS2557_REG(0, 0, 45) /* B0_P0_R0x2d*/
84 #define TAS2557_CLK_ERR_CTRL3 TAS2557_REG(0, 0, 46) /* B0_P0_R0x2e*/
85 #define TAS2557_DBOOST_CFG_REG TAS2557_REG(0, 0, 52)
86 #define TAS2557_POWER_UP_FLAG_REG TAS2557_REG(0, 0, 100)
87 #define TAS2557_FLAGS_1 TAS2557_REG(0, 0, 104) /* B0_P0_R0x68*/
88 #define TAS2557_FLAGS_2 TAS2557_REG(0, 0, 108) /* B0_P0_R0x6c*/
90 /* Book0, Page1 registers */
91 #define TAS2557_ASI1_DAC_FORMAT_REG TAS2557_REG(0, 1, 1)
92 #define TAS2557_ASI1_ADC_FORMAT_REG TAS2557_REG(0, 1, 2)
93 #define TAS2557_ASI1_OFFSET1_REG TAS2557_REG(0, 1, 3)
94 #define TAS2557_ASI1_ADC_PATH_REG TAS2557_REG(0, 1, 7)
95 #define TAS2557_ASI1_DAC_BCLK_REG TAS2557_REG(0, 1, 8)
96 #define TAS2557_ASI1_DAC_WCLK_REG TAS2557_REG(0, 1, 9)
97 #define TAS2557_ASI1_ADC_BCLK_REG TAS2557_REG(0, 1, 10)
98 #define TAS2557_ASI1_ADC_WCLK_REG TAS2557_REG(0, 1, 11)
99 #define TAS2557_ASI1_DIN_DOUT_MUX_REG TAS2557_REG(0, 1, 12)
100 #define TAS2557_ASI1_BDIV_CLK_SEL_REG TAS2557_REG(0, 1, 13)
101 #define TAS2557_ASI1_BDIV_CLK_RATIO_REG TAS2557_REG(0, 1, 14)
102 #define TAS2557_ASI1_WDIV_CLK_RATIO_REG TAS2557_REG(0, 1, 15)
103 #define TAS2557_ASI1_DAC_CLKOUT_REG TAS2557_REG(0, 1, 16)
104 #define TAS2557_ASI1_ADC_CLKOUT_REG TAS2557_REG(0, 1, 17)
105 #define TAS2557_ASI2_DAC_FORMAT_REG TAS2557_REG(0, 1, 21)
106 #define TAS2557_ASI2_ADC_FORMAT_REG TAS2557_REG(0, 1, 22)
107 #define TAS2557_ASI2_OFFSET1_REG TAS2557_REG(0, 1, 23)
108 #define TAS2557_ASI2_ADC_PATH_REG TAS2557_REG(0, 1, 27)
109 #define TAS2557_ASI2_DAC_BCLK_REG TAS2557_REG(0, 1, 28)
110 #define TAS2557_ASI2_DAC_WCLK_REG TAS2557_REG(0, 1, 29)
111 #define TAS2557_ASI2_ADC_BCLK_REG TAS2557_REG(0, 1, 30)
112 #define TAS2557_ASI2_ADC_WCLK_REG TAS2557_REG(0, 1, 31)
113 #define TAS2557_ASI2_DIN_DOUT_MUX_REG TAS2557_REG(0, 1, 32)
114 #define TAS2557_ASI2_BDIV_CLK_SEL_REG TAS2557_REG(0, 1, 33)
115 #define TAS2557_ASI2_BDIV_CLK_RATIO_REG TAS2557_REG(0, 1, 34)
116 #define TAS2557_ASI2_WDIV_CLK_RATIO_REG TAS2557_REG(0, 1, 35)
117 #define TAS2557_ASI2_DAC_CLKOUT_REG TAS2557_REG(0, 1, 36)
118 #define TAS2557_ASI2_ADC_CLKOUT_REG TAS2557_REG(0, 1, 37)
119 #define TAS2557_GPIO1_PIN_REG TAS2557_REG(0, 1, 61) /*B0_P1_R0x3d */
120 #define TAS2557_GPIO2_PIN_REG TAS2557_REG(0, 1, 62) /*B0_P1_R0x3e */
121 #define TAS2557_GPIO3_PIN_REG TAS2557_REG(0, 1, 63) /*B0_P1_R0x3f */
122 #define TAS2557_GPIO4_PIN_REG TAS2557_REG(0, 1, 64) /*B0_P1_R0x40 */
123 #define TAS2557_GPIO5_PIN_REG TAS2557_REG(0, 1, 65)
124 #define TAS2557_GPIO6_PIN_REG TAS2557_REG(0, 1, 66)
125 #define TAS2557_GPIO7_PIN_REG TAS2557_REG(0, 1, 67)
126 #define TAS2557_GPIO8_PIN_REG TAS2557_REG(0, 1, 68)
127 #define TAS2557_GPIO9_PIN_REG TAS2557_REG(0, 1, 69)
128 #define TAS2557_GPIO10_PIN_REG TAS2557_REG(0, 1, 70)
129 #define TAS2557_GPI_PIN_REG TAS2557_REG(0, 1, 77) /*B0_P1_R0x4d */
130 #define TAS2557_GPIO_HIZ_CTRL1_REG TAS2557_REG(0, 1, 79)
131 #define TAS2557_GPIO_HIZ_CTRL2_REG TAS2557_REG(0, 1, 80) /*B0_P1_R0x50 */
132 #define TAS2557_GPIO_HIZ_CTRL3_REG TAS2557_REG(0, 1, 81)
133 #define TAS2557_GPIO_HIZ_CTRL4_REG TAS2557_REG(0, 1, 82)
134 #define TAS2557_GPIO_HIZ_CTRL5_REG TAS2557_REG(0, 1, 83)
135 #define TAS2557_BIT_BANG_CTRL_REG TAS2557_REG(0, 1, 87)
136 #define TAS2557_BIT_BANG_OUT1_REG TAS2557_REG(0, 1, 88)
137 #define TAS2557_BIT_BANG_OUT2_REG TAS2557_REG(0, 1, 89)
138 #define TAS2557_BIT_BANG_IN1_REG TAS2557_REG(0, 1, 90)
139 #define TAS2557_BIT_BANG_IN2_REG TAS2557_REG(0, 1, 91)
140 #define TAS2557_BIT_BANG_IN3_REG TAS2557_REG(0, 1, 92)
141 #define TAS2557_PDM_IN_CLK_REG TAS2557_REG(0, 1, 94)
142 #define TAS2557_PDM_IN_PIN_REG TAS2557_REG(0, 1, 95)
143 #define TAS2557_ASIM_IFACE1_REG TAS2557_REG(0, 1, 98)
144 #define TAS2557_ASIM_FORMAT_REG TAS2557_REG(0, 1, 99)
145 #define TAS2557_ASIM_IFACE3_REG TAS2557_REG(0, 1, 100)
146 #define TAS2557_ASIM_IFACE4_REG TAS2557_REG(0, 1, 101)
147 #define TAS2557_ASIM_IFACE5_REG TAS2557_REG(0, 1, 102)
148 #define TAS2557_ASIM_IFACE6_REG TAS2557_REG(0, 1, 103)
149 #define TAS2557_ASIM_IFACE7_REG TAS2557_REG(0, 1, 104)
150 #define TAS2557_ASIM_IFACE8_REG TAS2557_REG(0, 1, 105)
151 #define TAS2557_CLK_HALT_REG TAS2557_REG(0, 1, 106) /* B0_P1_R0x6a */
152 #define TAS2557_INT_GEN1_REG TAS2557_REG(0, 1, 108) /* B0_P1_R0x6c */
153 #define TAS2557_INT_GEN2_REG TAS2557_REG(0, 1, 109) /* B0_P1_R0x6d */
154 #define TAS2557_INT_GEN3_REG TAS2557_REG(0, 1, 110) /* B0_P1_R0x6e */
155 #define TAS2557_INT_GEN4_REG TAS2557_REG(0, 1, 111) /* B0_P1_R0x6f */
156 #define TAS2557_INT_MODE_REG TAS2557_REG(0, 1, 114) /* B0_P1_R0x72 */
157 #define TAS2557_MAIN_CLKIN_REG TAS2557_REG(0, 1, 115)
158 #define TAS2557_PLL_CLKIN_REG TAS2557_REG(0, 1, 116)
159 #define TAS2557_CLKOUT_MUX_REG TAS2557_REG(0, 1, 117)
160 #define TAS2557_CLKOUT_CDIV_REG TAS2557_REG(0, 1, 118)
161 #define TAS2557_HACK_GP01_REG TAS2557_REG(0, 1, 122)
163 #define TAS2557_SLEEPMODE_CTL_REG TAS2557_REG(0, 2, 7)
164 #define TAS2557_HACK01_REG TAS2557_REG(0, 2, 10)
166 #define TAS2557_ISENSE_THRESHOLD TAS2557_REG(0, 50, 104)
167 #define TAS2557_BOOSTON_EFFICIENCY TAS2557_REG(0, 51, 16)
168 #define TAS2557_BOOSTOFF_EFFICIENCY TAS2557_REG(0, 51, 20)
169 #define TAS2557_BOOST_HEADROOM TAS2557_REG(0, 51, 24)
170 #define TAS2557_THERMAL_FOLDBACK_REG TAS2557_REG(0, 51, 100)
172 #define TAS2557_SA_PG2P1_CHL_CTRL_REG TAS2557_REG(0, 53, 20) /* B0_P0x35_R0x14 */
173 #define TAS2557_SA_COEFF_SWAP_REG TAS2557_REG(0, 53, 44) /* B0_P0x35_R0x2c */
175 #define TAS2557_SA_PG1P0_CHL_CTRL_REG TAS2557_REG(0, 58, 120) /* B0_P0x3a_R0x78 */
177 #define TAS2557_TEST_MODE_REG TAS2557_REG(0, 253, 13) /* B0_P0xfd_R0x0d */
178 #define TAS2557_BROADCAST_REG TAS2557_REG(0, 253, 54) /* B0_P0xfd_R0x36 */
179 #define TAS2557_VBST_VOLT_REG TAS2557_REG(0, 253, 58)
180 #define TAS2557_CRYPTIC_REG TAS2557_REG(0, 253, 71)
182 #define TAS2557_XMEM_687_REG TAS2557_REG(78, 23, 116) /* B0x78_P0x23_R0x40 */
184 #define TAS2557_PG2P1_CALI_R0_REG TAS2557_REG(0x8c, 0x2f, 0x40)
185 #define TAS2557_PG1P0_CALI_R0_REG TAS2557_REG(0x8c, 0x2f, 0x28)
186 #define TAS2557_PG2P1_CALI_T_REG TAS2557_REG(0x8c, 0x30, 0x20)
187 #define TAS2557_PG1P0_CALI_T_REG TAS2557_REG(0x8c, 0x30, 0x08)
189 #define TAS2557_DAC_INTERPOL_REG TAS2557_REG(100, 0, 1)
190 #define TAS2557_SOFT_MUTE_REG TAS2557_REG(100, 0, 7)
191 #define TAS2557_PLL_P_VAL_REG TAS2557_REG(100, 0, 27)
192 #define TAS2557_PLL_J_VAL_REG TAS2557_REG(100, 0, 28)
193 #define TAS2557_PLL_D_VAL_MSB_REG TAS2557_REG(100, 0, 29)
194 #define TAS2557_PLL_D_VAL_LSB_REG TAS2557_REG(100, 0, 30)
195 #define TAS2557_CLK_MISC_REG TAS2557_REG(100, 0, 31)
196 #define TAS2557_PLL_N_VAL_REG TAS2557_REG(100, 0, 32)
197 #define TAS2557_DAC_MADC_VAL_REG TAS2557_REG(100, 0, 33)
198 #define TAS2557_ISENSE_DIV_REG TAS2557_REG(100, 0, 42)
199 #define TAS2557_RAMP_CLK_DIV_MSB_REG TAS2557_REG(100, 0, 43)
200 #define TAS2557_RAMP_CLK_DIV_LSB_REG TAS2557_REG(100, 0, 44)
202 #define TAS2557_VBOOST_CTL_REG TAS2557_REG(100, 0, 64)
204 #define TAS2557_DIE_TEMP_REG TAS2557_REG(130, 2, 124) /* B0x82_P0x02_R0x7C */
206 /* Bits */
207 /* B0P0R4 - TAS2557_POWER_CTRL1_REG */
208 #define TAS2557_SW_SHUTDOWN (0x1 << 0)
209 #define TAS2557_MADC_POWER_UP (0x1 << 3)
210 #define TAS2557_MDAC_POWER_UP (0x1 << 4)
211 #define TAS2557_NDIV_POWER_UP (0x1 << 5)
212 #define TAS2557_PLL_POWER_UP (0x1 << 6)
213 #define TAS2557_DSP_POWER_UP (0x1 << 7)
215 /* B0P0R5 - TAS2557_POWER_CTRL2_REG */
216 #define TAS2557_VSENSE_ENABLE (0x1 << 0)
217 #define TAS2557_ISENSE_ENABLE (0x1 << 1)
218 #define TAS2557_BOOST_ENABLE (0x1 << 5)
219 #define TAS2557_CLASSD_ENABLE (0x1 << 7)
221 /* B0P0R7 - TAS2557_MUTE_REG */
222 #define TAS2557_CLASSD_MUTE (0x1 << 0)
223 #define TAS2557_ISENSE_MUTE (0x1 << 1)
225 /* B0P253R13 - TAS2557_TEST_MODE_REG */
226 #define TAS2557_TEST_MODE_ENABLE (13)
227 #define TAS2557_TEST_MODE_MASK (0xf << 0)
229 /* B0P253R71 - TAS2557_CRYPTIC_REG */
230 #define TAS2557_OSC_TRIM_CAP(x) ((x & 0x3f) << 0)
231 #define TAS2557_DISABLE_ENCRYPTION (0x1 << 6)
232 #define TAS2557_SL_COMP (0x1 << 7)
234 /* B0P1R115/6 - TAS2557_MAIN/PLL_CLKIN_REG */
235 #define TAS2557_XXX_CLKIN_GPIO1 (0)
236 #define TAS2557_XXX_CLKIN_GPIO2 (1)
237 #define TAS2557_XXX_CLKIN_GPIO3 (2)
238 #define TAS2557_XXX_CLKIN_GPIO4 (3)
239 #define TAS2557_XXX_CLKIN_GPIO5 (4)
240 #define TAS2557_XXX_CLKIN_GPIO6 (5)
241 #define TAS2557_XXX_CLKIN_GPIO7 (6)
242 #define TAS2557_XXX_CLKIN_GPIO8 (7)
243 #define TAS2557_XXX_CLKIN_GPIO9 (8)
244 #define TAS2557_XXX_CLKIN_GPIO10 (9)
245 #define TAS2557_XXX_CLKIN_GPI1 (12)
246 #define TAS2557_XXX_CLKIN_GPI2 (13)
247 #define TAS2557_XXX_CLKIN_GPI3 (14)
248 #define TAS2557_NDIV_CLKIN_PLL (15)
249 #define TAS2557_PLL_CLKIN_INT_OSC (15)
251 #define TAS2557_MCLK_CLKIN_SRC_GPIO1 (0)
252 #define TAS2557_MCLK_CLKIN_SRC_GPIO2 (1)
253 #define TAS2557_MCLK_CLKIN_SRC_GPIO3 (2)
254 #define TAS2557_MCLK_CLKIN_SRC_GPIO4 (3)
255 #define TAS2557_MCLK_CLKIN_SRC_GPIO5 (4)
256 #define TAS2557_MCLK_CLKIN_SRC_GPIO6 (5)
257 #define TAS2557_MCLK_CLKIN_SRC_GPIO7 (6)
258 #define TAS2557_MCLK_CLKIN_SRC_GPIO8 (7)
259 #define TAS2557_MCLK_CLKIN_SRC_GPIO9 (8)
260 #define TAS2557_MCLK_CLKIN_SRC_GPIO10 (9)
261 #define TAS2557_MCLK_CLKIN_SRC_GPI1 (12)
262 #define TAS2557_MCLK_CLKIN_SRC_GPI2 (13)
263 #define TAS2557_MCLK_CLKIN_SRC_GPI3 (14)
265 #define TAS2557_FORMAT_I2S (0x0 << 5)
266 #define TAS2557_FORMAT_DSP (0x1 << 5)
267 #define TAS2557_FORMAT_RIGHT_J (0x2 << 5)
268 #define TAS2557_FORMAT_LEFT_J (0x3 << 5)
269 #define TAS2557_FORMAT_MONO_PCM (0x4 << 5)
270 #define TAS2557_FORMAT_MASK (0x7 << 5)
272 #define TAS2557_WORDLENGTH_16BIT (0x0 << 3)
273 #define TAS2557_WORDLENGTH_20BIT (0x1 << 3)
274 #define TAS2557_WORDLENGTH_24BIT (0x2 << 3)
275 #define TAS2557_WORDLENGTH_32BIT (0x3 << 3)
276 #define TAS2557_WORDLENGTH_MASK TAS2557_WORDLENGTH_32BIT
278 /* B100P0R7 - TAS2557_SOFT_MUTE_REG */
279 #define TAS2557_PDM_SOFT_MUTE (0x1 << 0)
280 #define TAS2557_VSENSE_SOFT_MUTE (0x1 << 1)
281 #define TAS2557_ISENSE_SOFT_MUTE (0x1 << 2)
282 #define TAS2557_CLASSD_SOFT_MUTE (0x1 << 3)
284 /* B100P0R27 - TAS2557_PLL_P_VAL_REG */
285 #define TAS2557_PLL_P_VAL_MASK (0x3f << 0)
287 /* B100P0R28 - TAS2557_PLL_J_VAL_REG */
288 #define TAS2557_PLL_J_VAL_MASK ((unsigned int) (0x7f << 0))
289 #define TAS2557_PLL_J_VAL_MASKX 0x00
291 /* B100P0R29-30 - TAS2557_PLL_D_VAL_MSB/LSB_REG */
292 #define TAS2557_PLL_D_MSB_VAL(x) ((x >> 8) & 0x3f)
293 #define TAS2557_PLL_D_LSB_VAL(x) (x & 0xff)
295 /* B100P0R31 - TAS2557_CLK_MISC_REG */
296 #define TAS2557_DSP_CLK_FROM_PLL (0x1 << 5)
298 #define TAS2557_FW_NAME "tas2557s_uCDSP.bin"
300 #define TAS2557_BROADCAST_ADDR 0x4c
302 #define TAS2557_APP_ROM1MODE 0
303 #define TAS2557_APP_ROM2MODE 1
304 #define TAS2557_APP_TUNINGMODE 2
305 #define TAS2557_APP_ROM1_96KHZ 3
306 #define TAS2557_APP_ROM2_96KHZ 4
307 #define TAS2557_APP_RAMMODE 5
309 #define TAS2557_BOOST_OFF 0
310 #define TAS2557_BOOST_DEVA 1
311 #define TAS2557_BOOST_DEVB 2
312 #define TAS2557_BOOST_BOTH 3
314 #define TAS2557_DM_AD_BD 0 /* DevA default, DevB default */
315 #define TAS2557_DM_AM_BM 1 /* DevA mute, DevB mute */
316 #define TAS2557_DM_AL_BR 2 /* DevA left channel, DevB right channel */
317 #define TAS2557_DM_AR_BL 3 /* DevA right channel, DevB left channel */
318 #define TAS2557_DM_AH_BH 4 /* DevA (L+R)/2, DevB (L+R)/2 */
320 #define TAS2557_VBST_DEFAULT 0 /* firmware default */
321 #define TAS2557_VBST_A_ON 1 /* DevA always 8.5V, DevB default */
322 #define TAS2557_VBST_B_ON 2 /* DevA default, DevB always 8.5V */
323 #define TAS2557_VBST_A_ON_B_ON (TAS2557_VBST_A_ON | TAS2557_VBST_B_ON) /* both DevA and DevB always 8.5V */
324 #define TAS2557_VBST_NEED_DEFAULT 0xff /* need default value */
326 #define TAS2557_VBST_8P5V 0 /* coresponding PPG 0dB */
327 #define TAS2557_VBST_8P1V 1 /* coresponding PPG -1dB */
328 #define TAS2557_VBST_7P6V 2 /* coresponding PPG -2dB */
329 #define TAS2557_VBST_6P6V 3 /* coresponding PPG -3dB */
330 #define TAS2557_VBST_5P6V 4 /* coresponding PPG -4dB */
332 #define ERROR_NONE 0x00000000
333 #define ERROR_PLL_ABSENT 0x00000001
334 #define ERROR_DEVA_I2C_COMM 0x00000002
335 #define ERROR_DEVB_I2C_COMM 0x00000004
336 #define ERROR_PRAM_CRCCHK 0x00000008
337 #define ERROR_YRAM_CRCCHK 0x00000010
338 #define ERROR_CLK_DET2 0x00000020
339 #define ERROR_CLK_DET1 0x00000040
340 #define ERROR_CLK_LOST 0x00000080
341 #define ERROR_BROWNOUT 0x00000100
342 #define ERROR_DIE_OVERTEMP 0x00000200
343 #define ERROR_CLK_HALT 0x00000400
344 #define ERROR_UNDER_VOLTAGE 0x00000800
345 #define ERROR_OVER_CURRENT 0x00001000
346 #define ERROR_CLASSD_PWR 0x00002000
347 #define ERROR_SAFE_GUARD 0x00004000
348 #define ERROR_FAILSAFE 0x40000000
350 #define FLAG_CHECK_COUNTER 25
352 struct TBlock {
353 unsigned int mnType;
354 unsigned char mbPChkSumPresent;
355 unsigned char mnPChkSum;
356 unsigned char mbYChkSumPresent;
357 unsigned char mnYChkSum;
358 unsigned int mnCommands;
359 unsigned char *mpData;
360 };
362 struct TData {
363 char mpName[64];
364 char *mpDescription;
365 unsigned int mnBlocks;
366 struct TBlock *mpBlocks;
367 };
369 struct TProgram {
370 char mpName[64];
371 char *mpDescription;
372 unsigned char mnAppMode;
373 unsigned short mnBoost;
374 struct TData mData;
375 };
377 struct TPLL {
378 char mpName[64];
379 char *mpDescription;
380 struct TBlock mBlock;
381 };
383 struct TConfiguration {
384 char mpName[64];
385 char *mpDescription;
386 unsigned int mnDevices;
387 unsigned int mnProgram;
388 unsigned int mnPLL;
389 unsigned int mnSamplingRate;
390 unsigned char mnPLLSrc;
391 unsigned int mnPLLSrcRate;
392 struct TData mData;
393 };
395 struct TCalibration {
396 char mpName[64];
397 char *mpDescription;
398 unsigned int mnProgram;
399 unsigned int mnConfiguration;
400 struct TData mData;
401 };
403 struct TFirmware {
404 unsigned int mnFWSize;
405 unsigned int mnChecksum;
406 unsigned int mnPPCVersion;
407 unsigned int mnFWVersion;
408 unsigned int mnDriverVersion;
409 unsigned int mnTimeStamp;
410 char mpDDCName[64];
411 char *mpDescription;
412 unsigned int mnDeviceFamily;
413 unsigned int mnDevice;
414 unsigned int mnPLLs;
415 struct TPLL *mpPLLs;
416 unsigned int mnPrograms;
417 struct TProgram *mpPrograms;
418 unsigned int mnConfigurations;
419 struct TConfiguration *mpConfigurations;
420 unsigned int mnCalibrations;
421 struct TCalibration *mpCalibrations;
422 };
424 struct tas2557_register {
425 int book;
426 int page;
427 int reg;
428 };
430 enum channel {
431 channel_left = 0x01,
432 channel_right = 0x02,
433 channel_both = (channel_left|channel_right),
434 channel_broadcast = 0x4,
435 };
437 enum echo_reference {
438 echoref_left = 0x00,
439 echoref_right = 0x01,
440 echoref_both = 0x02
441 };
443 struct tas2557_priv {
444 struct device *dev;
445 struct regmap *mpRegmap;
446 struct i2c_client *client;
447 int mnLPGID;
448 int mnRPGID;
449 int mnLeftChlGpioRst;
450 int mnRightChlGpioRst;
451 struct mutex dev_lock;
452 struct TFirmware *mpFirmware;
453 struct TFirmware *mpCalFirmware;
454 unsigned int mnCurrentProgram;
455 unsigned int mnCurrentSampleRate;
456 unsigned int mnNewConfiguration;
457 unsigned int mnCurrentConfiguration;
458 unsigned int mnCurrentCalibration;
459 enum channel mnCurrentChannel;
460 unsigned char mnLAddr;
461 unsigned char mnRAddr;
462 unsigned char mnLCurrentBook;
463 unsigned char mnLCurrentPage;
464 unsigned char mnRCurrentBook;
465 unsigned char mnRCurrentPage;
466 unsigned int mnLBroadcastSet;
467 unsigned int mnRBroadcastSet;
468 bool mbTILoadActive;
469 bool mbPowerUp;
470 bool mbLoadConfigurationPrePowerUp;
471 bool mbLoadCalibrationPostPowerUp;
472 bool mbCalibrationLoaded;
473 int (*read)(struct tas2557_priv *pTAS2557,
474 enum channel chn,
475 unsigned int reg,
476 unsigned int *pValue);
477 int (*write)(struct tas2557_priv *pTAS2557,
478 enum channel chn,
479 unsigned int reg,
480 unsigned int Value);
481 int (*bulk_read)(struct tas2557_priv *pTAS2557,
482 enum channel chn,
483 unsigned int reg,
484 unsigned char *pData,
485 unsigned int len);
486 int (*bulk_write)(struct tas2557_priv *pTAS2557,
487 enum channel chn,
488 unsigned int reg,
489 unsigned char *pData,
490 unsigned int len);
491 int (*update_bits)(struct tas2557_priv *pTAS2557,
492 enum channel chn,
493 unsigned int reg,
494 unsigned int mask,
495 unsigned int value);
496 int (*set_config)(struct tas2557_priv *pTAS2557,
497 int config);
498 int (*set_calibration)(struct tas2557_priv *pTAS2557,
499 int calibration);
500 void (*clearIRQ)(struct tas2557_priv *pTAS2557);
501 void (*enableIRQ)(struct tas2557_priv *pTAS2557,
502 enum channel chl, bool enable);
503 void (*hw_reset)(struct tas2557_priv *pTAS2557);
504 /* device is working, but system is suspended */
505 int (*runtime_suspend)(struct tas2557_priv *pTAS2557);
506 int (*runtime_resume)(struct tas2557_priv *pTAS2557);
508 int mnLeftChlGpioINT;
509 int mnRightChlGpioINT;
510 struct delayed_work irq_work;
511 unsigned int mnLeftChlIRQ;
512 unsigned int mnRightChlIRQ;
513 bool mbIRQEnable;
514 enum echo_reference mnEchoRef;
515 unsigned char mnI2SBits;
517 unsigned int mnChannelState;
518 unsigned char mnDevAChlData[16];
519 unsigned char mnDevBChlData[16];
521 unsigned int mnVBoostState;
522 bool mbLoadVBoostPrePowerUp;
523 unsigned int mnVBoostVoltage;
524 unsigned int mnVBoostNewState;
525 unsigned int mnVBoostDefaultCfg[4];
527 /* for low temperature check */
528 unsigned int mnDevGain;
529 unsigned int mnDevCurrentGain;
530 unsigned int mnDieTvReadCounter;
531 struct hrtimer mtimer;
532 struct work_struct mtimerwork;
534 /* device is working, but system is suspended */
535 bool mbRuntimeSuspend;
537 unsigned int mnErrCode;
539 /* for configurations with maximum TLimit 0x7fffffff,
540 * bypass calibration update, usually used in factory test
541 */
542 bool mbBypassTMax;
544 unsigned int mnRestart;
545 #ifdef CONFIG_TAS2557_CODEC_STEREO
546 struct mutex codec_lock;
547 #endif
549 #ifdef CONFIG_TAS2557_MISC_STEREO
550 int mnDBGCmd;
551 int mnCurrentReg;
552 struct mutex file_lock;
553 #endif
555 };
557 #endif /* _TAS2557_H */