Commit fbe7a5db authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: rt5682: Use clk APIs better" from Stephen Boyd <swboyd@chromium.org>:

This patch series drops a printk message down to dev_dbg() because it
was noisy and then migrates this driver to use clk_hw based APIs instead
of clk based APIs because this device is a clk provider, not a clk
consumer. I've only lightly tested the last two patches but I don't have
all combinations of clks for this device.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Shuming Fan <shumingf@realtek.com>

Stephen Boyd (3):
  ASoC: rt5682: Use dev_dbg() in rt5682_clk_check()
  ASoC: rt5682: Drop usage of __clk_get_name()
  ASoC: rt5682: Use clk_hw based APIs for registration

 sound/soc/codecs/rt5682.c | 73 ++++++++++++---------------------------
 sound/soc/codecs/rt5682.h |  2 --
 2 files changed, 23 insertions(+), 52 deletions(-)

Based on the last patch to this driver in linux-next.

base-commit: 6301adf9
--
Sent by a computer, using git, on the internet
parents 9af73c31 653bdab2
...@@ -2481,7 +2481,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component, ...@@ -2481,7 +2481,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component,
static bool rt5682_clk_check(struct rt5682_priv *rt5682) static bool rt5682_clk_check(struct rt5682_priv *rt5682)
{ {
if (!rt5682->master[RT5682_AIF1]) { if (!rt5682->master[RT5682_AIF1]) {
dev_err(rt5682->component->dev, "sysclk/dai not set correctly\n"); dev_dbg(rt5682->component->dev, "sysclk/dai not set correctly\n");
return false; return false;
} }
return true; return true;
...@@ -2559,7 +2559,7 @@ static unsigned long rt5682_wclk_recalc_rate(struct clk_hw *hw, ...@@ -2559,7 +2559,7 @@ static unsigned long rt5682_wclk_recalc_rate(struct clk_hw *hw,
container_of(hw, struct rt5682_priv, container_of(hw, struct rt5682_priv,
dai_clks_hw[RT5682_DAI_WCLK_IDX]); dai_clks_hw[RT5682_DAI_WCLK_IDX]);
struct snd_soc_component *component = rt5682->component; struct snd_soc_component *component = rt5682->component;
const char * const clk_name = __clk_get_name(hw->clk); const char * const clk_name = clk_hw_get_name(hw);
if (!rt5682_clk_check(rt5682)) if (!rt5682_clk_check(rt5682))
return 0; return 0;
...@@ -2583,7 +2583,7 @@ static long rt5682_wclk_round_rate(struct clk_hw *hw, unsigned long rate, ...@@ -2583,7 +2583,7 @@ static long rt5682_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
container_of(hw, struct rt5682_priv, container_of(hw, struct rt5682_priv,
dai_clks_hw[RT5682_DAI_WCLK_IDX]); dai_clks_hw[RT5682_DAI_WCLK_IDX]);
struct snd_soc_component *component = rt5682->component; struct snd_soc_component *component = rt5682->component;
const char * const clk_name = __clk_get_name(hw->clk); const char * const clk_name = clk_hw_get_name(hw);
if (!rt5682_clk_check(rt5682)) if (!rt5682_clk_check(rt5682))
return -EINVAL; return -EINVAL;
...@@ -2608,7 +2608,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -2608,7 +2608,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
dai_clks_hw[RT5682_DAI_WCLK_IDX]); dai_clks_hw[RT5682_DAI_WCLK_IDX]);
struct snd_soc_component *component = rt5682->component; struct snd_soc_component *component = rt5682->component;
struct clk *parent_clk; struct clk *parent_clk;
const char * const clk_name = __clk_get_name(hw->clk); const char * const clk_name = clk_hw_get_name(hw);
int pre_div; int pre_div;
unsigned int clk_pll2_out; unsigned int clk_pll2_out;
...@@ -2766,39 +2766,34 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component) ...@@ -2766,39 +2766,34 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component)
struct device *dev = component->dev; struct device *dev = component->dev;
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
struct rt5682_platform_data *pdata = &rt5682->pdata; struct rt5682_platform_data *pdata = &rt5682->pdata;
struct clk_init_data init;
struct clk *dai_clk;
struct clk_lookup *dai_clk_lookup;
struct clk_hw *dai_clk_hw; struct clk_hw *dai_clk_hw;
const char *parent_name;
int i, ret; int i, ret;
for (i = 0; i < RT5682_DAI_NUM_CLKS; ++i) { for (i = 0; i < RT5682_DAI_NUM_CLKS; ++i) {
struct clk_init_data init = { };
dai_clk_hw = &rt5682->dai_clks_hw[i]; dai_clk_hw = &rt5682->dai_clks_hw[i];
switch (i) { switch (i) {
case RT5682_DAI_WCLK_IDX: case RT5682_DAI_WCLK_IDX:
/* Make MCLK the parent of WCLK */ /* Make MCLK the parent of WCLK */
if (rt5682->mclk) { if (rt5682->mclk) {
parent_name = __clk_get_name(rt5682->mclk); init.parent_data = &(struct clk_parent_data){
init.parent_names = &parent_name; .fw_name = "mclk",
};
init.num_parents = 1; init.num_parents = 1;
} else {
init.parent_names = NULL;
init.num_parents = 0;
} }
break; break;
case RT5682_DAI_BCLK_IDX: case RT5682_DAI_BCLK_IDX:
/* Make WCLK the parent of BCLK */ /* Make WCLK the parent of BCLK */
parent_name = __clk_get_name( init.parent_hws = &(const struct clk_hw *){
rt5682->dai_clks[RT5682_DAI_WCLK_IDX]); &rt5682->dai_clks_hw[RT5682_DAI_WCLK_IDX]
init.parent_names = &parent_name; };
init.num_parents = 1; init.num_parents = 1;
break; break;
default: default:
dev_err(dev, "Invalid clock index\n"); dev_err(dev, "Invalid clock index\n");
ret = -EINVAL; return -EINVAL;
goto err;
} }
init.name = pdata->dai_clk_names[i]; init.name = pdata->dai_clk_names[i];
...@@ -2806,39 +2801,26 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component) ...@@ -2806,39 +2801,26 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component)
init.flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_GATE; init.flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_GATE;
dai_clk_hw->init = &init; dai_clk_hw->init = &init;
dai_clk = devm_clk_register(dev, dai_clk_hw); ret = devm_clk_hw_register(dev, dai_clk_hw);
if (IS_ERR(dai_clk)) { if (ret) {
dev_warn(dev, "Failed to register %s: %ld\n", dev_warn(dev, "Failed to register %s: %d\n",
init.name, PTR_ERR(dai_clk)); init.name, ret);
ret = PTR_ERR(dai_clk); return ret;
goto err;
} }
rt5682->dai_clks[i] = dai_clk;
if (dev->of_node) { if (dev->of_node) {
devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
dai_clk_hw); dai_clk_hw);
} else { } else {
dai_clk_lookup = clkdev_create(dai_clk, init.name, ret = devm_clk_hw_register_clkdev(dev, dai_clk_hw,
"%s", dev_name(dev)); init.name,
if (!dai_clk_lookup) { dev_name(dev));
ret = -ENOMEM; if (ret)
goto err; return ret;
} else {
rt5682->dai_clks_lookup[i] = dai_clk_lookup;
}
} }
} }
return 0; return 0;
err:
do {
if (rt5682->dai_clks_lookup[i])
clkdev_drop(rt5682->dai_clks_lookup[i]);
} while (i-- > 0);
return ret;
} }
#endif /* CONFIG_COMMON_CLK */ #endif /* CONFIG_COMMON_CLK */
...@@ -2895,15 +2877,6 @@ static void rt5682_remove(struct snd_soc_component *component) ...@@ -2895,15 +2877,6 @@ static void rt5682_remove(struct snd_soc_component *component)
{ {
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
#ifdef CONFIG_COMMON_CLK
int i;
for (i = RT5682_DAI_NUM_CLKS - 1; i >= 0; --i) {
if (rt5682->dai_clks_lookup[i])
clkdev_drop(rt5682->dai_clks_lookup[i]);
}
#endif
rt5682_reset(rt5682); rt5682_reset(rt5682);
} }
......
...@@ -1411,8 +1411,6 @@ struct rt5682_priv { ...@@ -1411,8 +1411,6 @@ struct rt5682_priv {
#ifdef CONFIG_COMMON_CLK #ifdef CONFIG_COMMON_CLK
struct clk_hw dai_clks_hw[RT5682_DAI_NUM_CLKS]; struct clk_hw dai_clks_hw[RT5682_DAI_NUM_CLKS];
struct clk_lookup *dai_clks_lookup[RT5682_DAI_NUM_CLKS];
struct clk *dai_clks[RT5682_DAI_NUM_CLKS];
struct clk *mclk; struct clk *mclk;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment