ASoC: bolero: Use TX MCLK for non-island mode usecase

Use TX MCLK for non-island mode usecase.

Change-Id: Iff8f8efd3e83b09e5323abe19aabddb8c4de1964
Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
This commit is contained in:
Sudheer Papothi 2019-11-24 10:14:21 +05:30 committed by Gerrit - the friendly Code Review server
parent d50a581e04
commit fc3adb04c4
4 changed files with 66 additions and 3 deletions

View file

@ -640,6 +640,7 @@ int bolero_register_macro(struct device *dev, u16 macro_id,
priv->macro_params[macro_id].clk_switch = ops->clk_switch;
priv->macro_params[macro_id].reg_evt_listener =
ops->reg_evt_listener;
priv->macro_params[macro_id].clk_enable = ops->clk_enable;
}
if (macro_id == TX_MACRO || macro_id == VA_MACRO)
priv->macro_params[macro_id].clk_div_get = ops->clk_div_get;
@ -713,6 +714,7 @@ void bolero_unregister_macro(struct device *dev, u16 macro_id)
priv->macro_params[macro_id].reg_wake_irq = NULL;
priv->macro_params[macro_id].clk_switch = NULL;
priv->macro_params[macro_id].reg_evt_listener = NULL;
priv->macro_params[macro_id].clk_enable = NULL;
}
if (macro_id == TX_MACRO || macro_id == VA_MACRO)
priv->macro_params[macro_id].clk_div_get = NULL;
@ -1015,6 +1017,40 @@ int bolero_tx_clk_switch(struct snd_soc_component *component)
}
EXPORT_SYMBOL(bolero_tx_clk_switch);
/**
* bolero_tx_mclk_enable - Enable/Disable TX Macro mclk
*
* @component: pointer to codec component instance.
* @enable: set true to enable, otherwise false.
*
* Returns 0 on success or -EINVAL on error.
*/
int bolero_tx_mclk_enable(struct snd_soc_component *component,
bool enable)
{
struct bolero_priv *priv = NULL;
int ret = 0;
if (!component)
return -EINVAL;
priv = snd_soc_component_get_drvdata(component);
if (!priv)
return -EINVAL;
if (!bolero_is_valid_codec_dev(priv->dev)) {
dev_err(component->dev, "%s: invalid codec\n", __func__);
return -EINVAL;
}
if (priv->macro_params[TX_MACRO].clk_enable)
ret = priv->macro_params[TX_MACRO].clk_enable(component,
enable);
return ret;
}
EXPORT_SYMBOL(bolero_tx_mclk_enable);
/**
* bolero_register_event_listener - Register/Deregister to event listener
*

View file

@ -83,6 +83,7 @@ struct macro_ops {
int (*clk_switch)(struct snd_soc_component *component);
int (*clk_div_get)(struct snd_soc_component *component);
int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
int (*clk_enable)(struct snd_soc_component *c, bool en);
char __iomem *io_base;
u16 clk_id_req;
u16 default_clk_id;
@ -111,6 +112,7 @@ int bolero_register_event_listener(struct snd_soc_component *component,
bool enable);
void bolero_wsa_pa_on(struct device *dev);
bool bolero_check_core_votes(struct device *dev);
int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable);
int bolero_get_version(struct device *dev);
int bolero_dmic_clk_enable(struct snd_soc_component *component,
u32 dmic, u32 tx_mode, bool enable);
@ -204,5 +206,9 @@ static int bolero_dmic_clk_enable(struct snd_soc_component *component,
{
return 0;
}
static int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable)
{
return 0;
}
#endif /* CONFIG_SND_SOC_BOLERO */
#endif /* BOLERO_CDC_H */

View file

@ -275,6 +275,18 @@ static int tx_macro_mclk_enable(struct tx_macro_priv *tx_priv,
return ret;
}
static int __tx_macro_mclk_enable(struct snd_soc_component *component,
bool enable)
{
struct device *tx_dev = NULL;
struct tx_macro_priv *tx_priv = NULL;
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
return -EINVAL;
return tx_macro_mclk_enable(tx_priv, enable);
}
static int tx_macro_va_swr_clk_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
@ -2266,7 +2278,7 @@ static int tx_macro_register_event_listener(struct snd_soc_component *component,
"%s: priv is null for macro!\n", __func__);
return -EINVAL;
}
if (tx_priv->swr_ctrl_data) {
if (tx_priv->swr_ctrl_data && !tx_priv->tx_swr_clk_cnt) {
if (enable) {
ret = swrm_wcd_notify(
tx_priv->swr_ctrl_data[0].tx_swr_pdev,
@ -2977,6 +2989,7 @@ static void tx_macro_init_ops(struct macro_ops *ops,
ops->clk_div_get = tx_macro_clk_div_get;
ops->clk_switch = tx_macro_clk_switch;
ops->reg_evt_listener = tx_macro_register_event_listener;
ops->clk_enable = __tx_macro_mclk_enable;
}
static int tx_macro_probe(struct platform_device *pdev)

View file

@ -475,12 +475,20 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
true);
if (!ret)
va_priv->tx_clk_status++;
ret = va_macro_mclk_enable(va_priv, 1, true);
if (va_priv->lpi_enable)
ret = va_macro_mclk_enable(va_priv, 1, true);
else
ret = bolero_tx_mclk_enable(component, 1);
break;
case SND_SOC_DAPM_POST_PMD:
if (bolero_tx_clk_switch(component))
dev_dbg(va_dev, "%s: clock switch failed\n",__func__);
va_macro_mclk_enable(va_priv, 0, true);
if (va_priv->lpi_enable)
va_macro_mclk_enable(va_priv, 0, true);
else
bolero_tx_mclk_enable(component, 0);
if (va_priv->tx_clk_status > 0) {
bolero_clk_rsc_request_clock(va_priv->dev,
va_priv->default_clk_id,