15 #include <linux/module.h>
31 #define DATA_OUTBUF 0x10
36 #define CLKCTL_MASK 0x7
37 #define CLKCTL_MCLK_EXT (0x1 << 2)
38 #define CLKCTL_PWR_ON (0x1 << 0)
40 #define CON_MASK 0x3ffffff
41 #define CON_FIFO_TH_SHIFT 19
42 #define CON_FIFO_TH_MASK (0x7 << 19)
43 #define CON_USERDATA_23RDBIT (0x1 << 12)
45 #define CON_SW_RESET (0x1 << 5)
47 #define CON_MCLKDIV_MASK (0x3 << 3)
48 #define CON_MCLKDIV_256FS (0x0 << 3)
49 #define CON_MCLKDIV_384FS (0x1 << 3)
50 #define CON_MCLKDIV_512FS (0x2 << 3)
52 #define CON_PCM_MASK (0x3 << 1)
53 #define CON_PCM_16BIT (0x0 << 1)
54 #define CON_PCM_20BIT (0x1 << 1)
55 #define CON_PCM_24BIT (0x2 << 1)
57 #define CON_PCM_DATA (0x1 << 0)
59 #define CSTAS_MASK 0x3fffffff
60 #define CSTAS_SAMP_FREQ_MASK (0xF << 24)
61 #define CSTAS_SAMP_FREQ_44 (0x0 << 24)
62 #define CSTAS_SAMP_FREQ_48 (0x2 << 24)
63 #define CSTAS_SAMP_FREQ_32 (0x3 << 24)
64 #define CSTAS_SAMP_FREQ_96 (0xA << 24)
66 #define CSTAS_CATEGORY_MASK (0xFF << 8)
67 #define CSTAS_CATEGORY_CODE_CDP (0x01 << 8)
69 #define CSTAS_NO_COPYRIGHT (0x1 << 2)
98 .name =
"S/PDIF Stereo out",
106 return snd_soc_dai_get_drvdata(cpu_dai);
114 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
123 static int spdif_set_sysclk(
struct snd_soc_dai *cpu_dai,
124 int clk_id,
unsigned int freq,
int dir)
129 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
152 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
159 spdif_snd_txctrl(spdif, 1);
160 spin_unlock_irqrestore(&spdif->
lock, flags);
166 spdif_snd_txctrl(spdif, 0);
167 spin_unlock_irqrestore(&spdif->
lock, flags);
176 static int spdif_sysclk_ratios[] = {
192 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
197 dev_err(spdif->
dev,
"Capture is not supported\n");
201 snd_soc_dai_set_dma_data(rtd->
cpu_dai, substream, dma_data);
220 dev_err(spdif->
dev,
"Unsupported data size.\n");
225 for (i = 0; i <
ARRAY_SIZE(spdif_sysclk_ratios); i++)
226 if (ratio == spdif_sysclk_ratios[i])
229 dev_err(spdif->
dev,
"Invalid clock ratio %ld/%d\n",
262 dev_err(spdif->
dev,
"Invalid sampling rate %d\n",
275 spin_unlock_irqrestore(&spdif->
lock, flags);
279 spin_unlock_irqrestore(&spdif->
lock, flags);
291 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
308 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
324 dev_dbg(spdif->
dev,
"Entered %s\n", __func__);
333 #define spdif_suspend NULL
334 #define spdif_resume NULL
338 .set_sysclk = spdif_set_sysclk,
339 .trigger = spdif_trigger,
340 .hw_params = spdif_hw_params,
341 .shutdown = spdif_shutdown,
345 .name =
"samsung-spdif",
347 .stream_name =
"S/PDIF Playback",
355 .
ops = &spdif_dai_ops,
367 spdif_pdata = pdev->
dev.platform_data;
369 dev_dbg(&pdev->
dev,
"Entered %s\n", __func__);
373 dev_err(&pdev->
dev,
"Unable to get dma resource.\n");
379 dev_err(&pdev->
dev,
"Unable to get register resource.\n");
383 if (spdif_pdata && spdif_pdata->
cfg_gpio
385 dev_err(&pdev->
dev,
"Unable to configure GPIO pins\n");
395 if (IS_ERR(spdif->
pclk)) {
396 dev_err(&pdev->
dev,
"failed to get peri-clock\n");
403 if (IS_ERR(spdif->
sclk)) {
404 dev_err(&pdev->
dev,
"failed to get internal source clock\n");
412 resource_size(mem_res),
"samsung-spdif")) {
413 dev_err(&pdev->
dev,
"Unable to request register region\n");
420 dev_err(&pdev->
dev,
"Cannot ioremap registers\n");
429 dev_err(&pdev->
dev,
"fail to register dai\n");
433 spdif_stereo_out.dma_size = 2;
434 spdif_stereo_out.client = &spdif_dma_client_out;
436 spdif_stereo_out.channel = dma_res->
start;
478 .probe = spdif_probe,
481 .name =
"samsung-spdif",