15 #include <linux/device.h>
19 #include <linux/module.h>
20 #include <linux/slab.h>
36 #define LRBR_LTHR(x) (0x40 * x + 0x020)
37 #define RRBR_RTHR(x) (0x40 * x + 0x024)
38 #define RER(x) (0x40 * x + 0x028)
39 #define TER(x) (0x40 * x + 0x02C)
40 #define RCR(x) (0x40 * x + 0x030)
41 #define TCR(x) (0x40 * x + 0x034)
42 #define ISR(x) (0x40 * x + 0x038)
43 #define IMR(x) (0x40 * x + 0x03C)
44 #define ROR(x) (0x40 * x + 0x040)
45 #define TOR(x) (0x40 * x + 0x044)
46 #define RFCR(x) (0x40 * x + 0x048)
47 #define TFCR(x) (0x40 * x + 0x04C)
48 #define RFF(x) (0x40 * x + 0x050)
49 #define TFF(x) (0x40 * x + 0x054)
52 #define I2S_COMP_PARAM_2 0x01F0
53 #define I2S_COMP_PARAM_1 0x01F4
54 #define I2S_COMP_VERSION 0x01F8
55 #define I2S_COMP_TYPE 0x01FC
57 #define MAX_CHANNEL_NUM 8
58 #define MIN_CHANNEL_NUM 2
76 writel(val, io_base + reg);
81 return readl(io_base + reg);
89 for (i = 0; i < 4; i++)
92 for (i = 0; i < 4; i++)
97 static inline void i2s_clear_irqs(
struct dw_i2s_dev *dev,
u32 stream)
102 for (i = 0; i < 4; i++)
105 for (i = 0; i < 4; i++)
129 i2s_clear_irqs(dev, substream->
stream);
133 for (i = 0; i < 4; i++) {
140 for (i = 0; i < 4; i++) {
155 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
171 snd_soc_dai_set_dma_data(cpu_dai, substream, (
void *)dma_data);
179 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
188 xfer_resolution = 0x02;
194 xfer_resolution = 0x04;
200 xfer_resolution = 0x05;
204 dev_err(dev->
dev,
"designware-i2s: unsuppted PCM fmt");
224 i2s_disable_channels(dev, substream->
stream);
227 i2s_write_reg(dev->
i2s_base,
TCR(ch_reg), xfer_resolution);
230 i2s_write_reg(dev->
i2s_base,
IMR(ch_reg), irq & ~0x30);
233 i2s_write_reg(dev->
i2s_base,
RCR(ch_reg), xfer_resolution);
236 i2s_write_reg(dev->
i2s_base,
IMR(ch_reg), irq & ~0x03);
249 dev_err(dev->
dev,
"runtime audio clk config fail\n");
259 snd_soc_dai_set_dma_data(dai, substream,
NULL);
265 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
273 i2s_start(dev, substream);
280 i2s_stop(dev, substream);
290 .startup = dw_i2s_startup,
291 .shutdown = dw_i2s_shutdown,
292 .hw_params = dw_i2s_hw_params,
293 .trigger = dw_i2s_trigger,
300 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
308 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
315 #define dw_i2s_suspend NULL
316 #define dw_i2s_resume NULL
329 dev_err(&pdev->
dev,
"Invalid platform data\n");
335 dev_err(&pdev->
dev,
"no i2s resource defined\n");
340 resource_size(res), pdev->
name)) {
341 dev_err(&pdev->
dev,
"i2s region already claimed\n");
354 dev_err(&pdev->
dev,
"ioremap fail for i2s_region\n");
376 if (IS_ERR(dev->
clk))
377 return PTR_ERR(dev->
clk);
385 dev_err(&pdev->
dev,
"mem allocation failed for dai driver\n");
387 goto err_clk_disable;
391 dev_dbg(&pdev->
dev,
" SPEAr: play supported\n");
399 dev_dbg(&pdev->
dev,
"SPEAr: record supported\n");
406 dw_i2s_dai->
ops = &dw_i2s_dai_ops;
414 dev_err(&pdev->
dev,
"not able to register dai\n");
415 goto err_set_drvdata;
442 .probe = dw_i2s_probe,
443 .remove = dw_i2s_remove,
445 .name =
"designware-i2s",