1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
5 * lpass-platform.c -- ALSA SoC platform driver for QTi LPASS
8 #include <linux/dma-mapping.h>
9 #include <linux/export.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <sound/pcm_params.h>
14 #include <linux/regmap.h>
15 #include <sound/soc.h>
16 #include "lpass-lpaif-reg.h"
19 #define DRV_NAME "lpass-platform"
21 #define LPASS_PLATFORM_BUFFER_SIZE (24 * 2 * 1024)
22 #define LPASS_PLATFORM_PERIODS 2
23 #define LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE (8 * 1024)
24 #define LPASS_VA_CDC_DMA_LPM_BUFF_SIZE (12 * 1024)
25 #define LPASS_CDC_DMA_REGISTER_FIELDS_MAX 15
27 static const struct snd_pcm_hardware lpass_platform_pcm_hardware = {
28 .info = SNDRV_PCM_INFO_MMAP |
29 SNDRV_PCM_INFO_MMAP_VALID |
30 SNDRV_PCM_INFO_INTERLEAVED |
31 SNDRV_PCM_INFO_PAUSE |
32 SNDRV_PCM_INFO_RESUME,
33 .formats = SNDRV_PCM_FMTBIT_S16 |
34 SNDRV_PCM_FMTBIT_S24 |
36 .rates = SNDRV_PCM_RATE_8000_192000,
41 .buffer_bytes_max = LPASS_PLATFORM_BUFFER_SIZE,
42 .period_bytes_max = LPASS_PLATFORM_BUFFER_SIZE /
43 LPASS_PLATFORM_PERIODS,
44 .period_bytes_min = LPASS_PLATFORM_BUFFER_SIZE /
45 LPASS_PLATFORM_PERIODS,
46 .periods_min = LPASS_PLATFORM_PERIODS,
47 .periods_max = LPASS_PLATFORM_PERIODS,
51 static const struct snd_pcm_hardware lpass_platform_rxtx_hardware = {
52 .info = SNDRV_PCM_INFO_MMAP |
53 SNDRV_PCM_INFO_MMAP_VALID |
54 SNDRV_PCM_INFO_INTERLEAVED |
55 SNDRV_PCM_INFO_PAUSE |
56 SNDRV_PCM_INFO_RESUME,
57 .formats = SNDRV_PCM_FMTBIT_S16 |
58 SNDRV_PCM_FMTBIT_S24 |
60 .rates = SNDRV_PCM_RATE_8000_192000,
65 .buffer_bytes_max = LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE,
66 .period_bytes_max = LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE /
67 LPASS_PLATFORM_PERIODS,
68 .period_bytes_min = LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE /
69 LPASS_PLATFORM_PERIODS,
70 .periods_min = LPASS_PLATFORM_PERIODS,
71 .periods_max = LPASS_PLATFORM_PERIODS,
75 static const struct snd_pcm_hardware lpass_platform_va_hardware = {
76 .info = SNDRV_PCM_INFO_MMAP |
77 SNDRV_PCM_INFO_MMAP_VALID |
78 SNDRV_PCM_INFO_INTERLEAVED |
79 SNDRV_PCM_INFO_PAUSE |
80 SNDRV_PCM_INFO_RESUME,
81 .formats = SNDRV_PCM_FMTBIT_S16 |
82 SNDRV_PCM_FMTBIT_S24 |
84 .rates = SNDRV_PCM_RATE_8000_192000,
89 .buffer_bytes_max = LPASS_VA_CDC_DMA_LPM_BUFF_SIZE,
90 .period_bytes_max = LPASS_VA_CDC_DMA_LPM_BUFF_SIZE /
91 LPASS_PLATFORM_PERIODS,
92 .period_bytes_min = LPASS_VA_CDC_DMA_LPM_BUFF_SIZE /
93 LPASS_PLATFORM_PERIODS,
94 .periods_min = LPASS_PLATFORM_PERIODS,
95 .periods_max = LPASS_PLATFORM_PERIODS,
99 static int lpass_platform_alloc_rxtx_dmactl_fields(struct device *dev,
102 struct lpass_data *drvdata = dev_get_drvdata(dev);
103 struct lpass_variant *v = drvdata->variant;
104 struct lpaif_dmactl *rd_dmactl, *wr_dmactl;
107 rd_dmactl = devm_kzalloc(dev, sizeof(*rd_dmactl), GFP_KERNEL);
111 wr_dmactl = devm_kzalloc(dev, sizeof(*wr_dmactl), GFP_KERNEL);
115 drvdata->rxtx_rd_dmactl = rd_dmactl;
116 drvdata->rxtx_wr_dmactl = wr_dmactl;
118 rval = devm_regmap_field_bulk_alloc(dev, map, &rd_dmactl->intf,
119 &v->rxtx_rdma_intf, LPASS_CDC_DMA_REGISTER_FIELDS_MAX);
123 return devm_regmap_field_bulk_alloc(dev, map, &wr_dmactl->intf,
124 &v->rxtx_wrdma_intf, LPASS_CDC_DMA_REGISTER_FIELDS_MAX);
127 static int lpass_platform_alloc_va_dmactl_fields(struct device *dev,
130 struct lpass_data *drvdata = dev_get_drvdata(dev);
131 struct lpass_variant *v = drvdata->variant;
132 struct lpaif_dmactl *wr_dmactl;
134 wr_dmactl = devm_kzalloc(dev, sizeof(*wr_dmactl), GFP_KERNEL);
138 drvdata->va_wr_dmactl = wr_dmactl;
139 return devm_regmap_field_bulk_alloc(dev, map, &wr_dmactl->intf,
140 &v->va_wrdma_intf, LPASS_CDC_DMA_REGISTER_FIELDS_MAX);
144 static int lpass_platform_alloc_dmactl_fields(struct device *dev,
147 struct lpass_data *drvdata = dev_get_drvdata(dev);
148 struct lpass_variant *v = drvdata->variant;
149 struct lpaif_dmactl *rd_dmactl, *wr_dmactl;
152 drvdata->rd_dmactl = devm_kzalloc(dev, sizeof(struct lpaif_dmactl),
154 if (drvdata->rd_dmactl == NULL)
157 drvdata->wr_dmactl = devm_kzalloc(dev, sizeof(struct lpaif_dmactl),
159 if (drvdata->wr_dmactl == NULL)
162 rd_dmactl = drvdata->rd_dmactl;
163 wr_dmactl = drvdata->wr_dmactl;
165 rval = devm_regmap_field_bulk_alloc(dev, map, &rd_dmactl->intf,
170 return devm_regmap_field_bulk_alloc(dev, map, &wr_dmactl->intf,
174 static int lpass_platform_alloc_hdmidmactl_fields(struct device *dev,
177 struct lpass_data *drvdata = dev_get_drvdata(dev);
178 struct lpass_variant *v = drvdata->variant;
179 struct lpaif_dmactl *rd_dmactl;
181 rd_dmactl = devm_kzalloc(dev, sizeof(struct lpaif_dmactl), GFP_KERNEL);
182 if (rd_dmactl == NULL)
185 drvdata->hdmi_rd_dmactl = rd_dmactl;
187 return devm_regmap_field_bulk_alloc(dev, map, &rd_dmactl->bursten,
188 &v->hdmi_rdma_bursten, 8);
191 static int lpass_platform_pcmops_open(struct snd_soc_component *component,
192 struct snd_pcm_substream *substream)
194 struct snd_pcm_runtime *runtime = substream->runtime;
195 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
196 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
197 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
198 struct lpass_variant *v = drvdata->variant;
199 int ret, dma_ch, dir = substream->stream;
200 struct lpass_pcm_data *data;
202 unsigned int dai_id = cpu_dai->driver->id;
204 component->id = dai_id;
205 data = kzalloc(sizeof(*data), GFP_KERNEL);
209 data->i2s_port = cpu_dai->driver->id;
210 runtime->private_data = data;
212 if (v->alloc_dma_channel)
213 dma_ch = v->alloc_dma_channel(drvdata, dir, dai_id);
223 case MI2S_PRIMARY ... MI2S_QUINARY:
224 map = drvdata->lpaif_map;
225 drvdata->substream[dma_ch] = substream;
228 map = drvdata->hdmiif_map;
229 drvdata->hdmi_substream[dma_ch] = substream;
231 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
232 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
233 map = drvdata->rxtx_lpaif_map;
234 drvdata->rxtx_substream[dma_ch] = substream;
236 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
237 map = drvdata->va_lpaif_map;
238 drvdata->va_substream[dma_ch] = substream;
244 data->dma_ch = dma_ch;
246 case MI2S_PRIMARY ... MI2S_QUINARY:
248 ret = regmap_write(map, LPAIF_DMACTL_REG(v, dma_ch, dir, data->i2s_port), 0);
251 dev_err(soc_runtime->dev, "error writing to rdmactl reg: %d\n", ret);
254 snd_soc_set_runtime_hwparams(substream, &lpass_platform_pcm_hardware);
255 runtime->dma_bytes = lpass_platform_pcm_hardware.buffer_bytes_max;
257 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
258 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
259 snd_soc_set_runtime_hwparams(substream, &lpass_platform_rxtx_hardware);
260 runtime->dma_bytes = lpass_platform_rxtx_hardware.buffer_bytes_max;
261 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
263 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
264 snd_soc_set_runtime_hwparams(substream, &lpass_platform_va_hardware);
265 runtime->dma_bytes = lpass_platform_va_hardware.buffer_bytes_max;
266 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
271 ret = snd_pcm_hw_constraint_integer(runtime,
272 SNDRV_PCM_HW_PARAM_PERIODS);
275 dev_err(soc_runtime->dev, "setting constraints failed: %d\n",
283 static int lpass_platform_pcmops_close(struct snd_soc_component *component,
284 struct snd_pcm_substream *substream)
286 struct snd_pcm_runtime *runtime = substream->runtime;
287 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
288 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
289 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
290 struct lpass_variant *v = drvdata->variant;
291 struct lpass_pcm_data *data;
292 unsigned int dai_id = cpu_dai->driver->id;
294 data = runtime->private_data;
297 case MI2S_PRIMARY ... MI2S_QUINARY:
298 drvdata->substream[data->dma_ch] = NULL;
301 drvdata->hdmi_substream[data->dma_ch] = NULL;
303 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
304 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
305 drvdata->rxtx_substream[data->dma_ch] = NULL;
307 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
308 drvdata->va_substream[data->dma_ch] = NULL;
314 if (v->free_dma_channel)
315 v->free_dma_channel(drvdata, data->dma_ch, dai_id);
321 static struct lpaif_dmactl *__lpass_get_dmactl_handle(const struct snd_pcm_substream *substream,
322 struct snd_soc_component *component)
324 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
325 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
326 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
327 struct lpaif_dmactl *dmactl = NULL;
329 switch (cpu_dai->driver->id) {
330 case MI2S_PRIMARY ... MI2S_QUINARY:
331 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
332 dmactl = drvdata->rd_dmactl;
334 dmactl = drvdata->wr_dmactl;
337 dmactl = drvdata->hdmi_rd_dmactl;
339 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
340 dmactl = drvdata->rxtx_rd_dmactl;
342 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
343 dmactl = drvdata->rxtx_wr_dmactl;
345 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
346 dmactl = drvdata->va_wr_dmactl;
353 static int __lpass_get_id(const struct snd_pcm_substream *substream,
354 struct snd_soc_component *component)
356 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
357 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
358 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
359 struct snd_pcm_runtime *rt = substream->runtime;
360 struct lpass_pcm_data *pcm_data = rt->private_data;
361 struct lpass_variant *v = drvdata->variant;
364 switch (cpu_dai->driver->id) {
365 case MI2S_PRIMARY ... MI2S_QUINARY:
366 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
367 id = pcm_data->dma_ch;
369 id = pcm_data->dma_ch - v->wrdma_channel_start;
372 id = pcm_data->dma_ch;
374 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
375 id = pcm_data->dma_ch;
377 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
378 id = pcm_data->dma_ch - v->rxtx_wrdma_channel_start;
380 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
381 id = pcm_data->dma_ch - v->va_wrdma_channel_start;
388 static struct regmap *__lpass_get_regmap_handle(const struct snd_pcm_substream *substream,
389 struct snd_soc_component *component)
391 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
392 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
393 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
394 struct regmap *map = NULL;
396 switch (cpu_dai->driver->id) {
397 case MI2S_PRIMARY ... MI2S_QUINARY:
398 map = drvdata->lpaif_map;
401 map = drvdata->hdmiif_map;
403 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
404 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
405 map = drvdata->rxtx_lpaif_map;
407 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
408 map = drvdata->va_lpaif_map;
415 static int lpass_platform_pcmops_hw_params(struct snd_soc_component *component,
416 struct snd_pcm_substream *substream,
417 struct snd_pcm_hw_params *params)
419 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
420 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
421 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
422 struct snd_pcm_runtime *rt = substream->runtime;
423 struct lpass_pcm_data *pcm_data = rt->private_data;
424 struct lpass_variant *v = drvdata->variant;
425 snd_pcm_format_t format = params_format(params);
426 unsigned int channels = params_channels(params);
428 struct lpaif_dmactl *dmactl;
431 int ret, dma_port = pcm_data->i2s_port + v->dmactl_audif_start;
432 unsigned int dai_id = cpu_dai->driver->id;
434 dmactl = __lpass_get_dmactl_handle(substream, component);
435 id = __lpass_get_id(substream, component);
437 bitwidth = snd_pcm_format_width(format);
439 dev_err(soc_runtime->dev, "invalid bit width given: %d\n",
444 ret = regmap_fields_write(dmactl->bursten, id, LPAIF_DMACTL_BURSTEN_INCR4);
446 dev_err(soc_runtime->dev, "error updating bursten field: %d\n", ret);
450 ret = regmap_fields_write(dmactl->fifowm, id, LPAIF_DMACTL_FIFOWM_8);
452 dev_err(soc_runtime->dev, "error updating fifowm field: %d\n", ret);
458 ret = regmap_fields_write(dmactl->burst8, id,
459 LPAIF_DMACTL_BURSTEN_INCR4);
461 dev_err(soc_runtime->dev, "error updating burst8en field: %d\n", ret);
464 ret = regmap_fields_write(dmactl->burst16, id,
465 LPAIF_DMACTL_BURSTEN_INCR4);
467 dev_err(soc_runtime->dev, "error updating burst16en field: %d\n", ret);
470 ret = regmap_fields_write(dmactl->dynburst, id,
471 LPAIF_DMACTL_BURSTEN_INCR4);
473 dev_err(soc_runtime->dev, "error updating dynbursten field: %d\n", ret);
480 case MI2S_QUATERNARY:
482 ret = regmap_fields_write(dmactl->intf, id,
483 LPAIF_DMACTL_AUDINTF(dma_port));
485 dev_err(soc_runtime->dev, "error updating audio interface field: %d\n",
491 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
492 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
493 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX0:
496 dev_err(soc_runtime->dev, "%s: invalid interface: %d\n", __func__, dai_id);
504 regval = LPAIF_DMACTL_WPSCNT_ONE;
507 regval = LPAIF_DMACTL_WPSCNT_TWO;
510 regval = LPAIF_DMACTL_WPSCNT_THREE;
513 regval = LPAIF_DMACTL_WPSCNT_FOUR;
516 dev_err(soc_runtime->dev, "invalid PCM config given: bw=%d, ch=%u\n",
525 regval = LPAIF_DMACTL_WPSCNT_ONE;
528 regval = (dai_id == LPASS_DP_RX ?
529 LPAIF_DMACTL_WPSCNT_ONE :
530 LPAIF_DMACTL_WPSCNT_TWO);
533 regval = (dai_id == LPASS_DP_RX ?
534 LPAIF_DMACTL_WPSCNT_TWO :
535 LPAIF_DMACTL_WPSCNT_FOUR);
538 regval = (dai_id == LPASS_DP_RX ?
539 LPAIF_DMACTL_WPSCNT_THREE :
540 LPAIF_DMACTL_WPSCNT_SIX);
543 regval = (dai_id == LPASS_DP_RX ?
544 LPAIF_DMACTL_WPSCNT_FOUR :
545 LPAIF_DMACTL_WPSCNT_EIGHT);
548 dev_err(soc_runtime->dev, "invalid PCM config given: bw=%d, ch=%u\n",
554 dev_err(soc_runtime->dev, "invalid PCM config given: bw=%d, ch=%u\n",
559 ret = regmap_fields_write(dmactl->wpscnt, id, regval);
561 dev_err(soc_runtime->dev, "error writing to dmactl reg: %d\n",
569 static int lpass_platform_pcmops_hw_free(struct snd_soc_component *component,
570 struct snd_pcm_substream *substream)
572 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
573 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
574 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
575 struct snd_pcm_runtime *rt = substream->runtime;
576 struct lpass_pcm_data *pcm_data = rt->private_data;
577 struct lpass_variant *v = drvdata->variant;
581 unsigned int dai_id = cpu_dai->driver->id;
583 if (is_cdc_dma_port(dai_id))
585 map = __lpass_get_regmap_handle(substream, component);
587 reg = LPAIF_DMACTL_REG(v, pcm_data->dma_ch, substream->stream, dai_id);
588 ret = regmap_write(map, reg, 0);
590 dev_err(soc_runtime->dev, "error writing to rdmactl reg: %d\n",
596 static int lpass_platform_pcmops_prepare(struct snd_soc_component *component,
597 struct snd_pcm_substream *substream)
599 struct snd_pcm_runtime *runtime = substream->runtime;
600 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
601 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
602 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
603 struct snd_pcm_runtime *rt = substream->runtime;
604 struct lpass_pcm_data *pcm_data = rt->private_data;
605 struct lpass_variant *v = drvdata->variant;
606 struct lpaif_dmactl *dmactl;
608 int ret, id, ch, dir = substream->stream;
609 unsigned int dai_id = cpu_dai->driver->id;
611 ch = pcm_data->dma_ch;
613 dmactl = __lpass_get_dmactl_handle(substream, component);
614 id = __lpass_get_id(substream, component);
615 map = __lpass_get_regmap_handle(substream, component);
617 ret = regmap_write(map, LPAIF_DMABASE_REG(v, ch, dir, dai_id),
620 dev_err(soc_runtime->dev, "error writing to rdmabase reg: %d\n",
625 ret = regmap_write(map, LPAIF_DMABUFF_REG(v, ch, dir, dai_id),
626 (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1);
628 dev_err(soc_runtime->dev, "error writing to rdmabuff reg: %d\n",
633 ret = regmap_write(map, LPAIF_DMAPER_REG(v, ch, dir, dai_id),
634 (snd_pcm_lib_period_bytes(substream) >> 2) - 1);
636 dev_err(soc_runtime->dev, "error writing to rdmaper reg: %d\n",
641 if (is_cdc_dma_port(dai_id)) {
642 ret = regmap_fields_write(dmactl->fifowm, id, LPAIF_DMACTL_FIFOWM_8);
644 dev_err(soc_runtime->dev, "error writing fifowm field to dmactl reg: %d, id: %d\n",
649 ret = regmap_fields_write(dmactl->enable, id, LPAIF_DMACTL_ENABLE_ON);
651 dev_err(soc_runtime->dev, "error writing to rdmactl reg: %d\n",
659 static int lpass_platform_pcmops_trigger(struct snd_soc_component *component,
660 struct snd_pcm_substream *substream,
663 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
664 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
665 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
666 struct snd_pcm_runtime *rt = substream->runtime;
667 struct lpass_pcm_data *pcm_data = rt->private_data;
668 struct lpass_variant *v = drvdata->variant;
669 struct lpaif_dmactl *dmactl;
672 unsigned int reg_irqclr = 0, val_irqclr = 0;
673 unsigned int reg_irqen = 0, val_irqen = 0, val_mask = 0;
674 unsigned int dai_id = cpu_dai->driver->id;
676 ch = pcm_data->dma_ch;
677 dmactl = __lpass_get_dmactl_handle(substream, component);
678 id = __lpass_get_id(substream, component);
679 map = __lpass_get_regmap_handle(substream, component);
682 case SNDRV_PCM_TRIGGER_START:
683 case SNDRV_PCM_TRIGGER_RESUME:
684 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
685 ret = regmap_fields_write(dmactl->enable, id,
686 LPAIF_DMACTL_ENABLE_ON);
688 dev_err(soc_runtime->dev,
689 "error writing to rdmactl reg: %d\n", ret);
694 ret = regmap_fields_write(dmactl->dyncclk, id,
695 LPAIF_DMACTL_DYNCLK_ON);
697 dev_err(soc_runtime->dev,
698 "error writing to rdmactl reg: %d\n", ret);
701 reg_irqclr = LPASS_HDMITX_APP_IRQCLEAR_REG(v);
702 val_irqclr = (LPAIF_IRQ_ALL(ch) |
703 LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(ch) |
704 LPAIF_IRQ_HDMI_METADONE |
705 LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(ch));
707 reg_irqen = LPASS_HDMITX_APP_IRQEN_REG(v);
708 val_mask = (LPAIF_IRQ_ALL(ch) |
709 LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(ch) |
710 LPAIF_IRQ_HDMI_METADONE |
711 LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(ch));
712 val_irqen = (LPAIF_IRQ_ALL(ch) |
713 LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(ch) |
714 LPAIF_IRQ_HDMI_METADONE |
715 LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(ch));
720 case MI2S_QUATERNARY:
722 reg_irqclr = LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
723 val_irqclr = LPAIF_IRQ_ALL(ch);
726 reg_irqen = LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
727 val_mask = LPAIF_IRQ_ALL(ch);
728 val_irqen = LPAIF_IRQ_ALL(ch);
730 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
731 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
732 ret = regmap_fields_write(dmactl->dyncclk, id, LPAIF_DMACTL_DYNCLK_ON);
734 dev_err(soc_runtime->dev,
735 "error writing to rdmactl reg field: %d\n", ret);
738 reg_irqclr = LPAIF_RXTX_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
739 val_irqclr = LPAIF_IRQ_ALL(ch);
741 reg_irqen = LPAIF_RXTX_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
742 val_mask = LPAIF_IRQ_ALL(ch);
743 val_irqen = LPAIF_IRQ_ALL(ch);
745 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
746 ret = regmap_fields_write(dmactl->dyncclk, id, LPAIF_DMACTL_DYNCLK_ON);
748 dev_err(soc_runtime->dev,
749 "error writing to rdmactl reg field: %d\n", ret);
752 reg_irqclr = LPAIF_VA_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
753 val_irqclr = LPAIF_IRQ_ALL(ch);
755 reg_irqen = LPAIF_VA_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
756 val_mask = LPAIF_IRQ_ALL(ch);
757 val_irqen = LPAIF_IRQ_ALL(ch);
760 dev_err(soc_runtime->dev, "%s: invalid %d interface\n", __func__, dai_id);
764 ret = regmap_write_bits(map, reg_irqclr, val_irqclr, val_irqclr);
766 dev_err(soc_runtime->dev, "error writing to irqclear reg: %d\n", ret);
769 ret = regmap_update_bits(map, reg_irqen, val_mask, val_irqen);
771 dev_err(soc_runtime->dev, "error writing to irqen reg: %d\n", ret);
775 case SNDRV_PCM_TRIGGER_STOP:
776 case SNDRV_PCM_TRIGGER_SUSPEND:
777 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
778 ret = regmap_fields_write(dmactl->enable, id,
779 LPAIF_DMACTL_ENABLE_OFF);
781 dev_err(soc_runtime->dev,
782 "error writing to rdmactl reg: %d\n", ret);
787 ret = regmap_fields_write(dmactl->dyncclk, id,
788 LPAIF_DMACTL_DYNCLK_OFF);
790 dev_err(soc_runtime->dev,
791 "error writing to rdmactl reg: %d\n", ret);
794 reg_irqen = LPASS_HDMITX_APP_IRQEN_REG(v);
795 val_mask = (LPAIF_IRQ_ALL(ch) |
796 LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(ch) |
797 LPAIF_IRQ_HDMI_METADONE |
798 LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(ch));
804 case MI2S_QUATERNARY:
806 reg_irqen = LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
807 val_mask = LPAIF_IRQ_ALL(ch);
810 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
811 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
812 ret = regmap_fields_write(dmactl->dyncclk, id, LPAIF_DMACTL_DYNCLK_OFF);
814 dev_err(soc_runtime->dev,
815 "error writing to rdmactl reg field: %d\n", ret);
819 reg_irqclr = LPAIF_RXTX_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
820 val_irqclr = LPAIF_IRQ_ALL(ch);
822 reg_irqen = LPAIF_RXTX_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
823 val_mask = LPAIF_IRQ_ALL(ch);
824 val_irqen = LPAIF_IRQ_ALL(ch);
826 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
827 ret = regmap_fields_write(dmactl->dyncclk, id, LPAIF_DMACTL_DYNCLK_OFF);
829 dev_err(soc_runtime->dev,
830 "error writing to rdmactl reg field: %d\n", ret);
834 reg_irqclr = LPAIF_VA_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
835 val_irqclr = LPAIF_IRQ_ALL(ch);
837 reg_irqen = LPAIF_VA_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST);
838 val_mask = LPAIF_IRQ_ALL(ch);
839 val_irqen = LPAIF_IRQ_ALL(ch);
842 dev_err(soc_runtime->dev, "%s: invalid %d interface\n", __func__, dai_id);
846 ret = regmap_update_bits(map, reg_irqen, val_mask, val_irqen);
848 dev_err(soc_runtime->dev,
849 "error writing to irqen reg: %d\n", ret);
858 static snd_pcm_uframes_t lpass_platform_pcmops_pointer(
859 struct snd_soc_component *component,
860 struct snd_pcm_substream *substream)
862 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
863 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
864 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
865 struct snd_pcm_runtime *rt = substream->runtime;
866 struct lpass_pcm_data *pcm_data = rt->private_data;
867 struct lpass_variant *v = drvdata->variant;
868 unsigned int base_addr, curr_addr;
869 int ret, ch, dir = substream->stream;
871 unsigned int dai_id = cpu_dai->driver->id;
873 map = __lpass_get_regmap_handle(substream, component);
874 ch = pcm_data->dma_ch;
876 ret = regmap_read(map,
877 LPAIF_DMABASE_REG(v, ch, dir, dai_id), &base_addr);
879 dev_err(soc_runtime->dev,
880 "error reading from rdmabase reg: %d\n", ret);
884 ret = regmap_read(map,
885 LPAIF_DMACURR_REG(v, ch, dir, dai_id), &curr_addr);
887 dev_err(soc_runtime->dev,
888 "error reading from rdmacurr reg: %d\n", ret);
892 return bytes_to_frames(substream->runtime, curr_addr - base_addr);
895 static int lpass_platform_cdc_dma_mmap(struct snd_pcm_substream *substream,
896 struct vm_area_struct *vma)
898 struct snd_pcm_runtime *runtime = substream->runtime;
899 unsigned long size, offset;
901 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
902 size = vma->vm_end - vma->vm_start;
903 offset = vma->vm_pgoff << PAGE_SHIFT;
904 return io_remap_pfn_range(vma, vma->vm_start,
905 (runtime->dma_addr + offset) >> PAGE_SHIFT,
906 size, vma->vm_page_prot);
910 static int lpass_platform_pcmops_mmap(struct snd_soc_component *component,
911 struct snd_pcm_substream *substream,
912 struct vm_area_struct *vma)
914 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
915 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
916 unsigned int dai_id = cpu_dai->driver->id;
918 if (is_cdc_dma_port(dai_id))
919 return lpass_platform_cdc_dma_mmap(substream, vma);
921 return snd_pcm_lib_default_mmap(substream, vma);
924 static irqreturn_t lpass_dma_interrupt_handler(
925 struct snd_pcm_substream *substream,
926 struct lpass_data *drvdata,
927 int chan, u32 interrupts)
929 struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream);
930 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
931 struct lpass_variant *v = drvdata->variant;
932 irqreturn_t ret = IRQ_NONE;
934 unsigned int reg, val, mask;
936 unsigned int dai_id = cpu_dai->driver->id;
938 mask = LPAIF_IRQ_ALL(chan);
941 map = drvdata->hdmiif_map;
942 reg = LPASS_HDMITX_APP_IRQCLEAR_REG(v);
943 val = (LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(chan) |
944 LPAIF_IRQ_HDMI_METADONE |
945 LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(chan));
950 case MI2S_QUATERNARY:
952 map = drvdata->lpaif_map;
953 reg = LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
956 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
957 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
958 map = drvdata->rxtx_lpaif_map;
959 reg = LPAIF_RXTX_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
962 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
963 map = drvdata->va_lpaif_map;
964 reg = LPAIF_VA_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST);
968 dev_err(soc_runtime->dev, "%s: invalid %d interface\n", __func__, dai_id);
971 if (interrupts & LPAIF_IRQ_PER(chan)) {
972 rv = regmap_write_bits(map, reg, mask, (LPAIF_IRQ_PER(chan) | val));
974 dev_err(soc_runtime->dev,
975 "error writing to irqclear reg: %d\n", rv);
978 snd_pcm_period_elapsed(substream);
982 if (interrupts & LPAIF_IRQ_XRUN(chan)) {
983 rv = regmap_write_bits(map, reg, mask, (LPAIF_IRQ_XRUN(chan) | val));
985 dev_err(soc_runtime->dev,
986 "error writing to irqclear reg: %d\n", rv);
989 dev_warn_ratelimited(soc_runtime->dev, "xrun warning\n");
991 snd_pcm_stop_xrun(substream);
995 if (interrupts & LPAIF_IRQ_ERR(chan)) {
996 rv = regmap_write_bits(map, reg, mask, (LPAIF_IRQ_ERR(chan) | val));
998 dev_err(soc_runtime->dev,
999 "error writing to irqclear reg: %d\n", rv);
1002 dev_err(soc_runtime->dev, "bus access error\n");
1003 snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
1007 if (interrupts & val) {
1008 rv = regmap_write(map, reg, val);
1010 dev_err(soc_runtime->dev,
1011 "error writing to irqclear reg: %d\n", rv);
1020 static irqreturn_t lpass_platform_lpaif_irq(int irq, void *data)
1022 struct lpass_data *drvdata = data;
1023 struct lpass_variant *v = drvdata->variant;
1027 rv = regmap_read(drvdata->lpaif_map,
1028 LPAIF_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs);
1030 pr_err("error reading from irqstat reg: %d\n", rv);
1034 /* Handle per channel interrupts */
1035 for (chan = 0; chan < LPASS_MAX_DMA_CHANNELS; chan++) {
1036 if (irqs & LPAIF_IRQ_ALL(chan) && drvdata->substream[chan]) {
1037 rv = lpass_dma_interrupt_handler(
1038 drvdata->substream[chan],
1039 drvdata, chan, irqs);
1040 if (rv != IRQ_HANDLED)
1048 static irqreturn_t lpass_platform_hdmiif_irq(int irq, void *data)
1050 struct lpass_data *drvdata = data;
1051 struct lpass_variant *v = drvdata->variant;
1055 rv = regmap_read(drvdata->hdmiif_map,
1056 LPASS_HDMITX_APP_IRQSTAT_REG(v), &irqs);
1058 pr_err("error reading from irqstat reg: %d\n", rv);
1062 /* Handle per channel interrupts */
1063 for (chan = 0; chan < LPASS_MAX_HDMI_DMA_CHANNELS; chan++) {
1064 if (irqs & (LPAIF_IRQ_ALL(chan) | LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(chan) |
1065 LPAIF_IRQ_HDMI_METADONE |
1066 LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(chan))
1067 && drvdata->hdmi_substream[chan]) {
1068 rv = lpass_dma_interrupt_handler(
1069 drvdata->hdmi_substream[chan],
1070 drvdata, chan, irqs);
1071 if (rv != IRQ_HANDLED)
1078 static irqreturn_t lpass_platform_rxtxif_irq(int irq, void *data)
1080 struct lpass_data *drvdata = data;
1081 struct lpass_variant *v = drvdata->variant;
1086 rv = regmap_read(drvdata->rxtx_lpaif_map,
1087 LPAIF_RXTX_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs);
1089 /* Handle per channel interrupts */
1090 for (chan = 0; chan < LPASS_MAX_CDC_DMA_CHANNELS; chan++) {
1091 if (irqs & LPAIF_IRQ_ALL(chan) && drvdata->rxtx_substream[chan]) {
1092 rv = lpass_dma_interrupt_handler(
1093 drvdata->rxtx_substream[chan],
1094 drvdata, chan, irqs);
1095 if (rv != IRQ_HANDLED)
1103 static irqreturn_t lpass_platform_vaif_irq(int irq, void *data)
1105 struct lpass_data *drvdata = data;
1106 struct lpass_variant *v = drvdata->variant;
1111 rv = regmap_read(drvdata->va_lpaif_map,
1112 LPAIF_VA_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs);
1114 /* Handle per channel interrupts */
1115 for (chan = 0; chan < LPASS_MAX_VA_CDC_DMA_CHANNELS; chan++) {
1116 if (irqs & LPAIF_IRQ_ALL(chan) && drvdata->va_substream[chan]) {
1117 rv = lpass_dma_interrupt_handler(
1118 drvdata->va_substream[chan],
1119 drvdata, chan, irqs);
1120 if (rv != IRQ_HANDLED)
1127 static int lpass_platform_prealloc_cdc_dma_buffer(struct snd_soc_component *component,
1128 struct snd_pcm *pcm, int dai_id)
1130 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
1131 struct snd_pcm_substream *substream;
1132 struct snd_dma_buffer *buf;
1134 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
1135 substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
1137 substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
1139 buf = &substream->dma_buffer;
1140 buf->dev.dev = pcm->card->dev;
1141 buf->private_data = NULL;
1143 /* Assign Codec DMA buffer pointers */
1144 buf->dev.type = SNDRV_DMA_TYPE_CONTINUOUS;
1147 case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
1148 buf->bytes = lpass_platform_rxtx_hardware.buffer_bytes_max;
1149 buf->addr = drvdata->rxtx_cdc_dma_lpm_buf;
1151 case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
1152 buf->bytes = lpass_platform_rxtx_hardware.buffer_bytes_max;
1153 buf->addr = drvdata->rxtx_cdc_dma_lpm_buf + LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE;
1155 case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX8:
1156 buf->bytes = lpass_platform_va_hardware.buffer_bytes_max;
1157 buf->addr = drvdata->va_cdc_dma_lpm_buf;
1163 buf->area = (unsigned char * __force)memremap(buf->addr, buf->bytes, MEMREMAP_WC);
1168 static int lpass_platform_pcm_new(struct snd_soc_component *component,
1169 struct snd_soc_pcm_runtime *soc_runtime)
1171 struct snd_pcm *pcm = soc_runtime->pcm;
1172 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0);
1173 unsigned int dai_id = cpu_dai->driver->id;
1175 size_t size = lpass_platform_pcm_hardware.buffer_bytes_max;
1178 * Lpass codec dma can access only lpass lpm hardware memory.
1179 * ioremap is for HLOS to access hardware memory.
1181 if (is_cdc_dma_port(dai_id))
1182 return lpass_platform_prealloc_cdc_dma_buffer(component, pcm, dai_id);
1184 return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_NONCOHERENT,
1185 component->dev, size);
1188 static int lpass_platform_pcmops_suspend(struct snd_soc_component *component)
1190 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
1192 unsigned int dai_id = component->id;
1194 if (dai_id == LPASS_DP_RX)
1195 map = drvdata->hdmiif_map;
1197 map = drvdata->lpaif_map;
1199 regcache_cache_only(map, true);
1200 regcache_mark_dirty(map);
1205 static int lpass_platform_pcmops_resume(struct snd_soc_component *component)
1207 struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
1209 unsigned int dai_id = component->id;
1211 if (dai_id == LPASS_DP_RX)
1212 map = drvdata->hdmiif_map;
1214 map = drvdata->lpaif_map;
1216 regcache_cache_only(map, false);
1217 return regcache_sync(map);
1220 static int lpass_platform_copy(struct snd_soc_component *component,
1221 struct snd_pcm_substream *substream, int channel,
1222 unsigned long pos, struct iov_iter *buf,
1223 unsigned long bytes)
1225 struct snd_pcm_runtime *rt = substream->runtime;
1226 unsigned int dai_id = component->id;
1229 void __iomem *dma_buf = (void __iomem *) (rt->dma_area + pos +
1230 channel * (rt->dma_bytes / rt->channels));
1232 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1233 if (is_cdc_dma_port(dai_id)) {
1234 ret = copy_from_iter_toio(dma_buf, buf, bytes);
1236 if (copy_from_iter((void __force *)dma_buf, bytes, buf) != bytes)
1239 } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
1240 if (is_cdc_dma_port(dai_id)) {
1241 ret = copy_to_iter_fromio(buf, dma_buf, bytes);
1243 if (copy_to_iter((void __force *)dma_buf, bytes, buf) != bytes)
1251 static const struct snd_soc_component_driver lpass_component_driver = {
1253 .open = lpass_platform_pcmops_open,
1254 .close = lpass_platform_pcmops_close,
1255 .hw_params = lpass_platform_pcmops_hw_params,
1256 .hw_free = lpass_platform_pcmops_hw_free,
1257 .prepare = lpass_platform_pcmops_prepare,
1258 .trigger = lpass_platform_pcmops_trigger,
1259 .pointer = lpass_platform_pcmops_pointer,
1260 .mmap = lpass_platform_pcmops_mmap,
1261 .pcm_construct = lpass_platform_pcm_new,
1262 .suspend = lpass_platform_pcmops_suspend,
1263 .resume = lpass_platform_pcmops_resume,
1264 .copy = lpass_platform_copy,
1268 int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
1270 struct lpass_data *drvdata = platform_get_drvdata(pdev);
1271 struct lpass_variant *v = drvdata->variant;
1274 drvdata->lpaif_irq = platform_get_irq_byname(pdev, "lpass-irq-lpaif");
1275 if (drvdata->lpaif_irq < 0)
1278 /* ensure audio hardware is disabled */
1279 ret = regmap_write(drvdata->lpaif_map,
1280 LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), 0);
1282 dev_err(&pdev->dev, "error writing to irqen reg: %d\n", ret);
1286 ret = devm_request_irq(&pdev->dev, drvdata->lpaif_irq,
1287 lpass_platform_lpaif_irq, IRQF_TRIGGER_RISING,
1288 "lpass-irq-lpaif", drvdata);
1290 dev_err(&pdev->dev, "irq request failed: %d\n", ret);
1294 ret = lpass_platform_alloc_dmactl_fields(&pdev->dev,
1295 drvdata->lpaif_map);
1298 "error initializing dmactl fields: %d\n", ret);
1302 if (drvdata->codec_dma_enable) {
1303 ret = regmap_write(drvdata->rxtx_lpaif_map,
1304 LPAIF_RXTX_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), 0x0);
1306 dev_err(&pdev->dev, "error writing to rxtx irqen reg: %d\n", ret);
1309 ret = regmap_write(drvdata->va_lpaif_map,
1310 LPAIF_VA_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), 0x0);
1312 dev_err(&pdev->dev, "error writing to rxtx irqen reg: %d\n", ret);
1315 drvdata->rxtxif_irq = platform_get_irq_byname(pdev, "lpass-irq-rxtxif");
1316 if (drvdata->rxtxif_irq < 0)
1319 ret = devm_request_irq(&pdev->dev, drvdata->rxtxif_irq,
1320 lpass_platform_rxtxif_irq, 0, "lpass-irq-rxtxif", drvdata);
1322 dev_err(&pdev->dev, "rxtx irq request failed: %d\n", ret);
1326 ret = lpass_platform_alloc_rxtx_dmactl_fields(&pdev->dev,
1327 drvdata->rxtx_lpaif_map);
1330 "error initializing rxtx dmactl fields: %d\n", ret);
1334 drvdata->vaif_irq = platform_get_irq_byname(pdev, "lpass-irq-vaif");
1335 if (drvdata->vaif_irq < 0)
1338 ret = devm_request_irq(&pdev->dev, drvdata->vaif_irq,
1339 lpass_platform_vaif_irq, 0, "lpass-irq-vaif", drvdata);
1341 dev_err(&pdev->dev, "va irq request failed: %d\n", ret);
1345 ret = lpass_platform_alloc_va_dmactl_fields(&pdev->dev,
1346 drvdata->va_lpaif_map);
1349 "error initializing va dmactl fields: %d\n", ret);
1354 if (drvdata->hdmi_port_enable) {
1355 drvdata->hdmiif_irq = platform_get_irq_byname(pdev, "lpass-irq-hdmi");
1356 if (drvdata->hdmiif_irq < 0)
1359 ret = devm_request_irq(&pdev->dev, drvdata->hdmiif_irq,
1360 lpass_platform_hdmiif_irq, 0, "lpass-irq-hdmi", drvdata);
1362 dev_err(&pdev->dev, "irq hdmi request failed: %d\n", ret);
1365 ret = regmap_write(drvdata->hdmiif_map,
1366 LPASS_HDMITX_APP_IRQEN_REG(v), 0);
1368 dev_err(&pdev->dev, "error writing to hdmi irqen reg: %d\n", ret);
1372 ret = lpass_platform_alloc_hdmidmactl_fields(&pdev->dev,
1373 drvdata->hdmiif_map);
1376 "error initializing hdmidmactl fields: %d\n", ret);
1380 return devm_snd_soc_register_component(&pdev->dev,
1381 &lpass_component_driver, NULL, 0);
1383 EXPORT_SYMBOL_GPL(asoc_qcom_lpass_platform_register);
1385 MODULE_DESCRIPTION("QTi LPASS Platform Driver");
1386 MODULE_LICENSE("GPL v2");