xref: /openbmc/linux/sound/soc/google/chv3-i2s.c (revision 702648721db590b3425c31ade294000e18808345)
1*70264872SPaweł Anikiel // SPDX-License-Identifier: GPL-2.0-only
2*70264872SPaweł Anikiel #include <linux/module.h>
3*70264872SPaweł Anikiel #include <linux/of.h>
4*70264872SPaweł Anikiel #include <linux/platform_device.h>
5*70264872SPaweł Anikiel 
6*70264872SPaweł Anikiel #include <sound/soc.h>
7*70264872SPaweł Anikiel 
8*70264872SPaweł Anikiel /*
9*70264872SPaweł Anikiel  * The I2S interface consists of two ring buffers - one for RX and one for
10*70264872SPaweł Anikiel  * TX.  A ring buffer has a producer index and a consumer index. Depending
11*70264872SPaweł Anikiel  * on which way the data is flowing, either the software or the hardware
12*70264872SPaweł Anikiel  * writes data and updates the producer index, and the other end reads data
13*70264872SPaweł Anikiel  * and updates the consumer index.
14*70264872SPaweł Anikiel  *
15*70264872SPaweł Anikiel  * The pointer managed by software is updated using the .ack callback
16*70264872SPaweł Anikiel  * (see chv3_dma_ack). This seems to be the only way to reliably obtain
17*70264872SPaweł Anikiel  * the appl_ptr from within the driver and pass it to hardware.
18*70264872SPaweł Anikiel  *
19*70264872SPaweł Anikiel  * Because of the two pointer design, the ring buffer can never be full. With
20*70264872SPaweł Anikiel  * capture this isn't a problem, because the hardware being the producer
21*70264872SPaweł Anikiel  * will wait for the consumer index to move out of the way.  With playback,
22*70264872SPaweł Anikiel  * however, this is problematic, because ALSA wants to fill up the buffer
23*70264872SPaweł Anikiel  * completely when waiting for hardware. In the .ack callback, the driver
24*70264872SPaweł Anikiel  * would have to wait for the consumer index to move out of the way by
25*70264872SPaweł Anikiel  * busy-waiting, which would keep stalling the kernel for quite a long time.
26*70264872SPaweł Anikiel  *
27*70264872SPaweł Anikiel  * The workaround to this problem is to "lie" to ALSA that the hw_pointer
28*70264872SPaweł Anikiel  * is one frame behind what it actually is (see chv3_dma_pointer). This
29*70264872SPaweł Anikiel  * way, ALSA will not try to fill up the entire buffer, and all callbacks
30*70264872SPaweł Anikiel  * are wait-free.
31*70264872SPaweł Anikiel  */
32*70264872SPaweł Anikiel 
33*70264872SPaweł Anikiel #define I2S_TX_ENABLE		0x00
34*70264872SPaweł Anikiel #define I2S_TX_BASE_ADDR	0x04
35*70264872SPaweł Anikiel #define I2S_TX_BUFFER_SIZE	0x08
36*70264872SPaweł Anikiel #define I2S_TX_PRODUCER_IDX	0x0c
37*70264872SPaweł Anikiel #define I2S_TX_CONSUMER_IDX	0x10
38*70264872SPaweł Anikiel #define I2S_RX_ENABLE		0x14
39*70264872SPaweł Anikiel #define I2S_RX_BASE_ADDR	0x18
40*70264872SPaweł Anikiel #define I2S_RX_BUFFER_SIZE	0x1c
41*70264872SPaweł Anikiel #define I2S_RX_PRODUCER_IDX	0x20
42*70264872SPaweł Anikiel #define I2S_RX_CONSUMER_IDX	0x24
43*70264872SPaweł Anikiel 
44*70264872SPaweł Anikiel #define I2S_SOFT_RESET		0x2c
45*70264872SPaweł Anikiel #define I2S_SOFT_RESET_RX_BIT	0x1
46*70264872SPaweł Anikiel #define I2S_SOFT_RESET_TX_BIT	0x2
47*70264872SPaweł Anikiel 
48*70264872SPaweł Anikiel #define I2S_RX_IRQ		0x4c
49*70264872SPaweł Anikiel #define I2S_RX_IRQ_CONST	0x50
50*70264872SPaweł Anikiel #define I2S_TX_IRQ		0x54
51*70264872SPaweł Anikiel #define I2S_TX_IRQ_CONST	0x58
52*70264872SPaweł Anikiel 
53*70264872SPaweł Anikiel #define I2S_IRQ_MASK	0x8
54*70264872SPaweł Anikiel #define I2S_IRQ_CLR	0xc
55*70264872SPaweł Anikiel #define I2S_IRQ_RX_BIT	0x1
56*70264872SPaweł Anikiel #define I2S_IRQ_TX_BIT	0x2
57*70264872SPaweł Anikiel 
58*70264872SPaweł Anikiel #define I2S_MAX_BUFFER_SIZE	0x200000
59*70264872SPaweł Anikiel 
60*70264872SPaweł Anikiel struct chv3_i2s_dev {
61*70264872SPaweł Anikiel 	struct device *dev;
62*70264872SPaweł Anikiel 	void __iomem *iobase;
63*70264872SPaweł Anikiel 	void __iomem *iobase_irq;
64*70264872SPaweł Anikiel 	struct snd_pcm_substream *rx_substream;
65*70264872SPaweł Anikiel 	struct snd_pcm_substream *tx_substream;
66*70264872SPaweł Anikiel 	int tx_bytes_to_fetch;
67*70264872SPaweł Anikiel };
68*70264872SPaweł Anikiel 
69*70264872SPaweł Anikiel static struct snd_soc_dai_driver chv3_i2s_dai = {
70*70264872SPaweł Anikiel 	.name = "chv3-i2s",
71*70264872SPaweł Anikiel 	.capture = {
72*70264872SPaweł Anikiel 		.channels_min = 1,
73*70264872SPaweł Anikiel 		.channels_max = 128,
74*70264872SPaweł Anikiel 		.rates = SNDRV_PCM_RATE_CONTINUOUS,
75*70264872SPaweł Anikiel 		.rate_min = 8000,
76*70264872SPaweł Anikiel 		.rate_max = 96000,
77*70264872SPaweł Anikiel 		.formats = SNDRV_PCM_FMTBIT_S32_LE,
78*70264872SPaweł Anikiel 	},
79*70264872SPaweł Anikiel 	.playback = {
80*70264872SPaweł Anikiel 		.channels_min = 1,
81*70264872SPaweł Anikiel 		.channels_max = 128,
82*70264872SPaweł Anikiel 		.rates = SNDRV_PCM_RATE_CONTINUOUS,
83*70264872SPaweł Anikiel 		.rate_min = 8000,
84*70264872SPaweł Anikiel 		.rate_max = 96000,
85*70264872SPaweł Anikiel 		.formats = SNDRV_PCM_FMTBIT_S32_LE,
86*70264872SPaweł Anikiel 	},
87*70264872SPaweł Anikiel };
88*70264872SPaweł Anikiel 
89*70264872SPaweł Anikiel static const struct snd_pcm_hardware chv3_dma_hw = {
90*70264872SPaweł Anikiel 	.info = SNDRV_PCM_INFO_INTERLEAVED |
91*70264872SPaweł Anikiel 		SNDRV_PCM_INFO_MMAP |
92*70264872SPaweł Anikiel 		SNDRV_PCM_INFO_MMAP_VALID |
93*70264872SPaweł Anikiel 		SNDRV_PCM_INFO_BLOCK_TRANSFER,
94*70264872SPaweł Anikiel 	.buffer_bytes_max = I2S_MAX_BUFFER_SIZE,
95*70264872SPaweł Anikiel 	.period_bytes_min = 64,
96*70264872SPaweł Anikiel 	.period_bytes_max = 8192,
97*70264872SPaweł Anikiel 	.periods_min = 4,
98*70264872SPaweł Anikiel 	.periods_max = 256,
99*70264872SPaweł Anikiel };
100*70264872SPaweł Anikiel 
101*70264872SPaweł Anikiel static inline void chv3_i2s_wr(struct chv3_i2s_dev *i2s, int offset, u32 val)
102*70264872SPaweł Anikiel {
103*70264872SPaweł Anikiel 	writel(val, i2s->iobase + offset);
104*70264872SPaweł Anikiel }
105*70264872SPaweł Anikiel 
106*70264872SPaweł Anikiel static inline u32 chv3_i2s_rd(struct chv3_i2s_dev *i2s, int offset)
107*70264872SPaweł Anikiel {
108*70264872SPaweł Anikiel 	return readl(i2s->iobase + offset);
109*70264872SPaweł Anikiel }
110*70264872SPaweł Anikiel 
111*70264872SPaweł Anikiel static irqreturn_t chv3_i2s_isr(int irq, void *data)
112*70264872SPaweł Anikiel {
113*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = data;
114*70264872SPaweł Anikiel 	u32 reg;
115*70264872SPaweł Anikiel 
116*70264872SPaweł Anikiel 	reg = readl(i2s->iobase_irq + I2S_IRQ_CLR);
117*70264872SPaweł Anikiel 	if (!reg)
118*70264872SPaweł Anikiel 		return IRQ_NONE;
119*70264872SPaweł Anikiel 
120*70264872SPaweł Anikiel 	if (reg & I2S_IRQ_RX_BIT)
121*70264872SPaweł Anikiel 		snd_pcm_period_elapsed(i2s->rx_substream);
122*70264872SPaweł Anikiel 
123*70264872SPaweł Anikiel 	if (reg & I2S_IRQ_TX_BIT)
124*70264872SPaweł Anikiel 		snd_pcm_period_elapsed(i2s->tx_substream);
125*70264872SPaweł Anikiel 
126*70264872SPaweł Anikiel 	writel(reg, i2s->iobase_irq + I2S_IRQ_CLR);
127*70264872SPaweł Anikiel 
128*70264872SPaweł Anikiel 	return IRQ_HANDLED;
129*70264872SPaweł Anikiel }
130*70264872SPaweł Anikiel 
131*70264872SPaweł Anikiel static int chv3_dma_open(struct snd_soc_component *component,
132*70264872SPaweł Anikiel 			 struct snd_pcm_substream *substream)
133*70264872SPaweł Anikiel {
134*70264872SPaweł Anikiel 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
135*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
136*70264872SPaweł Anikiel 	int res;
137*70264872SPaweł Anikiel 
138*70264872SPaweł Anikiel 	snd_soc_set_runtime_hwparams(substream, &chv3_dma_hw);
139*70264872SPaweł Anikiel 
140*70264872SPaweł Anikiel 	res = snd_pcm_hw_constraint_pow2(substream->runtime, 0,
141*70264872SPaweł Anikiel 			SNDRV_PCM_HW_PARAM_BUFFER_BYTES);
142*70264872SPaweł Anikiel 	if (res)
143*70264872SPaweł Anikiel 		return res;
144*70264872SPaweł Anikiel 
145*70264872SPaweł Anikiel 	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
146*70264872SPaweł Anikiel 		i2s->rx_substream = substream;
147*70264872SPaweł Anikiel 	else
148*70264872SPaweł Anikiel 		i2s->tx_substream = substream;
149*70264872SPaweł Anikiel 
150*70264872SPaweł Anikiel 	return 0;
151*70264872SPaweł Anikiel }
152*70264872SPaweł Anikiel static int chv3_dma_close(struct snd_soc_component *component,
153*70264872SPaweł Anikiel 			  struct snd_pcm_substream *substream)
154*70264872SPaweł Anikiel {
155*70264872SPaweł Anikiel 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
156*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
157*70264872SPaweł Anikiel 
158*70264872SPaweł Anikiel 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
159*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_RX_ENABLE, 0);
160*70264872SPaweł Anikiel 	else
161*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_TX_ENABLE, 0);
162*70264872SPaweł Anikiel 
163*70264872SPaweł Anikiel 	return 0;
164*70264872SPaweł Anikiel }
165*70264872SPaweł Anikiel 
166*70264872SPaweł Anikiel static int chv3_dma_pcm_construct(struct snd_soc_component *component,
167*70264872SPaweł Anikiel 				  struct snd_soc_pcm_runtime *rtd)
168*70264872SPaweł Anikiel {
169*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
170*70264872SPaweł Anikiel 	struct snd_pcm_substream *substream;
171*70264872SPaweł Anikiel 	int res;
172*70264872SPaweł Anikiel 
173*70264872SPaweł Anikiel 	substream = rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
174*70264872SPaweł Anikiel 	if (substream) {
175*70264872SPaweł Anikiel 		res = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, i2s->dev,
176*70264872SPaweł Anikiel 				I2S_MAX_BUFFER_SIZE, &substream->dma_buffer);
177*70264872SPaweł Anikiel 		if (res)
178*70264872SPaweł Anikiel 			return res;
179*70264872SPaweł Anikiel 	}
180*70264872SPaweł Anikiel 
181*70264872SPaweł Anikiel 	substream = rtd->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
182*70264872SPaweł Anikiel 	if (substream) {
183*70264872SPaweł Anikiel 		res = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, i2s->dev,
184*70264872SPaweł Anikiel 				I2S_MAX_BUFFER_SIZE, &substream->dma_buffer);
185*70264872SPaweł Anikiel 		if (res)
186*70264872SPaweł Anikiel 			return res;
187*70264872SPaweł Anikiel 	}
188*70264872SPaweł Anikiel 
189*70264872SPaweł Anikiel 	return 0;
190*70264872SPaweł Anikiel }
191*70264872SPaweł Anikiel 
192*70264872SPaweł Anikiel static int chv3_dma_hw_params(struct snd_soc_component *component,
193*70264872SPaweł Anikiel 			      struct snd_pcm_substream *substream,
194*70264872SPaweł Anikiel 			      struct snd_pcm_hw_params *params)
195*70264872SPaweł Anikiel {
196*70264872SPaweł Anikiel 	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
197*70264872SPaweł Anikiel 	return 0;
198*70264872SPaweł Anikiel }
199*70264872SPaweł Anikiel 
200*70264872SPaweł Anikiel static int chv3_dma_prepare(struct snd_soc_component *component,
201*70264872SPaweł Anikiel 			    struct snd_pcm_substream *substream)
202*70264872SPaweł Anikiel {
203*70264872SPaweł Anikiel 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
204*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
205*70264872SPaweł Anikiel 	unsigned int buffer_bytes, period_bytes, period_size;
206*70264872SPaweł Anikiel 
207*70264872SPaweł Anikiel 	buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
208*70264872SPaweł Anikiel 	period_bytes = snd_pcm_lib_period_bytes(substream);
209*70264872SPaweł Anikiel 	period_size = substream->runtime->period_size;
210*70264872SPaweł Anikiel 
211*70264872SPaweł Anikiel 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
212*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_SOFT_RESET, I2S_SOFT_RESET_RX_BIT);
213*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_RX_BASE_ADDR, substream->dma_buffer.addr);
214*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_RX_BUFFER_SIZE, buffer_bytes);
215*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_RX_IRQ, (period_size << 8) | 1);
216*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_RX_ENABLE, 1);
217*70264872SPaweł Anikiel 	} else {
218*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_SOFT_RESET, I2S_SOFT_RESET_TX_BIT);
219*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_TX_BASE_ADDR, substream->dma_buffer.addr);
220*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_TX_BUFFER_SIZE, buffer_bytes);
221*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_TX_IRQ, ((period_bytes / i2s->tx_bytes_to_fetch) << 8) | 1);
222*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_TX_ENABLE, 1);
223*70264872SPaweł Anikiel 	}
224*70264872SPaweł Anikiel 	writel(I2S_IRQ_RX_BIT | I2S_IRQ_TX_BIT, i2s->iobase_irq + I2S_IRQ_MASK);
225*70264872SPaweł Anikiel 
226*70264872SPaweł Anikiel 	return 0;
227*70264872SPaweł Anikiel }
228*70264872SPaweł Anikiel 
229*70264872SPaweł Anikiel static snd_pcm_uframes_t chv3_dma_pointer(struct snd_soc_component *component,
230*70264872SPaweł Anikiel 					  struct snd_pcm_substream *substream)
231*70264872SPaweł Anikiel {
232*70264872SPaweł Anikiel 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
233*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
234*70264872SPaweł Anikiel 	u32 frame_bytes, buffer_bytes;
235*70264872SPaweł Anikiel 	u32 idx_bytes;
236*70264872SPaweł Anikiel 
237*70264872SPaweł Anikiel 	frame_bytes = substream->runtime->frame_bits * 8;
238*70264872SPaweł Anikiel 	buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
239*70264872SPaweł Anikiel 
240*70264872SPaweł Anikiel 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
241*70264872SPaweł Anikiel 		idx_bytes = chv3_i2s_rd(i2s, I2S_RX_PRODUCER_IDX);
242*70264872SPaweł Anikiel 	} else {
243*70264872SPaweł Anikiel 		idx_bytes = chv3_i2s_rd(i2s, I2S_TX_CONSUMER_IDX);
244*70264872SPaweł Anikiel 		/* lag the pointer by one frame */
245*70264872SPaweł Anikiel 		idx_bytes = (idx_bytes - frame_bytes) & (buffer_bytes - 1);
246*70264872SPaweł Anikiel 	}
247*70264872SPaweł Anikiel 
248*70264872SPaweł Anikiel 	return bytes_to_frames(substream->runtime, idx_bytes);
249*70264872SPaweł Anikiel }
250*70264872SPaweł Anikiel 
251*70264872SPaweł Anikiel static int chv3_dma_ack(struct snd_soc_component *component,
252*70264872SPaweł Anikiel 			struct snd_pcm_substream *substream)
253*70264872SPaweł Anikiel {
254*70264872SPaweł Anikiel 	struct snd_pcm_runtime *runtime = substream->runtime;
255*70264872SPaweł Anikiel 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
256*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
257*70264872SPaweł Anikiel 	unsigned int bytes, idx;
258*70264872SPaweł Anikiel 
259*70264872SPaweł Anikiel 	bytes = frames_to_bytes(runtime, runtime->control->appl_ptr);
260*70264872SPaweł Anikiel 	idx = bytes & (snd_pcm_lib_buffer_bytes(substream) - 1);
261*70264872SPaweł Anikiel 
262*70264872SPaweł Anikiel 	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
263*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_RX_CONSUMER_IDX, idx);
264*70264872SPaweł Anikiel 	else
265*70264872SPaweł Anikiel 		chv3_i2s_wr(i2s, I2S_TX_PRODUCER_IDX, idx);
266*70264872SPaweł Anikiel 
267*70264872SPaweł Anikiel 	return 0;
268*70264872SPaweł Anikiel }
269*70264872SPaweł Anikiel 
270*70264872SPaweł Anikiel static const struct snd_soc_component_driver chv3_i2s_comp = {
271*70264872SPaweł Anikiel 	.name = "chv3-i2s-comp",
272*70264872SPaweł Anikiel 	.open = chv3_dma_open,
273*70264872SPaweł Anikiel 	.close = chv3_dma_close,
274*70264872SPaweł Anikiel 	.pcm_construct = chv3_dma_pcm_construct,
275*70264872SPaweł Anikiel 	.hw_params = chv3_dma_hw_params,
276*70264872SPaweł Anikiel 	.prepare = chv3_dma_prepare,
277*70264872SPaweł Anikiel 	.pointer = chv3_dma_pointer,
278*70264872SPaweł Anikiel 	.ack = chv3_dma_ack,
279*70264872SPaweł Anikiel };
280*70264872SPaweł Anikiel 
281*70264872SPaweł Anikiel static int chv3_i2s_probe(struct platform_device *pdev)
282*70264872SPaweł Anikiel {
283*70264872SPaweł Anikiel 	struct chv3_i2s_dev *i2s;
284*70264872SPaweł Anikiel 	int res;
285*70264872SPaweł Anikiel 	int irq;
286*70264872SPaweł Anikiel 
287*70264872SPaweł Anikiel 	i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
288*70264872SPaweł Anikiel 	if (!i2s)
289*70264872SPaweł Anikiel 		return -ENOMEM;
290*70264872SPaweł Anikiel 
291*70264872SPaweł Anikiel 	i2s->iobase = devm_platform_ioremap_resource(pdev, 0);
292*70264872SPaweł Anikiel 	if (IS_ERR(i2s->iobase))
293*70264872SPaweł Anikiel 		return PTR_ERR(i2s->iobase);
294*70264872SPaweł Anikiel 
295*70264872SPaweł Anikiel 	i2s->iobase_irq = devm_platform_ioremap_resource(pdev, 1);
296*70264872SPaweł Anikiel 	if (IS_ERR(i2s->iobase_irq))
297*70264872SPaweł Anikiel 		return PTR_ERR(i2s->iobase_irq);
298*70264872SPaweł Anikiel 
299*70264872SPaweł Anikiel 	i2s->tx_bytes_to_fetch = (chv3_i2s_rd(i2s, I2S_TX_IRQ_CONST) >> 8) & 0xffff;
300*70264872SPaweł Anikiel 
301*70264872SPaweł Anikiel 	i2s->dev = &pdev->dev;
302*70264872SPaweł Anikiel 	dev_set_drvdata(&pdev->dev, i2s);
303*70264872SPaweł Anikiel 
304*70264872SPaweł Anikiel 	irq = platform_get_irq(pdev, 0);
305*70264872SPaweł Anikiel 	if (irq < 0)
306*70264872SPaweł Anikiel 		return -ENXIO;
307*70264872SPaweł Anikiel 	res = devm_request_irq(i2s->dev, irq, chv3_i2s_isr, 0, "chv3-i2s", i2s);
308*70264872SPaweł Anikiel 	if (res)
309*70264872SPaweł Anikiel 		return res;
310*70264872SPaweł Anikiel 
311*70264872SPaweł Anikiel 	res = devm_snd_soc_register_component(&pdev->dev, &chv3_i2s_comp,
312*70264872SPaweł Anikiel 					      &chv3_i2s_dai, 1);
313*70264872SPaweł Anikiel 	if (res) {
314*70264872SPaweł Anikiel 		dev_err(&pdev->dev, "couldn't register component: %d\n", res);
315*70264872SPaweł Anikiel 		return res;
316*70264872SPaweł Anikiel 	}
317*70264872SPaweł Anikiel 
318*70264872SPaweł Anikiel 	return 0;
319*70264872SPaweł Anikiel }
320*70264872SPaweł Anikiel 
321*70264872SPaweł Anikiel static const struct of_device_id chv3_i2s_of_match[] = {
322*70264872SPaweł Anikiel 	{ .compatible = "google,chv3-i2s" },
323*70264872SPaweł Anikiel 	{},
324*70264872SPaweł Anikiel };
325*70264872SPaweł Anikiel 
326*70264872SPaweł Anikiel static struct platform_driver chv3_i2s_driver = {
327*70264872SPaweł Anikiel 	.probe = chv3_i2s_probe,
328*70264872SPaweł Anikiel 	.driver = {
329*70264872SPaweł Anikiel 		.name = "chv3-i2s",
330*70264872SPaweł Anikiel 		.of_match_table = chv3_i2s_of_match,
331*70264872SPaweł Anikiel 	},
332*70264872SPaweł Anikiel };
333*70264872SPaweł Anikiel 
334*70264872SPaweł Anikiel module_platform_driver(chv3_i2s_driver);
335*70264872SPaweł Anikiel 
336*70264872SPaweł Anikiel MODULE_AUTHOR("Pawel Anikiel <pan@semihalf.com>");
337*70264872SPaweł Anikiel MODULE_DESCRIPTION("Chameleon v3 I2S interface");
338*70264872SPaweł Anikiel MODULE_LICENSE("GPL");
339