Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 1 | /* |
| 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/clk.h> |
| 22 | #include <linux/io.h> |
Sebastian Andrzej Siewior | 8348c25 | 2010-11-22 17:12:15 -0800 | [diff] [blame] | 23 | #include <linux/pxa2xx_ssp.h> |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 24 | #include <linux/of.h> |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 25 | #include <linux/dmaengine.h> |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 26 | |
Philipp Zabel | 0664678 | 2009-02-03 21:18:26 +0100 | [diff] [blame] | 27 | #include <asm/irq.h> |
| 28 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 29 | #include <sound/core.h> |
| 30 | #include <sound/pcm.h> |
| 31 | #include <sound/initval.h> |
| 32 | #include <sound/pcm_params.h> |
| 33 | #include <sound/soc.h> |
| 34 | #include <sound/pxa2xx-lib.h> |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 35 | #include <sound/dmaengine_pcm.h> |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 36 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 37 | #include "pxa-ssp.h" |
| 38 | |
| 39 | /* |
| 40 | * SSP audio private data |
| 41 | */ |
| 42 | struct ssp_priv { |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 43 | struct ssp_device *ssp; |
Daniel Mack | 90eb6b5 | 2018-07-02 17:11:00 +0200 | [diff] [blame^] | 44 | struct clk *extclk; |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 45 | unsigned long ssp_clk; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 46 | unsigned int sysclk; |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 47 | unsigned int dai_fmt; |
| 48 | unsigned int configured_dai_fmt; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 49 | #ifdef CONFIG_PM |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 50 | uint32_t cr0; |
| 51 | uint32_t cr1; |
| 52 | uint32_t to; |
| 53 | uint32_t psp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 54 | #endif |
| 55 | }; |
| 56 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 57 | static void dump_registers(struct ssp_device *ssp) |
| 58 | { |
| 59 | dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 60 | pxa_ssp_read_reg(ssp, SSCR0), pxa_ssp_read_reg(ssp, SSCR1), |
| 61 | pxa_ssp_read_reg(ssp, SSTO)); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 62 | |
| 63 | dev_dbg(&ssp->pdev->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 64 | pxa_ssp_read_reg(ssp, SSPSP), pxa_ssp_read_reg(ssp, SSSR), |
| 65 | pxa_ssp_read_reg(ssp, SSACD)); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 66 | } |
| 67 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 68 | static void pxa_ssp_enable(struct ssp_device *ssp) |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 69 | { |
| 70 | uint32_t sscr0; |
| 71 | |
| 72 | sscr0 = __raw_readl(ssp->mmio_base + SSCR0) | SSCR0_SSE; |
| 73 | __raw_writel(sscr0, ssp->mmio_base + SSCR0); |
| 74 | } |
| 75 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 76 | static void pxa_ssp_disable(struct ssp_device *ssp) |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 77 | { |
| 78 | uint32_t sscr0; |
| 79 | |
| 80 | sscr0 = __raw_readl(ssp->mmio_base + SSCR0) & ~SSCR0_SSE; |
| 81 | __raw_writel(sscr0, ssp->mmio_base + SSCR0); |
| 82 | } |
| 83 | |
guoyh | d93ca1a | 2012-05-07 15:34:24 +0800 | [diff] [blame] | 84 | static void pxa_ssp_set_dma_params(struct ssp_device *ssp, int width4, |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 85 | int out, struct snd_dmaengine_dai_dma_data *dma) |
Eric Miao | 2d7e71f | 2009-04-23 17:05:38 +0800 | [diff] [blame] | 86 | { |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 87 | dma->addr_width = width4 ? DMA_SLAVE_BUSWIDTH_4_BYTES : |
| 88 | DMA_SLAVE_BUSWIDTH_2_BYTES; |
| 89 | dma->maxburst = 16; |
| 90 | dma->addr = ssp->phys_base + SSDR; |
Eric Miao | 2d7e71f | 2009-04-23 17:05:38 +0800 | [diff] [blame] | 91 | } |
| 92 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 93 | static int pxa_ssp_startup(struct snd_pcm_substream *substream, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 94 | struct snd_soc_dai *cpu_dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 95 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 96 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 97 | struct ssp_device *ssp = priv->ssp; |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 98 | struct snd_dmaengine_dai_dma_data *dma; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 99 | int ret = 0; |
| 100 | |
| 101 | if (!cpu_dai->active) { |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 102 | clk_prepare_enable(ssp->clk); |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 103 | pxa_ssp_disable(ssp); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 104 | } |
Eric Miao | 2d7e71f | 2009-04-23 17:05:38 +0800 | [diff] [blame] | 105 | |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 106 | dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL); |
guoyh | d93ca1a | 2012-05-07 15:34:24 +0800 | [diff] [blame] | 107 | if (!dma) |
| 108 | return -ENOMEM; |
Robert Jarzmik | cd31b80 | 2018-06-17 19:02:17 +0200 | [diff] [blame] | 109 | dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? |
| 110 | "tx" : "rx"; |
Daniel Mack | a671468 | 2013-08-12 10:42:40 +0200 | [diff] [blame] | 111 | |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 112 | snd_soc_dai_set_dma_data(cpu_dai, substream, dma); |
Daniel Mack | 5f712b2 | 2010-03-22 10:11:15 +0100 | [diff] [blame] | 113 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 114 | return ret; |
| 115 | } |
| 116 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 117 | static void pxa_ssp_shutdown(struct snd_pcm_substream *substream, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 118 | struct snd_soc_dai *cpu_dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 119 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 120 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 121 | struct ssp_device *ssp = priv->ssp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 122 | |
| 123 | if (!cpu_dai->active) { |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 124 | pxa_ssp_disable(ssp); |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 125 | clk_disable_unprepare(ssp->clk); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 126 | } |
Eric Miao | 2d7e71f | 2009-04-23 17:05:38 +0800 | [diff] [blame] | 127 | |
Daniel Mack | 5f712b2 | 2010-03-22 10:11:15 +0100 | [diff] [blame] | 128 | kfree(snd_soc_dai_get_dma_data(cpu_dai, substream)); |
| 129 | snd_soc_dai_set_dma_data(cpu_dai, substream, NULL); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | #ifdef CONFIG_PM |
| 133 | |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 134 | static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 135 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 136 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 137 | struct ssp_device *ssp = priv->ssp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 138 | |
| 139 | if (!cpu_dai->active) |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 140 | clk_prepare_enable(ssp->clk); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 141 | |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 142 | priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0); |
| 143 | priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1); |
| 144 | priv->to = __raw_readl(ssp->mmio_base + SSTO); |
| 145 | priv->psp = __raw_readl(ssp->mmio_base + SSPSP); |
| 146 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 147 | pxa_ssp_disable(ssp); |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 148 | clk_disable_unprepare(ssp->clk); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 149 | return 0; |
| 150 | } |
| 151 | |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 152 | static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 153 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 154 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 155 | struct ssp_device *ssp = priv->ssp; |
| 156 | uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 157 | |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 158 | clk_prepare_enable(ssp->clk); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 159 | |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 160 | __raw_writel(sssr, ssp->mmio_base + SSSR); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 161 | __raw_writel(priv->cr0 & ~SSCR0_SSE, ssp->mmio_base + SSCR0); |
| 162 | __raw_writel(priv->cr1, ssp->mmio_base + SSCR1); |
| 163 | __raw_writel(priv->to, ssp->mmio_base + SSTO); |
| 164 | __raw_writel(priv->psp, ssp->mmio_base + SSPSP); |
Daniel Mack | 026384d | 2010-02-02 18:45:27 +0800 | [diff] [blame] | 165 | |
| 166 | if (cpu_dai->active) |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 167 | pxa_ssp_enable(ssp); |
Daniel Mack | 026384d | 2010-02-02 18:45:27 +0800 | [diff] [blame] | 168 | else |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 169 | clk_disable_unprepare(ssp->clk); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 170 | |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | #else |
| 175 | #define pxa_ssp_suspend NULL |
| 176 | #define pxa_ssp_resume NULL |
| 177 | #endif |
| 178 | |
| 179 | /** |
| 180 | * ssp_set_clkdiv - set SSP clock divider |
| 181 | * @div: serial clock rate divider |
| 182 | */ |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 183 | static void pxa_ssp_set_scr(struct ssp_device *ssp, u32 div) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 184 | { |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 185 | u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 186 | |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 187 | if (ssp->type == PXA25x_SSP) { |
Philipp Zabel | 1a29728 | 2009-04-17 11:39:38 +0200 | [diff] [blame] | 188 | sscr0 &= ~0x0000ff00; |
| 189 | sscr0 |= ((div - 2)/2) << 8; /* 2..512 */ |
| 190 | } else { |
| 191 | sscr0 &= ~0x000fff00; |
| 192 | sscr0 |= (div - 1) << 8; /* 1..4096 */ |
| 193 | } |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 194 | pxa_ssp_write_reg(ssp, SSCR0, sscr0); |
Philipp Zabel | 1a29728 | 2009-04-17 11:39:38 +0200 | [diff] [blame] | 195 | } |
| 196 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 197 | /* |
| 198 | * Set the SSP ports SYSCLK. |
| 199 | */ |
| 200 | static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai, |
| 201 | int clk_id, unsigned int freq, int dir) |
| 202 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 203 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 204 | struct ssp_device *ssp = priv->ssp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 205 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 206 | u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & |
Daniel Mack | 05f3828 | 2018-05-21 23:50:17 +0200 | [diff] [blame] | 207 | ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 208 | |
Daniel Mack | 90eb6b5 | 2018-07-02 17:11:00 +0200 | [diff] [blame^] | 209 | if (priv->extclk) { |
| 210 | int ret; |
| 211 | |
| 212 | /* |
| 213 | * For DT based boards, if an extclk is given, use it |
| 214 | * here and configure PXA_SSP_CLK_EXT. |
| 215 | */ |
| 216 | |
| 217 | ret = clk_set_rate(priv->extclk, freq); |
| 218 | if (ret < 0) |
| 219 | return ret; |
| 220 | |
| 221 | clk_id = PXA_SSP_CLK_EXT; |
| 222 | } |
| 223 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 224 | dev_dbg(&ssp->pdev->dev, |
Roel Kluin | 449bd54 | 2009-05-27 17:08:39 -0700 | [diff] [blame] | 225 | "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n", |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 226 | cpu_dai->id, clk_id, freq); |
| 227 | |
| 228 | switch (clk_id) { |
| 229 | case PXA_SSP_CLK_NET_PLL: |
| 230 | sscr0 |= SSCR0_MOD; |
| 231 | break; |
| 232 | case PXA_SSP_CLK_PLL: |
| 233 | /* Internal PLL is fixed */ |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 234 | if (ssp->type == PXA25x_SSP) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 235 | priv->sysclk = 1843200; |
| 236 | else |
| 237 | priv->sysclk = 13000000; |
| 238 | break; |
| 239 | case PXA_SSP_CLK_EXT: |
| 240 | priv->sysclk = freq; |
| 241 | sscr0 |= SSCR0_ECS; |
| 242 | break; |
| 243 | case PXA_SSP_CLK_NET: |
| 244 | priv->sysclk = freq; |
| 245 | sscr0 |= SSCR0_NCS | SSCR0_MOD; |
| 246 | break; |
| 247 | case PXA_SSP_CLK_AUDIO: |
| 248 | priv->sysclk = 0; |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 249 | pxa_ssp_set_scr(ssp, 1); |
Daniel Mack | 20a41ea | 2009-03-04 21:16:57 +0100 | [diff] [blame] | 250 | sscr0 |= SSCR0_ACS; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 251 | break; |
| 252 | default: |
| 253 | return -ENODEV; |
| 254 | } |
| 255 | |
| 256 | /* The SSP clock must be disabled when changing SSP clock mode |
| 257 | * on PXA2xx. On PXA3xx it must be enabled when doing so. */ |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 258 | if (ssp->type != PXA3xx_SSP) |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 259 | clk_disable_unprepare(ssp->clk); |
Daniel Mack | 05f3828 | 2018-05-21 23:50:17 +0200 | [diff] [blame] | 260 | pxa_ssp_write_reg(ssp, SSCR0, sscr0); |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 261 | if (ssp->type != PXA3xx_SSP) |
Dmitry Eremin-Solenikov | 6d3efa4 | 2014-11-15 22:51:46 +0300 | [diff] [blame] | 262 | clk_prepare_enable(ssp->clk); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | /* |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 268 | * Configure the PLL frequency pxa27x and (afaik - pxa320 only) |
| 269 | */ |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 270 | static int pxa_ssp_set_pll(struct ssp_priv *priv, unsigned int freq) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 271 | { |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 272 | struct ssp_device *ssp = priv->ssp; |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 273 | u32 ssacd = pxa_ssp_read_reg(ssp, SSACD) & ~0x70; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 274 | |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 275 | if (ssp->type == PXA3xx_SSP) |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 276 | pxa_ssp_write_reg(ssp, SSACDD, 0); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 277 | |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 278 | switch (freq) { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 279 | case 5622000: |
| 280 | break; |
| 281 | case 11345000: |
| 282 | ssacd |= (0x1 << 4); |
| 283 | break; |
| 284 | case 12235000: |
| 285 | ssacd |= (0x2 << 4); |
| 286 | break; |
| 287 | case 14857000: |
| 288 | ssacd |= (0x3 << 4); |
| 289 | break; |
| 290 | case 32842000: |
| 291 | ssacd |= (0x4 << 4); |
| 292 | break; |
| 293 | case 48000000: |
| 294 | ssacd |= (0x5 << 4); |
| 295 | break; |
| 296 | case 0: |
| 297 | /* Disable */ |
| 298 | break; |
| 299 | |
| 300 | default: |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 301 | /* PXA3xx has a clock ditherer which can be used to generate |
| 302 | * a wider range of frequencies - calculate a value for it. |
| 303 | */ |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 304 | if (ssp->type == PXA3xx_SSP) { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 305 | u32 val; |
| 306 | u64 tmp = 19968; |
Codrut Grosu | 1dbe692 | 2017-02-25 23:33:50 +0200 | [diff] [blame] | 307 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 308 | tmp *= 1000000; |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 309 | do_div(tmp, freq); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 310 | val = tmp; |
| 311 | |
Joe Perches | a419aef | 2009-08-18 11:18:35 -0700 | [diff] [blame] | 312 | val = (val << 16) | 64; |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 313 | pxa_ssp_write_reg(ssp, SSACDD, val); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 314 | |
| 315 | ssacd |= (0x6 << 4); |
| 316 | |
| 317 | dev_dbg(&ssp->pdev->dev, |
Roel Kluin | 449bd54 | 2009-05-27 17:08:39 -0700 | [diff] [blame] | 318 | "Using SSACDD %x to supply %uHz\n", |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 319 | val, freq); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 320 | break; |
| 321 | } |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 322 | |
| 323 | return -EINVAL; |
| 324 | } |
| 325 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 326 | pxa_ssp_write_reg(ssp, SSACD, ssacd); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 327 | |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | /* |
| 332 | * Set the active slots in TDM/Network mode |
| 333 | */ |
| 334 | static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 335 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 336 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 337 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 338 | struct ssp_device *ssp = priv->ssp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 339 | u32 sscr0; |
| 340 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 341 | sscr0 = pxa_ssp_read_reg(ssp, SSCR0); |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 342 | sscr0 &= ~(SSCR0_MOD | SSCR0_SlotsPerFrm(8) | SSCR0_EDSS | SSCR0_DSS); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 343 | |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 344 | /* set slot width */ |
| 345 | if (slot_width > 16) |
| 346 | sscr0 |= SSCR0_EDSS | SSCR0_DataSize(slot_width - 16); |
| 347 | else |
| 348 | sscr0 |= SSCR0_DataSize(slot_width); |
| 349 | |
| 350 | if (slots > 1) { |
| 351 | /* enable network mode */ |
| 352 | sscr0 |= SSCR0_MOD; |
| 353 | |
| 354 | /* set number of active slots */ |
| 355 | sscr0 |= SSCR0_SlotsPerFrm(slots); |
| 356 | |
| 357 | /* set active slot mask */ |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 358 | pxa_ssp_write_reg(ssp, SSTSA, tx_mask); |
| 359 | pxa_ssp_write_reg(ssp, SSRSA, rx_mask); |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 360 | } |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 361 | pxa_ssp_write_reg(ssp, SSCR0, sscr0); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 362 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | /* |
| 367 | * Tristate the SSP DAI lines |
| 368 | */ |
| 369 | static int pxa_ssp_set_dai_tristate(struct snd_soc_dai *cpu_dai, |
| 370 | int tristate) |
| 371 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 372 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 373 | struct ssp_device *ssp = priv->ssp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 374 | u32 sscr1; |
| 375 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 376 | sscr1 = pxa_ssp_read_reg(ssp, SSCR1); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 377 | if (tristate) |
| 378 | sscr1 &= ~SSCR1_TTE; |
| 379 | else |
| 380 | sscr1 |= SSCR1_TTE; |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 381 | pxa_ssp_write_reg(ssp, SSCR1, sscr1); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 386 | static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, |
| 387 | unsigned int fmt) |
| 388 | { |
| 389 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
| 390 | |
| 391 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 392 | case SND_SOC_DAIFMT_CBM_CFM: |
| 393 | case SND_SOC_DAIFMT_CBM_CFS: |
| 394 | case SND_SOC_DAIFMT_CBS_CFS: |
| 395 | break; |
| 396 | default: |
| 397 | return -EINVAL; |
| 398 | } |
| 399 | |
| 400 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
| 401 | case SND_SOC_DAIFMT_NB_NF: |
| 402 | case SND_SOC_DAIFMT_NB_IF: |
| 403 | case SND_SOC_DAIFMT_IB_IF: |
| 404 | case SND_SOC_DAIFMT_IB_NF: |
| 405 | break; |
| 406 | default: |
| 407 | return -EINVAL; |
| 408 | } |
| 409 | |
| 410 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 411 | case SND_SOC_DAIFMT_I2S: |
| 412 | case SND_SOC_DAIFMT_DSP_A: |
| 413 | case SND_SOC_DAIFMT_DSP_B: |
| 414 | break; |
| 415 | |
| 416 | default: |
| 417 | return -EINVAL; |
| 418 | } |
| 419 | |
| 420 | /* Settings will be applied in hw_params() */ |
| 421 | priv->dai_fmt = fmt; |
| 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 426 | /* |
| 427 | * Set up the SSP DAI format. |
| 428 | * The SSP Port must be inactive before calling this function as the |
| 429 | * physical interface format is changed. |
| 430 | */ |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 431 | static int pxa_ssp_configure_dai_fmt(struct ssp_priv *priv) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 432 | { |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 433 | struct ssp_device *ssp = priv->ssp; |
Haojian Zhuang | f5d1e5e | 2010-08-13 21:55:35 +0800 | [diff] [blame] | 434 | u32 sscr0, sscr1, sspsp, scfr; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 435 | |
Daniel Mack | cbf1146 | 2009-03-10 16:41:00 +0100 | [diff] [blame] | 436 | /* check if we need to change anything at all */ |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 437 | if (priv->configured_dai_fmt == priv->dai_fmt) |
Daniel Mack | cbf1146 | 2009-03-10 16:41:00 +0100 | [diff] [blame] | 438 | return 0; |
| 439 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 440 | /* reset port settings */ |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 441 | sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 442 | ~(SSCR0_PSP | SSCR0_MOD); |
| 443 | sscr1 = pxa_ssp_read_reg(ssp, SSCR1) & |
| 444 | ~(SSCR1_SCLKDIR | SSCR1_SFRMDIR | SSCR1_SCFR | |
| 445 | SSCR1_RWOT | SSCR1_TRAIL | SSCR1_TFT | SSCR1_RFT); |
| 446 | sspsp = pxa_ssp_read_reg(ssp, SSPSP) & |
| 447 | ~(SSPSP_SFRMP | SSPSP_SCMODE(3)); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 448 | |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 449 | sscr1 |= SSCR1_RxTresh(8) | SSCR1_TxTresh(7); |
| 450 | |
| 451 | switch (priv->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 452 | case SND_SOC_DAIFMT_CBM_CFM: |
Haojian Zhuang | f5d1e5e | 2010-08-13 21:55:35 +0800 | [diff] [blame] | 453 | sscr1 |= SSCR1_SCLKDIR | SSCR1_SFRMDIR | SSCR1_SCFR; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 454 | break; |
| 455 | case SND_SOC_DAIFMT_CBM_CFS: |
Haojian Zhuang | f5d1e5e | 2010-08-13 21:55:35 +0800 | [diff] [blame] | 456 | sscr1 |= SSCR1_SCLKDIR | SSCR1_SCFR; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 457 | break; |
| 458 | case SND_SOC_DAIFMT_CBS_CFS: |
| 459 | break; |
| 460 | default: |
| 461 | return -EINVAL; |
| 462 | } |
| 463 | |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 464 | switch (priv->dai_fmt & SND_SOC_DAIFMT_INV_MASK) { |
Daniel Ribeiro | fa44c07 | 2009-06-10 15:23:24 -0300 | [diff] [blame] | 465 | case SND_SOC_DAIFMT_NB_NF: |
| 466 | sspsp |= SSPSP_SFRMP; |
| 467 | break; |
| 468 | case SND_SOC_DAIFMT_NB_IF: |
| 469 | break; |
| 470 | case SND_SOC_DAIFMT_IB_IF: |
| 471 | sspsp |= SSPSP_SCMODE(2); |
| 472 | break; |
| 473 | case SND_SOC_DAIFMT_IB_NF: |
| 474 | sspsp |= SSPSP_SCMODE(2) | SSPSP_SFRMP; |
| 475 | break; |
| 476 | default: |
| 477 | return -EINVAL; |
| 478 | } |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 479 | |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 480 | switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 481 | case SND_SOC_DAIFMT_I2S: |
Daniel Mack | 72d7466 | 2009-03-12 11:27:49 +0100 | [diff] [blame] | 482 | sscr0 |= SSCR0_PSP; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 483 | sscr1 |= SSCR1_RWOT | SSCR1_TRAIL; |
Mark Brown | 0ce36c5 | 2009-03-13 14:26:08 +0000 | [diff] [blame] | 484 | /* See hw_params() */ |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 485 | break; |
| 486 | |
| 487 | case SND_SOC_DAIFMT_DSP_A: |
| 488 | sspsp |= SSPSP_FSRT; |
Gustavo A. R. Silva | e0431de | 2018-07-02 07:17:07 -0500 | [diff] [blame] | 489 | /* fall through */ |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 490 | case SND_SOC_DAIFMT_DSP_B: |
| 491 | sscr0 |= SSCR0_MOD | SSCR0_PSP; |
| 492 | sscr1 |= SSCR1_TRAIL | SSCR1_RWOT; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 493 | break; |
| 494 | |
| 495 | default: |
| 496 | return -EINVAL; |
| 497 | } |
| 498 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 499 | pxa_ssp_write_reg(ssp, SSCR0, sscr0); |
| 500 | pxa_ssp_write_reg(ssp, SSCR1, sscr1); |
| 501 | pxa_ssp_write_reg(ssp, SSPSP, sspsp); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 502 | |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 503 | switch (priv->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
Haojian Zhuang | f5d1e5e | 2010-08-13 21:55:35 +0800 | [diff] [blame] | 504 | case SND_SOC_DAIFMT_CBM_CFM: |
| 505 | case SND_SOC_DAIFMT_CBM_CFS: |
| 506 | scfr = pxa_ssp_read_reg(ssp, SSCR1) | SSCR1_SCFR; |
| 507 | pxa_ssp_write_reg(ssp, SSCR1, scfr); |
| 508 | |
| 509 | while (pxa_ssp_read_reg(ssp, SSSR) & SSSR_BSY) |
| 510 | cpu_relax(); |
| 511 | break; |
| 512 | } |
| 513 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 514 | dump_registers(ssp); |
| 515 | |
| 516 | /* Since we are configuring the timings for the format by hand |
| 517 | * we have to defer some things until hw_params() where we |
| 518 | * know parameters like the sample size. |
| 519 | */ |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 520 | priv->configured_dai_fmt = priv->dai_fmt; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 521 | |
| 522 | return 0; |
| 523 | } |
| 524 | |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 525 | struct pxa_ssp_clock_mode { |
| 526 | int rate; |
| 527 | int pll; |
| 528 | u8 acds; |
| 529 | u8 scdb; |
| 530 | }; |
| 531 | |
| 532 | static const struct pxa_ssp_clock_mode pxa_ssp_clock_modes[] = { |
| 533 | { .rate = 8000, .pll = 32842000, .acds = SSACD_ACDS_32, .scdb = SSACD_SCDB_4X }, |
| 534 | { .rate = 11025, .pll = 5622000, .acds = SSACD_ACDS_4, .scdb = SSACD_SCDB_4X }, |
| 535 | { .rate = 16000, .pll = 32842000, .acds = SSACD_ACDS_16, .scdb = SSACD_SCDB_4X }, |
| 536 | { .rate = 22050, .pll = 5622000, .acds = SSACD_ACDS_2, .scdb = SSACD_SCDB_4X }, |
| 537 | { .rate = 44100, .pll = 11345000, .acds = SSACD_ACDS_2, .scdb = SSACD_SCDB_4X }, |
| 538 | { .rate = 48000, .pll = 12235000, .acds = SSACD_ACDS_2, .scdb = SSACD_SCDB_4X }, |
| 539 | { .rate = 96000, .pll = 12235000, .acds = SSACD_ACDS_4, .scdb = SSACD_SCDB_1X }, |
| 540 | {} |
| 541 | }; |
| 542 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 543 | /* |
| 544 | * Set the SSP audio DMA parameters and sample size. |
| 545 | * Can be called multiple times by oss emulation. |
| 546 | */ |
| 547 | static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 548 | struct snd_pcm_hw_params *params, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 549 | struct snd_soc_dai *cpu_dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 550 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 551 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 552 | struct ssp_device *ssp = priv->ssp; |
Eric Miao | 2d7e71f | 2009-04-23 17:05:38 +0800 | [diff] [blame] | 553 | int chn = params_channels(params); |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 554 | u32 sscr0, sspsp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 555 | int width = snd_pcm_format_physical_width(params_format(params)); |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 556 | int ttsa = pxa_ssp_read_reg(ssp, SSTSA) & 0xf; |
Daniel Mack | d65a145 | 2013-08-12 10:42:39 +0200 | [diff] [blame] | 557 | struct snd_dmaengine_dai_dma_data *dma_data; |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 558 | int rate = params_rate(params); |
| 559 | int bclk = rate * chn * (width / 8); |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 560 | int ret; |
Daniel Mack | 5f712b2 | 2010-03-22 10:11:15 +0100 | [diff] [blame] | 561 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 562 | dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 563 | |
Philipp Zabel | 9242906 | 2009-03-19 09:32:01 +0100 | [diff] [blame] | 564 | /* Network mode with one active slot (ttsa == 1) can be used |
| 565 | * to force 16-bit frame width on the wire (for S16_LE), even |
| 566 | * with two channels. Use 16-bit DMA transfers for this case. |
| 567 | */ |
guoyh | d93ca1a | 2012-05-07 15:34:24 +0800 | [diff] [blame] | 568 | pxa_ssp_set_dma_params(ssp, |
| 569 | ((chn == 2) && (ttsa != 1)) || (width == 32), |
| 570 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK, dma_data); |
Daniel Mack | 5f712b2 | 2010-03-22 10:11:15 +0100 | [diff] [blame] | 571 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 572 | /* we can only change the settings if the port is not in use */ |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 573 | if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 574 | return 0; |
| 575 | |
Daniel Mack | 737e370 | 2018-05-21 23:50:16 +0200 | [diff] [blame] | 576 | ret = pxa_ssp_configure_dai_fmt(priv); |
| 577 | if (ret < 0) |
| 578 | return ret; |
| 579 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 580 | /* clear selected SSP bits */ |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 581 | sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & ~(SSCR0_DSS | SSCR0_EDSS); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 582 | |
| 583 | /* bit size */ |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 584 | switch (params_format(params)) { |
| 585 | case SNDRV_PCM_FORMAT_S16_LE: |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 586 | if (ssp->type == PXA3xx_SSP) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 587 | sscr0 |= SSCR0_FPCKE; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 588 | sscr0 |= SSCR0_DataSize(16); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 589 | break; |
| 590 | case SNDRV_PCM_FORMAT_S24_LE: |
| 591 | sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8)); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 592 | break; |
| 593 | case SNDRV_PCM_FORMAT_S32_LE: |
| 594 | sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(16)); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 595 | break; |
| 596 | } |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 597 | pxa_ssp_write_reg(ssp, SSCR0, sscr0); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 598 | |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 599 | if (sscr0 & SSCR0_ACS) { |
| 600 | ret = pxa_ssp_set_pll(priv, bclk); |
| 601 | |
| 602 | /* |
| 603 | * If we were able to generate the bclk directly, |
| 604 | * all is fine. Otherwise, look up the closest rate |
| 605 | * from the table and also set the dividers. |
| 606 | */ |
| 607 | |
| 608 | if (ret < 0) { |
| 609 | const struct pxa_ssp_clock_mode *m; |
| 610 | int ssacd, acds; |
| 611 | |
| 612 | for (m = pxa_ssp_clock_modes; m->rate; m++) { |
| 613 | if (m->rate == rate) |
| 614 | break; |
| 615 | } |
| 616 | |
| 617 | if (!m->rate) |
| 618 | return -EINVAL; |
| 619 | |
| 620 | acds = m->acds; |
| 621 | |
| 622 | /* The values in the table are for 16 bits */ |
| 623 | if (width == 32) |
| 624 | acds--; |
| 625 | |
| 626 | ret = pxa_ssp_set_pll(priv, bclk); |
| 627 | if (ret < 0) |
| 628 | return ret; |
| 629 | |
| 630 | ssacd = pxa_ssp_read_reg(ssp, SSACD); |
| 631 | ssacd &= ~(SSACD_ACDS(7) | SSACD_SCDB_1X); |
| 632 | ssacd |= SSACD_ACDS(m->acds); |
| 633 | ssacd |= m->scdb; |
| 634 | pxa_ssp_write_reg(ssp, SSACD, ssacd); |
| 635 | } |
| 636 | } else if (sscr0 & SSCR0_ECS) { |
| 637 | /* |
| 638 | * For setups with external clocking, the PLL and its diviers |
| 639 | * are not active. Instead, the SCR bits in SSCR0 can be used |
| 640 | * to divide the clock. |
| 641 | */ |
| 642 | pxa_ssp_set_scr(ssp, bclk / rate); |
| 643 | } |
| 644 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 645 | switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 646 | case SND_SOC_DAIFMT_I2S: |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 647 | sspsp = pxa_ssp_read_reg(ssp, SSPSP); |
Daniel Mack | 72d7466 | 2009-03-12 11:27:49 +0100 | [diff] [blame] | 648 | |
Daniel Mack | 0573937 | 2018-06-29 14:59:40 +0200 | [diff] [blame] | 649 | if (((priv->sysclk / bclk) == 64) && (width == 16)) { |
Daniel Mack | 72d7466 | 2009-03-12 11:27:49 +0100 | [diff] [blame] | 650 | /* This is a special case where the bitclk is 64fs |
Codrut Grosu | 34e8243 | 2017-02-25 23:40:31 +0200 | [diff] [blame] | 651 | * and we're not dealing with 2*32 bits of audio |
| 652 | * samples. |
| 653 | * |
| 654 | * The SSP values used for that are all found out by |
| 655 | * trying and failing a lot; some of the registers |
| 656 | * needed for that mode are only available on PXA3xx. |
| 657 | */ |
Qiao Zhou | 972a55b | 2012-06-04 10:41:04 +0800 | [diff] [blame] | 658 | if (ssp->type != PXA3xx_SSP) |
Daniel Mack | 72d7466 | 2009-03-12 11:27:49 +0100 | [diff] [blame] | 659 | return -EINVAL; |
| 660 | |
| 661 | sspsp |= SSPSP_SFRMWDTH(width * 2); |
| 662 | sspsp |= SSPSP_SFRMDLY(width * 4); |
| 663 | sspsp |= SSPSP_EDMYSTOP(3); |
| 664 | sspsp |= SSPSP_DMYSTOP(3); |
| 665 | sspsp |= SSPSP_DMYSTRT(1); |
Mark Brown | 0ce36c5 | 2009-03-13 14:26:08 +0000 | [diff] [blame] | 666 | } else { |
| 667 | /* The frame width is the width the LRCLK is |
| 668 | * asserted for; the delay is expressed in |
| 669 | * half cycle units. We need the extra cycle |
| 670 | * because the data starts clocking out one BCLK |
| 671 | * after LRCLK changes polarity. |
| 672 | */ |
| 673 | sspsp |= SSPSP_SFRMWDTH(width + 1); |
| 674 | sspsp |= SSPSP_SFRMDLY((width + 1) * 2); |
| 675 | sspsp |= SSPSP_DMYSTRT(1); |
| 676 | } |
Daniel Mack | 72d7466 | 2009-03-12 11:27:49 +0100 | [diff] [blame] | 677 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 678 | pxa_ssp_write_reg(ssp, SSPSP, sspsp); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 679 | break; |
| 680 | default: |
| 681 | break; |
| 682 | } |
| 683 | |
Daniel Mack | 72d7466 | 2009-03-12 11:27:49 +0100 | [diff] [blame] | 684 | /* When we use a network mode, we always require TDM slots |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 685 | * - complain loudly and fail if they've not been set up yet. |
| 686 | */ |
Philipp Zabel | 9242906 | 2009-03-19 09:32:01 +0100 | [diff] [blame] | 687 | if ((sscr0 & SSCR0_MOD) && !ttsa) { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 688 | dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); |
| 689 | return -EINVAL; |
| 690 | } |
| 691 | |
| 692 | dump_registers(ssp); |
| 693 | |
| 694 | return 0; |
| 695 | } |
| 696 | |
Daniel Mack | 273b72c | 2012-03-19 09:12:53 +0100 | [diff] [blame] | 697 | static void pxa_ssp_set_running_bit(struct snd_pcm_substream *substream, |
| 698 | struct ssp_device *ssp, int value) |
| 699 | { |
| 700 | uint32_t sscr0 = pxa_ssp_read_reg(ssp, SSCR0); |
| 701 | uint32_t sscr1 = pxa_ssp_read_reg(ssp, SSCR1); |
| 702 | uint32_t sspsp = pxa_ssp_read_reg(ssp, SSPSP); |
| 703 | uint32_t sssr = pxa_ssp_read_reg(ssp, SSSR); |
| 704 | |
| 705 | if (value && (sscr0 & SSCR0_SSE)) |
| 706 | pxa_ssp_write_reg(ssp, SSCR0, sscr0 & ~SSCR0_SSE); |
| 707 | |
| 708 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 709 | if (value) |
| 710 | sscr1 |= SSCR1_TSRE; |
| 711 | else |
| 712 | sscr1 &= ~SSCR1_TSRE; |
| 713 | } else { |
| 714 | if (value) |
| 715 | sscr1 |= SSCR1_RSRE; |
| 716 | else |
| 717 | sscr1 &= ~SSCR1_RSRE; |
| 718 | } |
| 719 | |
| 720 | pxa_ssp_write_reg(ssp, SSCR1, sscr1); |
| 721 | |
| 722 | if (value) { |
| 723 | pxa_ssp_write_reg(ssp, SSSR, sssr); |
| 724 | pxa_ssp_write_reg(ssp, SSPSP, sspsp); |
| 725 | pxa_ssp_write_reg(ssp, SSCR0, sscr0 | SSCR0_SSE); |
| 726 | } |
| 727 | } |
| 728 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 729 | static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 730 | struct snd_soc_dai *cpu_dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 731 | { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 732 | int ret = 0; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 733 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
Eric Miao | f9efc9d | 2010-02-09 19:46:01 +0800 | [diff] [blame] | 734 | struct ssp_device *ssp = priv->ssp; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 735 | int val; |
| 736 | |
| 737 | switch (cmd) { |
| 738 | case SNDRV_PCM_TRIGGER_RESUME: |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 739 | pxa_ssp_enable(ssp); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 740 | break; |
| 741 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
Daniel Mack | 273b72c | 2012-03-19 09:12:53 +0100 | [diff] [blame] | 742 | pxa_ssp_set_running_bit(substream, ssp, 1); |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 743 | val = pxa_ssp_read_reg(ssp, SSSR); |
| 744 | pxa_ssp_write_reg(ssp, SSSR, val); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 745 | break; |
| 746 | case SNDRV_PCM_TRIGGER_START: |
Daniel Mack | 273b72c | 2012-03-19 09:12:53 +0100 | [diff] [blame] | 747 | pxa_ssp_set_running_bit(substream, ssp, 1); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 748 | break; |
| 749 | case SNDRV_PCM_TRIGGER_STOP: |
Daniel Mack | 273b72c | 2012-03-19 09:12:53 +0100 | [diff] [blame] | 750 | pxa_ssp_set_running_bit(substream, ssp, 0); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 751 | break; |
| 752 | case SNDRV_PCM_TRIGGER_SUSPEND: |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 753 | pxa_ssp_disable(ssp); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 754 | break; |
| 755 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
Daniel Mack | 273b72c | 2012-03-19 09:12:53 +0100 | [diff] [blame] | 756 | pxa_ssp_set_running_bit(substream, ssp, 0); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 757 | break; |
| 758 | |
| 759 | default: |
| 760 | ret = -EINVAL; |
| 761 | } |
| 762 | |
| 763 | dump_registers(ssp); |
| 764 | |
| 765 | return ret; |
| 766 | } |
| 767 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 768 | static int pxa_ssp_probe(struct snd_soc_dai *dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 769 | { |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 770 | struct device *dev = dai->dev; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 771 | struct ssp_priv *priv; |
| 772 | int ret; |
| 773 | |
| 774 | priv = kzalloc(sizeof(struct ssp_priv), GFP_KERNEL); |
| 775 | if (!priv) |
| 776 | return -ENOMEM; |
| 777 | |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 778 | if (dev->of_node) { |
| 779 | struct device_node *ssp_handle; |
| 780 | |
| 781 | ssp_handle = of_parse_phandle(dev->of_node, "port", 0); |
| 782 | if (!ssp_handle) { |
| 783 | dev_err(dev, "unable to get 'port' phandle\n"); |
Dan Carpenter | 4548728 | 2014-07-31 15:57:51 +0300 | [diff] [blame] | 784 | ret = -ENODEV; |
| 785 | goto err_priv; |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio"); |
| 789 | if (priv->ssp == NULL) { |
| 790 | ret = -ENODEV; |
| 791 | goto err_priv; |
| 792 | } |
Daniel Mack | 90eb6b5 | 2018-07-02 17:11:00 +0200 | [diff] [blame^] | 793 | |
| 794 | priv->extclk = devm_clk_get(dev, "extclk"); |
| 795 | if (IS_ERR(priv->extclk)) { |
| 796 | ret = PTR_ERR(priv->extclk); |
| 797 | if (ret == -EPROBE_DEFER) |
| 798 | return ret; |
| 799 | |
| 800 | priv->extclk = NULL; |
| 801 | } |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 802 | } else { |
| 803 | priv->ssp = pxa_ssp_request(dai->id + 1, "SoC audio"); |
| 804 | if (priv->ssp == NULL) { |
| 805 | ret = -ENODEV; |
| 806 | goto err_priv; |
| 807 | } |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 808 | } |
| 809 | |
Daniel Mack | a5735b7 | 2009-04-15 20:24:45 +0200 | [diff] [blame] | 810 | priv->dai_fmt = (unsigned int) -1; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 811 | snd_soc_dai_set_drvdata(dai, priv); |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 812 | |
| 813 | return 0; |
| 814 | |
| 815 | err_priv: |
| 816 | kfree(priv); |
| 817 | return ret; |
| 818 | } |
| 819 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 820 | static int pxa_ssp_remove(struct snd_soc_dai *dai) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 821 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 822 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(dai); |
| 823 | |
Haojian Zhuang | baffe16 | 2010-05-05 10:11:15 -0400 | [diff] [blame] | 824 | pxa_ssp_free(priv->ssp); |
Axel Lin | 014a275 | 2010-08-25 16:59:11 +0800 | [diff] [blame] | 825 | kfree(priv); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 826 | return 0; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | #define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ |
| 830 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \ |
Qiao Zhou | 8d8bf58 | 2012-03-08 10:02:36 +0800 | [diff] [blame] | 831 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ |
| 832 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \ |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 833 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) |
| 834 | |
Daniel Mack | 9301503 | 2014-08-13 21:51:06 +0200 | [diff] [blame] | 835 | #define PXA_SSP_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 836 | |
Lars-Peter Clausen | 85e7652 | 2011-11-23 11:40:40 +0100 | [diff] [blame] | 837 | static const struct snd_soc_dai_ops pxa_ssp_dai_ops = { |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 838 | .startup = pxa_ssp_startup, |
| 839 | .shutdown = pxa_ssp_shutdown, |
| 840 | .trigger = pxa_ssp_trigger, |
| 841 | .hw_params = pxa_ssp_hw_params, |
| 842 | .set_sysclk = pxa_ssp_set_dai_sysclk, |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 843 | .set_fmt = pxa_ssp_set_dai_fmt, |
| 844 | .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, |
| 845 | .set_tristate = pxa_ssp_set_dai_tristate, |
| 846 | }; |
| 847 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 848 | static struct snd_soc_dai_driver pxa_ssp_dai = { |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 849 | .probe = pxa_ssp_probe, |
| 850 | .remove = pxa_ssp_remove, |
| 851 | .suspend = pxa_ssp_suspend, |
| 852 | .resume = pxa_ssp_resume, |
| 853 | .playback = { |
| 854 | .channels_min = 1, |
Graeme Gregory | f34762b | 2009-09-25 13:30:26 +0100 | [diff] [blame] | 855 | .channels_max = 8, |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 856 | .rates = PXA_SSP_RATES, |
| 857 | .formats = PXA_SSP_FORMATS, |
| 858 | }, |
| 859 | .capture = { |
| 860 | .channels_min = 1, |
Graeme Gregory | f34762b | 2009-09-25 13:30:26 +0100 | [diff] [blame] | 861 | .channels_max = 8, |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 862 | .rates = PXA_SSP_RATES, |
| 863 | .formats = PXA_SSP_FORMATS, |
| 864 | }, |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 865 | .ops = &pxa_ssp_dai_ops, |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 866 | }; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 867 | |
Kuninori Morimoto | e580f1c | 2013-03-21 03:34:12 -0700 | [diff] [blame] | 868 | static const struct snd_soc_component_driver pxa_ssp_component = { |
| 869 | .name = "pxa-ssp", |
Daniel Mack | d767d3c | 2018-06-27 21:33:57 +0200 | [diff] [blame] | 870 | .ops = &pxa2xx_pcm_ops, |
| 871 | .pcm_new = pxa2xx_soc_pcm_new, |
| 872 | .pcm_free = pxa2xx_pcm_free_dma_buffers, |
Kuninori Morimoto | e580f1c | 2013-03-21 03:34:12 -0700 | [diff] [blame] | 873 | }; |
| 874 | |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 875 | #ifdef CONFIG_OF |
| 876 | static const struct of_device_id pxa_ssp_of_ids[] = { |
| 877 | { .compatible = "mrvl,pxa-ssp-dai" }, |
Stephen Boyd | 4c715c7 | 2014-05-23 17:16:49 -0700 | [diff] [blame] | 878 | {} |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 879 | }; |
Luis de Bethencourt | baafd37 | 2015-09-03 13:00:03 +0200 | [diff] [blame] | 880 | MODULE_DEVICE_TABLE(of, pxa_ssp_of_ids); |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 881 | #endif |
| 882 | |
Bill Pemberton | 570f6fe | 2012-12-07 09:26:17 -0500 | [diff] [blame] | 883 | static int asoc_ssp_probe(struct platform_device *pdev) |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 884 | { |
Axel Lin | 637ce53 | 2015-08-28 10:48:35 +0800 | [diff] [blame] | 885 | return devm_snd_soc_register_component(&pdev->dev, &pxa_ssp_component, |
| 886 | &pxa_ssp_dai, 1); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | static struct platform_driver asoc_ssp_driver = { |
| 890 | .driver = { |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 891 | .name = "pxa-ssp-dai", |
Daniel Mack | 2023c90 | 2013-08-12 10:42:38 +0200 | [diff] [blame] | 892 | .of_match_table = of_match_ptr(pxa_ssp_of_ids), |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 893 | }, |
| 894 | |
| 895 | .probe = asoc_ssp_probe, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 896 | }; |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 897 | |
Axel Lin | 2f702a1 | 2011-11-25 10:13:37 +0800 | [diff] [blame] | 898 | module_platform_driver(asoc_ssp_driver); |
Mark Brown | 3f4b783 | 2008-12-03 19:26:35 +0000 | [diff] [blame] | 899 | |
Mark Brown | 1b340bd | 2008-07-30 19:12:04 +0100 | [diff] [blame] | 900 | /* Module information */ |
| 901 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 902 | MODULE_DESCRIPTION("PXA SSP/PCM SoC Interface"); |
| 903 | MODULE_LICENSE("GPL"); |
Andrea Adami | e5b7d71 | 2016-05-06 17:27:34 +0200 | [diff] [blame] | 904 | MODULE_ALIAS("platform:pxa-ssp-dai"); |