From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current R-Car sound driver is using device independent audio clock, but it is not good design for DT (= common clock) support. This patch adds device dependent clock support. But, there are some platform which is using old style clock. Old style clock is still supported at this point, but it will be removed soon.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/adg.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index a53235c..e82ab75 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -259,8 +259,9 @@ int rsnd_adg_probe(struct platform_device *pdev, { struct rsnd_adg *adg; struct device *dev = rsnd_priv_to_dev(priv); - struct clk *clk; + struct clk *clk, *clk_orig; int i; + bool use_old_style = false;
adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL); if (!adg) { @@ -268,10 +269,34 @@ int rsnd_adg_probe(struct platform_device *pdev, return -ENOMEM; }
- adg->clk[CLKA] = clk_get(NULL, "audio_clk_a"); - adg->clk[CLKB] = clk_get(NULL, "audio_clk_b"); - adg->clk[CLKC] = clk_get(NULL, "audio_clk_c"); - adg->clk[CLKI] = clk_get(NULL, "audio_clk_internal"); + clk_orig = clk_get(dev, NULL); + adg->clk[CLKA] = clk_get(dev, "clk_a"); + adg->clk[CLKB] = clk_get(dev, "clk_b"); + adg->clk[CLKC] = clk_get(dev, "clk_c"); + adg->clk[CLKI] = clk_get(dev, "clk_i"); + + for_each_rsnd_clk(clk, adg, i) { + if (clk_orig == clk) { + dev_warn(dev, + "Audio clock doesn't support new style," + "use old style\n"); + use_old_style = true; + break; + } + } + + /* + * note: + * these exist in order to keep compatible with old style, + * but will be removed soon + */ + if (use_old_style) { + adg->clk[CLKA] = clk_get(NULL, "audio_clk_a"); + adg->clk[CLKB] = clk_get(NULL, "audio_clk_b"); + adg->clk[CLKC] = clk_get(NULL, "audio_clk_c"); + adg->clk[CLKI] = clk_get(NULL, "audio_clk_internal"); + } + for_each_rsnd_clk(clk, adg, i) { if (IS_ERR(clk)) { dev_err(dev, "Audio clock failed\n");