3 * pxa-ssp.c -- ALSA Soc Audio Layer
5 * Copyright 2005,2008 Wolfson Microelectronics PLC.
6 * Author: Liam Girdwood
7 * Mark Brown <broonie@opensource.wolfsonmicro.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
15 * o Test network mode for > 16bit sample size
18 #include <linux/init.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/clk.h>
26 #include <sound/core.h>
27 #include <sound/pcm.h>
28 #include <sound/initval.h>
29 #include <sound/pcm_params.h>
30 #include <sound/soc.h>
31 #include <sound/pxa2xx-lib.h>
33 #include <mach/hardware.h>
34 #include <mach/pxa-regs.h>
35 #include <mach/regs-ssp.h>
36 #include <mach/audio.h>
39 #include "pxa2xx-pcm.h"
43 * SSP audio private data
50 struct ssp_state state
;
54 #define PXA2xx_SSP1_BASE 0x41000000
55 #define PXA27x_SSP2_BASE 0x41700000
56 #define PXA27x_SSP3_BASE 0x41900000
57 #define PXA3xx_SSP4_BASE 0x41a00000
59 static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_mono_out
= {
60 .name
= "SSP1 PCM Mono out",
61 .dev_addr
= PXA2xx_SSP1_BASE
+ SSDR
,
63 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
64 DCMD_BURST16
| DCMD_WIDTH2
,
67 static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_mono_in
= {
68 .name
= "SSP1 PCM Mono in",
69 .dev_addr
= PXA2xx_SSP1_BASE
+ SSDR
,
71 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
72 DCMD_BURST16
| DCMD_WIDTH2
,
75 static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_stereo_out
= {
76 .name
= "SSP1 PCM Stereo out",
77 .dev_addr
= PXA2xx_SSP1_BASE
+ SSDR
,
79 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
80 DCMD_BURST16
| DCMD_WIDTH4
,
83 static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_stereo_in
= {
84 .name
= "SSP1 PCM Stereo in",
85 .dev_addr
= PXA2xx_SSP1_BASE
+ SSDR
,
87 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
88 DCMD_BURST16
| DCMD_WIDTH4
,
91 static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_mono_out
= {
92 .name
= "SSP2 PCM Mono out",
93 .dev_addr
= PXA27x_SSP2_BASE
+ SSDR
,
95 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
96 DCMD_BURST16
| DCMD_WIDTH2
,
99 static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_mono_in
= {
100 .name
= "SSP2 PCM Mono in",
101 .dev_addr
= PXA27x_SSP2_BASE
+ SSDR
,
103 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
104 DCMD_BURST16
| DCMD_WIDTH2
,
107 static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_stereo_out
= {
108 .name
= "SSP2 PCM Stereo out",
109 .dev_addr
= PXA27x_SSP2_BASE
+ SSDR
,
111 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
112 DCMD_BURST16
| DCMD_WIDTH4
,
115 static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_stereo_in
= {
116 .name
= "SSP2 PCM Stereo in",
117 .dev_addr
= PXA27x_SSP2_BASE
+ SSDR
,
119 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
120 DCMD_BURST16
| DCMD_WIDTH4
,
123 static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_mono_out
= {
124 .name
= "SSP3 PCM Mono out",
125 .dev_addr
= PXA27x_SSP3_BASE
+ SSDR
,
127 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
128 DCMD_BURST16
| DCMD_WIDTH2
,
131 static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_mono_in
= {
132 .name
= "SSP3 PCM Mono in",
133 .dev_addr
= PXA27x_SSP3_BASE
+ SSDR
,
135 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
136 DCMD_BURST16
| DCMD_WIDTH2
,
139 static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_stereo_out
= {
140 .name
= "SSP3 PCM Stereo out",
141 .dev_addr
= PXA27x_SSP3_BASE
+ SSDR
,
143 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
144 DCMD_BURST16
| DCMD_WIDTH4
,
147 static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_stereo_in
= {
148 .name
= "SSP3 PCM Stereo in",
149 .dev_addr
= PXA27x_SSP3_BASE
+ SSDR
,
151 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
152 DCMD_BURST16
| DCMD_WIDTH4
,
155 static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_mono_out
= {
156 .name
= "SSP4 PCM Mono out",
157 .dev_addr
= PXA3xx_SSP4_BASE
+ SSDR
,
159 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
160 DCMD_BURST16
| DCMD_WIDTH2
,
163 static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_mono_in
= {
164 .name
= "SSP4 PCM Mono in",
165 .dev_addr
= PXA3xx_SSP4_BASE
+ SSDR
,
167 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
168 DCMD_BURST16
| DCMD_WIDTH2
,
171 static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_stereo_out
= {
172 .name
= "SSP4 PCM Stereo out",
173 .dev_addr
= PXA3xx_SSP4_BASE
+ SSDR
,
175 .dcmd
= DCMD_INCSRCADDR
| DCMD_FLOWTRG
|
176 DCMD_BURST16
| DCMD_WIDTH4
,
179 static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_stereo_in
= {
180 .name
= "SSP4 PCM Stereo in",
181 .dev_addr
= PXA3xx_SSP4_BASE
+ SSDR
,
183 .dcmd
= DCMD_INCTRGADDR
| DCMD_FLOWSRC
|
184 DCMD_BURST16
| DCMD_WIDTH4
,
187 static void dump_registers(struct ssp_device
*ssp
)
189 dev_dbg(&ssp
->pdev
->dev
, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n",
190 ssp_read_reg(ssp
, SSCR0
), ssp_read_reg(ssp
, SSCR1
),
191 ssp_read_reg(ssp
, SSTO
));
193 dev_dbg(&ssp
->pdev
->dev
, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n",
194 ssp_read_reg(ssp
, SSPSP
), ssp_read_reg(ssp
, SSSR
),
195 ssp_read_reg(ssp
, SSACD
));
198 static struct pxa2xx_pcm_dma_params
*ssp_dma_params
[4][4] = {
200 &pxa_ssp1_pcm_mono_out
, &pxa_ssp1_pcm_mono_in
,
201 &pxa_ssp1_pcm_stereo_out
, &pxa_ssp1_pcm_stereo_in
,
204 &pxa_ssp2_pcm_mono_out
, &pxa_ssp2_pcm_mono_in
,
205 &pxa_ssp2_pcm_stereo_out
, &pxa_ssp2_pcm_stereo_in
,
208 &pxa_ssp3_pcm_mono_out
, &pxa_ssp3_pcm_mono_in
,
209 &pxa_ssp3_pcm_stereo_out
, &pxa_ssp3_pcm_stereo_in
,
212 &pxa_ssp4_pcm_mono_out
, &pxa_ssp4_pcm_mono_in
,
213 &pxa_ssp4_pcm_stereo_out
, &pxa_ssp4_pcm_stereo_in
,
217 static int pxa_ssp_startup(struct snd_pcm_substream
*substream
,
218 struct snd_soc_dai
*dai
)
220 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
221 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
222 struct ssp_priv
*priv
= cpu_dai
->private_data
;
225 if (!cpu_dai
->active
) {
226 priv
->dev
.port
= cpu_dai
->id
+ 1;
227 priv
->dev
.irq
= NO_IRQ
;
228 clk_enable(priv
->dev
.ssp
->clk
);
229 ssp_disable(&priv
->dev
);
234 static void pxa_ssp_shutdown(struct snd_pcm_substream
*substream
,
235 struct snd_soc_dai
*dai
)
237 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
238 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
239 struct ssp_priv
*priv
= cpu_dai
->private_data
;
241 if (!cpu_dai
->active
) {
242 ssp_disable(&priv
->dev
);
243 clk_disable(priv
->dev
.ssp
->clk
);
249 static int pxa_ssp_suspend(struct snd_soc_dai
*cpu_dai
)
251 struct ssp_priv
*priv
= cpu_dai
->private_data
;
253 if (!cpu_dai
->active
)
256 ssp_save_state(&priv
->dev
, &priv
->state
);
257 clk_disable(priv
->dev
.ssp
->clk
);
261 static int pxa_ssp_resume(struct snd_soc_dai
*cpu_dai
)
263 struct ssp_priv
*priv
= cpu_dai
->private_data
;
265 if (!cpu_dai
->active
)
268 clk_enable(priv
->dev
.ssp
->clk
);
269 ssp_restore_state(&priv
->dev
, &priv
->state
);
270 ssp_enable(&priv
->dev
);
276 #define pxa_ssp_suspend NULL
277 #define pxa_ssp_resume NULL
281 * ssp_set_clkdiv - set SSP clock divider
282 * @div: serial clock rate divider
284 static void ssp_set_scr(struct ssp_dev
*dev
, u32 div
)
286 struct ssp_device
*ssp
= dev
->ssp
;
287 u32 sscr0
= ssp_read_reg(dev
->ssp
, SSCR0
) & ~SSCR0_SCR
;
289 ssp_write_reg(ssp
, SSCR0
, (sscr0
| SSCR0_SerClkDiv(div
)));
293 * Set the SSP ports SYSCLK.
295 static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai
*cpu_dai
,
296 int clk_id
, unsigned int freq
, int dir
)
298 struct ssp_priv
*priv
= cpu_dai
->private_data
;
299 struct ssp_device
*ssp
= priv
->dev
.ssp
;
302 u32 sscr0
= ssp_read_reg(ssp
, SSCR0
) &
303 ~(SSCR0_ECS
| SSCR0_NCS
| SSCR0_MOD
| SSCR0_ACS
);
305 dev_dbg(&ssp
->pdev
->dev
,
306 "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %d\n",
307 cpu_dai
->id
, clk_id
, freq
);
310 case PXA_SSP_CLK_NET_PLL
:
313 case PXA_SSP_CLK_PLL
:
314 /* Internal PLL is fixed */
316 priv
->sysclk
= 1843200;
318 priv
->sysclk
= 13000000;
320 case PXA_SSP_CLK_EXT
:
324 case PXA_SSP_CLK_NET
:
326 sscr0
|= SSCR0_NCS
| SSCR0_MOD
;
328 case PXA_SSP_CLK_AUDIO
:
330 ssp_set_scr(&priv
->dev
, 1);
337 /* The SSP clock must be disabled when changing SSP clock mode
338 * on PXA2xx. On PXA3xx it must be enabled when doing so. */
339 if (!cpu_is_pxa3xx())
340 clk_disable(priv
->dev
.ssp
->clk
);
341 val
= ssp_read_reg(ssp
, SSCR0
) | sscr0
;
342 ssp_write_reg(ssp
, SSCR0
, val
);
343 if (!cpu_is_pxa3xx())
344 clk_enable(priv
->dev
.ssp
->clk
);
350 * Set the SSP clock dividers.
352 static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai
*cpu_dai
,
355 struct ssp_priv
*priv
= cpu_dai
->private_data
;
356 struct ssp_device
*ssp
= priv
->dev
.ssp
;
360 case PXA_SSP_AUDIO_DIV_ACDS
:
361 val
= (ssp_read_reg(ssp
, SSACD
) & ~0x7) | SSACD_ACDS(div
);
362 ssp_write_reg(ssp
, SSACD
, val
);
364 case PXA_SSP_AUDIO_DIV_SCDB
:
365 val
= ssp_read_reg(ssp
, SSACD
);
367 #if defined(CONFIG_PXA3xx)
372 case PXA_SSP_CLK_SCDB_1
:
375 case PXA_SSP_CLK_SCDB_4
:
377 #if defined(CONFIG_PXA3xx)
378 case PXA_SSP_CLK_SCDB_8
:
388 ssp_write_reg(ssp
, SSACD
, val
);
390 case PXA_SSP_DIV_SCR
:
391 ssp_set_scr(&priv
->dev
, div
);
401 * Configure the PLL frequency pxa27x and (afaik - pxa320 only)
403 static int pxa_ssp_set_dai_pll(struct snd_soc_dai
*cpu_dai
,
404 int pll_id
, unsigned int freq_in
, unsigned int freq_out
)
406 struct ssp_priv
*priv
= cpu_dai
->private_data
;
407 struct ssp_device
*ssp
= priv
->dev
.ssp
;
408 u32 ssacd
= ssp_read_reg(ssp
, SSACD
) & ~0x70;
410 #if defined(CONFIG_PXA3xx)
412 ssp_write_reg(ssp
, SSACDD
, 0);
439 /* PXA3xx has a clock ditherer which can be used to generate
440 * a wider range of frequencies - calculate a value for it.
442 if (cpu_is_pxa3xx()) {
446 do_div(tmp
, freq_out
);
449 val
= (val
<< 16) | 64;;
450 ssp_write_reg(ssp
, SSACDD
, val
);
454 dev_dbg(&ssp
->pdev
->dev
,
455 "Using SSACDD %x to supply %dHz\n",
464 ssp_write_reg(ssp
, SSACD
, ssacd
);
470 * Set the active slots in TDM/Network mode
472 static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai
*cpu_dai
,
473 unsigned int mask
, int slots
)
475 struct ssp_priv
*priv
= cpu_dai
->private_data
;
476 struct ssp_device
*ssp
= priv
->dev
.ssp
;
479 sscr0
= ssp_read_reg(ssp
, SSCR0
) & ~SSCR0_SlotsPerFrm(7);
481 /* set number of active slots */
482 sscr0
|= SSCR0_SlotsPerFrm(slots
);
483 ssp_write_reg(ssp
, SSCR0
, sscr0
);
485 /* set active slot mask */
486 ssp_write_reg(ssp
, SSTSA
, mask
);
487 ssp_write_reg(ssp
, SSRSA
, mask
);
492 * Tristate the SSP DAI lines
494 static int pxa_ssp_set_dai_tristate(struct snd_soc_dai
*cpu_dai
,
497 struct ssp_priv
*priv
= cpu_dai
->private_data
;
498 struct ssp_device
*ssp
= priv
->dev
.ssp
;
501 sscr1
= ssp_read_reg(ssp
, SSCR1
);
506 ssp_write_reg(ssp
, SSCR1
, sscr1
);
512 * Set up the SSP DAI format.
513 * The SSP Port must be inactive before calling this function as the
514 * physical interface format is changed.
516 static int pxa_ssp_set_dai_fmt(struct snd_soc_dai
*cpu_dai
,
519 struct ssp_priv
*priv
= cpu_dai
->private_data
;
520 struct ssp_device
*ssp
= priv
->dev
.ssp
;
525 /* check if we need to change anything at all */
526 if (priv
->dai_fmt
== fmt
)
529 /* we can only change the settings if the port is not in use */
530 if (ssp_read_reg(ssp
, SSCR0
) & SSCR0_SSE
) {
531 dev_err(&ssp
->pdev
->dev
,
532 "can't change hardware dai format: stream is in use");
536 /* reset port settings */
537 sscr0
= ssp_read_reg(ssp
, SSCR0
) &
538 (SSCR0_ECS
| SSCR0_NCS
| SSCR0_MOD
| SSCR0_ACS
);
539 sscr1
= SSCR1_RxTresh(8) | SSCR1_TxTresh(7);
542 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
543 case SND_SOC_DAIFMT_CBM_CFM
:
544 sscr1
|= SSCR1_SCLKDIR
| SSCR1_SFRMDIR
;
546 case SND_SOC_DAIFMT_CBM_CFS
:
547 sscr1
|= SSCR1_SCLKDIR
;
549 case SND_SOC_DAIFMT_CBS_CFS
:
555 ssp_write_reg(ssp
, SSCR0
, sscr0
);
556 ssp_write_reg(ssp
, SSCR1
, sscr1
);
557 ssp_write_reg(ssp
, SSPSP
, sspsp
);
559 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
560 case SND_SOC_DAIFMT_I2S
:
561 sscr0
|= SSCR0_MOD
| SSCR0_PSP
;
562 sscr1
|= SSCR1_RWOT
| SSCR1_TRAIL
;
564 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
565 case SND_SOC_DAIFMT_NB_NF
:
568 case SND_SOC_DAIFMT_NB_IF
:
569 sspsp
|= SSPSP_SFRMP
| SSPSP_FSRT
;
571 case SND_SOC_DAIFMT_IB_IF
:
572 sspsp
|= SSPSP_SFRMP
;
579 case SND_SOC_DAIFMT_DSP_A
:
581 case SND_SOC_DAIFMT_DSP_B
:
582 sscr0
|= SSCR0_MOD
| SSCR0_PSP
;
583 sscr1
|= SSCR1_TRAIL
| SSCR1_RWOT
;
585 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
586 case SND_SOC_DAIFMT_NB_NF
:
587 sspsp
|= SSPSP_SFRMP
;
589 case SND_SOC_DAIFMT_IB_IF
:
600 ssp_write_reg(ssp
, SSCR0
, sscr0
);
601 ssp_write_reg(ssp
, SSCR1
, sscr1
);
602 ssp_write_reg(ssp
, SSPSP
, sspsp
);
606 /* Since we are configuring the timings for the format by hand
607 * we have to defer some things until hw_params() where we
608 * know parameters like the sample size.
616 * Set the SSP audio DMA parameters and sample size.
617 * Can be called multiple times by oss emulation.
619 static int pxa_ssp_hw_params(struct snd_pcm_substream
*substream
,
620 struct snd_pcm_hw_params
*params
,
621 struct snd_soc_dai
*dai
)
623 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
624 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
625 struct ssp_priv
*priv
= cpu_dai
->private_data
;
626 struct ssp_device
*ssp
= priv
->dev
.ssp
;
627 int dma
= 0, chn
= params_channels(params
);
630 int width
= snd_pcm_format_physical_width(params_format(params
));
632 /* select correct DMA params */
633 if (substream
->stream
!= SNDRV_PCM_STREAM_PLAYBACK
)
634 dma
= 1; /* capture DMA offset is 1,3 */
636 dma
+= 2; /* stereo DMA offset is 2, mono is 0 */
637 cpu_dai
->dma_data
= ssp_dma_params
[cpu_dai
->id
][dma
];
639 dev_dbg(&ssp
->pdev
->dev
, "pxa_ssp_hw_params: dma %d\n", dma
);
641 /* we can only change the settings if the port is not in use */
642 if (ssp_read_reg(ssp
, SSCR0
) & SSCR0_SSE
)
645 /* clear selected SSP bits */
646 sscr0
= ssp_read_reg(ssp
, SSCR0
) & ~(SSCR0_DSS
| SSCR0_EDSS
);
647 ssp_write_reg(ssp
, SSCR0
, sscr0
);
650 sscr0
= ssp_read_reg(ssp
, SSCR0
);
651 switch (params_format(params
)) {
652 case SNDRV_PCM_FORMAT_S16_LE
:
655 sscr0
|= SSCR0_FPCKE
;
657 sscr0
|= SSCR0_DataSize(16);
658 /* use network mode (2 slots) for 16 bit stereo */
660 case SNDRV_PCM_FORMAT_S24_LE
:
661 sscr0
|= (SSCR0_EDSS
| SSCR0_DataSize(8));
662 /* we must be in network mode (2 slots) for 24 bit stereo */
664 case SNDRV_PCM_FORMAT_S32_LE
:
665 sscr0
|= (SSCR0_EDSS
| SSCR0_DataSize(16));
666 /* we must be in network mode (2 slots) for 32 bit stereo */
669 ssp_write_reg(ssp
, SSCR0
, sscr0
);
671 switch (priv
->dai_fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
672 case SND_SOC_DAIFMT_I2S
:
673 /* Cleared when the DAI format is set */
674 sspsp
= ssp_read_reg(ssp
, SSPSP
) | SSPSP_SFRMWDTH(width
);
675 ssp_write_reg(ssp
, SSPSP
, sspsp
);
681 /* We always use a network mode so we always require TDM slots
682 * - complain loudly and fail if they've not been set up yet.
684 if (!(ssp_read_reg(ssp
, SSTSA
) & 0xf)) {
685 dev_err(&ssp
->pdev
->dev
, "No TDM timeslot configured\n");
694 static int pxa_ssp_trigger(struct snd_pcm_substream
*substream
, int cmd
,
695 struct snd_soc_dai
*dai
)
697 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
698 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
700 struct ssp_priv
*priv
= cpu_dai
->private_data
;
701 struct ssp_device
*ssp
= priv
->dev
.ssp
;
705 case SNDRV_PCM_TRIGGER_RESUME
:
706 ssp_enable(&priv
->dev
);
708 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
709 val
= ssp_read_reg(ssp
, SSCR1
);
710 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
714 ssp_write_reg(ssp
, SSCR1
, val
);
715 val
= ssp_read_reg(ssp
, SSSR
);
716 ssp_write_reg(ssp
, SSSR
, val
);
718 case SNDRV_PCM_TRIGGER_START
:
719 val
= ssp_read_reg(ssp
, SSCR1
);
720 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
724 ssp_write_reg(ssp
, SSCR1
, val
);
725 ssp_enable(&priv
->dev
);
727 case SNDRV_PCM_TRIGGER_STOP
:
728 val
= ssp_read_reg(ssp
, SSCR1
);
729 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
733 ssp_write_reg(ssp
, SSCR1
, val
);
735 case SNDRV_PCM_TRIGGER_SUSPEND
:
736 ssp_disable(&priv
->dev
);
738 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
739 val
= ssp_read_reg(ssp
, SSCR1
);
740 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
744 ssp_write_reg(ssp
, SSCR1
, val
);
756 static int pxa_ssp_probe(struct platform_device
*pdev
,
757 struct snd_soc_dai
*dai
)
759 struct ssp_priv
*priv
;
762 priv
= kzalloc(sizeof(struct ssp_priv
), GFP_KERNEL
);
766 priv
->dev
.ssp
= ssp_request(dai
->id
+ 1, "SoC audio");
767 if (priv
->dev
.ssp
== NULL
) {
772 dai
->private_data
= priv
;
781 static void pxa_ssp_remove(struct platform_device
*pdev
,
782 struct snd_soc_dai
*dai
)
784 struct ssp_priv
*priv
= dai
->private_data
;
785 ssp_free(priv
->dev
.ssp
);
788 #define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
789 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
790 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | \
791 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
793 #define PXA_SSP_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
794 SNDRV_PCM_FMTBIT_S24_LE | \
795 SNDRV_PCM_FMTBIT_S32_LE)
797 static struct snd_soc_dai_ops pxa_ssp_dai_ops
= {
798 .startup
= pxa_ssp_startup
,
799 .shutdown
= pxa_ssp_shutdown
,
800 .trigger
= pxa_ssp_trigger
,
801 .hw_params
= pxa_ssp_hw_params
,
802 .set_sysclk
= pxa_ssp_set_dai_sysclk
,
803 .set_clkdiv
= pxa_ssp_set_dai_clkdiv
,
804 .set_pll
= pxa_ssp_set_dai_pll
,
805 .set_fmt
= pxa_ssp_set_dai_fmt
,
806 .set_tdm_slot
= pxa_ssp_set_dai_tdm_slot
,
807 .set_tristate
= pxa_ssp_set_dai_tristate
,
810 struct snd_soc_dai pxa_ssp_dai
[] = {
812 .name
= "pxa2xx-ssp1",
814 .probe
= pxa_ssp_probe
,
815 .remove
= pxa_ssp_remove
,
816 .suspend
= pxa_ssp_suspend
,
817 .resume
= pxa_ssp_resume
,
821 .rates
= PXA_SSP_RATES
,
822 .formats
= PXA_SSP_FORMATS
,
827 .rates
= PXA_SSP_RATES
,
828 .formats
= PXA_SSP_FORMATS
,
830 .ops
= &pxa_ssp_dai_ops
,
832 { .name
= "pxa2xx-ssp2",
834 .probe
= pxa_ssp_probe
,
835 .remove
= pxa_ssp_remove
,
836 .suspend
= pxa_ssp_suspend
,
837 .resume
= pxa_ssp_resume
,
841 .rates
= PXA_SSP_RATES
,
842 .formats
= PXA_SSP_FORMATS
,
847 .rates
= PXA_SSP_RATES
,
848 .formats
= PXA_SSP_FORMATS
,
850 .ops
= &pxa_ssp_dai_ops
,
853 .name
= "pxa2xx-ssp3",
855 .probe
= pxa_ssp_probe
,
856 .remove
= pxa_ssp_remove
,
857 .suspend
= pxa_ssp_suspend
,
858 .resume
= pxa_ssp_resume
,
862 .rates
= PXA_SSP_RATES
,
863 .formats
= PXA_SSP_FORMATS
,
868 .rates
= PXA_SSP_RATES
,
869 .formats
= PXA_SSP_FORMATS
,
871 .ops
= &pxa_ssp_dai_ops
,
874 .name
= "pxa2xx-ssp4",
876 .probe
= pxa_ssp_probe
,
877 .remove
= pxa_ssp_remove
,
878 .suspend
= pxa_ssp_suspend
,
879 .resume
= pxa_ssp_resume
,
883 .rates
= PXA_SSP_RATES
,
884 .formats
= PXA_SSP_FORMATS
,
889 .rates
= PXA_SSP_RATES
,
890 .formats
= PXA_SSP_FORMATS
,
892 .ops
= &pxa_ssp_dai_ops
,
895 EXPORT_SYMBOL_GPL(pxa_ssp_dai
);
897 static int __init
pxa_ssp_init(void)
899 return snd_soc_register_dais(pxa_ssp_dai
, ARRAY_SIZE(pxa_ssp_dai
));
901 module_init(pxa_ssp_init
);
903 static void __exit
pxa_ssp_exit(void)
905 snd_soc_unregister_dais(pxa_ssp_dai
, ARRAY_SIZE(pxa_ssp_dai
));
907 module_exit(pxa_ssp_exit
);
909 /* Module information */
910 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
911 MODULE_DESCRIPTION("PXA SSP/PCM SoC Interface");
912 MODULE_LICENSE("GPL");