forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/pxa/pxa-ssp.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * pxa-ssp.c -- ALSA Soc Audio Layer
34 *
45 * Copyright 2005,2008 Wolfson Microelectronics PLC.
56 * Author: Liam Girdwood
67 * 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.
128 *
139 * TODO:
1410 * o Test network mode for > 16bit sample size
....@@ -56,11 +52,11 @@
5652
5753 static void dump_registers(struct ssp_device *ssp)
5854 {
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",
6056 pxa_ssp_read_reg(ssp, SSCR0), pxa_ssp_read_reg(ssp, SSCR1),
6157 pxa_ssp_read_reg(ssp, SSTO));
6258
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",
6460 pxa_ssp_read_reg(ssp, SSPSP), pxa_ssp_read_reg(ssp, SSSR),
6561 pxa_ssp_read_reg(ssp, SSACD));
6662 }
....@@ -98,10 +94,13 @@
9894 struct snd_dmaengine_dai_dma_data *dma;
9995 int ret = 0;
10096
101
- if (!cpu_dai->active) {
97
+ if (!snd_soc_dai_active(cpu_dai)) {
10298 clk_prepare_enable(ssp->clk);
10399 pxa_ssp_disable(ssp);
104100 }
101
+
102
+ if (priv->extclk)
103
+ clk_prepare_enable(priv->extclk);
105104
106105 dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL);
107106 if (!dma)
....@@ -120,10 +119,13 @@
120119 struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
121120 struct ssp_device *ssp = priv->ssp;
122121
123
- if (!cpu_dai->active) {
122
+ if (!snd_soc_dai_active(cpu_dai)) {
124123 pxa_ssp_disable(ssp);
125124 clk_disable_unprepare(ssp->clk);
126125 }
126
+
127
+ if (priv->extclk)
128
+ clk_disable_unprepare(priv->extclk);
127129
128130 kfree(snd_soc_dai_get_dma_data(cpu_dai, substream));
129131 snd_soc_dai_set_dma_data(cpu_dai, substream, NULL);
....@@ -131,12 +133,12 @@
131133
132134 #ifdef CONFIG_PM
133135
134
-static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
136
+static int pxa_ssp_suspend(struct snd_soc_component *component)
135137 {
136
- struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
138
+ struct ssp_priv *priv = snd_soc_component_get_drvdata(component);
137139 struct ssp_device *ssp = priv->ssp;
138140
139
- if (!cpu_dai->active)
141
+ if (!snd_soc_component_active(component))
140142 clk_prepare_enable(ssp->clk);
141143
142144 priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0);
....@@ -149,9 +151,9 @@
149151 return 0;
150152 }
151153
152
-static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
154
+static int pxa_ssp_resume(struct snd_soc_component *component)
153155 {
154
- struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
156
+ struct ssp_priv *priv = snd_soc_component_get_drvdata(component);
155157 struct ssp_device *ssp = priv->ssp;
156158 uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE;
157159
....@@ -163,7 +165,7 @@
163165 __raw_writel(priv->to, ssp->mmio_base + SSTO);
164166 __raw_writel(priv->psp, ssp->mmio_base + SSPSP);
165167
166
- if (cpu_dai->active)
168
+ if (snd_soc_component_active(component))
167169 pxa_ssp_enable(ssp);
168170 else
169171 clk_disable_unprepare(ssp->clk);
....@@ -176,7 +178,7 @@
176178 #define pxa_ssp_resume NULL
177179 #endif
178180
179
-/**
181
+/*
180182 * ssp_set_clkdiv - set SSP clock divider
181183 * @div: serial clock rate divider
182184 */
....@@ -221,7 +223,7 @@
221223 clk_id = PXA_SSP_CLK_EXT;
222224 }
223225
224
- dev_dbg(&ssp->pdev->dev,
226
+ dev_dbg(ssp->dev,
225227 "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n",
226228 cpu_dai->id, clk_id, freq);
227229
....@@ -314,7 +316,7 @@
314316
315317 ssacd |= (0x6 << 4);
316318
317
- dev_dbg(&ssp->pdev->dev,
319
+ dev_dbg(ssp->dev,
318320 "Using SSACDD %x to supply %uHz\n",
319321 val, freq);
320322 break;
....@@ -486,7 +488,7 @@
486488
487489 case SND_SOC_DAIFMT_DSP_A:
488490 sspsp |= SSPSP_FSRT;
489
- /* fall through */
491
+ fallthrough;
490492 case SND_SOC_DAIFMT_DSP_B:
491493 sscr0 |= SSCR0_MOD | SSCR0_PSP;
492494 sscr1 |= SSCR1_TRAIL | SSCR1_RWOT;
....@@ -685,7 +687,7 @@
685687 * - complain loudly and fail if they've not been set up yet.
686688 */
687689 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");
689691 return -EINVAL;
690692 }
691693
....@@ -848,8 +850,6 @@
848850 static struct snd_soc_dai_driver pxa_ssp_dai = {
849851 .probe = pxa_ssp_probe,
850852 .remove = pxa_ssp_remove,
851
- .suspend = pxa_ssp_suspend,
852
- .resume = pxa_ssp_resume,
853853 .playback = {
854854 .channels_min = 1,
855855 .channels_max = 8,
....@@ -867,9 +867,18 @@
867867
868868 static const struct snd_soc_component_driver pxa_ssp_component = {
869869 .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,
873882 };
874883
875884 #ifdef CONFIG_OF