.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * pxa-ssp.c -- ALSA Soc Audio Layer |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2005,2008 Wolfson Microelectronics PLC. |
---|
5 | 6 | * Author: Liam Girdwood |
---|
6 | 7 | * 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 | 8 | * |
---|
13 | 9 | * TODO: |
---|
14 | 10 | * o Test network mode for > 16bit sample size |
---|
.. | .. |
---|
56 | 52 | |
---|
57 | 53 | static void dump_registers(struct ssp_device *ssp) |
---|
58 | 54 | { |
---|
59 | | - dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", |
---|
| 55 | + dev_dbg(ssp->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", |
---|
60 | 56 | pxa_ssp_read_reg(ssp, SSCR0), pxa_ssp_read_reg(ssp, SSCR1), |
---|
61 | 57 | pxa_ssp_read_reg(ssp, SSTO)); |
---|
62 | 58 | |
---|
63 | | - dev_dbg(&ssp->pdev->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", |
---|
| 59 | + dev_dbg(ssp->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", |
---|
64 | 60 | pxa_ssp_read_reg(ssp, SSPSP), pxa_ssp_read_reg(ssp, SSSR), |
---|
65 | 61 | pxa_ssp_read_reg(ssp, SSACD)); |
---|
66 | 62 | } |
---|
.. | .. |
---|
98 | 94 | struct snd_dmaengine_dai_dma_data *dma; |
---|
99 | 95 | int ret = 0; |
---|
100 | 96 | |
---|
101 | | - if (!cpu_dai->active) { |
---|
| 97 | + if (!snd_soc_dai_active(cpu_dai)) { |
---|
102 | 98 | clk_prepare_enable(ssp->clk); |
---|
103 | 99 | pxa_ssp_disable(ssp); |
---|
104 | 100 | } |
---|
| 101 | + |
---|
| 102 | + if (priv->extclk) |
---|
| 103 | + clk_prepare_enable(priv->extclk); |
---|
105 | 104 | |
---|
106 | 105 | dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL); |
---|
107 | 106 | if (!dma) |
---|
.. | .. |
---|
120 | 119 | struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
---|
121 | 120 | struct ssp_device *ssp = priv->ssp; |
---|
122 | 121 | |
---|
123 | | - if (!cpu_dai->active) { |
---|
| 122 | + if (!snd_soc_dai_active(cpu_dai)) { |
---|
124 | 123 | pxa_ssp_disable(ssp); |
---|
125 | 124 | clk_disable_unprepare(ssp->clk); |
---|
126 | 125 | } |
---|
| 126 | + |
---|
| 127 | + if (priv->extclk) |
---|
| 128 | + clk_disable_unprepare(priv->extclk); |
---|
127 | 129 | |
---|
128 | 130 | kfree(snd_soc_dai_get_dma_data(cpu_dai, substream)); |
---|
129 | 131 | snd_soc_dai_set_dma_data(cpu_dai, substream, NULL); |
---|
.. | .. |
---|
131 | 133 | |
---|
132 | 134 | #ifdef CONFIG_PM |
---|
133 | 135 | |
---|
134 | | -static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) |
---|
| 136 | +static int pxa_ssp_suspend(struct snd_soc_component *component) |
---|
135 | 137 | { |
---|
136 | | - struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
---|
| 138 | + struct ssp_priv *priv = snd_soc_component_get_drvdata(component); |
---|
137 | 139 | struct ssp_device *ssp = priv->ssp; |
---|
138 | 140 | |
---|
139 | | - if (!cpu_dai->active) |
---|
| 141 | + if (!snd_soc_component_active(component)) |
---|
140 | 142 | clk_prepare_enable(ssp->clk); |
---|
141 | 143 | |
---|
142 | 144 | priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0); |
---|
.. | .. |
---|
149 | 151 | return 0; |
---|
150 | 152 | } |
---|
151 | 153 | |
---|
152 | | -static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) |
---|
| 154 | +static int pxa_ssp_resume(struct snd_soc_component *component) |
---|
153 | 155 | { |
---|
154 | | - struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); |
---|
| 156 | + struct ssp_priv *priv = snd_soc_component_get_drvdata(component); |
---|
155 | 157 | struct ssp_device *ssp = priv->ssp; |
---|
156 | 158 | uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE; |
---|
157 | 159 | |
---|
.. | .. |
---|
163 | 165 | __raw_writel(priv->to, ssp->mmio_base + SSTO); |
---|
164 | 166 | __raw_writel(priv->psp, ssp->mmio_base + SSPSP); |
---|
165 | 167 | |
---|
166 | | - if (cpu_dai->active) |
---|
| 168 | + if (snd_soc_component_active(component)) |
---|
167 | 169 | pxa_ssp_enable(ssp); |
---|
168 | 170 | else |
---|
169 | 171 | clk_disable_unprepare(ssp->clk); |
---|
.. | .. |
---|
176 | 178 | #define pxa_ssp_resume NULL |
---|
177 | 179 | #endif |
---|
178 | 180 | |
---|
179 | | -/** |
---|
| 181 | +/* |
---|
180 | 182 | * ssp_set_clkdiv - set SSP clock divider |
---|
181 | 183 | * @div: serial clock rate divider |
---|
182 | 184 | */ |
---|
.. | .. |
---|
221 | 223 | clk_id = PXA_SSP_CLK_EXT; |
---|
222 | 224 | } |
---|
223 | 225 | |
---|
224 | | - dev_dbg(&ssp->pdev->dev, |
---|
| 226 | + dev_dbg(ssp->dev, |
---|
225 | 227 | "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n", |
---|
226 | 228 | cpu_dai->id, clk_id, freq); |
---|
227 | 229 | |
---|
.. | .. |
---|
314 | 316 | |
---|
315 | 317 | ssacd |= (0x6 << 4); |
---|
316 | 318 | |
---|
317 | | - dev_dbg(&ssp->pdev->dev, |
---|
| 319 | + dev_dbg(ssp->dev, |
---|
318 | 320 | "Using SSACDD %x to supply %uHz\n", |
---|
319 | 321 | val, freq); |
---|
320 | 322 | break; |
---|
.. | .. |
---|
486 | 488 | |
---|
487 | 489 | case SND_SOC_DAIFMT_DSP_A: |
---|
488 | 490 | sspsp |= SSPSP_FSRT; |
---|
489 | | - /* fall through */ |
---|
| 491 | + fallthrough; |
---|
490 | 492 | case SND_SOC_DAIFMT_DSP_B: |
---|
491 | 493 | sscr0 |= SSCR0_MOD | SSCR0_PSP; |
---|
492 | 494 | sscr1 |= SSCR1_TRAIL | SSCR1_RWOT; |
---|
.. | .. |
---|
685 | 687 | * - complain loudly and fail if they've not been set up yet. |
---|
686 | 688 | */ |
---|
687 | 689 | if ((sscr0 & SSCR0_MOD) && !ttsa) { |
---|
688 | | - dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); |
---|
| 690 | + dev_err(ssp->dev, "No TDM timeslot configured\n"); |
---|
689 | 691 | return -EINVAL; |
---|
690 | 692 | } |
---|
691 | 693 | |
---|
.. | .. |
---|
848 | 850 | static struct snd_soc_dai_driver pxa_ssp_dai = { |
---|
849 | 851 | .probe = pxa_ssp_probe, |
---|
850 | 852 | .remove = pxa_ssp_remove, |
---|
851 | | - .suspend = pxa_ssp_suspend, |
---|
852 | | - .resume = pxa_ssp_resume, |
---|
853 | 853 | .playback = { |
---|
854 | 854 | .channels_min = 1, |
---|
855 | 855 | .channels_max = 8, |
---|
.. | .. |
---|
867 | 867 | |
---|
868 | 868 | static const struct snd_soc_component_driver pxa_ssp_component = { |
---|
869 | 869 | .name = "pxa-ssp", |
---|
870 | | - .ops = &pxa2xx_pcm_ops, |
---|
871 | | - .pcm_new = pxa2xx_soc_pcm_new, |
---|
872 | | - .pcm_free = pxa2xx_pcm_free_dma_buffers, |
---|
| 870 | + .pcm_construct = pxa2xx_soc_pcm_new, |
---|
| 871 | + .pcm_destruct = pxa2xx_soc_pcm_free, |
---|
| 872 | + .open = pxa2xx_soc_pcm_open, |
---|
| 873 | + .close = pxa2xx_soc_pcm_close, |
---|
| 874 | + .hw_params = pxa2xx_soc_pcm_hw_params, |
---|
| 875 | + .hw_free = pxa2xx_soc_pcm_hw_free, |
---|
| 876 | + .prepare = pxa2xx_soc_pcm_prepare, |
---|
| 877 | + .trigger = pxa2xx_soc_pcm_trigger, |
---|
| 878 | + .pointer = pxa2xx_soc_pcm_pointer, |
---|
| 879 | + .mmap = pxa2xx_soc_pcm_mmap, |
---|
| 880 | + .suspend = pxa_ssp_suspend, |
---|
| 881 | + .resume = pxa_ssp_resume, |
---|
873 | 882 | }; |
---|
874 | 883 | |
---|
875 | 884 | #ifdef CONFIG_OF |
---|