blob: 6f4dd7543e829db8e73577f1184c667a596c89d0 [file] [log] [blame]
Mark Brown1b340bd2008-07-30 19:12:04 +01001/*
2 * pxa-ssp.c -- ALSA Soc Audio Layer
3 *
4 * Copyright 2005,2008 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * TODO:
14 * o Test network mode for > 16bit sample size
15 */
16
17#include <linux/init.h>
18#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Mark Brown1b340bd2008-07-30 19:12:04 +010020#include <linux/platform_device.h>
21#include <linux/clk.h>
22#include <linux/io.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080023#include <linux/pxa2xx_ssp.h>
Mark Brown1b340bd2008-07-30 19:12:04 +010024
Philipp Zabel06646782009-02-03 21:18:26 +010025#include <asm/irq.h>
26
Mark Brown1b340bd2008-07-30 19:12:04 +010027#include <sound/core.h>
28#include <sound/pcm.h>
29#include <sound/initval.h>
30#include <sound/pcm_params.h>
31#include <sound/soc.h>
32#include <sound/pxa2xx-lib.h>
33
34#include <mach/hardware.h>
Eric Miao7ebc8d52009-01-02 19:38:42 +080035#include <mach/dma.h>
Mark Brown1b340bd2008-07-30 19:12:04 +010036
Haojian Zhuangdd99a452010-08-13 21:55:27 +080037#include "../../arm/pxa2xx-pcm.h"
Mark Brown1b340bd2008-07-30 19:12:04 +010038#include "pxa-ssp.h"
39
40/*
41 * SSP audio private data
42 */
43struct ssp_priv {
Eric Miaof9efc9d2010-02-09 19:46:01 +080044 struct ssp_device *ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +010045 unsigned int sysclk;
46 int dai_fmt;
47#ifdef CONFIG_PM
Eric Miaof9efc9d2010-02-09 19:46:01 +080048 uint32_t cr0;
49 uint32_t cr1;
50 uint32_t to;
51 uint32_t psp;
Mark Brown1b340bd2008-07-30 19:12:04 +010052#endif
53};
54
Mark Brown1b340bd2008-07-30 19:12:04 +010055static void dump_registers(struct ssp_device *ssp)
56{
57 dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n",
Haojian Zhuangbaffe162010-05-05 10:11:15 -040058 pxa_ssp_read_reg(ssp, SSCR0), pxa_ssp_read_reg(ssp, SSCR1),
59 pxa_ssp_read_reg(ssp, SSTO));
Mark Brown1b340bd2008-07-30 19:12:04 +010060
61 dev_dbg(&ssp->pdev->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n",
Haojian Zhuangbaffe162010-05-05 10:11:15 -040062 pxa_ssp_read_reg(ssp, SSPSP), pxa_ssp_read_reg(ssp, SSSR),
63 pxa_ssp_read_reg(ssp, SSACD));
Mark Brown1b340bd2008-07-30 19:12:04 +010064}
65
Haojian Zhuangbaffe162010-05-05 10:11:15 -040066static void pxa_ssp_enable(struct ssp_device *ssp)
Eric Miaof9efc9d2010-02-09 19:46:01 +080067{
68 uint32_t sscr0;
69
70 sscr0 = __raw_readl(ssp->mmio_base + SSCR0) | SSCR0_SSE;
71 __raw_writel(sscr0, ssp->mmio_base + SSCR0);
72}
73
Haojian Zhuangbaffe162010-05-05 10:11:15 -040074static void pxa_ssp_disable(struct ssp_device *ssp)
Eric Miaof9efc9d2010-02-09 19:46:01 +080075{
76 uint32_t sscr0;
77
78 sscr0 = __raw_readl(ssp->mmio_base + SSCR0) & ~SSCR0_SSE;
79 __raw_writel(sscr0, ssp->mmio_base + SSCR0);
80}
81
Eric Miao2d7e71f2009-04-23 17:05:38 +080082struct pxa2xx_pcm_dma_data {
83 struct pxa2xx_pcm_dma_params params;
84 char name[20];
Mark Brown1b340bd2008-07-30 19:12:04 +010085};
86
guoyhd93ca1a2012-05-07 15:34:24 +080087static void pxa_ssp_set_dma_params(struct ssp_device *ssp, int width4,
88 int out, struct pxa2xx_pcm_dma_params *dma_data)
Eric Miao2d7e71f2009-04-23 17:05:38 +080089{
90 struct pxa2xx_pcm_dma_data *dma;
91
guoyhd93ca1a2012-05-07 15:34:24 +080092 dma = container_of(dma_data, struct pxa2xx_pcm_dma_data, params);
Eric Miao2d7e71f2009-04-23 17:05:38 +080093
94 snprintf(dma->name, 20, "SSP%d PCM %s %s", ssp->port_id,
Eric Miao8eb9fea2009-04-23 17:57:46 +080095 width4 ? "32-bit" : "16-bit", out ? "out" : "in");
Eric Miao2d7e71f2009-04-23 17:05:38 +080096
97 dma->params.name = dma->name;
98 dma->params.drcmr = &DRCMR(out ? ssp->drcmr_tx : ssp->drcmr_rx);
99 dma->params.dcmd = (out ? (DCMD_INCSRCADDR | DCMD_FLOWTRG) :
100 (DCMD_INCTRGADDR | DCMD_FLOWSRC)) |
Eric Miao8eb9fea2009-04-23 17:57:46 +0800101 (width4 ? DCMD_WIDTH4 : DCMD_WIDTH2) | DCMD_BURST16;
Eric Miao2d7e71f2009-04-23 17:05:38 +0800102 dma->params.dev_addr = ssp->phys_base + SSDR;
Eric Miao2d7e71f2009-04-23 17:05:38 +0800103}
104
Mark Browndee89c42008-11-18 22:11:38 +0000105static int pxa_ssp_startup(struct snd_pcm_substream *substream,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000106 struct snd_soc_dai *cpu_dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100107{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000108 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800109 struct ssp_device *ssp = priv->ssp;
guoyhd93ca1a2012-05-07 15:34:24 +0800110 struct pxa2xx_pcm_dma_data *dma;
Mark Brown1b340bd2008-07-30 19:12:04 +0100111 int ret = 0;
112
113 if (!cpu_dai->active) {
Eric Miaof9efc9d2010-02-09 19:46:01 +0800114 clk_enable(ssp->clk);
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400115 pxa_ssp_disable(ssp);
Mark Brown1b340bd2008-07-30 19:12:04 +0100116 }
Eric Miao2d7e71f2009-04-23 17:05:38 +0800117
guoyhd93ca1a2012-05-07 15:34:24 +0800118 dma = kzalloc(sizeof(struct pxa2xx_pcm_dma_data), GFP_KERNEL);
119 if (!dma)
120 return -ENOMEM;
121 snd_soc_dai_set_dma_data(cpu_dai, substream, &dma->params);
Daniel Mack5f712b22010-03-22 10:11:15 +0100122
Mark Brown1b340bd2008-07-30 19:12:04 +0100123 return ret;
124}
125
Mark Browndee89c42008-11-18 22:11:38 +0000126static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000127 struct snd_soc_dai *cpu_dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100128{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000129 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800130 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100131
132 if (!cpu_dai->active) {
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400133 pxa_ssp_disable(ssp);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800134 clk_disable(ssp->clk);
Mark Brown1b340bd2008-07-30 19:12:04 +0100135 }
Eric Miao2d7e71f2009-04-23 17:05:38 +0800136
Daniel Mack5f712b22010-03-22 10:11:15 +0100137 kfree(snd_soc_dai_get_dma_data(cpu_dai, substream));
138 snd_soc_dai_set_dma_data(cpu_dai, substream, NULL);
Mark Brown1b340bd2008-07-30 19:12:04 +0100139}
140
141#ifdef CONFIG_PM
142
Mark Browndc7d7b82008-12-03 18:21:52 +0000143static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100144{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000145 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800146 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100147
148 if (!cpu_dai->active)
Russell King988addf2010-03-08 20:21:04 +0000149 clk_enable(ssp->clk);
Mark Brown1b340bd2008-07-30 19:12:04 +0100150
Eric Miaof9efc9d2010-02-09 19:46:01 +0800151 priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0);
152 priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1);
153 priv->to = __raw_readl(ssp->mmio_base + SSTO);
154 priv->psp = __raw_readl(ssp->mmio_base + SSPSP);
155
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400156 pxa_ssp_disable(ssp);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800157 clk_disable(ssp->clk);
Mark Brown1b340bd2008-07-30 19:12:04 +0100158 return 0;
159}
160
Mark Browndc7d7b82008-12-03 18:21:52 +0000161static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100162{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000163 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800164 struct ssp_device *ssp = priv->ssp;
165 uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE;
Mark Brown1b340bd2008-07-30 19:12:04 +0100166
Eric Miaof9efc9d2010-02-09 19:46:01 +0800167 clk_enable(ssp->clk);
Mark Brown1b340bd2008-07-30 19:12:04 +0100168
Eric Miaof9efc9d2010-02-09 19:46:01 +0800169 __raw_writel(sssr, ssp->mmio_base + SSSR);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800170 __raw_writel(priv->cr0 & ~SSCR0_SSE, ssp->mmio_base + SSCR0);
171 __raw_writel(priv->cr1, ssp->mmio_base + SSCR1);
172 __raw_writel(priv->to, ssp->mmio_base + SSTO);
173 __raw_writel(priv->psp, ssp->mmio_base + SSPSP);
Daniel Mack026384d2010-02-02 18:45:27 +0800174
175 if (cpu_dai->active)
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400176 pxa_ssp_enable(ssp);
Daniel Mack026384d2010-02-02 18:45:27 +0800177 else
Russell King988addf2010-03-08 20:21:04 +0000178 clk_disable(ssp->clk);
Mark Brown1b340bd2008-07-30 19:12:04 +0100179
180 return 0;
181}
182
183#else
184#define pxa_ssp_suspend NULL
185#define pxa_ssp_resume NULL
186#endif
187
188/**
189 * ssp_set_clkdiv - set SSP clock divider
190 * @div: serial clock rate divider
191 */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400192static void pxa_ssp_set_scr(struct ssp_device *ssp, u32 div)
Mark Brown1b340bd2008-07-30 19:12:04 +0100193{
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400194 u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0);
Mark Brown1b340bd2008-07-30 19:12:04 +0100195
Qiao Zhou972a55b2012-06-04 10:41:04 +0800196 if (ssp->type == PXA25x_SSP) {
Philipp Zabel1a297282009-04-17 11:39:38 +0200197 sscr0 &= ~0x0000ff00;
198 sscr0 |= ((div - 2)/2) << 8; /* 2..512 */
199 } else {
200 sscr0 &= ~0x000fff00;
201 sscr0 |= (div - 1) << 8; /* 1..4096 */
202 }
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400203 pxa_ssp_write_reg(ssp, SSCR0, sscr0);
Philipp Zabel1a297282009-04-17 11:39:38 +0200204}
205
206/**
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400207 * pxa_ssp_get_clkdiv - get SSP clock divider
Philipp Zabel1a297282009-04-17 11:39:38 +0200208 */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400209static u32 pxa_ssp_get_scr(struct ssp_device *ssp)
Philipp Zabel1a297282009-04-17 11:39:38 +0200210{
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400211 u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0);
Philipp Zabel1a297282009-04-17 11:39:38 +0200212 u32 div;
213
Qiao Zhou972a55b2012-06-04 10:41:04 +0800214 if (ssp->type == PXA25x_SSP)
Philipp Zabel1a297282009-04-17 11:39:38 +0200215 div = ((sscr0 >> 8) & 0xff) * 2 + 2;
216 else
217 div = ((sscr0 >> 8) & 0xfff) + 1;
218 return div;
Mark Brown1b340bd2008-07-30 19:12:04 +0100219}
220
221/*
222 * Set the SSP ports SYSCLK.
223 */
224static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
225 int clk_id, unsigned int freq, int dir)
226{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000227 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800228 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100229 int val;
230
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400231 u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0) &
Daniel Mack20a41ea2009-03-04 21:16:57 +0100232 ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS);
Mark Brown1b340bd2008-07-30 19:12:04 +0100233
234 dev_dbg(&ssp->pdev->dev,
Roel Kluin449bd542009-05-27 17:08:39 -0700235 "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n",
Mark Brown1b340bd2008-07-30 19:12:04 +0100236 cpu_dai->id, clk_id, freq);
237
238 switch (clk_id) {
239 case PXA_SSP_CLK_NET_PLL:
240 sscr0 |= SSCR0_MOD;
241 break;
242 case PXA_SSP_CLK_PLL:
243 /* Internal PLL is fixed */
Qiao Zhou972a55b2012-06-04 10:41:04 +0800244 if (ssp->type == PXA25x_SSP)
Mark Brown1b340bd2008-07-30 19:12:04 +0100245 priv->sysclk = 1843200;
246 else
247 priv->sysclk = 13000000;
248 break;
249 case PXA_SSP_CLK_EXT:
250 priv->sysclk = freq;
251 sscr0 |= SSCR0_ECS;
252 break;
253 case PXA_SSP_CLK_NET:
254 priv->sysclk = freq;
255 sscr0 |= SSCR0_NCS | SSCR0_MOD;
256 break;
257 case PXA_SSP_CLK_AUDIO:
258 priv->sysclk = 0;
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400259 pxa_ssp_set_scr(ssp, 1);
Daniel Mack20a41ea2009-03-04 21:16:57 +0100260 sscr0 |= SSCR0_ACS;
Mark Brown1b340bd2008-07-30 19:12:04 +0100261 break;
262 default:
263 return -ENODEV;
264 }
265
266 /* The SSP clock must be disabled when changing SSP clock mode
267 * on PXA2xx. On PXA3xx it must be enabled when doing so. */
Qiao Zhou972a55b2012-06-04 10:41:04 +0800268 if (ssp->type != PXA3xx_SSP)
Eric Miaof9efc9d2010-02-09 19:46:01 +0800269 clk_disable(ssp->clk);
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400270 val = pxa_ssp_read_reg(ssp, SSCR0) | sscr0;
271 pxa_ssp_write_reg(ssp, SSCR0, val);
Qiao Zhou972a55b2012-06-04 10:41:04 +0800272 if (ssp->type != PXA3xx_SSP)
Eric Miaof9efc9d2010-02-09 19:46:01 +0800273 clk_enable(ssp->clk);
Mark Brown1b340bd2008-07-30 19:12:04 +0100274
275 return 0;
276}
277
278/*
279 * Set the SSP clock dividers.
280 */
281static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai *cpu_dai,
282 int div_id, int div)
283{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000284 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800285 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100286 int val;
287
288 switch (div_id) {
289 case PXA_SSP_AUDIO_DIV_ACDS:
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400290 val = (pxa_ssp_read_reg(ssp, SSACD) & ~0x7) | SSACD_ACDS(div);
291 pxa_ssp_write_reg(ssp, SSACD, val);
Mark Brown1b340bd2008-07-30 19:12:04 +0100292 break;
293 case PXA_SSP_AUDIO_DIV_SCDB:
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400294 val = pxa_ssp_read_reg(ssp, SSACD);
Mark Brown1b340bd2008-07-30 19:12:04 +0100295 val &= ~SSACD_SCDB;
Qiao Zhou972a55b2012-06-04 10:41:04 +0800296 if (ssp->type == PXA3xx_SSP)
Mark Brown1b340bd2008-07-30 19:12:04 +0100297 val &= ~SSACD_SCDX8;
Mark Brown1b340bd2008-07-30 19:12:04 +0100298 switch (div) {
299 case PXA_SSP_CLK_SCDB_1:
300 val |= SSACD_SCDB;
301 break;
302 case PXA_SSP_CLK_SCDB_4:
303 break;
Mark Brown1b340bd2008-07-30 19:12:04 +0100304 case PXA_SSP_CLK_SCDB_8:
Qiao Zhou972a55b2012-06-04 10:41:04 +0800305 if (ssp->type == PXA3xx_SSP)
Mark Brown1b340bd2008-07-30 19:12:04 +0100306 val |= SSACD_SCDX8;
307 else
308 return -EINVAL;
309 break;
Mark Brown1b340bd2008-07-30 19:12:04 +0100310 default:
311 return -EINVAL;
312 }
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400313 pxa_ssp_write_reg(ssp, SSACD, val);
Mark Brown1b340bd2008-07-30 19:12:04 +0100314 break;
315 case PXA_SSP_DIV_SCR:
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400316 pxa_ssp_set_scr(ssp, div);
Mark Brown1b340bd2008-07-30 19:12:04 +0100317 break;
318 default:
319 return -ENODEV;
320 }
321
322 return 0;
323}
324
325/*
326 * Configure the PLL frequency pxa27x and (afaik - pxa320 only)
327 */
Mark Brown85488032009-09-05 18:52:16 +0100328static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id,
329 int source, unsigned int freq_in, unsigned int freq_out)
Mark Brown1b340bd2008-07-30 19:12:04 +0100330{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000331 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800332 struct ssp_device *ssp = priv->ssp;
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400333 u32 ssacd = pxa_ssp_read_reg(ssp, SSACD) & ~0x70;
Mark Brown1b340bd2008-07-30 19:12:04 +0100334
Qiao Zhou972a55b2012-06-04 10:41:04 +0800335 if (ssp->type == PXA3xx_SSP)
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400336 pxa_ssp_write_reg(ssp, SSACDD, 0);
Mark Brown1b340bd2008-07-30 19:12:04 +0100337
338 switch (freq_out) {
339 case 5622000:
340 break;
341 case 11345000:
342 ssacd |= (0x1 << 4);
343 break;
344 case 12235000:
345 ssacd |= (0x2 << 4);
346 break;
347 case 14857000:
348 ssacd |= (0x3 << 4);
349 break;
350 case 32842000:
351 ssacd |= (0x4 << 4);
352 break;
353 case 48000000:
354 ssacd |= (0x5 << 4);
355 break;
356 case 0:
357 /* Disable */
358 break;
359
360 default:
Mark Brown1b340bd2008-07-30 19:12:04 +0100361 /* PXA3xx has a clock ditherer which can be used to generate
362 * a wider range of frequencies - calculate a value for it.
363 */
Qiao Zhou972a55b2012-06-04 10:41:04 +0800364 if (ssp->type == PXA3xx_SSP) {
Mark Brown1b340bd2008-07-30 19:12:04 +0100365 u32 val;
366 u64 tmp = 19968;
367 tmp *= 1000000;
368 do_div(tmp, freq_out);
369 val = tmp;
370
Joe Perchesa419aef2009-08-18 11:18:35 -0700371 val = (val << 16) | 64;
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400372 pxa_ssp_write_reg(ssp, SSACDD, val);
Mark Brown1b340bd2008-07-30 19:12:04 +0100373
374 ssacd |= (0x6 << 4);
375
376 dev_dbg(&ssp->pdev->dev,
Roel Kluin449bd542009-05-27 17:08:39 -0700377 "Using SSACDD %x to supply %uHz\n",
Mark Brown1b340bd2008-07-30 19:12:04 +0100378 val, freq_out);
379 break;
380 }
Mark Brown1b340bd2008-07-30 19:12:04 +0100381
382 return -EINVAL;
383 }
384
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400385 pxa_ssp_write_reg(ssp, SSACD, ssacd);
Mark Brown1b340bd2008-07-30 19:12:04 +0100386
387 return 0;
388}
389
390/*
391 * Set the active slots in TDM/Network mode
392 */
393static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai,
Daniel Ribeiroa5479e32009-06-15 21:44:31 -0300394 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
Mark Brown1b340bd2008-07-30 19:12:04 +0100395{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000396 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800397 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100398 u32 sscr0;
399
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400400 sscr0 = pxa_ssp_read_reg(ssp, SSCR0);
Daniel Ribeiroa5479e32009-06-15 21:44:31 -0300401 sscr0 &= ~(SSCR0_MOD | SSCR0_SlotsPerFrm(8) | SSCR0_EDSS | SSCR0_DSS);
Mark Brown1b340bd2008-07-30 19:12:04 +0100402
Daniel Ribeiroa5479e32009-06-15 21:44:31 -0300403 /* set slot width */
404 if (slot_width > 16)
405 sscr0 |= SSCR0_EDSS | SSCR0_DataSize(slot_width - 16);
406 else
407 sscr0 |= SSCR0_DataSize(slot_width);
408
409 if (slots > 1) {
410 /* enable network mode */
411 sscr0 |= SSCR0_MOD;
412
413 /* set number of active slots */
414 sscr0 |= SSCR0_SlotsPerFrm(slots);
415
416 /* set active slot mask */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400417 pxa_ssp_write_reg(ssp, SSTSA, tx_mask);
418 pxa_ssp_write_reg(ssp, SSRSA, rx_mask);
Daniel Ribeiroa5479e32009-06-15 21:44:31 -0300419 }
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400420 pxa_ssp_write_reg(ssp, SSCR0, sscr0);
Mark Brown1b340bd2008-07-30 19:12:04 +0100421
Mark Brown1b340bd2008-07-30 19:12:04 +0100422 return 0;
423}
424
425/*
426 * Tristate the SSP DAI lines
427 */
428static int pxa_ssp_set_dai_tristate(struct snd_soc_dai *cpu_dai,
429 int tristate)
430{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000431 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800432 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100433 u32 sscr1;
434
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400435 sscr1 = pxa_ssp_read_reg(ssp, SSCR1);
Mark Brown1b340bd2008-07-30 19:12:04 +0100436 if (tristate)
437 sscr1 &= ~SSCR1_TTE;
438 else
439 sscr1 |= SSCR1_TTE;
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400440 pxa_ssp_write_reg(ssp, SSCR1, sscr1);
Mark Brown1b340bd2008-07-30 19:12:04 +0100441
442 return 0;
443}
444
445/*
446 * Set up the SSP DAI format.
447 * The SSP Port must be inactive before calling this function as the
448 * physical interface format is changed.
449 */
450static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
451 unsigned int fmt)
452{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000453 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800454 struct ssp_device *ssp = priv->ssp;
Haojian Zhuangf5d1e5e2010-08-13 21:55:35 +0800455 u32 sscr0, sscr1, sspsp, scfr;
Mark Brown1b340bd2008-07-30 19:12:04 +0100456
Daniel Mackcbf11462009-03-10 16:41:00 +0100457 /* check if we need to change anything at all */
458 if (priv->dai_fmt == fmt)
459 return 0;
460
461 /* we can only change the settings if the port is not in use */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400462 if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) {
Daniel Mackcbf11462009-03-10 16:41:00 +0100463 dev_err(&ssp->pdev->dev,
464 "can't change hardware dai format: stream is in use");
465 return -EINVAL;
466 }
467
Mark Brown1b340bd2008-07-30 19:12:04 +0100468 /* reset port settings */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400469 sscr0 = pxa_ssp_read_reg(ssp, SSCR0) &
Haojian Zhuangf5d1e5e2010-08-13 21:55:35 +0800470 ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS);
Mark Brown1b340bd2008-07-30 19:12:04 +0100471 sscr1 = SSCR1_RxTresh(8) | SSCR1_TxTresh(7);
472 sspsp = 0;
473
474 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
475 case SND_SOC_DAIFMT_CBM_CFM:
Haojian Zhuangf5d1e5e2010-08-13 21:55:35 +0800476 sscr1 |= SSCR1_SCLKDIR | SSCR1_SFRMDIR | SSCR1_SCFR;
Mark Brown1b340bd2008-07-30 19:12:04 +0100477 break;
478 case SND_SOC_DAIFMT_CBM_CFS:
Haojian Zhuangf5d1e5e2010-08-13 21:55:35 +0800479 sscr1 |= SSCR1_SCLKDIR | SSCR1_SCFR;
Mark Brown1b340bd2008-07-30 19:12:04 +0100480 break;
481 case SND_SOC_DAIFMT_CBS_CFS:
482 break;
483 default:
484 return -EINVAL;
485 }
486
Daniel Ribeirofa44c072009-06-10 15:23:24 -0300487 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
488 case SND_SOC_DAIFMT_NB_NF:
489 sspsp |= SSPSP_SFRMP;
490 break;
491 case SND_SOC_DAIFMT_NB_IF:
492 break;
493 case SND_SOC_DAIFMT_IB_IF:
494 sspsp |= SSPSP_SCMODE(2);
495 break;
496 case SND_SOC_DAIFMT_IB_NF:
497 sspsp |= SSPSP_SCMODE(2) | SSPSP_SFRMP;
498 break;
499 default:
500 return -EINVAL;
501 }
Mark Brown1b340bd2008-07-30 19:12:04 +0100502
503 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
504 case SND_SOC_DAIFMT_I2S:
Daniel Mack72d74662009-03-12 11:27:49 +0100505 sscr0 |= SSCR0_PSP;
Mark Brown1b340bd2008-07-30 19:12:04 +0100506 sscr1 |= SSCR1_RWOT | SSCR1_TRAIL;
Mark Brown0ce36c52009-03-13 14:26:08 +0000507 /* See hw_params() */
Mark Brown1b340bd2008-07-30 19:12:04 +0100508 break;
509
510 case SND_SOC_DAIFMT_DSP_A:
511 sspsp |= SSPSP_FSRT;
512 case SND_SOC_DAIFMT_DSP_B:
513 sscr0 |= SSCR0_MOD | SSCR0_PSP;
514 sscr1 |= SSCR1_TRAIL | SSCR1_RWOT;
Mark Brown1b340bd2008-07-30 19:12:04 +0100515 break;
516
517 default:
518 return -EINVAL;
519 }
520
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400521 pxa_ssp_write_reg(ssp, SSCR0, sscr0);
522 pxa_ssp_write_reg(ssp, SSCR1, sscr1);
523 pxa_ssp_write_reg(ssp, SSPSP, sspsp);
Mark Brown1b340bd2008-07-30 19:12:04 +0100524
Haojian Zhuangf5d1e5e2010-08-13 21:55:35 +0800525 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
526 case SND_SOC_DAIFMT_CBM_CFM:
527 case SND_SOC_DAIFMT_CBM_CFS:
528 scfr = pxa_ssp_read_reg(ssp, SSCR1) | SSCR1_SCFR;
529 pxa_ssp_write_reg(ssp, SSCR1, scfr);
530
531 while (pxa_ssp_read_reg(ssp, SSSR) & SSSR_BSY)
532 cpu_relax();
533 break;
534 }
535
Mark Brown1b340bd2008-07-30 19:12:04 +0100536 dump_registers(ssp);
537
538 /* Since we are configuring the timings for the format by hand
539 * we have to defer some things until hw_params() where we
540 * know parameters like the sample size.
541 */
542 priv->dai_fmt = fmt;
543
544 return 0;
545}
546
547/*
548 * Set the SSP audio DMA parameters and sample size.
549 * Can be called multiple times by oss emulation.
550 */
551static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
Mark Browndee89c42008-11-18 22:11:38 +0000552 struct snd_pcm_hw_params *params,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000553 struct snd_soc_dai *cpu_dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100554{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000555 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800556 struct ssp_device *ssp = priv->ssp;
Eric Miao2d7e71f2009-04-23 17:05:38 +0800557 int chn = params_channels(params);
Mark Brown1b340bd2008-07-30 19:12:04 +0100558 u32 sscr0;
559 u32 sspsp;
560 int width = snd_pcm_format_physical_width(params_format(params));
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400561 int ttsa = pxa_ssp_read_reg(ssp, SSTSA) & 0xf;
Daniel Mack5f712b22010-03-22 10:11:15 +0100562 struct pxa2xx_pcm_dma_params *dma_data;
563
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000564 dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream);
Mark Brown1b340bd2008-07-30 19:12:04 +0100565
Philipp Zabel92429062009-03-19 09:32:01 +0100566 /* Network mode with one active slot (ttsa == 1) can be used
567 * to force 16-bit frame width on the wire (for S16_LE), even
568 * with two channels. Use 16-bit DMA transfers for this case.
569 */
guoyhd93ca1a2012-05-07 15:34:24 +0800570 pxa_ssp_set_dma_params(ssp,
571 ((chn == 2) && (ttsa != 1)) || (width == 32),
572 substream->stream == SNDRV_PCM_STREAM_PLAYBACK, dma_data);
Daniel Mack5f712b22010-03-22 10:11:15 +0100573
Mark Brown1b340bd2008-07-30 19:12:04 +0100574 /* we can only change the settings if the port is not in use */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400575 if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE)
Mark Brown1b340bd2008-07-30 19:12:04 +0100576 return 0;
577
578 /* clear selected SSP bits */
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400579 sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & ~(SSCR0_DSS | SSCR0_EDSS);
Mark Brown1b340bd2008-07-30 19:12:04 +0100580
581 /* bit size */
Mark Brown1b340bd2008-07-30 19:12:04 +0100582 switch (params_format(params)) {
583 case SNDRV_PCM_FORMAT_S16_LE:
Qiao Zhou972a55b2012-06-04 10:41:04 +0800584 if (ssp->type == PXA3xx_SSP)
Mark Brown1b340bd2008-07-30 19:12:04 +0100585 sscr0 |= SSCR0_FPCKE;
Mark Brown1b340bd2008-07-30 19:12:04 +0100586 sscr0 |= SSCR0_DataSize(16);
Mark Brown1b340bd2008-07-30 19:12:04 +0100587 break;
588 case SNDRV_PCM_FORMAT_S24_LE:
589 sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8));
Mark Brown1b340bd2008-07-30 19:12:04 +0100590 break;
591 case SNDRV_PCM_FORMAT_S32_LE:
592 sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(16));
Mark Brown1b340bd2008-07-30 19:12:04 +0100593 break;
594 }
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400595 pxa_ssp_write_reg(ssp, SSCR0, sscr0);
Mark Brown1b340bd2008-07-30 19:12:04 +0100596
597 switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
598 case SND_SOC_DAIFMT_I2S:
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400599 sspsp = pxa_ssp_read_reg(ssp, SSPSP);
Daniel Mack72d74662009-03-12 11:27:49 +0100600
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400601 if ((pxa_ssp_get_scr(ssp) == 4) && (width == 16)) {
Daniel Mack72d74662009-03-12 11:27:49 +0100602 /* This is a special case where the bitclk is 64fs
603 * and we're not dealing with 2*32 bits of audio
604 * samples.
605 *
606 * The SSP values used for that are all found out by
607 * trying and failing a lot; some of the registers
608 * needed for that mode are only available on PXA3xx.
609 */
Qiao Zhou972a55b2012-06-04 10:41:04 +0800610 if (ssp->type != PXA3xx_SSP)
Daniel Mack72d74662009-03-12 11:27:49 +0100611 return -EINVAL;
612
613 sspsp |= SSPSP_SFRMWDTH(width * 2);
614 sspsp |= SSPSP_SFRMDLY(width * 4);
615 sspsp |= SSPSP_EDMYSTOP(3);
616 sspsp |= SSPSP_DMYSTOP(3);
617 sspsp |= SSPSP_DMYSTRT(1);
Mark Brown0ce36c52009-03-13 14:26:08 +0000618 } else {
619 /* The frame width is the width the LRCLK is
620 * asserted for; the delay is expressed in
621 * half cycle units. We need the extra cycle
622 * because the data starts clocking out one BCLK
623 * after LRCLK changes polarity.
624 */
625 sspsp |= SSPSP_SFRMWDTH(width + 1);
626 sspsp |= SSPSP_SFRMDLY((width + 1) * 2);
627 sspsp |= SSPSP_DMYSTRT(1);
628 }
Daniel Mack72d74662009-03-12 11:27:49 +0100629
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400630 pxa_ssp_write_reg(ssp, SSPSP, sspsp);
Mark Brown1b340bd2008-07-30 19:12:04 +0100631 break;
632 default:
633 break;
634 }
635
Daniel Mack72d74662009-03-12 11:27:49 +0100636 /* When we use a network mode, we always require TDM slots
Mark Brown1b340bd2008-07-30 19:12:04 +0100637 * - complain loudly and fail if they've not been set up yet.
638 */
Philipp Zabel92429062009-03-19 09:32:01 +0100639 if ((sscr0 & SSCR0_MOD) && !ttsa) {
Mark Brown1b340bd2008-07-30 19:12:04 +0100640 dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n");
641 return -EINVAL;
642 }
643
644 dump_registers(ssp);
645
646 return 0;
647}
648
Daniel Mack273b72c2012-03-19 09:12:53 +0100649static void pxa_ssp_set_running_bit(struct snd_pcm_substream *substream,
650 struct ssp_device *ssp, int value)
651{
652 uint32_t sscr0 = pxa_ssp_read_reg(ssp, SSCR0);
653 uint32_t sscr1 = pxa_ssp_read_reg(ssp, SSCR1);
654 uint32_t sspsp = pxa_ssp_read_reg(ssp, SSPSP);
655 uint32_t sssr = pxa_ssp_read_reg(ssp, SSSR);
656
657 if (value && (sscr0 & SSCR0_SSE))
658 pxa_ssp_write_reg(ssp, SSCR0, sscr0 & ~SSCR0_SSE);
659
660 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
661 if (value)
662 sscr1 |= SSCR1_TSRE;
663 else
664 sscr1 &= ~SSCR1_TSRE;
665 } else {
666 if (value)
667 sscr1 |= SSCR1_RSRE;
668 else
669 sscr1 &= ~SSCR1_RSRE;
670 }
671
672 pxa_ssp_write_reg(ssp, SSCR1, sscr1);
673
674 if (value) {
675 pxa_ssp_write_reg(ssp, SSSR, sssr);
676 pxa_ssp_write_reg(ssp, SSPSP, sspsp);
677 pxa_ssp_write_reg(ssp, SSCR0, sscr0 | SSCR0_SSE);
678 }
679}
680
Mark Browndee89c42008-11-18 22:11:38 +0000681static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000682 struct snd_soc_dai *cpu_dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100683{
Mark Brown1b340bd2008-07-30 19:12:04 +0100684 int ret = 0;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000685 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
Eric Miaof9efc9d2010-02-09 19:46:01 +0800686 struct ssp_device *ssp = priv->ssp;
Mark Brown1b340bd2008-07-30 19:12:04 +0100687 int val;
688
689 switch (cmd) {
690 case SNDRV_PCM_TRIGGER_RESUME:
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400691 pxa_ssp_enable(ssp);
Mark Brown1b340bd2008-07-30 19:12:04 +0100692 break;
693 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
Daniel Mack273b72c2012-03-19 09:12:53 +0100694 pxa_ssp_set_running_bit(substream, ssp, 1);
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400695 val = pxa_ssp_read_reg(ssp, SSSR);
696 pxa_ssp_write_reg(ssp, SSSR, val);
Mark Brown1b340bd2008-07-30 19:12:04 +0100697 break;
698 case SNDRV_PCM_TRIGGER_START:
Daniel Mack273b72c2012-03-19 09:12:53 +0100699 pxa_ssp_set_running_bit(substream, ssp, 1);
Mark Brown1b340bd2008-07-30 19:12:04 +0100700 break;
701 case SNDRV_PCM_TRIGGER_STOP:
Daniel Mack273b72c2012-03-19 09:12:53 +0100702 pxa_ssp_set_running_bit(substream, ssp, 0);
Mark Brown1b340bd2008-07-30 19:12:04 +0100703 break;
704 case SNDRV_PCM_TRIGGER_SUSPEND:
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400705 pxa_ssp_disable(ssp);
Mark Brown1b340bd2008-07-30 19:12:04 +0100706 break;
707 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
Daniel Mack273b72c2012-03-19 09:12:53 +0100708 pxa_ssp_set_running_bit(substream, ssp, 0);
Mark Brown1b340bd2008-07-30 19:12:04 +0100709 break;
710
711 default:
712 ret = -EINVAL;
713 }
714
715 dump_registers(ssp);
716
717 return ret;
718}
719
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000720static int pxa_ssp_probe(struct snd_soc_dai *dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100721{
722 struct ssp_priv *priv;
723 int ret;
724
725 priv = kzalloc(sizeof(struct ssp_priv), GFP_KERNEL);
726 if (!priv)
727 return -ENOMEM;
728
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400729 priv->ssp = pxa_ssp_request(dai->id + 1, "SoC audio");
Eric Miaof9efc9d2010-02-09 19:46:01 +0800730 if (priv->ssp == NULL) {
Mark Brown1b340bd2008-07-30 19:12:04 +0100731 ret = -ENODEV;
732 goto err_priv;
733 }
734
Daniel Macka5735b72009-04-15 20:24:45 +0200735 priv->dai_fmt = (unsigned int) -1;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000736 snd_soc_dai_set_drvdata(dai, priv);
Mark Brown1b340bd2008-07-30 19:12:04 +0100737
738 return 0;
739
740err_priv:
741 kfree(priv);
742 return ret;
743}
744
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000745static int pxa_ssp_remove(struct snd_soc_dai *dai)
Mark Brown1b340bd2008-07-30 19:12:04 +0100746{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000747 struct ssp_priv *priv = snd_soc_dai_get_drvdata(dai);
748
Haojian Zhuangbaffe162010-05-05 10:11:15 -0400749 pxa_ssp_free(priv->ssp);
Axel Lin014a2752010-08-25 16:59:11 +0800750 kfree(priv);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000751 return 0;
Mark Brown1b340bd2008-07-30 19:12:04 +0100752}
753
754#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
755 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
Qiao Zhou8d8bf582012-03-08 10:02:36 +0800756 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
757 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \
Mark Brown1b340bd2008-07-30 19:12:04 +0100758 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
759
760#define PXA_SSP_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
761 SNDRV_PCM_FMTBIT_S24_LE | \
762 SNDRV_PCM_FMTBIT_S32_LE)
763
Lars-Peter Clausen85e76522011-11-23 11:40:40 +0100764static const struct snd_soc_dai_ops pxa_ssp_dai_ops = {
Eric Miao6335d052009-03-03 09:41:00 +0800765 .startup = pxa_ssp_startup,
766 .shutdown = pxa_ssp_shutdown,
767 .trigger = pxa_ssp_trigger,
768 .hw_params = pxa_ssp_hw_params,
769 .set_sysclk = pxa_ssp_set_dai_sysclk,
770 .set_clkdiv = pxa_ssp_set_dai_clkdiv,
771 .set_pll = pxa_ssp_set_dai_pll,
772 .set_fmt = pxa_ssp_set_dai_fmt,
773 .set_tdm_slot = pxa_ssp_set_dai_tdm_slot,
774 .set_tristate = pxa_ssp_set_dai_tristate,
775};
776
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000777static struct snd_soc_dai_driver pxa_ssp_dai = {
Mark Brown1b340bd2008-07-30 19:12:04 +0100778 .probe = pxa_ssp_probe,
779 .remove = pxa_ssp_remove,
780 .suspend = pxa_ssp_suspend,
781 .resume = pxa_ssp_resume,
782 .playback = {
783 .channels_min = 1,
Graeme Gregoryf34762b2009-09-25 13:30:26 +0100784 .channels_max = 8,
Mark Brown1b340bd2008-07-30 19:12:04 +0100785 .rates = PXA_SSP_RATES,
786 .formats = PXA_SSP_FORMATS,
787 },
788 .capture = {
789 .channels_min = 1,
Graeme Gregoryf34762b2009-09-25 13:30:26 +0100790 .channels_max = 8,
Mark Brown1b340bd2008-07-30 19:12:04 +0100791 .rates = PXA_SSP_RATES,
792 .formats = PXA_SSP_FORMATS,
793 },
Eric Miao6335d052009-03-03 09:41:00 +0800794 .ops = &pxa_ssp_dai_ops,
Mark Brown1b340bd2008-07-30 19:12:04 +0100795};
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000796
Kuninori Morimotoe580f1c2013-03-21 03:34:12 -0700797static const struct snd_soc_component_driver pxa_ssp_component = {
798 .name = "pxa-ssp",
799};
800
Bill Pemberton570f6fe2012-12-07 09:26:17 -0500801static int asoc_ssp_probe(struct platform_device *pdev)
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000802{
Kuninori Morimotoe580f1c2013-03-21 03:34:12 -0700803 return snd_soc_register_component(&pdev->dev, &pxa_ssp_component,
804 &pxa_ssp_dai, 1);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000805}
806
Bill Pemberton570f6fe2012-12-07 09:26:17 -0500807static int asoc_ssp_remove(struct platform_device *pdev)
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000808{
Kuninori Morimotoe580f1c2013-03-21 03:34:12 -0700809 snd_soc_unregister_component(&pdev->dev);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000810 return 0;
811}
812
813static struct platform_driver asoc_ssp_driver = {
814 .driver = {
815 .name = "pxa-ssp-dai",
816 .owner = THIS_MODULE,
817 },
818
819 .probe = asoc_ssp_probe,
Bill Pemberton570f6fe2012-12-07 09:26:17 -0500820 .remove = asoc_ssp_remove,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000821};
Mark Brown1b340bd2008-07-30 19:12:04 +0100822
Axel Lin2f702a12011-11-25 10:13:37 +0800823module_platform_driver(asoc_ssp_driver);
Mark Brown3f4b7832008-12-03 19:26:35 +0000824
Mark Brown1b340bd2008-07-30 19:12:04 +0100825/* Module information */
826MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
827MODULE_DESCRIPTION("PXA SSP/PCM SoC Interface");
828MODULE_LICENSE("GPL");