85dec5cd2eb913b8a3d8fc46bc9680e5e5de6ef0
[openwrt/staging/linusw.git] /
1 From 2d6dfbd200d8de9bef8fb30bec90594acea9a145 Mon Sep 17 00:00:00 2001
2 From: Dong Aisheng <aisheng.dong@nxp.com>
3 Date: Fri, 16 Aug 2019 18:01:26 +0800
4 Subject: [PATCH] Revert "ASoC: fsl_sai: Add support for SAI new version"
5
6 This reverts commit 4f7a0728b5305e2d865f543fbcffd617e03c7674.
7 ---
8 sound/soc/fsl/fsl_sai.c | 228 ++++++++++++++++++++----------------------------
9 sound/soc/fsl/fsl_sai.h | 41 +++++----
10 2 files changed, 113 insertions(+), 156 deletions(-)
11
12 --- a/sound/soc/fsl/fsl_sai.c
13 +++ b/sound/soc/fsl/fsl_sai.c
14 @@ -40,7 +40,6 @@ static const struct snd_pcm_hw_constrain
15 static irqreturn_t fsl_sai_isr(int irq, void *devid)
16 {
17 struct fsl_sai *sai = (struct fsl_sai *)devid;
18 - unsigned int ofs = sai->soc_data->reg_offset;
19 struct device *dev = &sai->pdev->dev;
20 u32 flags, xcsr, mask;
21 bool irq_none = true;
22 @@ -53,7 +52,7 @@ static irqreturn_t fsl_sai_isr(int irq,
23 mask = (FSL_SAI_FLAGS >> FSL_SAI_CSR_xIE_SHIFT) << FSL_SAI_CSR_xF_SHIFT;
24
25 /* Tx IRQ */
26 - regmap_read(sai->regmap, FSL_SAI_TCSR(ofs), &xcsr);
27 + regmap_read(sai->regmap, FSL_SAI_TCSR, &xcsr);
28 flags = xcsr & mask;
29
30 if (flags)
31 @@ -83,11 +82,11 @@ static irqreturn_t fsl_sai_isr(int irq,
32 xcsr &= ~FSL_SAI_CSR_xF_MASK;
33
34 if (flags)
35 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), flags | xcsr);
36 + regmap_write(sai->regmap, FSL_SAI_TCSR, flags | xcsr);
37
38 irq_rx:
39 /* Rx IRQ */
40 - regmap_read(sai->regmap, FSL_SAI_RCSR(ofs), &xcsr);
41 + regmap_read(sai->regmap, FSL_SAI_RCSR, &xcsr);
42 flags = xcsr & mask;
43
44 if (flags)
45 @@ -117,7 +116,7 @@ irq_rx:
46 xcsr &= ~FSL_SAI_CSR_xF_MASK;
47
48 if (flags)
49 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), flags | xcsr);
50 + regmap_write(sai->regmap, FSL_SAI_RCSR, flags | xcsr);
51
52 out:
53 if (irq_none)
54 @@ -141,7 +140,6 @@ static int fsl_sai_set_dai_sysclk_tr(str
55 int clk_id, unsigned int freq, int fsl_dir)
56 {
57 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
58 - unsigned int ofs = sai->soc_data->reg_offset;
59 bool tx = fsl_dir == FSL_FMT_TRANSMITTER;
60 u32 val_cr2 = 0;
61
62 @@ -162,7 +160,7 @@ static int fsl_sai_set_dai_sysclk_tr(str
63 return -EINVAL;
64 }
65
66 - regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx, ofs),
67 + regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx),
68 FSL_SAI_CR2_MSEL_MASK, val_cr2);
69
70 return 0;
71 @@ -195,7 +193,6 @@ static int fsl_sai_set_dai_fmt_tr(struct
72 unsigned int fmt, int fsl_dir)
73 {
74 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
75 - unsigned int ofs = sai->soc_data->reg_offset;
76 bool tx = fsl_dir == FSL_FMT_TRANSMITTER;
77 u32 val_cr2 = 0, val_cr4 = 0;
78
79 @@ -290,9 +287,9 @@ static int fsl_sai_set_dai_fmt_tr(struct
80 return -EINVAL;
81 }
82
83 - regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx, ofs),
84 + regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx),
85 FSL_SAI_CR2_BCP | FSL_SAI_CR2_BCD_MSTR, val_cr2);
86 - regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, ofs),
87 + regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx),
88 FSL_SAI_CR4_MF | FSL_SAI_CR4_FSE |
89 FSL_SAI_CR4_FSP | FSL_SAI_CR4_FSD_MSTR, val_cr4);
90
91 @@ -319,7 +316,6 @@ static int fsl_sai_set_dai_fmt(struct sn
92 static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)
93 {
94 struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
95 - unsigned int ofs = sai->soc_data->reg_offset;
96 unsigned long clk_rate;
97 u32 savediv = 0, ratio, savesub = freq;
98 u32 id;
99 @@ -382,17 +378,17 @@ static int fsl_sai_set_bclk(struct snd_s
100 */
101 if ((sai->synchronous[TX] && !sai->synchronous[RX]) ||
102 (!tx && !sai->synchronous[RX])) {
103 - regmap_update_bits(sai->regmap, FSL_SAI_RCR2(ofs),
104 + regmap_update_bits(sai->regmap, FSL_SAI_RCR2,
105 FSL_SAI_CR2_MSEL_MASK,
106 FSL_SAI_CR2_MSEL(sai->mclk_id[tx]));
107 - regmap_update_bits(sai->regmap, FSL_SAI_RCR2(ofs),
108 + regmap_update_bits(sai->regmap, FSL_SAI_RCR2,
109 FSL_SAI_CR2_DIV_MASK, savediv - 1);
110 } else if ((sai->synchronous[RX] && !sai->synchronous[TX]) ||
111 (tx && !sai->synchronous[TX])) {
112 - regmap_update_bits(sai->regmap, FSL_SAI_TCR2(ofs),
113 + regmap_update_bits(sai->regmap, FSL_SAI_TCR2,
114 FSL_SAI_CR2_MSEL_MASK,
115 FSL_SAI_CR2_MSEL(sai->mclk_id[tx]));
116 - regmap_update_bits(sai->regmap, FSL_SAI_TCR2(ofs),
117 + regmap_update_bits(sai->regmap, FSL_SAI_TCR2,
118 FSL_SAI_CR2_DIV_MASK, savediv - 1);
119 }
120
121 @@ -407,7 +403,6 @@ static int fsl_sai_hw_params(struct snd_
122 struct snd_soc_dai *cpu_dai)
123 {
124 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
125 - unsigned int ofs = sai->soc_data->reg_offset;
126 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
127 unsigned int channels = params_channels(params);
128 u32 word_width = params_width(params);
129 @@ -460,19 +455,19 @@ static int fsl_sai_hw_params(struct snd_
130
131 if (!sai->is_slave_mode) {
132 if (!sai->synchronous[TX] && sai->synchronous[RX] && !tx) {
133 - regmap_update_bits(sai->regmap, FSL_SAI_TCR4(ofs),
134 + regmap_update_bits(sai->regmap, FSL_SAI_TCR4,
135 FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK,
136 val_cr4);
137 - regmap_update_bits(sai->regmap, FSL_SAI_TCR5(ofs),
138 + regmap_update_bits(sai->regmap, FSL_SAI_TCR5,
139 FSL_SAI_CR5_WNW_MASK | FSL_SAI_CR5_W0W_MASK |
140 FSL_SAI_CR5_FBT_MASK, val_cr5);
141 regmap_write(sai->regmap, FSL_SAI_TMR,
142 ~0UL - ((1 << channels) - 1));
143 } else if (!sai->synchronous[RX] && sai->synchronous[TX] && tx) {
144 - regmap_update_bits(sai->regmap, FSL_SAI_RCR4(ofs),
145 + regmap_update_bits(sai->regmap, FSL_SAI_RCR4,
146 FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK,
147 val_cr4);
148 - regmap_update_bits(sai->regmap, FSL_SAI_RCR5(ofs),
149 + regmap_update_bits(sai->regmap, FSL_SAI_RCR5,
150 FSL_SAI_CR5_WNW_MASK | FSL_SAI_CR5_W0W_MASK |
151 FSL_SAI_CR5_FBT_MASK, val_cr5);
152 regmap_write(sai->regmap, FSL_SAI_RMR,
153 @@ -480,10 +475,10 @@ static int fsl_sai_hw_params(struct snd_
154 }
155 }
156
157 - regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, ofs),
158 + regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx),
159 FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK,
160 val_cr4);
161 - regmap_update_bits(sai->regmap, FSL_SAI_xCR5(tx, ofs),
162 + regmap_update_bits(sai->regmap, FSL_SAI_xCR5(tx),
163 FSL_SAI_CR5_WNW_MASK | FSL_SAI_CR5_W0W_MASK |
164 FSL_SAI_CR5_FBT_MASK, val_cr5);
165 regmap_write(sai->regmap, FSL_SAI_xMR(tx), ~0UL - ((1 << channels) - 1));
166 @@ -511,8 +506,6 @@ static int fsl_sai_trigger(struct snd_pc
167 struct snd_soc_dai *cpu_dai)
168 {
169 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
170 - unsigned int ofs = sai->soc_data->reg_offset;
171 -
172 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
173 u32 xcsr, count = 100;
174
175 @@ -521,9 +514,9 @@ static int fsl_sai_trigger(struct snd_pc
176 * Rx sync with Tx clocks: Clear SYNC for Tx, set it for Rx.
177 * Tx sync with Rx clocks: Clear SYNC for Rx, set it for Tx.
178 */
179 - regmap_update_bits(sai->regmap, FSL_SAI_TCR2(ofs), FSL_SAI_CR2_SYNC,
180 - sai->synchronous[TX] ? FSL_SAI_CR2_SYNC : 0);
181 - regmap_update_bits(sai->regmap, FSL_SAI_RCR2(ofs), FSL_SAI_CR2_SYNC,
182 + regmap_update_bits(sai->regmap, FSL_SAI_TCR2, FSL_SAI_CR2_SYNC,
183 + sai->synchronous[TX] ? FSL_SAI_CR2_SYNC : 0);
184 + regmap_update_bits(sai->regmap, FSL_SAI_RCR2, FSL_SAI_CR2_SYNC,
185 sai->synchronous[RX] ? FSL_SAI_CR2_SYNC : 0);
186
187 /*
188 @@ -534,44 +527,43 @@ static int fsl_sai_trigger(struct snd_pc
189 case SNDRV_PCM_TRIGGER_START:
190 case SNDRV_PCM_TRIGGER_RESUME:
191 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
192 - regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx, ofs),
193 + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx),
194 FSL_SAI_CSR_FRDE, FSL_SAI_CSR_FRDE);
195
196 - regmap_update_bits(sai->regmap, FSL_SAI_RCSR(ofs),
197 + regmap_update_bits(sai->regmap, FSL_SAI_RCSR,
198 FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE);
199 - regmap_update_bits(sai->regmap, FSL_SAI_TCSR(ofs),
200 + regmap_update_bits(sai->regmap, FSL_SAI_TCSR,
201 FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE);
202
203 - regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx, ofs),
204 + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx),
205 FSL_SAI_CSR_xIE_MASK, FSL_SAI_FLAGS);
206 break;
207 case SNDRV_PCM_TRIGGER_STOP:
208 case SNDRV_PCM_TRIGGER_SUSPEND:
209 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
210 - regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx, ofs),
211 + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx),
212 FSL_SAI_CSR_FRDE, 0);
213 - regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx, ofs),
214 + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx),
215 FSL_SAI_CSR_xIE_MASK, 0);
216
217 /* Check if the opposite FRDE is also disabled */
218 - regmap_read(sai->regmap, FSL_SAI_xCSR(!tx, ofs), &xcsr);
219 + regmap_read(sai->regmap, FSL_SAI_xCSR(!tx), &xcsr);
220 if (!(xcsr & FSL_SAI_CSR_FRDE)) {
221 /* Disable both directions and reset their FIFOs */
222 - regmap_update_bits(sai->regmap, FSL_SAI_TCSR(ofs),
223 + regmap_update_bits(sai->regmap, FSL_SAI_TCSR,
224 FSL_SAI_CSR_TERE, 0);
225 - regmap_update_bits(sai->regmap, FSL_SAI_RCSR(ofs),
226 + regmap_update_bits(sai->regmap, FSL_SAI_RCSR,
227 FSL_SAI_CSR_TERE, 0);
228
229 /* TERE will remain set till the end of current frame */
230 do {
231 udelay(10);
232 - regmap_read(sai->regmap,
233 - FSL_SAI_xCSR(tx, ofs), &xcsr);
234 + regmap_read(sai->regmap, FSL_SAI_xCSR(tx), &xcsr);
235 } while (--count && xcsr & FSL_SAI_CSR_TERE);
236
237 - regmap_update_bits(sai->regmap, FSL_SAI_TCSR(ofs),
238 + regmap_update_bits(sai->regmap, FSL_SAI_TCSR,
239 FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
240 - regmap_update_bits(sai->regmap, FSL_SAI_RCSR(ofs),
241 + regmap_update_bits(sai->regmap, FSL_SAI_RCSR,
242 FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
243
244 /*
245 @@ -583,13 +575,13 @@ static int fsl_sai_trigger(struct snd_pc
246 */
247 if (!sai->is_slave_mode) {
248 /* Software Reset for both Tx and Rx */
249 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs),
250 - FSL_SAI_CSR_SR);
251 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs),
252 - FSL_SAI_CSR_SR);
253 + regmap_write(sai->regmap,
254 + FSL_SAI_TCSR, FSL_SAI_CSR_SR);
255 + regmap_write(sai->regmap,
256 + FSL_SAI_RCSR, FSL_SAI_CSR_SR);
257 /* Clear SR bit to finish the reset */
258 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), 0);
259 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), 0);
260 + regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
261 + regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
262 }
263 }
264 break;
265 @@ -604,11 +596,10 @@ static int fsl_sai_startup(struct snd_pc
266 struct snd_soc_dai *cpu_dai)
267 {
268 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
269 - unsigned int ofs = sai->soc_data->reg_offset;
270 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
271 int ret;
272
273 - regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx, ofs),
274 + regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx),
275 FSL_SAI_CR3_TRCE_MASK,
276 FSL_SAI_CR3_TRCE);
277
278 @@ -622,10 +613,9 @@ static void fsl_sai_shutdown(struct snd_
279 struct snd_soc_dai *cpu_dai)
280 {
281 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
282 - unsigned int ofs = sai->soc_data->reg_offset;
283 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
284
285 - regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx, ofs),
286 + regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx),
287 FSL_SAI_CR3_TRCE_MASK, 0);
288 }
289
290 @@ -643,20 +633,18 @@ static const struct snd_soc_dai_ops fsl_
291 static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
292 {
293 struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev);
294 - unsigned int ofs = sai->soc_data->reg_offset;
295
296 /* Software Reset for both Tx and Rx */
297 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), FSL_SAI_CSR_SR);
298 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), FSL_SAI_CSR_SR);
299 + regmap_write(sai->regmap, FSL_SAI_TCSR, FSL_SAI_CSR_SR);
300 + regmap_write(sai->regmap, FSL_SAI_RCSR, FSL_SAI_CSR_SR);
301 /* Clear SR bit to finish the reset */
302 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), 0);
303 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), 0);
304 + regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
305 + regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
306
307 - regmap_update_bits(sai->regmap, FSL_SAI_TCR1(ofs),
308 - FSL_SAI_CR1_RFW_MASK,
309 + regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK,
310 sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX);
311 - regmap_update_bits(sai->regmap, FSL_SAI_RCR1(ofs),
312 - FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_RX - 1);
313 + regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK,
314 + FSL_SAI_MAXBURST_RX - 1);
315
316 snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx,
317 &sai->dma_params_rx);
318 @@ -693,12 +681,12 @@ static const struct snd_soc_component_dr
319 .name = "fsl-sai",
320 };
321
322 -static struct reg_default fsl_sai_reg_defaults_ofs0[] = {
323 - {FSL_SAI_TCR1(0), 0},
324 - {FSL_SAI_TCR2(0), 0},
325 - {FSL_SAI_TCR3(0), 0},
326 - {FSL_SAI_TCR4(0), 0},
327 - {FSL_SAI_TCR5(0), 0},
328 +static struct reg_default fsl_sai_reg_defaults[] = {
329 + {FSL_SAI_TCR1, 0},
330 + {FSL_SAI_TCR2, 0},
331 + {FSL_SAI_TCR3, 0},
332 + {FSL_SAI_TCR4, 0},
333 + {FSL_SAI_TCR5, 0},
334 {FSL_SAI_TDR0, 0},
335 {FSL_SAI_TDR1, 0},
336 {FSL_SAI_TDR2, 0},
337 @@ -707,50 +695,24 @@ static struct reg_default fsl_sai_reg_de
338 {FSL_SAI_TDR5, 0},
339 {FSL_SAI_TDR6, 0},
340 {FSL_SAI_TDR7, 0},
341 - {FSL_SAI_TMR, 0},
342 - {FSL_SAI_RCR1(0), 0},
343 - {FSL_SAI_RCR2(0), 0},
344 - {FSL_SAI_RCR3(0), 0},
345 - {FSL_SAI_RCR4(0), 0},
346 - {FSL_SAI_RCR5(0), 0},
347 - {FSL_SAI_RMR, 0},
348 -};
349 -
350 -static struct reg_default fsl_sai_reg_defaults_ofs8[] = {
351 - {FSL_SAI_TCR1(8), 0},
352 - {FSL_SAI_TCR2(8), 0},
353 - {FSL_SAI_TCR3(8), 0},
354 - {FSL_SAI_TCR4(8), 0},
355 - {FSL_SAI_TCR5(8), 0},
356 - {FSL_SAI_TDR0, 0},
357 - {FSL_SAI_TDR1, 0},
358 - {FSL_SAI_TDR2, 0},
359 - {FSL_SAI_TDR3, 0},
360 - {FSL_SAI_TDR4, 0},
361 - {FSL_SAI_TDR5, 0},
362 - {FSL_SAI_TDR6, 0},
363 - {FSL_SAI_TDR7, 0},
364 - {FSL_SAI_TMR, 0},
365 - {FSL_SAI_RCR1(8), 0},
366 - {FSL_SAI_RCR2(8), 0},
367 - {FSL_SAI_RCR3(8), 0},
368 - {FSL_SAI_RCR4(8), 0},
369 - {FSL_SAI_RCR5(8), 0},
370 - {FSL_SAI_RMR, 0},
371 + {FSL_SAI_TMR, 0},
372 + {FSL_SAI_RCR1, 0},
373 + {FSL_SAI_RCR2, 0},
374 + {FSL_SAI_RCR3, 0},
375 + {FSL_SAI_RCR4, 0},
376 + {FSL_SAI_RCR5, 0},
377 + {FSL_SAI_RMR, 0},
378 };
379
380 static bool fsl_sai_readable_reg(struct device *dev, unsigned int reg)
381 {
382 - struct fsl_sai *sai = dev_get_drvdata(dev);
383 - unsigned int ofs = sai->soc_data->reg_offset;
384 -
385 - if (reg >= FSL_SAI_TCSR(ofs) && reg <= FSL_SAI_TCR5(ofs))
386 - return true;
387 -
388 - if (reg >= FSL_SAI_RCSR(ofs) && reg <= FSL_SAI_RCR5(ofs))
389 - return true;
390 -
391 switch (reg) {
392 + case FSL_SAI_TCSR:
393 + case FSL_SAI_TCR1:
394 + case FSL_SAI_TCR2:
395 + case FSL_SAI_TCR3:
396 + case FSL_SAI_TCR4:
397 + case FSL_SAI_TCR5:
398 case FSL_SAI_TFR0:
399 case FSL_SAI_TFR1:
400 case FSL_SAI_TFR2:
401 @@ -760,6 +722,12 @@ static bool fsl_sai_readable_reg(struct
402 case FSL_SAI_TFR6:
403 case FSL_SAI_TFR7:
404 case FSL_SAI_TMR:
405 + case FSL_SAI_RCSR:
406 + case FSL_SAI_RCR1:
407 + case FSL_SAI_RCR2:
408 + case FSL_SAI_RCR3:
409 + case FSL_SAI_RCR4:
410 + case FSL_SAI_RCR5:
411 case FSL_SAI_RDR0:
412 case FSL_SAI_RDR1:
413 case FSL_SAI_RDR2:
414 @@ -785,13 +753,9 @@ static bool fsl_sai_readable_reg(struct
415
416 static bool fsl_sai_volatile_reg(struct device *dev, unsigned int reg)
417 {
418 - struct fsl_sai *sai = dev_get_drvdata(dev);
419 - unsigned int ofs = sai->soc_data->reg_offset;
420 -
421 - if (reg == FSL_SAI_TCSR(ofs) || reg == FSL_SAI_RCSR(ofs))
422 - return true;
423 -
424 switch (reg) {
425 + case FSL_SAI_TCSR:
426 + case FSL_SAI_RCSR:
427 case FSL_SAI_TFR0:
428 case FSL_SAI_TFR1:
429 case FSL_SAI_TFR2:
430 @@ -824,16 +788,13 @@ static bool fsl_sai_volatile_reg(struct
431
432 static bool fsl_sai_writeable_reg(struct device *dev, unsigned int reg)
433 {
434 - struct fsl_sai *sai = dev_get_drvdata(dev);
435 - unsigned int ofs = sai->soc_data->reg_offset;
436 -
437 - if (reg >= FSL_SAI_TCSR(ofs) && reg <= FSL_SAI_TCR5(ofs))
438 - return true;
439 -
440 - if (reg >= FSL_SAI_RCSR(ofs) && reg <= FSL_SAI_RCR5(ofs))
441 - return true;
442 -
443 switch (reg) {
444 + case FSL_SAI_TCSR:
445 + case FSL_SAI_TCR1:
446 + case FSL_SAI_TCR2:
447 + case FSL_SAI_TCR3:
448 + case FSL_SAI_TCR4:
449 + case FSL_SAI_TCR5:
450 case FSL_SAI_TDR0:
451 case FSL_SAI_TDR1:
452 case FSL_SAI_TDR2:
453 @@ -843,6 +804,12 @@ static bool fsl_sai_writeable_reg(struct
454 case FSL_SAI_TDR6:
455 case FSL_SAI_TDR7:
456 case FSL_SAI_TMR:
457 + case FSL_SAI_RCSR:
458 + case FSL_SAI_RCR1:
459 + case FSL_SAI_RCR2:
460 + case FSL_SAI_RCR3:
461 + case FSL_SAI_RCR4:
462 + case FSL_SAI_RCR5:
463 case FSL_SAI_RMR:
464 return true;
465 default:
466 @@ -850,15 +817,15 @@ static bool fsl_sai_writeable_reg(struct
467 }
468 }
469
470 -static struct regmap_config fsl_sai_regmap_config = {
471 +static const struct regmap_config fsl_sai_regmap_config = {
472 .reg_bits = 32,
473 .reg_stride = 4,
474 .val_bits = 32,
475 .fast_io = true,
476
477 .max_register = FSL_SAI_RMR,
478 - .reg_defaults = fsl_sai_reg_defaults_ofs0,
479 - .num_reg_defaults = ARRAY_SIZE(fsl_sai_reg_defaults_ofs0),
480 + .reg_defaults = fsl_sai_reg_defaults,
481 + .num_reg_defaults = ARRAY_SIZE(fsl_sai_reg_defaults),
482 .readable_reg = fsl_sai_readable_reg,
483 .volatile_reg = fsl_sai_volatile_reg,
484 .writeable_reg = fsl_sai_writeable_reg,
485 @@ -890,12 +857,6 @@ static int fsl_sai_probe(struct platform
486 if (IS_ERR(base))
487 return PTR_ERR(base);
488
489 - if (sai->soc_data->reg_offset == 8) {
490 - fsl_sai_regmap_config.reg_defaults = fsl_sai_reg_defaults_ofs8;
491 - fsl_sai_regmap_config.num_reg_defaults =
492 - ARRAY_SIZE(fsl_sai_reg_defaults_ofs8);
493 - }
494 -
495 sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev,
496 "bus", base, &fsl_sai_regmap_config);
497
498 @@ -1022,13 +983,11 @@ static int fsl_sai_remove(struct platfor
499 static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
500 .use_imx_pcm = false,
501 .fifo_depth = 32,
502 - .reg_offset = 0,
503 };
504
505 static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
506 .use_imx_pcm = true,
507 .fifo_depth = 32,
508 - .reg_offset = 0,
509 };
510
511 static const struct of_device_id fsl_sai_ids[] = {
512 @@ -1061,7 +1020,6 @@ static int fsl_sai_runtime_suspend(struc
513 static int fsl_sai_runtime_resume(struct device *dev)
514 {
515 struct fsl_sai *sai = dev_get_drvdata(dev);
516 - unsigned int ofs = sai->soc_data->reg_offset;
517 int ret;
518
519 ret = clk_prepare_enable(sai->bus_clk);
520 @@ -1083,11 +1041,11 @@ static int fsl_sai_runtime_resume(struct
521 }
522
523 regcache_cache_only(sai->regmap, false);
524 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), FSL_SAI_CSR_SR);
525 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), FSL_SAI_CSR_SR);
526 + regmap_write(sai->regmap, FSL_SAI_TCSR, FSL_SAI_CSR_SR);
527 + regmap_write(sai->regmap, FSL_SAI_RCSR, FSL_SAI_CSR_SR);
528 usleep_range(1000, 2000);
529 - regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), 0);
530 - regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), 0);
531 + regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
532 + regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
533
534 ret = regcache_sync(sai->regmap);
535 if (ret)
536 --- a/sound/soc/fsl/fsl_sai.h
537 +++ b/sound/soc/fsl/fsl_sai.h
538 @@ -14,12 +14,12 @@
539 SNDRV_PCM_FMTBIT_S32_LE)
540
541 /* SAI Register Map Register */
542 -#define FSL_SAI_TCSR(ofs) (0x00 + ofs) /* SAI Transmit Control */
543 -#define FSL_SAI_TCR1(ofs) (0x04 + ofs) /* SAI Transmit Configuration 1 */
544 -#define FSL_SAI_TCR2(ofs) (0x08 + ofs) /* SAI Transmit Configuration 2 */
545 -#define FSL_SAI_TCR3(ofs) (0x0c + ofs) /* SAI Transmit Configuration 3 */
546 -#define FSL_SAI_TCR4(ofs) (0x10 + ofs) /* SAI Transmit Configuration 4 */
547 -#define FSL_SAI_TCR5(ofs) (0x14 + ofs) /* SAI Transmit Configuration 5 */
548 +#define FSL_SAI_TCSR 0x00 /* SAI Transmit Control */
549 +#define FSL_SAI_TCR1 0x04 /* SAI Transmit Configuration 1 */
550 +#define FSL_SAI_TCR2 0x08 /* SAI Transmit Configuration 2 */
551 +#define FSL_SAI_TCR3 0x0c /* SAI Transmit Configuration 3 */
552 +#define FSL_SAI_TCR4 0x10 /* SAI Transmit Configuration 4 */
553 +#define FSL_SAI_TCR5 0x14 /* SAI Transmit Configuration 5 */
554 #define FSL_SAI_TDR0 0x20 /* SAI Transmit Data 0 */
555 #define FSL_SAI_TDR1 0x24 /* SAI Transmit Data 1 */
556 #define FSL_SAI_TDR2 0x28 /* SAI Transmit Data 2 */
557 @@ -37,12 +37,12 @@
558 #define FSL_SAI_TFR6 0x58 /* SAI Transmit FIFO 6 */
559 #define FSL_SAI_TFR7 0x5C /* SAI Transmit FIFO 7 */
560 #define FSL_SAI_TMR 0x60 /* SAI Transmit Mask */
561 -#define FSL_SAI_RCSR(ofs) (0x80 + ofs) /* SAI Receive Control */
562 -#define FSL_SAI_RCR1(ofs) (0x84 + ofs)/* SAI Receive Configuration 1 */
563 -#define FSL_SAI_RCR2(ofs) (0x88 + ofs) /* SAI Receive Configuration 2 */
564 -#define FSL_SAI_RCR3(ofs) (0x8c + ofs) /* SAI Receive Configuration 3 */
565 -#define FSL_SAI_RCR4(ofs) (0x90 + ofs) /* SAI Receive Configuration 4 */
566 -#define FSL_SAI_RCR5(ofs) (0x94 + ofs) /* SAI Receive Configuration 5 */
567 +#define FSL_SAI_RCSR 0x80 /* SAI Receive Control */
568 +#define FSL_SAI_RCR1 0x84 /* SAI Receive Configuration 1 */
569 +#define FSL_SAI_RCR2 0x88 /* SAI Receive Configuration 2 */
570 +#define FSL_SAI_RCR3 0x8c /* SAI Receive Configuration 3 */
571 +#define FSL_SAI_RCR4 0x90 /* SAI Receive Configuration 4 */
572 +#define FSL_SAI_RCR5 0x94 /* SAI Receive Configuration 5 */
573 #define FSL_SAI_RDR0 0xa0 /* SAI Receive Data 0 */
574 #define FSL_SAI_RDR1 0xa4 /* SAI Receive Data 1 */
575 #define FSL_SAI_RDR2 0xa8 /* SAI Receive Data 2 */
576 @@ -61,14 +61,14 @@
577 #define FSL_SAI_RFR7 0xdc /* SAI Receive FIFO 7 */
578 #define FSL_SAI_RMR 0xe0 /* SAI Receive Mask */
579
580 -#define FSL_SAI_xCSR(tx, ofs) (tx ? FSL_SAI_TCSR(ofs) : FSL_SAI_RCSR(ofs))
581 -#define FSL_SAI_xCR1(tx, ofs) (tx ? FSL_SAI_TCR1(ofs) : FSL_SAI_RCR1(ofs))
582 -#define FSL_SAI_xCR2(tx, ofs) (tx ? FSL_SAI_TCR2(ofs) : FSL_SAI_RCR2(ofs))
583 -#define FSL_SAI_xCR3(tx, ofs) (tx ? FSL_SAI_TCR3(ofs) : FSL_SAI_RCR3(ofs))
584 -#define FSL_SAI_xCR4(tx, ofs) (tx ? FSL_SAI_TCR4(ofs) : FSL_SAI_RCR4(ofs))
585 -#define FSL_SAI_xCR5(tx, ofs) (tx ? FSL_SAI_TCR5(ofs) : FSL_SAI_RCR5(ofs))
586 -#define FSL_SAI_xDR(tx, ofs) (tx ? FSL_SAI_TDR(ofs) : FSL_SAI_RDR(ofs))
587 -#define FSL_SAI_xFR(tx, ofs) (tx ? FSL_SAI_TFR(ofs) : FSL_SAI_RFR(ofs))
588 +#define FSL_SAI_xCSR(tx) (tx ? FSL_SAI_TCSR : FSL_SAI_RCSR)
589 +#define FSL_SAI_xCR1(tx) (tx ? FSL_SAI_TCR1 : FSL_SAI_RCR1)
590 +#define FSL_SAI_xCR2(tx) (tx ? FSL_SAI_TCR2 : FSL_SAI_RCR2)
591 +#define FSL_SAI_xCR3(tx) (tx ? FSL_SAI_TCR3 : FSL_SAI_RCR3)
592 +#define FSL_SAI_xCR4(tx) (tx ? FSL_SAI_TCR4 : FSL_SAI_RCR4)
593 +#define FSL_SAI_xCR5(tx) (tx ? FSL_SAI_TCR5 : FSL_SAI_RCR5)
594 +#define FSL_SAI_xDR(tx) (tx ? FSL_SAI_TDR : FSL_SAI_RDR)
595 +#define FSL_SAI_xFR(tx) (tx ? FSL_SAI_TFR : FSL_SAI_RFR)
596 #define FSL_SAI_xMR(tx) (tx ? FSL_SAI_TMR : FSL_SAI_RMR)
597
598 /* SAI Transmit/Receive Control Register */
599 @@ -158,7 +158,6 @@
600 struct fsl_sai_soc_data {
601 bool use_imx_pcm;
602 unsigned int fifo_depth;
603 - unsigned int reg_offset;
604 };
605
606 struct fsl_sai {