aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sh
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2014-01-23 21:41:10 -0500
committerMark Brown <broonie@linaro.org>2014-02-03 07:41:37 -0500
commit28dc4b63cdb96f2448a677320fcc0eb112e13e3f (patch)
tree3cf5e71537e640c426db51206a9864bc0f875279 /sound/soc/sh
parent96c7c0d6f8c6e09e9123f0518130c047c5de40f6 (diff)
ASoC: rsnd: merge SRC clock timing/setting
SRC clock and timing setting register exist in SRU and ADG on Gen1. But, these are merged into ADG on Gen2. Current driver is supporting Gen1 SRC only at this point, but, above settings are set as different function. This patch merges these as preparation of Gen2 support. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/sh')
-rw-r--r--sound/soc/sh/rcar/adg.c20
-rw-r--r--sound/soc/sh/rcar/rsnd.h8
-rw-r--r--sound/soc/sh/rcar/scu.c48
3 files changed, 43 insertions, 33 deletions
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index a53235c4d1b0..5bdffa480245 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -30,10 +30,10 @@ struct rsnd_adg {
30 i++, (pos) = adg->clk[i]) 30 i++, (pos) = adg->clk[i])
31#define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg) 31#define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg)
32 32
33static int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv, 33int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
34 struct rsnd_mod *mod, 34 struct rsnd_mod *mod,
35 unsigned int src_rate, 35 unsigned int src_rate,
36 unsigned int dst_rate) 36 unsigned int dst_rate)
37{ 37{
38 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 38 struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
39 struct device *dev = rsnd_priv_to_dev(priv); 39 struct device *dev = rsnd_priv_to_dev(priv);
@@ -91,18 +91,6 @@ find_rate:
91 return 0; 91 return 0;
92} 92}
93 93
94int rsnd_adg_set_convert_clk(struct rsnd_priv *priv,
95 struct rsnd_mod *mod,
96 unsigned int src_rate,
97 unsigned int dst_rate)
98{
99 if (rsnd_is_gen1(priv))
100 return rsnd_adg_set_convert_clk_gen1(priv, mod,
101 src_rate, dst_rate);
102
103 return -EINVAL;
104}
105
106static void rsnd_adg_set_ssi_clk(struct rsnd_mod *mod, u32 val) 94static void rsnd_adg_set_ssi_clk(struct rsnd_mod *mod, u32 val)
107{ 95{
108 int id = rsnd_mod_id(mod); 96 int id = rsnd_mod_id(mod);
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index a9c58305e2f1..39914558e857 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -246,10 +246,10 @@ int rsnd_adg_probe(struct platform_device *pdev,
246 struct rsnd_priv *priv); 246 struct rsnd_priv *priv);
247void rsnd_adg_remove(struct platform_device *pdev, 247void rsnd_adg_remove(struct platform_device *pdev,
248 struct rsnd_priv *priv); 248 struct rsnd_priv *priv);
249int rsnd_adg_set_convert_clk(struct rsnd_priv *priv, 249int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
250 struct rsnd_mod *mod, 250 struct rsnd_mod *mod,
251 unsigned int src_rate, 251 unsigned int src_rate,
252 unsigned int dst_rate); 252 unsigned int dst_rate);
253 253
254/* 254/*
255 * R-Car sound priv 255 * R-Car sound priv
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c
index 2f839f72c99c..e2ffcc415057 100644
--- a/sound/soc/sh/rcar/scu.c
+++ b/sound/soc/sh/rcar/scu.c
@@ -172,10 +172,8 @@ static int rsnd_src_set_route_if_gen1(
172 { 0x3, 30, }, /* 8 */ 172 { 0x3, 30, }, /* 8 */
173 }; 173 };
174 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 174 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
175 struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
176 u32 mask; 175 u32 mask;
177 u32 val; 176 u32 val;
178 int shift;
179 int id; 177 int id;
180 178
181 /* 179 /*
@@ -197,6 +195,23 @@ static int rsnd_src_set_route_if_gen1(
197 195
198 rsnd_mod_bset(mod, SRC_ROUTE_SEL, mask, val); 196 rsnd_mod_bset(mod, SRC_ROUTE_SEL, mask, val);
199 197
198 return 0;
199}
200
201static int rsnd_scu_set_convert_timing_gen1(struct rsnd_mod *mod,
202 struct rsnd_dai *rdai,
203 struct rsnd_dai_stream *io)
204{
205 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
206 struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
207 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
208 u32 convert_rate = rsnd_scu_convert_rate(scu);
209 u32 mask;
210 u32 val;
211 int shift;
212 int id = rsnd_mod_id(mod);
213 int ret;
214
200 /* 215 /*
201 * SRC_TIMING_SELECT 216 * SRC_TIMING_SELECT
202 */ 217 */
@@ -209,12 +224,23 @@ static int rsnd_src_set_route_if_gen1(
209 * SSI WS is used as source clock if SRC is not used 224 * SSI WS is used as source clock if SRC is not used
210 * (when playback, source/destination become reverse when capture) 225 * (when playback, source/destination become reverse when capture)
211 */ 226 */
212 if (rsnd_scu_convert_rate(scu)) /* use ADG */ 227 ret = 0;
228 if (convert_rate) {
229 /* use ADG */
213 val = 0; 230 val = 0;
214 else if (8 == id) /* use SSI WS, but SRU8 is special */ 231 ret = rsnd_adg_set_convert_clk_gen1(priv, mod,
232 runtime->rate,
233 convert_rate);
234 } else if (8 == id) {
235 /* use SSI WS, but SRU8 is special */
215 val = id << shift; 236 val = id << shift;
216 else /* use SSI WS */ 237 } else {
238 /* use SSI WS */
217 val = (id + 1) << shift; 239 val = (id + 1) << shift;
240 }
241
242 if (ret < 0)
243 return ret;
218 244
219 switch (id / 4) { 245 switch (id / 4) {
220 case 0: 246 case 0:
@@ -284,7 +310,6 @@ static int rsnd_scu_set_convert_rate(struct rsnd_mod *mod,
284 310
285 if (convert_rate) { 311 if (convert_rate) {
286 u32 fsrate = 0x0400000 / convert_rate * runtime->rate; 312 u32 fsrate = 0x0400000 / convert_rate * runtime->rate;
287 int ret;
288 313
289 /* Enable the initial value of IFS */ 314 /* Enable the initial value of IFS */
290 rsnd_mod_write(mod, SRC_IFSCR, 1); 315 rsnd_mod_write(mod, SRC_IFSCR, 1);
@@ -301,13 +326,6 @@ static int rsnd_scu_set_convert_rate(struct rsnd_mod *mod,
301 if (rsnd_is_gen1(priv)) { 326 if (rsnd_is_gen1(priv)) {
302 /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */ 327 /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */
303 } 328 }
304
305 /* set convert clock */
306 ret = rsnd_adg_set_convert_clk(priv, mod,
307 runtime->rate,
308 convert_rate);
309 if (ret < 0)
310 return ret;
311 } 329 }
312 330
313 /* Cancel the initialization and operate the SRC function */ 331 /* Cancel the initialization and operate the SRC function */
@@ -340,6 +358,10 @@ static int rsnd_scu_init(struct rsnd_mod *mod,
340 if (ret < 0) 358 if (ret < 0)
341 return ret; 359 return ret;
342 360
361 ret = rsnd_scu_set_convert_timing_gen1(mod, rdai, io);
362 if (ret < 0)
363 return ret;
364
343 return 0; 365 return 0;
344} 366}
345 367