2 * linux/sound/soc/m8m/hi6210_i2s.c - I2S IP driver
4 * Copyright (C) 2015 Linaro, Ltd
5 * Author: Andy Green <andy.green@linaro.org>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * This driver only deals with S2 interface (BT)
19 #include <linux/init.h>
20 #include <linux/module.h>
21 #include <linux/device.h>
22 #include <linux/delay.h>
23 #include <linux/clk.h>
24 #include <linux/jiffies.h>
26 #include <linux/gpio.h>
27 #include <sound/core.h>
28 #include <sound/pcm.h>
29 #include <sound/pcm_params.h>
30 #include <sound/dmaengine_pcm.h>
31 #include <sound/initval.h>
32 #include <sound/soc.h>
33 #include <linux/interrupt.h>
34 #include <linux/reset.h>
35 #include <linux/of_address.h>
36 #include <linux/of_irq.h>
37 #include <linux/mfd/syscon.h>
38 #include <linux/reset-controller.h>
39 #include <linux/clk.h>
41 #include "hi6210-i2s.h"
45 struct reset_control
*rc
;
48 struct snd_soc_dai_driver dai
;
50 struct regmap
*sysctrl
;
51 phys_addr_t base_phys
;
52 struct snd_dmaengine_dai_dma_data dma_data
[2];
66 #define SC_PERIPH_CLKEN1 0x210
67 #define SC_PERIPH_CLKDIS1 0x214
69 #define SC_PERIPH_CLKEN3 0x230
70 #define SC_PERIPH_CLKDIS3 0x234
72 #define SC_PERIPH_CLKEN12 0x270
73 #define SC_PERIPH_CLKDIS12 0x274
75 #define SC_PERIPH_RSTEN1 0x310
76 #define SC_PERIPH_RSTDIS1 0x314
77 #define SC_PERIPH_RSTSTAT1 0x318
79 #define SC_PERIPH_RSTEN2 0x320
80 #define SC_PERIPH_RSTDIS2 0x324
81 #define SC_PERIPH_RSTSTAT2 0x328
83 #define SOC_PMCTRL_BBPPLLALIAS 0x48
90 static inline void hi6210_write_reg(struct hi6210_i2s
*i2s
, int reg
, u32 val
)
92 writel(val
, i2s
->base
+ reg
);
95 static inline u32
hi6210_read_reg(struct hi6210_i2s
*i2s
, int reg
)
97 return readl(i2s
->base
+ reg
);
100 static int hi6210_i2s_startup(struct snd_pcm_substream
*substream
,
101 struct snd_soc_dai
*cpu_dai
)
103 struct hi6210_i2s
*i2s
= dev_get_drvdata(cpu_dai
->dev
);
107 /* deassert reset on ABB */
108 regmap_read(i2s
->sysctrl
, SC_PERIPH_RSTSTAT2
, &val
);
110 regmap_write(i2s
->sysctrl
, SC_PERIPH_RSTDIS2
, BIT(4));
112 for (n
= 0; n
< i2s
->clocks
; n
++) {
113 ret
= clk_prepare_enable(i2s
->clk
[n
]);
116 clk_disable_unprepare(i2s
->clk
[n
]);
121 ret
= clk_set_rate(i2s
->clk
[CLK_I2S_BASE
], 49152000);
123 dev_err(i2s
->dev
, "%s: setting 49.152MHz base rate failed %d\n",
128 /* enable clock before frequency division */
129 regmap_write(i2s
->sysctrl
, SC_PERIPH_CLKEN12
, BIT(9));
131 /* enable codec working clock / == "codec bus clock" */
132 regmap_write(i2s
->sysctrl
, SC_PERIPH_CLKEN1
, BIT(5));
134 /* deassert reset on codec / interface clock / working clock */
135 regmap_write(i2s
->sysctrl
, SC_PERIPH_RSTEN1
, BIT(5));
136 regmap_write(i2s
->sysctrl
, SC_PERIPH_RSTDIS1
, BIT(5));
138 /* not interested in i2s irqs */
139 val
= hi6210_read_reg(i2s
, HII2S_CODEC_IRQ_MASK
);
141 hi6210_write_reg(i2s
, HII2S_CODEC_IRQ_MASK
, val
);
144 /* reset the stereo downlink fifo */
145 val
= hi6210_read_reg(i2s
, HII2S_APB_AFIFO_CFG_1
);
146 val
|= (BIT(5) | BIT(4));
147 hi6210_write_reg(i2s
, HII2S_APB_AFIFO_CFG_1
, val
);
149 val
= hi6210_read_reg(i2s
, HII2S_APB_AFIFO_CFG_1
);
150 val
&= ~(BIT(5) | BIT(4));
151 hi6210_write_reg(i2s
, HII2S_APB_AFIFO_CFG_1
, val
);
154 val
= hi6210_read_reg(i2s
, HII2S_SW_RST_N
);
155 val
&= ~(HII2S_SW_RST_N__ST_DL_WORDLEN_MASK
<<
156 HII2S_SW_RST_N__ST_DL_WORDLEN_SHIFT
);
157 val
|= (HII2S_BITS_16
<< HII2S_SW_RST_N__ST_DL_WORDLEN_SHIFT
);
158 hi6210_write_reg(i2s
, HII2S_SW_RST_N
, val
);
160 val
= hi6210_read_reg(i2s
, HII2S_MISC_CFG
);
161 /* mux 11/12 = APB not i2s */
162 val
&= ~HII2S_MISC_CFG__ST_DL_TEST_SEL
;
163 /* BT R ch 0 = mixer op of DACR ch */
164 val
&= ~HII2S_MISC_CFG__S2_DOUT_RIGHT_SEL
;
165 val
&= ~HII2S_MISC_CFG__S2_DOUT_TEST_SEL
;
167 val
|= HII2S_MISC_CFG__S2_DOUT_RIGHT_SEL
;
168 /* BT L ch = 1 = mux 7 = "mixer output of DACL */
169 val
|= HII2S_MISC_CFG__S2_DOUT_TEST_SEL
;
170 hi6210_write_reg(i2s
, HII2S_MISC_CFG
, val
);
172 val
= hi6210_read_reg(i2s
, HII2S_SW_RST_N
);
173 val
|= HII2S_SW_RST_N__SW_RST_N
;
174 hi6210_write_reg(i2s
, HII2S_SW_RST_N
, val
);
179 static void hi6210_i2s_shutdown(struct snd_pcm_substream
*substream
,
180 struct snd_soc_dai
*cpu_dai
)
182 struct hi6210_i2s
*i2s
= dev_get_drvdata(cpu_dai
->dev
);
185 for (n
= 0; n
< i2s
->clocks
; n
++)
186 clk_disable_unprepare(i2s
->clk
[n
]);
188 regmap_write(i2s
->sysctrl
, SC_PERIPH_RSTEN1
, BIT(5));
191 static void hi6210_i2s_txctrl(struct snd_soc_dai
*cpu_dai
, int on
)
193 struct hi6210_i2s
*i2s
= dev_get_drvdata(cpu_dai
->dev
);
196 spin_lock(&i2s
->lock
);
199 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
200 val
|= HII2S_I2S_CFG__S2_IF_TX_EN
;
201 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
204 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
205 val
&= ~HII2S_I2S_CFG__S2_IF_TX_EN
;
206 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
208 spin_unlock(&i2s
->lock
);
211 static void hi6210_i2s_rxctrl(struct snd_soc_dai
*cpu_dai
, int on
)
213 struct hi6210_i2s
*i2s
= dev_get_drvdata(cpu_dai
->dev
);
216 spin_lock(&i2s
->lock
);
218 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
219 val
|= HII2S_I2S_CFG__S2_IF_RX_EN
;
220 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
222 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
223 val
&= ~HII2S_I2S_CFG__S2_IF_RX_EN
;
224 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
226 spin_unlock(&i2s
->lock
);
229 static int hi6210_i2s_set_fmt(struct snd_soc_dai
*cpu_dai
, unsigned int fmt
)
231 struct hi6210_i2s
*i2s
= dev_get_drvdata(cpu_dai
->dev
);
234 * We don't actually set the hardware until the hw_params
235 * call, but we need to validate the user input here.
237 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
238 case SND_SOC_DAIFMT_CBM_CFM
:
239 case SND_SOC_DAIFMT_CBS_CFS
:
245 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
246 case SND_SOC_DAIFMT_I2S
:
247 case SND_SOC_DAIFMT_LEFT_J
:
248 case SND_SOC_DAIFMT_RIGHT_J
:
255 i2s
->master
= (i2s
->format
& SND_SOC_DAIFMT_MASTER_MASK
) ==
256 SND_SOC_DAIFMT_CBS_CFS
;
261 static int hi6210_i2s_hw_params(struct snd_pcm_substream
*substream
,
262 struct snd_pcm_hw_params
*params
,
263 struct snd_soc_dai
*cpu_dai
)
265 struct hi6210_i2s
*i2s
= dev_get_drvdata(cpu_dai
->dev
);
266 u32 bits
= 0, rate
= 0, signed_data
= 0, fmt
= 0;
268 struct snd_dmaengine_dai_dma_data
*dma_data
;
270 switch (params_format(params
)) {
271 case SNDRV_PCM_FORMAT_U16_LE
:
272 signed_data
= HII2S_I2S_CFG__S2_CODEC_DATA_FORMAT
;
274 case SNDRV_PCM_FORMAT_S16_LE
:
275 bits
= HII2S_BITS_16
;
277 case SNDRV_PCM_FORMAT_U24_LE
:
278 signed_data
= HII2S_I2S_CFG__S2_CODEC_DATA_FORMAT
;
280 case SNDRV_PCM_FORMAT_S24_LE
:
281 bits
= HII2S_BITS_24
;
284 dev_err(cpu_dai
->dev
, "Bad format\n");
289 switch (params_rate(params
)) {
291 rate
= HII2S_FS_RATE_8KHZ
;
294 rate
= HII2S_FS_RATE_16KHZ
;
297 rate
= HII2S_FS_RATE_32KHZ
;
300 rate
= HII2S_FS_RATE_48KHZ
;
303 rate
= HII2S_FS_RATE_96KHZ
;
306 rate
= HII2S_FS_RATE_192KHZ
;
309 dev_err(cpu_dai
->dev
, "Bad rate: %d\n", params_rate(params
));
313 if (!(params_channels(params
))) {
314 dev_err(cpu_dai
->dev
, "Bad channels\n");
318 dma_data
= snd_soc_dai_get_dma_data(cpu_dai
, substream
);
323 dma_data
->addr_width
= 3;
327 dma_data
->addr_width
= 2;
330 i2s
->rate
= params_rate(params
);
331 i2s
->channels
= params_channels(params
);
332 i2s
->channel_length
= i2s
->channels
* i2s
->bits
;
334 val
= hi6210_read_reg(i2s
, HII2S_ST_DL_FIFO_TH_CFG
);
335 val
&= ~((HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AEMPTY_MASK
<<
336 HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AEMPTY_SHIFT
) |
337 (HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AFULL_MASK
<<
338 HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AFULL_SHIFT
) |
339 (HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AEMPTY_MASK
<<
340 HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AEMPTY_SHIFT
) |
341 (HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AFULL_MASK
<<
342 HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AFULL_SHIFT
));
343 val
|= ((16 << HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AEMPTY_SHIFT
) |
344 (30 << HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AFULL_SHIFT
) |
345 (16 << HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AEMPTY_SHIFT
) |
346 (30 << HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AFULL_SHIFT
));
347 hi6210_write_reg(i2s
, HII2S_ST_DL_FIFO_TH_CFG
, val
);
350 val
= hi6210_read_reg(i2s
, HII2S_IF_CLK_EN_CFG
);
351 val
|= (BIT(19) | BIT(18) | BIT(17) |
352 HII2S_IF_CLK_EN_CFG__S2_IF_CLK_EN
|
353 HII2S_IF_CLK_EN_CFG__S2_OL_MIXER_EN
|
354 HII2S_IF_CLK_EN_CFG__S2_OL_SRC_EN
|
355 HII2S_IF_CLK_EN_CFG__ST_DL_R_EN
|
356 HII2S_IF_CLK_EN_CFG__ST_DL_L_EN
);
357 hi6210_write_reg(i2s
, HII2S_IF_CLK_EN_CFG
, val
);
360 val
= hi6210_read_reg(i2s
, HII2S_DIG_FILTER_CLK_EN_CFG
);
361 val
&= ~(HII2S_DIG_FILTER_CLK_EN_CFG__DACR_SDM_EN
|
362 HII2S_DIG_FILTER_CLK_EN_CFG__DACR_HBF2I_EN
|
363 HII2S_DIG_FILTER_CLK_EN_CFG__DACR_AGC_EN
|
364 HII2S_DIG_FILTER_CLK_EN_CFG__DACL_SDM_EN
|
365 HII2S_DIG_FILTER_CLK_EN_CFG__DACL_HBF2I_EN
|
366 HII2S_DIG_FILTER_CLK_EN_CFG__DACL_AGC_EN
);
367 val
|= (HII2S_DIG_FILTER_CLK_EN_CFG__DACR_MIXER_EN
|
368 HII2S_DIG_FILTER_CLK_EN_CFG__DACL_MIXER_EN
);
369 hi6210_write_reg(i2s
, HII2S_DIG_FILTER_CLK_EN_CFG
, val
);
372 val
= hi6210_read_reg(i2s
, HII2S_DIG_FILTER_MODULE_CFG
);
373 val
&= ~(HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_IN2_MUTE
|
374 HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_IN2_MUTE
);
375 hi6210_write_reg(i2s
, HII2S_DIG_FILTER_MODULE_CFG
, val
);
377 val
= hi6210_read_reg(i2s
, HII2S_MUX_TOP_MODULE_CFG
);
378 val
&= ~(HII2S_MUX_TOP_MODULE_CFG__S2_OL_MIXER_IN1_MUTE
|
379 HII2S_MUX_TOP_MODULE_CFG__S2_OL_MIXER_IN2_MUTE
|
380 HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_MIXER_IN1_MUTE
|
381 HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_MIXER_IN2_MUTE
);
382 hi6210_write_reg(i2s
, HII2S_MUX_TOP_MODULE_CFG
, val
);
385 switch (i2s
->format
& SND_SOC_DAIFMT_MASTER_MASK
) {
386 case SND_SOC_DAIFMT_CBM_CFM
:
388 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
389 val
|= HII2S_I2S_CFG__S2_MST_SLV
;
390 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
392 case SND_SOC_DAIFMT_CBS_CFS
:
394 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
395 val
&= ~HII2S_I2S_CFG__S2_MST_SLV
;
396 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
399 WARN_ONCE(1, "Invalid i2s->fmt MASTER_MASK. This shouldn't happen\n");
403 switch (i2s
->format
& SND_SOC_DAIFMT_FORMAT_MASK
) {
404 case SND_SOC_DAIFMT_I2S
:
405 fmt
= HII2S_FORMAT_I2S
;
407 case SND_SOC_DAIFMT_LEFT_J
:
408 fmt
= HII2S_FORMAT_LEFT_JUST
;
410 case SND_SOC_DAIFMT_RIGHT_J
:
411 fmt
= HII2S_FORMAT_RIGHT_JUST
;
414 WARN_ONCE(1, "Invalid i2s->fmt FORMAT_MASK. This shouldn't happen\n");
418 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
419 val
&= ~(HII2S_I2S_CFG__S2_FUNC_MODE_MASK
<<
420 HII2S_I2S_CFG__S2_FUNC_MODE_SHIFT
);
421 val
|= fmt
<< HII2S_I2S_CFG__S2_FUNC_MODE_SHIFT
;
422 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
425 val
= hi6210_read_reg(i2s
, HII2S_CLK_SEL
);
426 val
&= ~(HII2S_CLK_SEL__I2S_BT_FM_SEL
| /* BT gets the I2S */
427 HII2S_CLK_SEL__EXT_12_288MHZ_SEL
);
428 hi6210_write_reg(i2s
, HII2S_CLK_SEL
, val
);
430 dma_data
->maxburst
= 2;
432 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
433 dma_data
->addr
= i2s
->base_phys
+ HII2S_ST_DL_CHANNEL
;
435 dma_data
->addr
= i2s
->base_phys
+ HII2S_STEREO_UPLINK_CHANNEL
;
437 switch (i2s
->channels
) {
439 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
440 val
|= HII2S_I2S_CFG__S2_FRAME_MODE
;
441 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
444 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
445 val
&= ~HII2S_I2S_CFG__S2_FRAME_MODE
;
446 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
450 /* clear loopback, set signed type and word length */
451 val
= hi6210_read_reg(i2s
, HII2S_I2S_CFG
);
452 val
&= ~HII2S_I2S_CFG__S2_CODEC_DATA_FORMAT
;
453 val
&= ~(HII2S_I2S_CFG__S2_CODEC_IO_WORDLENGTH_MASK
<<
454 HII2S_I2S_CFG__S2_CODEC_IO_WORDLENGTH_SHIFT
);
455 val
&= ~(HII2S_I2S_CFG__S2_DIRECT_LOOP_MASK
<<
456 HII2S_I2S_CFG__S2_DIRECT_LOOP_SHIFT
);
458 val
|= (bits
<< HII2S_I2S_CFG__S2_CODEC_IO_WORDLENGTH_SHIFT
);
459 hi6210_write_reg(i2s
, HII2S_I2S_CFG
, val
);
465 /* set DAC and related units to correct rate */
466 val
= hi6210_read_reg(i2s
, HII2S_FS_CFG
);
467 val
&= ~(HII2S_FS_CFG__FS_S2_MASK
<< HII2S_FS_CFG__FS_S2_SHIFT
);
468 val
&= ~(HII2S_FS_CFG__FS_DACLR_MASK
<< HII2S_FS_CFG__FS_DACLR_SHIFT
);
469 val
&= ~(HII2S_FS_CFG__FS_ST_DL_R_MASK
<<
470 HII2S_FS_CFG__FS_ST_DL_R_SHIFT
);
471 val
&= ~(HII2S_FS_CFG__FS_ST_DL_L_MASK
<<
472 HII2S_FS_CFG__FS_ST_DL_L_SHIFT
);
473 val
|= (rate
<< HII2S_FS_CFG__FS_S2_SHIFT
);
474 val
|= (rate
<< HII2S_FS_CFG__FS_DACLR_SHIFT
);
475 val
|= (rate
<< HII2S_FS_CFG__FS_ST_DL_R_SHIFT
);
476 val
|= (rate
<< HII2S_FS_CFG__FS_ST_DL_L_SHIFT
);
477 hi6210_write_reg(i2s
, HII2S_FS_CFG
, val
);
482 static int hi6210_i2s_trigger(struct snd_pcm_substream
*substream
, int cmd
,
483 struct snd_soc_dai
*cpu_dai
)
485 pr_debug("%s\n", __func__
);
487 case SNDRV_PCM_TRIGGER_START
:
488 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
489 if (substream
->stream
== SNDRV_PCM_STREAM_CAPTURE
)
490 hi6210_i2s_rxctrl(cpu_dai
, 1);
492 hi6210_i2s_txctrl(cpu_dai
, 1);
494 case SNDRV_PCM_TRIGGER_STOP
:
495 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
496 if (substream
->stream
== SNDRV_PCM_STREAM_CAPTURE
)
497 hi6210_i2s_rxctrl(cpu_dai
, 0);
499 hi6210_i2s_txctrl(cpu_dai
, 0);
502 dev_err(cpu_dai
->dev
, "uknown cmd\n");
508 static int hi6210_i2s_dai_probe(struct snd_soc_dai
*dai
)
510 struct hi6210_i2s
*i2s
= snd_soc_dai_get_drvdata(dai
);
512 snd_soc_dai_init_dma_data(dai
,
513 &i2s
->dma_data
[SNDRV_PCM_STREAM_PLAYBACK
],
514 &i2s
->dma_data
[SNDRV_PCM_STREAM_CAPTURE
]);
520 static const struct snd_soc_dai_ops hi6210_i2s_dai_ops
= {
521 .trigger
= hi6210_i2s_trigger
,
522 .hw_params
= hi6210_i2s_hw_params
,
523 .set_fmt
= hi6210_i2s_set_fmt
,
524 .startup
= hi6210_i2s_startup
,
525 .shutdown
= hi6210_i2s_shutdown
,
528 static const struct snd_soc_dai_driver hi6210_i2s_dai_init
= {
529 .probe
= hi6210_i2s_dai_probe
,
533 .formats
= SNDRV_PCM_FMTBIT_S16_LE
|
534 SNDRV_PCM_FMTBIT_U16_LE
,
535 .rates
= SNDRV_PCM_RATE_48000
,
540 .formats
= SNDRV_PCM_FMTBIT_S16_LE
|
541 SNDRV_PCM_FMTBIT_U16_LE
,
542 .rates
= SNDRV_PCM_RATE_48000
,
544 .ops
= &hi6210_i2s_dai_ops
,
547 static const struct snd_soc_component_driver hi6210_i2s_i2s_comp
= {
548 .name
= "hi6210_i2s-i2s",
551 static int hi6210_i2s_probe(struct platform_device
*pdev
)
553 struct device_node
*node
= pdev
->dev
.of_node
;
554 struct device
*dev
= &pdev
->dev
;
555 struct hi6210_i2s
*i2s
;
556 struct resource
*res
;
559 i2s
= devm_kzalloc(&pdev
->dev
, sizeof(*i2s
), GFP_KERNEL
);
564 spin_lock_init(&i2s
->lock
);
566 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
567 i2s
->base
= devm_ioremap_resource(dev
, res
);
568 if (IS_ERR(i2s
->base
))
569 return PTR_ERR(i2s
->base
);
571 i2s
->base_phys
= (phys_addr_t
)res
->start
;
572 i2s
->dai
= hi6210_i2s_dai_init
;
574 dev_set_drvdata(&pdev
->dev
, i2s
);
576 i2s
->sysctrl
= syscon_regmap_lookup_by_phandle(node
,
577 "hisilicon,sysctrl-syscon");
578 if (IS_ERR(i2s
->sysctrl
))
579 return PTR_ERR(i2s
->sysctrl
);
581 i2s
->clk
[CLK_DACODEC
] = devm_clk_get(&pdev
->dev
, "dacodec");
582 if (IS_ERR_OR_NULL(i2s
->clk
[CLK_DACODEC
]))
583 return PTR_ERR(i2s
->clk
[CLK_DACODEC
]);
586 i2s
->clk
[CLK_I2S_BASE
] = devm_clk_get(&pdev
->dev
, "i2s-base");
587 if (IS_ERR_OR_NULL(i2s
->clk
[CLK_I2S_BASE
]))
588 return PTR_ERR(i2s
->clk
[CLK_I2S_BASE
]);
591 ret
= devm_snd_dmaengine_pcm_register(&pdev
->dev
, NULL
, 0);
595 ret
= devm_snd_soc_register_component(&pdev
->dev
, &hi6210_i2s_i2s_comp
,
600 static const struct of_device_id hi6210_i2s_dt_ids
[] = {
601 { .compatible
= "hisilicon,hi6210-i2s" },
605 MODULE_DEVICE_TABLE(of
, hi6210_i2s_dt_ids
);
607 static struct platform_driver hi6210_i2s_driver
= {
608 .probe
= hi6210_i2s_probe
,
610 .name
= "hi6210_i2s",
611 .of_match_table
= hi6210_i2s_dt_ids
,
615 module_platform_driver(hi6210_i2s_driver
);
617 MODULE_DESCRIPTION("Hisilicon HI6210 I2S driver");
618 MODULE_AUTHOR("Andy Green <andy.green@linaro.org>");
619 MODULE_LICENSE("GPL");