Loading asoc/codecs/bolero/bolero-cdc.c +7 −0 Original line number Diff line number Diff line Loading @@ -569,6 +569,13 @@ static int bolero_ssr_enable(struct device *dev, void *data) priv->macro_params[VA_MACRO].event_handler(priv->codec, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, 0x0); /* reset clock to force enable any clock disabled in ssr */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; priv->macro_params[macro_idx].event_handler(priv->codec, BOLERO_MACRO_EVT_CLK_RESET, 0x0); } regcache_cache_only(priv->regmap, false); /* call ssr event for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { Loading asoc/codecs/bolero/bolero-cdc.h +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ enum { BOLERO_MACRO_EVT_SSR_DOWN, BOLERO_MACRO_EVT_SSR_UP, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, BOLERO_MACRO_EVT_CLK_RESET, BOLERO_MACRO_EVT_REG_WAKE_IRQ }; Loading asoc/codecs/bolero/rx-macro.c +33 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include <linux/io.h> #include <linux/platform_device.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <sound/soc.h> #include <sound/pcm.h> #include <sound/pcm_params.h> Loading Loading @@ -363,6 +364,7 @@ struct rx_macro_priv { u16 mclk_mux; struct mutex mclk_lock; struct mutex swr_clk_lock; struct mutex clk_lock; struct rx_swr_ctrl_data *swr_ctrl_data; struct rx_swr_ctrl_platform_data swr_plat_data; struct work_struct rx_macro_add_child_devices_work; Loading Loading @@ -1140,11 +1142,35 @@ static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w, return ret; } static int rx_macro_mclk_reset(struct device *dev) { struct rx_macro_priv *rx_priv = dev_get_drvdata(dev); int count = 0; mutex_lock(&rx_priv->clk_lock); while (__clk_is_enabled(rx_priv->rx_core_clk)) { clk_disable_unprepare(rx_priv->rx_npl_clk); clk_disable_unprepare(rx_priv->rx_core_clk); count++; } dev_dbg(rx_priv->dev, "%s: clock reset after ssr, count %d\n", __func__, count); while (count) { clk_prepare_enable(rx_priv->rx_core_clk); clk_prepare_enable(rx_priv->rx_npl_clk); count--; } mutex_unlock(&rx_priv->clk_lock); return 0; } static int rx_macro_mclk_ctrl(struct device *dev, bool enable) { struct rx_macro_priv *rx_priv = dev_get_drvdata(dev); int ret = 0; mutex_lock(&rx_priv->clk_lock); if (enable) { ret = clk_prepare_enable(rx_priv->rx_core_clk); if (ret < 0) { Loading Loading @@ -1176,6 +1202,7 @@ static int rx_macro_mclk_ctrl(struct device *dev, bool enable) clk_disable_unprepare(rx_priv->rx_core_clk); } mutex_unlock(&rx_priv->clk_lock); return 0; } Loading Loading @@ -1229,6 +1256,9 @@ static int rx_macro_event_handler(struct snd_soc_codec *codec, u16 event, rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; case BOLERO_MACRO_EVT_CLK_RESET: rx_macro_mclk_reset(rx_dev); break; } return 0; } Loading Loading @@ -3545,6 +3575,7 @@ static int rx_macro_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, rx_priv); mutex_init(&rx_priv->mclk_lock); mutex_init(&rx_priv->swr_clk_lock); mutex_init(&rx_priv->clk_lock); rx_macro_init_ops(&ops, rx_io_base); ret = bolero_register_macro(&pdev->dev, RX_MACRO, &ops); Loading @@ -3560,6 +3591,7 @@ static int rx_macro_probe(struct platform_device *pdev) err_reg_macro: mutex_destroy(&rx_priv->mclk_lock); mutex_destroy(&rx_priv->swr_clk_lock); mutex_destroy(&rx_priv->clk_lock); return ret; } Loading @@ -3580,6 +3612,7 @@ static int rx_macro_remove(struct platform_device *pdev) bolero_unregister_macro(&pdev->dev, RX_MACRO); mutex_destroy(&rx_priv->mclk_lock); mutex_destroy(&rx_priv->swr_clk_lock); mutex_destroy(&rx_priv->clk_lock); kfree(rx_priv->swr_ctrl_data); return 0; } Loading asoc/codecs/bolero/tx-macro.c +32 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/io.h> #include <linux/platform_device.h> #include <linux/regmap.h> Loading Loading @@ -140,6 +141,7 @@ struct tx_macro_priv { struct clk *tx_npl_clk; struct mutex mclk_lock; struct mutex swr_clk_lock; struct mutex clk_lock; struct snd_soc_codec *codec; struct device_node *tx_swr_gpio_p; struct tx_macro_swr_ctrl_data *swr_ctrl_data; Loading Loading @@ -284,11 +286,34 @@ static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w, return ret; } static int tx_macro_mclk_reset(struct device *dev) { struct tx_macro_priv *tx_priv = dev_get_drvdata(dev); int count = 0; mutex_lock(&tx_priv->clk_lock); while (__clk_is_enabled(tx_priv->tx_core_clk)) { clk_disable_unprepare(tx_priv->tx_npl_clk); clk_disable_unprepare(tx_priv->tx_core_clk); count++; } dev_dbg(tx_priv->dev, "%s: clock reset after ssr, count %d\n", __func__, count); while (count) { clk_prepare_enable(tx_priv->tx_core_clk); clk_prepare_enable(tx_priv->tx_npl_clk); count--; } mutex_unlock(&tx_priv->clk_lock); return 0; } static int tx_macro_mclk_ctrl(struct device *dev, bool enable) { struct tx_macro_priv *tx_priv = dev_get_drvdata(dev); int ret = 0; mutex_lock(&tx_priv->clk_lock); if (enable) { ret = clk_prepare_enable(tx_priv->tx_core_clk); if (ret < 0) { Loading @@ -308,6 +333,7 @@ static int tx_macro_mclk_ctrl(struct device *dev, bool enable) } exit: mutex_unlock(&tx_priv->clk_lock); return ret; } Loading Loading @@ -336,6 +362,9 @@ static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event, tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; case BOLERO_MACRO_EVT_CLK_RESET: tx_macro_mclk_reset(tx_dev); break; } return 0; } Loading Loading @@ -1803,6 +1832,7 @@ static int tx_macro_probe(struct platform_device *pdev) mutex_init(&tx_priv->mclk_lock); mutex_init(&tx_priv->swr_clk_lock); mutex_init(&tx_priv->clk_lock); tx_macro_init_ops(&ops, tx_io_base); ret = bolero_register_macro(&pdev->dev, TX_MACRO, &ops); if (ret) { Loading @@ -1815,6 +1845,7 @@ static int tx_macro_probe(struct platform_device *pdev) err_reg_macro: mutex_destroy(&tx_priv->mclk_lock); mutex_destroy(&tx_priv->swr_clk_lock); mutex_destroy(&tx_priv->clk_lock); return ret; } Loading @@ -1835,6 +1866,7 @@ static int tx_macro_remove(struct platform_device *pdev) mutex_destroy(&tx_priv->mclk_lock); mutex_destroy(&tx_priv->swr_clk_lock); mutex_destroy(&tx_priv->clk_lock); bolero_unregister_macro(&pdev->dev, TX_MACRO); return 0; } Loading asoc/codecs/bolero/va-macro.c +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ #define VA_MACRO_TX_DMIC_CLK_DIV_SHFT 0x01 #define BOLERO_CDC_VA_TX_UNMUTE_DELAY_MS 40 #define MAX_RETRY_ATTEMPTS 500 #define MAX_RETRY_ATTEMPTS 200 static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); static int va_tx_unmute_delay = BOLERO_CDC_VA_TX_UNMUTE_DELAY_MS; Loading Loading
asoc/codecs/bolero/bolero-cdc.c +7 −0 Original line number Diff line number Diff line Loading @@ -569,6 +569,13 @@ static int bolero_ssr_enable(struct device *dev, void *data) priv->macro_params[VA_MACRO].event_handler(priv->codec, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, 0x0); /* reset clock to force enable any clock disabled in ssr */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; priv->macro_params[macro_idx].event_handler(priv->codec, BOLERO_MACRO_EVT_CLK_RESET, 0x0); } regcache_cache_only(priv->regmap, false); /* call ssr event for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { Loading
asoc/codecs/bolero/bolero-cdc.h +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ enum { BOLERO_MACRO_EVT_SSR_DOWN, BOLERO_MACRO_EVT_SSR_UP, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, BOLERO_MACRO_EVT_CLK_RESET, BOLERO_MACRO_EVT_REG_WAKE_IRQ }; Loading
asoc/codecs/bolero/rx-macro.c +33 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include <linux/io.h> #include <linux/platform_device.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <sound/soc.h> #include <sound/pcm.h> #include <sound/pcm_params.h> Loading Loading @@ -363,6 +364,7 @@ struct rx_macro_priv { u16 mclk_mux; struct mutex mclk_lock; struct mutex swr_clk_lock; struct mutex clk_lock; struct rx_swr_ctrl_data *swr_ctrl_data; struct rx_swr_ctrl_platform_data swr_plat_data; struct work_struct rx_macro_add_child_devices_work; Loading Loading @@ -1140,11 +1142,35 @@ static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w, return ret; } static int rx_macro_mclk_reset(struct device *dev) { struct rx_macro_priv *rx_priv = dev_get_drvdata(dev); int count = 0; mutex_lock(&rx_priv->clk_lock); while (__clk_is_enabled(rx_priv->rx_core_clk)) { clk_disable_unprepare(rx_priv->rx_npl_clk); clk_disable_unprepare(rx_priv->rx_core_clk); count++; } dev_dbg(rx_priv->dev, "%s: clock reset after ssr, count %d\n", __func__, count); while (count) { clk_prepare_enable(rx_priv->rx_core_clk); clk_prepare_enable(rx_priv->rx_npl_clk); count--; } mutex_unlock(&rx_priv->clk_lock); return 0; } static int rx_macro_mclk_ctrl(struct device *dev, bool enable) { struct rx_macro_priv *rx_priv = dev_get_drvdata(dev); int ret = 0; mutex_lock(&rx_priv->clk_lock); if (enable) { ret = clk_prepare_enable(rx_priv->rx_core_clk); if (ret < 0) { Loading Loading @@ -1176,6 +1202,7 @@ static int rx_macro_mclk_ctrl(struct device *dev, bool enable) clk_disable_unprepare(rx_priv->rx_core_clk); } mutex_unlock(&rx_priv->clk_lock); return 0; } Loading Loading @@ -1229,6 +1256,9 @@ static int rx_macro_event_handler(struct snd_soc_codec *codec, u16 event, rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; case BOLERO_MACRO_EVT_CLK_RESET: rx_macro_mclk_reset(rx_dev); break; } return 0; } Loading Loading @@ -3545,6 +3575,7 @@ static int rx_macro_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, rx_priv); mutex_init(&rx_priv->mclk_lock); mutex_init(&rx_priv->swr_clk_lock); mutex_init(&rx_priv->clk_lock); rx_macro_init_ops(&ops, rx_io_base); ret = bolero_register_macro(&pdev->dev, RX_MACRO, &ops); Loading @@ -3560,6 +3591,7 @@ static int rx_macro_probe(struct platform_device *pdev) err_reg_macro: mutex_destroy(&rx_priv->mclk_lock); mutex_destroy(&rx_priv->swr_clk_lock); mutex_destroy(&rx_priv->clk_lock); return ret; } Loading @@ -3580,6 +3612,7 @@ static int rx_macro_remove(struct platform_device *pdev) bolero_unregister_macro(&pdev->dev, RX_MACRO); mutex_destroy(&rx_priv->mclk_lock); mutex_destroy(&rx_priv->swr_clk_lock); mutex_destroy(&rx_priv->clk_lock); kfree(rx_priv->swr_ctrl_data); return 0; } Loading
asoc/codecs/bolero/tx-macro.c +32 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/io.h> #include <linux/platform_device.h> #include <linux/regmap.h> Loading Loading @@ -140,6 +141,7 @@ struct tx_macro_priv { struct clk *tx_npl_clk; struct mutex mclk_lock; struct mutex swr_clk_lock; struct mutex clk_lock; struct snd_soc_codec *codec; struct device_node *tx_swr_gpio_p; struct tx_macro_swr_ctrl_data *swr_ctrl_data; Loading Loading @@ -284,11 +286,34 @@ static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w, return ret; } static int tx_macro_mclk_reset(struct device *dev) { struct tx_macro_priv *tx_priv = dev_get_drvdata(dev); int count = 0; mutex_lock(&tx_priv->clk_lock); while (__clk_is_enabled(tx_priv->tx_core_clk)) { clk_disable_unprepare(tx_priv->tx_npl_clk); clk_disable_unprepare(tx_priv->tx_core_clk); count++; } dev_dbg(tx_priv->dev, "%s: clock reset after ssr, count %d\n", __func__, count); while (count) { clk_prepare_enable(tx_priv->tx_core_clk); clk_prepare_enable(tx_priv->tx_npl_clk); count--; } mutex_unlock(&tx_priv->clk_lock); return 0; } static int tx_macro_mclk_ctrl(struct device *dev, bool enable) { struct tx_macro_priv *tx_priv = dev_get_drvdata(dev); int ret = 0; mutex_lock(&tx_priv->clk_lock); if (enable) { ret = clk_prepare_enable(tx_priv->tx_core_clk); if (ret < 0) { Loading @@ -308,6 +333,7 @@ static int tx_macro_mclk_ctrl(struct device *dev, bool enable) } exit: mutex_unlock(&tx_priv->clk_lock); return ret; } Loading Loading @@ -336,6 +362,9 @@ static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event, tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; case BOLERO_MACRO_EVT_CLK_RESET: tx_macro_mclk_reset(tx_dev); break; } return 0; } Loading Loading @@ -1803,6 +1832,7 @@ static int tx_macro_probe(struct platform_device *pdev) mutex_init(&tx_priv->mclk_lock); mutex_init(&tx_priv->swr_clk_lock); mutex_init(&tx_priv->clk_lock); tx_macro_init_ops(&ops, tx_io_base); ret = bolero_register_macro(&pdev->dev, TX_MACRO, &ops); if (ret) { Loading @@ -1815,6 +1845,7 @@ static int tx_macro_probe(struct platform_device *pdev) err_reg_macro: mutex_destroy(&tx_priv->mclk_lock); mutex_destroy(&tx_priv->swr_clk_lock); mutex_destroy(&tx_priv->clk_lock); return ret; } Loading @@ -1835,6 +1866,7 @@ static int tx_macro_remove(struct platform_device *pdev) mutex_destroy(&tx_priv->mclk_lock); mutex_destroy(&tx_priv->swr_clk_lock); mutex_destroy(&tx_priv->clk_lock); bolero_unregister_macro(&pdev->dev, TX_MACRO); return 0; } Loading
asoc/codecs/bolero/va-macro.c +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ #define VA_MACRO_TX_DMIC_CLK_DIV_SHFT 0x01 #define BOLERO_CDC_VA_TX_UNMUTE_DELAY_MS 40 #define MAX_RETRY_ATTEMPTS 500 #define MAX_RETRY_ATTEMPTS 200 static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); static int va_tx_unmute_delay = BOLERO_CDC_VA_TX_UNMUTE_DELAY_MS; Loading