forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/samsung/s3c2412-i2s.c
....@@ -1,20 +1,14 @@
1
-/* sound/soc/samsung/s3c2412-i2s.c
2
- *
3
- * ALSA Soc Audio Layer - S3C2412 I2S driver
4
- *
5
- * Copyright (c) 2006 Wolfson Microelectronics PLC.
6
- * Graeme Gregory graeme.gregory@wolfsonmicro.com
7
- * linux@wolfsonmicro.com
8
- *
9
- * Copyright (c) 2007, 2004-2005 Simtec Electronics
10
- * http://armlinux.simtec.co.uk/
11
- * Ben Dooks <ben@simtec.co.uk>
12
- *
13
- * This program is free software; you can redistribute it and/or modify it
14
- * under the terms of the GNU General Public License as published by the
15
- * Free Software Foundation; either version 2 of the License, or (at your
16
- * option) any later version.
17
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// ALSA Soc Audio Layer - S3C2412 I2S driver
4
+//
5
+// Copyright (c) 2006 Wolfson Microelectronics PLC.
6
+// Graeme Gregory graeme.gregory@wolfsonmicro.com
7
+// linux@wolfsonmicro.com
8
+//
9
+// Copyright (c) 2007, 2004-2005 Simtec Electronics
10
+// http://armlinux.simtec.co.uk/
11
+// Ben Dooks <ben@simtec.co.uk>
1812
1913 #include <linux/delay.h>
2014 #include <linux/gpio.h>
....@@ -24,9 +18,6 @@
2418
2519 #include <sound/soc.h>
2620 #include <sound/pcm_params.h>
27
-
28
-#include <mach/gpio-samsung.h>
29
-#include <plat/gpio-cfg.h>
3021
3122 #include "dma.h"
3223 #include "regs-i2s-v2.h"
....@@ -55,7 +46,7 @@
5546 snd_soc_dai_init_dma_data(dai, &s3c2412_i2s_pcm_stereo_out,
5647 &s3c2412_i2s_pcm_stereo_in);
5748
58
- ret = s3c_i2sv2_probe(dai, &s3c2412_i2s, S3C2410_PA_IIS);
49
+ ret = s3c_i2sv2_probe(dai, &s3c2412_i2s);
5950 if (ret)
6051 return ret;
6152
....@@ -75,10 +66,6 @@
7566 ret = clk_prepare_enable(s3c2412_i2s.iis_cclk);
7667 if (ret)
7768 goto err;
78
-
79
- /* Configure the I2S pins (GPE0...GPE4) in correct mode */
80
- s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
81
- S3C_GPIO_PULL_NONE);
8269
8370 return 0;
8471
....@@ -123,6 +110,60 @@
123110 return 0;
124111 }
125112
113
+#ifdef CONFIG_PM
114
+static int s3c2412_i2s_suspend(struct snd_soc_component *component)
115
+{
116
+ struct s3c_i2sv2_info *i2s = snd_soc_component_get_drvdata(component);
117
+ u32 iismod;
118
+
119
+ if (component->active) {
120
+ i2s->suspend_iismod = readl(i2s->regs + S3C2412_IISMOD);
121
+ i2s->suspend_iiscon = readl(i2s->regs + S3C2412_IISCON);
122
+ i2s->suspend_iispsr = readl(i2s->regs + S3C2412_IISPSR);
123
+
124
+ /* some basic suspend checks */
125
+
126
+ iismod = readl(i2s->regs + S3C2412_IISMOD);
127
+
128
+ if (iismod & S3C2412_IISCON_RXDMA_ACTIVE)
129
+ pr_warn("%s: RXDMA active?\n", __func__);
130
+
131
+ if (iismod & S3C2412_IISCON_TXDMA_ACTIVE)
132
+ pr_warn("%s: TXDMA active?\n", __func__);
133
+
134
+ if (iismod & S3C2412_IISCON_IIS_ACTIVE)
135
+ pr_warn("%s: IIS active\n", __func__);
136
+ }
137
+
138
+ return 0;
139
+}
140
+
141
+static int s3c2412_i2s_resume(struct snd_soc_component *component)
142
+{
143
+ struct s3c_i2sv2_info *i2s = snd_soc_component_get_drvdata(component);
144
+
145
+ pr_info("component_active %d, IISMOD %08x, IISCON %08x\n",
146
+ component->active, i2s->suspend_iismod, i2s->suspend_iiscon);
147
+
148
+ if (component->active) {
149
+ writel(i2s->suspend_iiscon, i2s->regs + S3C2412_IISCON);
150
+ writel(i2s->suspend_iismod, i2s->regs + S3C2412_IISMOD);
151
+ writel(i2s->suspend_iispsr, i2s->regs + S3C2412_IISPSR);
152
+
153
+ writel(S3C2412_IISFIC_RXFLUSH | S3C2412_IISFIC_TXFLUSH,
154
+ i2s->regs + S3C2412_IISFIC);
155
+
156
+ ndelay(250);
157
+ writel(0x0, i2s->regs + S3C2412_IISFIC);
158
+ }
159
+
160
+ return 0;
161
+}
162
+#else
163
+#define s3c2412_i2s_suspend NULL
164
+#define s3c2412_i2s_resume NULL
165
+#endif
166
+
126167 #define S3C2412_I2S_RATES \
127168 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
128169 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
....@@ -152,6 +193,8 @@
152193
153194 static const struct snd_soc_component_driver s3c2412_i2s_component = {
154195 .name = "s3c2412-i2s",
196
+ .suspend = s3c2412_i2s_suspend,
197
+ .resume = s3c2412_i2s_resume,
155198 };
156199
157200 static int s3c2412_iis_dev_probe(struct platform_device *pdev)
....@@ -177,7 +220,7 @@
177220
178221 ret = samsung_asoc_dma_platform_register(&pdev->dev,
179222 pdata->dma_filter,
180
- NULL, NULL);
223
+ "tx", "rx", NULL);
181224 if (ret) {
182225 pr_err("failed to register the DMA: %d\n", ret);
183226 return ret;