13 #include <linux/module.h>
14 #include <linux/device.h>
19 #include <linux/slab.h>
41 #define S6_I2S_INTERRUPT_STATUS 0x00
42 #define S6_I2S_INT_OVERRUN 1
43 #define S6_I2S_INT_UNDERRUN 2
44 #define S6_I2S_INT_ALIGNMENT 4
45 #define S6_I2S_INTERRUPT_ENABLE 0x04
46 #define S6_I2S_INTERRUPT_RAW 0x08
47 #define S6_I2S_INTERRUPT_CLEAR 0x0C
48 #define S6_I2S_INTERRUPT_SET 0x10
49 #define S6_I2S_MODE 0x20
52 #define S6_I2S_TX_DEFAULT 0x24
53 #define S6_I2S_DATA_CFG(c) (0x40 + 0x10 * (c))
56 #define S6_I2S_UNUSED 2
57 #define S6_I2S_INTERFACE_CFG(c) (0x44 + 0x10 * (c))
58 #define S6_I2S_DIV_MASK 0x001fff
59 #define S6_I2S_16BIT 0x000000
60 #define S6_I2S_20BIT 0x002000
61 #define S6_I2S_24BIT 0x004000
62 #define S6_I2S_32BIT 0x006000
63 #define S6_I2S_BITS_MASK 0x006000
64 #define S6_I2S_MEM_16BIT 0x000000
65 #define S6_I2S_MEM_32BIT 0x008000
66 #define S6_I2S_MEM_MASK 0x008000
67 #define S6_I2S_CHANNELS_SHIFT 16
68 #define S6_I2S_CHANNELS_MASK 0x030000
69 #define S6_I2S_SCK_IN 0x000000
70 #define S6_I2S_SCK_OUT 0x040000
71 #define S6_I2S_SCK_DIR 0x040000
72 #define S6_I2S_WS_IN 0x000000
73 #define S6_I2S_WS_OUT 0x080000
74 #define S6_I2S_WS_DIR 0x080000
75 #define S6_I2S_LEFT_FIRST 0x000000
76 #define S6_I2S_RIGHT_FIRST 0x100000
77 #define S6_I2S_FIRST 0x100000
78 #define S6_I2S_CUR_SCK 0x200000
79 #define S6_I2S_CUR_WS 0x400000
80 #define S6_I2S_ENABLE(c) (0x48 + 0x10 * (c))
81 #define S6_I2S_DISABLE_IF 0x02
82 #define S6_I2S_ENABLE_IF 0x03
83 #define S6_I2S_IS_BUSY 0x04
84 #define S6_I2S_DMA_ACTIVE 0x08
85 #define S6_I2S_IS_ENABLED 0x10
87 #define S6_I2S_NUM_LINES 4
89 #define S6_I2S_SIF_PORT0 0x0000000
90 #define S6_I2S_SIF_PORT1 0x0000080
105 val ^= s6_i2s_read_reg(dev, reg) & ~mask;
106 s6_i2s_write_reg(dev, reg, val);
121 for (i = 1000000; --i && j < 6; ) {
135 static void s6000_i2s_stop_channel(
struct s6000_i2s_dev *dev,
int channel)
149 s6000_i2s_start_channel(dev, channel);
161 s6000_i2s_stop_channel(dev, channel);
172 s6000_i2s_start(substream);
178 s6000_i2s_stop(substream);
183 static unsigned int s6000_i2s_int_sources(
struct s6000_i2s_dev *dev)
185 unsigned int pending;
195 static unsigned int s6000_i2s_check_xrun(
struct snd_soc_dai *cpu_dai)
197 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
201 errors = s6000_i2s_int_sources(dev);
215 static void s6000_i2s_wait_disabled(
struct s6000_i2s_dev *dev)
219 for (channel = 0; channel < 2; channel++) {
232 static int s6000_i2s_set_dai_fmt(
struct snd_soc_dai *cpu_dai,
235 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
317 & S6_I2S_IS_ENABLED) {
329 static int s6000_i2s_dai_probe(
struct snd_soc_dai *dai)
358 dai->
driver->capture.channels_max = dai->
driver->capture.channels_min;
360 dai->
driver->playback.channels_max = dai->
driver->playback.channels_min;
408 #define S6000_I2S_RATES (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_5512 | \
409 SNDRV_PCM_RATE_8000_192000)
410 #define S6000_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
413 .set_fmt = s6000_i2s_set_dai_fmt,
414 .set_clkdiv = s6000_i2s_set_clkdiv,
415 .hw_params = s6000_i2s_hw_params,
419 .probe = s6000_i2s_dai_probe,
436 .ops = &s6000_i2s_dai_ops,
450 goto err_release_none;
456 dev_err(&pdev->
dev,
"I2S SCB region already claimed\n");
458 goto err_release_none;
463 dev_err(&pdev->
dev,
"can't ioremap SCB region\n");
465 goto err_release_scb;
470 dev_err(&pdev->
dev,
"no second mem resource?\n");
472 goto err_release_map;
478 dev_err(&pdev->
dev,
"I2S SIF region already claimed\n");
480 goto err_release_map;
487 goto err_release_sif;
493 dev_err(&pdev->
dev,
"I2S DMA region already claimed\n");
495 goto err_release_sif;
504 "I2S DMA region already claimed\n");
506 goto err_release_dma1;
513 goto err_release_dma2;
522 S6_I2S_INT_ALIGNMENT |
523 S6_I2S_INT_UNDERRUN |
526 s6000_i2s_stop_channel(dev, 0);
527 s6000_i2s_stop_channel(dev, 1);
528 s6000_i2s_wait_disabled(dev);
530 dev->
dma_params.check_xrun = s6000_i2s_check_xrun;
538 goto err_release_dev;
542 S6_I2S_INT_ALIGNMENT |
543 S6_I2S_INT_UNDERRUN |
548 goto err_release_dev;
577 s6000_i2s_stop_channel(dev, 0);
578 s6000_i2s_stop_channel(dev, 1);
599 .probe = s6000_i2s_probe,