From 45ac4ca12af784230d0c5b882dc03a963fe33d12 Mon Sep 17 00:00:00 2001 From: Sumit Bhattacharya Date: Tue, 21 Jun 2011 15:39:32 +0530 Subject: ARM: tegra: Enable cdev1 clk from board file Enabling cdev1 clk or DAP Mclk from board file instead of codec soc file because Mclk needs to be enabled before codec initialization. Also exposing set_parent() for cdev clocks so that it is possible to enable them from board file. Bug 827709 Bug 839210 Bug 821178 Reviewed-on: http://git-master/r/37631 (cherry picked from commit 6643460bd1fa0b8cdf9ddfc75dd3dd228093819f) Change-Id: Ie7fa948aead75c6e7e6c32a280ee336d8341ccbe Reviewed-on: http://git-master/r/44978 Tested-by: Sumit Bhattacharya Reviewed-by: Bharat Nihalani --- arch/arm/mach-tegra/board-ventana.c | 1 + arch/arm/mach-tegra/tegra2_clocks.c | 36 +++++++++++++++++++++++++----------- sound/soc/tegra/tegra_soc_wm8903.c | 1 - 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-tegra/board-ventana.c b/arch/arm/mach-tegra/board-ventana.c index 04beec75935d..146856df0977 100644 --- a/arch/arm/mach-tegra/board-ventana.c +++ b/arch/arm/mach-tegra/board-ventana.c @@ -309,6 +309,7 @@ static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = { { "pwm", "clk_32k", 32768, false}, { "pll_a", NULL, 56448000, false}, { "pll_a_out0", NULL, 11289600, false}, + { "clk_dev1", "pll_a_out0", 0, true}, { "i2s1", "pll_a_out0", 11289600, false}, { "i2s2", "pll_a_out0", 11289600, false}, { "audio", "pll_a_out0", 11289600, false}, diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c index a48baf9c8d35..15f3b75cbdee 100644 --- a/arch/arm/mach-tegra/tegra2_clocks.c +++ b/arch/arm/mach-tegra/tegra2_clocks.c @@ -1233,25 +1233,38 @@ static struct clk_ops tegra_audio_sync_clk_ops = { }; /* call this function after pinmux configuration */ -static void tegra2_cdev_clk_set_parent(struct clk *c) +static int tegra2_cdev_clk_set_parent(struct clk *c, struct clk *p) { const struct clk_mux_sel *mux = 0; const struct clk_mux_sel *sel; enum tegra_pingroup pg = TEGRA_PINGROUP_CDEV1; int val; - /* Get pinmux setting for cdev1 and cdev2 from APB_MISC register */ - if (!strcmp(c->name, "clk_dev2")) - pg = TEGRA_PINGROUP_CDEV2; + if (p) { + for (sel = c->inputs; sel->input != NULL; sel++) { + if (sel->input == p) { + clk_reparent(c, p); + return 0; + } + } + } + else { + /* Get pinmux setting for cdev1 and cdev2 from APB_MISC reg */ + if (!strcmp(c->name, "clk_dev2")) + pg = TEGRA_PINGROUP_CDEV2; - val = tegra_pinmux_get_func(pg); - for (sel = c->inputs; sel->input != NULL; sel++) { - if (val == sel->value) - mux = sel; + val = tegra_pinmux_get_func(pg); + for (sel = c->inputs; sel->input != NULL; sel++) { + if (val == sel->value) { + mux = sel; + BUG_ON(!mux); + clk_reparent(c, mux->input); + return 0; + } + } } - BUG_ON(!mux); - c->parent = mux->input; + return -EINVAL; } /* cdev1 and cdev2 (dap_mclk1 and dap_mclk2) ops */ @@ -1276,7 +1289,7 @@ static int tegra2_cdev_clk_enable(struct clk *c) { if (!c->parent) { /* Set parent from inputs */ - tegra2_cdev_clk_set_parent(c); + tegra2_cdev_clk_set_parent(c, NULL); clk_enable(c->parent); } @@ -1295,6 +1308,7 @@ static struct clk_ops tegra_cdev_clk_ops = { .init = &tegra2_cdev_clk_init, .enable = &tegra2_cdev_clk_enable, .disable = &tegra2_cdev_clk_disable, + .set_parent = &tegra2_cdev_clk_set_parent, }; /* shared bus ops */ diff --git a/sound/soc/tegra/tegra_soc_wm8903.c b/sound/soc/tegra/tegra_soc_wm8903.c index 2483d2efb115..bad6c1f80966 100644 --- a/sound/soc/tegra/tegra_soc_wm8903.c +++ b/sound/soc/tegra/tegra_soc_wm8903.c @@ -516,7 +516,6 @@ static int tegra_codec_init(struct snd_soc_codec *codec) err = -ENODEV; return err; } - clk_enable(audio_data->dap_mclk); /* Add tegra specific widgets */ snd_soc_dapm_new_controls(codec, tegra_dapm_widgets, -- cgit v1.2.3