ASoC: da7219: Add recalc_rate function to return DAI clock rate

By making MCLK parent of DAI clocks, when querying the rate of the
clock the rate returned is now given from the parent clock so
gives the MCLK rate rather than 0 as previously returned. This is
a bit misleading, and actually there's no major reason why we can't
at least return the DAI WCLK rate, as set in HW, so that's what we
now do.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Adam Thomson 2019-01-08 09:13:28 +00:00 committed by Mark Brown
parent a6028cc60a
commit a58943abcb
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 43 additions and 3 deletions

View File

@ -1767,7 +1767,7 @@ static int da7219_dai_clks_prepare(struct clk_hw *hw)
{
struct da7219_priv *da7219 =
container_of(hw, struct da7219_priv, dai_clks_hw);
struct snd_soc_component *component = da7219->aad->component;
struct snd_soc_component *component = da7219->component;
snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_CLK_EN_MASK,
@ -1780,7 +1780,7 @@ static void da7219_dai_clks_unprepare(struct clk_hw *hw)
{
struct da7219_priv *da7219 =
container_of(hw, struct da7219_priv, dai_clks_hw);
struct snd_soc_component *component = da7219->aad->component;
struct snd_soc_component *component = da7219->component;
snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_CLK_EN_MASK, 0);
@ -1790,7 +1790,7 @@ static int da7219_dai_clks_is_prepared(struct clk_hw *hw)
{
struct da7219_priv *da7219 =
container_of(hw, struct da7219_priv, dai_clks_hw);
struct snd_soc_component *component = da7219->aad->component;
struct snd_soc_component *component = da7219->component;
u8 clk_reg;
clk_reg = snd_soc_component_read32(component, DA7219_DAI_CLK_MODE);
@ -1798,10 +1798,47 @@ static int da7219_dai_clks_is_prepared(struct clk_hw *hw)
return !!(clk_reg & DA7219_DAI_CLK_EN_MASK);
}
static unsigned long da7219_dai_clks_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct da7219_priv *da7219 =
container_of(hw, struct da7219_priv, dai_clks_hw);
struct snd_soc_component *component = da7219->component;
u8 fs = snd_soc_component_read32(component, DA7219_SR);
switch (fs & DA7219_SR_MASK) {
case DA7219_SR_8000:
return 8000;
case DA7219_SR_11025:
return 11025;
case DA7219_SR_12000:
return 12000;
case DA7219_SR_16000:
return 16000;
case DA7219_SR_22050:
return 22050;
case DA7219_SR_24000:
return 24000;
case DA7219_SR_32000:
return 32000;
case DA7219_SR_44100:
return 44100;
case DA7219_SR_48000:
return 48000;
case DA7219_SR_88200:
return 88200;
case DA7219_SR_96000:
return 96000;
default:
return 0;
}
}
static const struct clk_ops da7219_dai_clks_ops = {
.prepare = da7219_dai_clks_prepare,
.unprepare = da7219_dai_clks_unprepare,
.is_prepared = da7219_dai_clks_is_prepared,
.recalc_rate = da7219_dai_clks_recalc_rate,
};
static int da7219_register_dai_clks(struct snd_soc_component *component)
@ -1825,6 +1862,7 @@ static int da7219_register_dai_clks(struct snd_soc_component *component)
init.name = pdata->dai_clks_name;
init.ops = &da7219_dai_clks_ops;
init.flags = CLK_GET_RATE_NOCACHE;
da7219->dai_clks_hw.init = &init;
dai_clks = devm_clk_register(dev, &da7219->dai_clks_hw);
@ -1912,6 +1950,7 @@ static int da7219_probe(struct snd_soc_component *component)
unsigned int rev;
int ret;
da7219->component = component;
mutex_init(&da7219->ctrl_lock);
mutex_init(&da7219->pll_lock);

View File

@ -809,6 +809,7 @@ struct da7219_aad_priv;
/* Private data */
struct da7219_priv {
struct snd_soc_component *component;
struct da7219_aad_priv *aad;
struct da7219_pdata *pdata;