Merge "ASoC: Bolero: Vote for LPASS HW core during register access"

This commit is contained in:
qctecmdr 2019-04-14 23:24:39 -07:00 • committed by Gerrit - the friendly Code Review server
commit e039f16fa4
3 changed files with 67 additions and 2 deletions

View file

@ -7,6 +7,7 @@
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@ -20,6 +21,7 @@
#include "bolero-cdc-registers.h"
#include "bolero-clk-rsc.h"
#define AUTO_SUSPEND_DELAY 50 /* delay in msec */
#define RX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
@ -3235,6 +3237,7 @@ static int rx_swrm_clock(void *handle, bool enable)
dev_dbg(rx_priv->dev, "%s: swrm clock %s\n",
__func__, (enable ? "enable" : "disable"));
if (enable) {
pm_runtime_get_sync(rx_priv->dev);
if (rx_priv->swr_clk_users == 0) {
msm_cdc_pinctrl_select_active_state(
rx_priv->rx_swr_gpio_p);
@ -3260,6 +3263,8 @@ static int rx_swrm_clock(void *handle, bool enable)
0x02, 0x00);
rx_priv->reset_swr = false;
}
pm_runtime_mark_last_busy(rx_priv->dev);
pm_runtime_put_autosuspend(rx_priv->dev);
rx_priv->swr_clk_users++;
} else {
if (rx_priv->swr_clk_users <= 0) {
@ -3647,6 +3652,10 @@ static int rx_macro_probe(struct platform_device *pdev)
goto err_reg_macro;
}
schedule_work(&rx_priv->rx_macro_add_child_devices_work);
pm_runtime_set_autosuspend_delay(&pdev->dev, AUTO_SUSPEND_DELAY);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_enable(&pdev->dev);
return 0;
@ -3670,6 +3679,8 @@ static int rx_macro_remove(struct platform_device *pdev)
count < RX_MACRO_CHILD_DEVICES_MAX; count++)
platform_device_unregister(rx_priv->pdev_child_devices[count]);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
bolero_unregister_macro(&pdev->dev, RX_MACRO);
mutex_destroy(&rx_priv->mclk_lock);
mutex_destroy(&rx_priv->swr_clk_lock);
@ -3682,10 +3693,19 @@ static const struct of_device_id rx_macro_dt_match[] = {
{}
};
static const struct dev_pm_ops bolero_dev_pm_ops = {
SET_RUNTIME_PM_OPS(
bolero_runtime_suspend,
bolero_runtime_resume,
NULL
)
};
static struct platform_driver rx_macro_driver = {
.driver = {
.name = "rx_macro",
.owner = THIS_MODULE,
.pm = &bolero_dev_pm_ops,
.of_match_table = rx_macro_dt_match,
},
.probe = rx_macro_probe,

View file

@ -8,6 +8,7 @@
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/pm_runtime.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>
@ -18,6 +19,7 @@
#include "bolero-cdc-registers.h"
#include "bolero-clk-rsc.h"
#define AUTO_SUSPEND_DELAY 50 /* delay in msec */
#define TX_MACRO_MAX_OFFSET 0x1000
#define NUM_DECIMATORS 8
@ -1469,9 +1471,10 @@ static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv,
{
int ret = 0;
dev_dbg(tx_priv->dev, "%s: clock type %s, enable: %s\n",
dev_dbg(tx_priv->dev,
"%s: clock type %s, enable: %s tx_mclk_users: %d\n",
__func__, (clk_type ? "VA_MCLK" : "TX_MCLK"),
(enable ? "enable" : "disable"));
(enable ? "enable" : "disable"), tx_priv->tx_mclk_users);
if (enable) {
if (tx_priv->swr_clk_users == 0) {
@ -1518,6 +1521,8 @@ static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv,
0x01, 0x01);
}
}
dev_dbg(tx_priv->dev, "%s: reset_swr: %d\n",
__func__, tx_priv->reset_swr);
if (tx_priv->reset_swr)
regmap_update_bits(regmap,
BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
@ -1608,6 +1613,7 @@ static int tx_macro_swrm_clock(void *handle, bool enable)
__func__, (enable ? "enable" : "disable"));
if (enable) {
pm_runtime_get_sync(tx_priv->dev);
/*For standalone VA usecase, enable VA macro clock */
if (tx_priv->va_swr_clk_cnt && !tx_priv->tx_swr_clk_cnt
&& (tx_priv->swr_clk_type == TX_MCLK)) {
@ -1627,6 +1633,8 @@ static int tx_macro_swrm_clock(void *handle, bool enable)
goto done;
tx_priv->swr_clk_type = TX_MCLK;
}
pm_runtime_mark_last_busy(tx_priv->dev);
pm_runtime_put_autosuspend(tx_priv->dev);
} else {
if (tx_priv->swr_clk_type == VA_MCLK) {
ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
@ -2014,6 +2022,11 @@ static int tx_macro_probe(struct platform_device *pdev)
}
schedule_work(&tx_priv->tx_macro_add_child_devices_work);
pm_runtime_set_autosuspend_delay(&pdev->dev, AUTO_SUSPEND_DELAY);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_enable(&pdev->dev);
return 0;
err_reg_macro:
mutex_destroy(&tx_priv->mclk_lock);
@ -2036,6 +2049,8 @@ static int tx_macro_remove(struct platform_device *pdev)
count < TX_MACRO_CHILD_DEVICES_MAX; count++)
platform_device_unregister(tx_priv->pdev_child_devices[count]);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
mutex_destroy(&tx_priv->mclk_lock);
mutex_destroy(&tx_priv->swr_clk_lock);
bolero_unregister_macro(&pdev->dev, TX_MACRO);
@ -2048,10 +2063,19 @@ static const struct of_device_id tx_macro_dt_match[] = {
{}
};
static const struct dev_pm_ops bolero_dev_pm_ops = {
SET_RUNTIME_PM_OPS(
bolero_runtime_suspend,
bolero_runtime_resume,
NULL
)
};
static struct platform_driver tx_macro_driver = {
.driver = {
.name = "tx_macro",
.owner = THIS_MODULE,
.pm = &bolero_dev_pm_ops,
.of_match_table = tx_macro_dt_match,
},
.probe = tx_macro_probe,

View file

@ -7,6 +7,7 @@
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>
@ -19,6 +20,7 @@
#include "wsa-macro.h"
#include "bolero-clk-rsc.h"
#define AUTO_SUSPEND_DELAY 50 /* delay in msec */
#define WSA_MACRO_MAX_OFFSET 0x1000
#define WSA_MACRO_RX_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
@ -2548,6 +2550,7 @@ static int wsa_swrm_clock(void *handle, bool enable)
dev_dbg(wsa_priv->dev, "%s: swrm clock %s\n",
__func__, (enable ? "enable" : "disable"));
if (enable) {
pm_runtime_get_sync(wsa_priv->dev);
if (wsa_priv->swr_clk_users == 0) {
msm_cdc_pinctrl_select_active_state(
wsa_priv->wsa_swr_gpio_p);
@ -2573,6 +2576,8 @@ static int wsa_swrm_clock(void *handle, bool enable)
0x02, 0x00);
wsa_priv->reset_swr = false;
}
pm_runtime_mark_last_busy(wsa_priv->dev);
pm_runtime_put_autosuspend(wsa_priv->dev);
wsa_priv->swr_clk_users++;
} else {
if (wsa_priv->swr_clk_users <= 0) {
@ -2871,6 +2876,11 @@ static int wsa_macro_probe(struct platform_device *pdev)
goto reg_macro_fail;
}
schedule_work(&wsa_priv->wsa_macro_add_child_devices_work);
pm_runtime_set_autosuspend_delay(&pdev->dev, AUTO_SUSPEND_DELAY);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_enable(&pdev->dev);
return ret;
reg_macro_fail:
mutex_destroy(&wsa_priv->mclk_lock);
@ -2892,6 +2902,8 @@ static int wsa_macro_remove(struct platform_device *pdev)
count < WSA_MACRO_CHILD_DEVICES_MAX; count++)
platform_device_unregister(wsa_priv->pdev_child_devices[count]);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
bolero_unregister_macro(&pdev->dev, WSA_MACRO);
mutex_destroy(&wsa_priv->mclk_lock);
mutex_destroy(&wsa_priv->swr_clk_lock);
@ -2903,10 +2915,19 @@ static const struct of_device_id wsa_macro_dt_match[] = {
{}
};
static const struct dev_pm_ops bolero_dev_pm_ops = {
SET_RUNTIME_PM_OPS(
bolero_runtime_suspend,
bolero_runtime_resume,
NULL
)
};
static struct platform_driver wsa_macro_driver = {
.driver = {
.name = "wsa_macro",
.owner = THIS_MODULE,
.pm = &bolero_dev_pm_ops,
.of_match_table = wsa_macro_dt_match,
},
.probe = wsa_macro_probe,