From 04d31da985449beb1ae0683b501ffb2ef9e717f3 Mon Sep 17 00:00:00 2001 From: Sudheer Papothi Date: Sun, 24 Nov 2019 10:14:21 +0530 Subject: [PATCH] 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 --- asoc/codecs/bolero/bolero-cdc.c | 36 +++++++++++++++++++++++++++++++++ asoc/codecs/bolero/bolero-cdc.h | 6 ++++++ asoc/codecs/bolero/tx-macro.c | 15 +++++++++++++- asoc/codecs/bolero/va-macro.c | 12 +++++++++-- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/asoc/codecs/bolero/bolero-cdc.c b/asoc/codecs/bolero/bolero-cdc.c index 7ccbaa4f2276..4a4c705ffdbe 100644 --- a/asoc/codecs/bolero/bolero-cdc.c +++ b/asoc/codecs/bolero/bolero-cdc.c @@ -646,6 +646,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; @@ -719,6 +720,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; @@ -1029,6 +1031,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 * diff --git a/asoc/codecs/bolero/bolero-cdc.h b/asoc/codecs/bolero/bolero-cdc.h index dd58eed87c86..5231668430f2 100644 --- a/asoc/codecs/bolero/bolero-cdc.h +++ b/asoc/codecs/bolero/bolero-cdc.h @@ -71,6 +71,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; @@ -99,6 +100,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); @@ -192,5 +194,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 */ diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c index c8aa2fb9a0dd..5bd54e3a3c68 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -279,6 +279,18 @@ exit: 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) { @@ -2428,7 +2440,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, @@ -3131,6 +3143,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) diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c index 2dc224909ecc..bbbc159f0334 100644 --- a/asoc/codecs/bolero/va-macro.c +++ b/asoc/codecs/bolero/va-macro.c @@ -477,12 +477,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,