2 * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * lpass-ipq806x.c -- ALSA SoC CPU DAI driver for QTi LPASS
14 * Splited out the IPQ8064 soc specific from lpass-cpu.c
17 #include <linux/clk.h>
18 #include <linux/device.h>
19 #include <linux/err.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
23 #include <linux/platform_device.h>
24 #include <sound/pcm.h>
25 #include <sound/soc.h>
26 #include <sound/soc-dai.h>
28 #include "lpass-lpaif-reg.h"
31 enum lpaif_i2s_ports {
32 IPQ806X_LPAIF_I2S_PORT_CODEC_SPK,
33 IPQ806X_LPAIF_I2S_PORT_CODEC_MIC,
34 IPQ806X_LPAIF_I2S_PORT_SEC_SPK,
35 IPQ806X_LPAIF_I2S_PORT_SEC_MIC,
36 IPQ806X_LPAIF_I2S_PORT_MI2S,
39 enum lpaif_dma_channels {
40 IPQ806X_LPAIF_RDMA_CHAN_MI2S,
41 IPQ806X_LPAIF_RDMA_CHAN_PCM0,
42 IPQ806X_LPAIF_RDMA_CHAN_PCM1,
45 static struct snd_soc_dai_driver ipq806x_lpass_cpu_dai_driver = {
46 .id = IPQ806X_LPAIF_I2S_PORT_MI2S,
48 .stream_name = "lpass-cpu-playback",
49 .formats = SNDRV_PCM_FMTBIT_S16 |
50 SNDRV_PCM_FMTBIT_S24 |
52 .rates = SNDRV_PCM_RATE_8000 |
53 SNDRV_PCM_RATE_16000 |
54 SNDRV_PCM_RATE_32000 |
55 SNDRV_PCM_RATE_48000 |
62 .probe = &asoc_qcom_lpass_cpu_dai_probe,
63 .ops = &asoc_qcom_lpass_cpu_dai_ops,
66 static int ipq806x_lpass_alloc_dma_channel(struct lpass_data *drvdata, int dir)
68 if (dir == SNDRV_PCM_STREAM_PLAYBACK)
69 return IPQ806X_LPAIF_RDMA_CHAN_MI2S;
70 else /* Capture currently not implemented */
74 static int ipq806x_lpass_free_dma_channel(struct lpass_data *drvdata, int chan)
79 static struct lpass_variant ipq806x_data = {
80 .i2sctrl_reg_base = 0x0010,
81 .i2sctrl_reg_stride = 0x04,
83 .irq_reg_base = 0x3000,
84 .irq_reg_stride = 0x1000,
86 .rdma_reg_base = 0x6000,
87 .rdma_reg_stride = 0x1000,
89 .wrdma_reg_base = 0xB000,
90 .wrdma_reg_stride = 0x1000,
91 .wrdma_channel_start = 5,
93 .dai_driver = &ipq806x_lpass_cpu_dai_driver,
95 .alloc_dma_channel = ipq806x_lpass_alloc_dma_channel,
96 .free_dma_channel = ipq806x_lpass_free_dma_channel,
99 static const struct of_device_id ipq806x_lpass_cpu_device_id[] = {
100 { .compatible = "qcom,lpass-cpu", .data = &ipq806x_data },
103 MODULE_DEVICE_TABLE(of, ipq806x_lpass_cpu_device_id);
105 static struct platform_driver ipq806x_lpass_cpu_platform_driver = {
108 .of_match_table = of_match_ptr(ipq806x_lpass_cpu_device_id),
110 .probe = asoc_qcom_lpass_cpu_platform_probe,
111 .remove = asoc_qcom_lpass_cpu_platform_remove,
113 module_platform_driver(ipq806x_lpass_cpu_platform_driver);
115 MODULE_DESCRIPTION("QTi LPASS CPU Driver");
116 MODULE_LICENSE("GPL v2");