Merge "ASoC: bolero: Enable clock Fs generation in bolero codec"

This commit is contained in:
Linux Build Service Account 2019-02-17 00:21:49 -08:00 • committed by Gerrit - the friendly Code Review server
commit 2591646070
3 changed files with 43 additions and 18 deletions

View file

@ -464,6 +464,46 @@ void bolero_unregister_macro(struct device *dev, u16 macro_id)
}
EXPORT_SYMBOL(bolero_unregister_macro);
static void bolero_fs_gen_enable(struct bolero_priv *priv, bool enable)
{
if (enable) {
if (++priv->clk_users == 1) {
mutex_unlock(&priv->clk_lock);
regmap_update_bits(priv->regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_MCLK_CONTROL,
0x01, 0x01);
regmap_update_bits(priv->regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_FS_CNT_CONTROL,
0x01, 0x01);
regmap_update_bits(priv->regmap,
BOLERO_CDC_VA_TOP_CSR_TOP_CFG0,
0x02, 0x02);
mutex_lock(&priv->clk_lock);
}
} else {
if (priv->clk_users <= 0) {
dev_err(priv->dev,
"%s:clock already disabled\n",
__func__);
priv->clk_users = 0;
return;
}
if (--priv->clk_users == 0) {
mutex_unlock(&priv->clk_lock);
regmap_update_bits(priv->regmap,
BOLERO_CDC_VA_TOP_CSR_TOP_CFG0,
0x02, 0x00);
regmap_update_bits(priv->regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_FS_CNT_CONTROL,
0x01, 0x00);
regmap_update_bits(priv->regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_MCLK_CONTROL,
0x01, 0x00);
mutex_lock(&priv->clk_lock);
}
}
}
/**
* bolero_request_clock - request for clock enable/disable
*
@ -510,6 +550,7 @@ int bolero_request_clock(struct device *dev, u16 macro_id,
macro_id, mclk_mux0_macro);
goto err;
}
bolero_fs_gen_enable(priv, enable);
break;
case MCLK_MUX1:
mclk_mux1_macro = bolero_mclk_mux_tbl[macro_id][MCLK_MUX1];
@ -527,6 +568,7 @@ int bolero_request_clock(struct device *dev, u16 macro_id,
if (enable)
goto err;
}
bolero_fs_gen_enable(priv, enable);
/*
* need different return value as ret variable
* is used to track mclk_mux0 enable success or fail

View file

@ -73,6 +73,7 @@ struct bolero_priv {
struct wcd_ctrl_platform_data plat_data;
struct device *wcd_dev;
struct blocking_notifier_head notifier;
int clk_users;
};
struct regmap *bolero_regmap_init(struct device *dev,

View file

@ -166,15 +166,6 @@ static int va_macro_mclk_enable(struct va_macro_priv *va_priv,
regcache_sync_region(regmap,
VA_START_OFFSET,
VA_MAX_OFFSET);
regmap_update_bits(regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_MCLK_CONTROL,
0x01, 0x01);
regmap_update_bits(regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_FS_CNT_CONTROL,
0x01, 0x01);
regmap_update_bits(regmap,
BOLERO_CDC_VA_TOP_CSR_TOP_CFG0,
0x02, 0x02);
}
va_priv->va_mclk_users++;
} else {
@ -186,15 +177,6 @@ static int va_macro_mclk_enable(struct va_macro_priv *va_priv,
}
va_priv->va_mclk_users--;
if (va_priv->va_mclk_users == 0) {
regmap_update_bits(regmap,
BOLERO_CDC_VA_TOP_CSR_TOP_CFG0,
0x02, 0x00);
regmap_update_bits(regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_FS_CNT_CONTROL,
0x01, 0x00);
regmap_update_bits(regmap,
BOLERO_CDC_VA_CLK_RST_CTRL_MCLK_CONTROL,
0x01, 0x00);
bolero_request_clock(va_priv->dev,
VA_MACRO,
va_priv->mclk_mux_sel, false);