Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2936,28 +2936,24 @@ config SND_SOC_LPASS_MACRO_COMMON

config SND_SOC_LPASS_WSA_MACRO
depends on COMMON_CLK
depends on PM_CLK
select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm WSA Macro in LPASS(Low Power Audio SubSystem)"

config SND_SOC_LPASS_VA_MACRO
depends on COMMON_CLK
depends on PM_CLK
select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm VA Macro in LPASS(Low Power Audio SubSystem)"

config SND_SOC_LPASS_RX_MACRO
depends on COMMON_CLK
depends on PM_CLK
select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm RX Macro in LPASS(Low Power Audio SubSystem)"

config SND_SOC_LPASS_TX_MACRO
depends on COMMON_CLK
depends on PM_CLK
select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm TX Macro in LPASS(Low Power Audio SubSystem)"
Expand Down
74 changes: 52 additions & 22 deletions sound/soc/codecs/lpass-rx-macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/pm_clock.h>
#include <linux/pm_runtime.h>
#include <linux/clk.h>
#include <sound/soc.h>
Expand Down Expand Up @@ -670,6 +669,53 @@ struct rx_macro {
};
#define to_rx_macro(_hw) container_of(_hw, struct rx_macro, hw)

static void rx_macro_disable_clocks(struct rx_macro *rx)
{
clk_disable_unprepare(rx->fsgen);
clk_disable_unprepare(rx->npl);
clk_disable_unprepare(rx->mclk);
clk_disable_unprepare(rx->dcodec);
clk_disable_unprepare(rx->macro);
}

static int rx_macro_enable_clocks(struct rx_macro *rx)
{
int ret;

ret = clk_prepare_enable(rx->macro);
if (ret)
return ret;

ret = clk_prepare_enable(rx->dcodec);
if (ret)
goto err_dcodec;

ret = clk_prepare_enable(rx->mclk);
if (ret)
goto err_mclk;

ret = clk_prepare_enable(rx->npl);
if (ret)
goto err_npl;

ret = clk_prepare_enable(rx->fsgen);
if (ret)
goto err_fsgen;

return 0;

err_fsgen:
clk_disable_unprepare(rx->npl);
err_npl:
clk_disable_unprepare(rx->mclk);
err_mclk:
clk_disable_unprepare(rx->dcodec);
err_dcodec:
clk_disable_unprepare(rx->macro);

return ret;
}

struct wcd_iir_filter_ctl {
unsigned int iir_idx;
unsigned int band_idx;
Expand Down Expand Up @@ -3883,14 +3929,6 @@ static int rx_macro_probe(struct platform_device *pdev)
if (ret)
return ret;

ret = devm_pm_clk_create(dev);
if (ret)
return ret;

ret = of_pm_clk_add_clks(dev);
if (ret < 0)
return ret;

pm_runtime_set_autosuspend_delay(dev, 100);
pm_runtime_use_autosuspend(dev);
ret = devm_pm_runtime_enable(dev);
Expand Down Expand Up @@ -3964,16 +4002,9 @@ MODULE_DEVICE_TABLE(of, rx_macro_dt_match);
static int rx_macro_runtime_suspend(struct device *dev)
{
struct rx_macro *rx = dev_get_drvdata(dev);
int ret;

regcache_cache_only(rx->regmap, true);

ret = pm_clk_suspend(dev);
if (ret) {
regcache_cache_only(rx->regmap, false);
return ret;
}

rx_macro_disable_clocks(rx);
regcache_mark_dirty(rx->regmap);

return 0;
Expand All @@ -3984,7 +4015,7 @@ static int rx_macro_runtime_resume(struct device *dev)
struct rx_macro *rx = dev_get_drvdata(dev);
int ret;

ret = pm_clk_resume(dev);
ret = rx_macro_enable_clocks(rx);
if (ret) {
regcache_cache_only(rx->regmap, true);
regcache_mark_dirty(rx->regmap);
Expand All @@ -3996,16 +4027,15 @@ static int rx_macro_runtime_resume(struct device *dev)
if (ret) {
regcache_cache_only(rx->regmap, true);
regcache_mark_dirty(rx->regmap);
pm_clk_suspend(dev);
rx_macro_disable_clocks(rx);
return ret;
}

return 0;
}

static const struct dev_pm_ops rx_macro_pm_ops = {
RUNTIME_PM_OPS(rx_macro_runtime_suspend, rx_macro_runtime_resume, NULL)
};
static DEFINE_RUNTIME_DEV_PM_OPS(rx_macro_pm_ops, rx_macro_runtime_suspend,
rx_macro_runtime_resume, NULL);

static struct platform_driver rx_macro_driver = {
.driver = {
Expand Down
75 changes: 52 additions & 23 deletions sound/soc/codecs/lpass-tx-macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/pm_clock.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <sound/soc.h>
Expand Down Expand Up @@ -289,6 +288,53 @@ struct tx_macro {
};
#define to_tx_macro(_hw) container_of(_hw, struct tx_macro, hw)

static void tx_macro_disable_clocks(struct tx_macro *tx)
{
clk_disable_unprepare(tx->fsgen);
clk_disable_unprepare(tx->npl);
clk_disable_unprepare(tx->mclk);
clk_disable_unprepare(tx->dcodec);
clk_disable_unprepare(tx->macro);
}

static int tx_macro_enable_clocks(struct tx_macro *tx)
{
int ret;

ret = clk_prepare_enable(tx->macro);
if (ret)
return ret;

ret = clk_prepare_enable(tx->dcodec);
if (ret)
goto err_dcodec;

ret = clk_prepare_enable(tx->mclk);
if (ret)
goto err_mclk;

ret = clk_prepare_enable(tx->npl);
if (ret)
goto err_npl;

ret = clk_prepare_enable(tx->fsgen);
if (ret)
goto err_fsgen;

return 0;

err_fsgen:
clk_disable_unprepare(tx->npl);
err_npl:
clk_disable_unprepare(tx->mclk);
err_mclk:
clk_disable_unprepare(tx->dcodec);
err_dcodec:
clk_disable_unprepare(tx->macro);

return ret;
}

static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);

static struct reg_default tx_defaults[] = {
Expand Down Expand Up @@ -2328,14 +2374,6 @@ static int tx_macro_probe(struct platform_device *pdev)
if (ret)
goto err;

ret = devm_pm_clk_create(dev);
if (ret)
goto err;

ret = of_pm_clk_add_clks(dev);
if (ret < 0)
goto err;

pm_runtime_set_autosuspend_delay(dev, 100);
pm_runtime_use_autosuspend(dev);
ret = devm_pm_runtime_enable(dev);
Expand All @@ -2346,7 +2384,6 @@ static int tx_macro_probe(struct platform_device *pdev)
if (ret < 0)
goto err;


/* reset soundwire block */
if (tx->data->flags & LPASS_MACRO_FLAG_RESET_SWR)
regmap_update_bits(tx->regmap, CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
Expand Down Expand Up @@ -2395,16 +2432,9 @@ static void tx_macro_remove(struct platform_device *pdev)
static int tx_macro_runtime_suspend(struct device *dev)
{
struct tx_macro *tx = dev_get_drvdata(dev);
int ret;

regcache_cache_only(tx->regmap, true);

ret = pm_clk_suspend(dev);
if (ret) {
regcache_cache_only(tx->regmap, false);
return ret;
}

tx_macro_disable_clocks(tx);
regcache_mark_dirty(tx->regmap);

return 0;
Expand All @@ -2415,7 +2445,7 @@ static int tx_macro_runtime_resume(struct device *dev)
struct tx_macro *tx = dev_get_drvdata(dev);
int ret;

ret = pm_clk_resume(dev);
ret = tx_macro_enable_clocks(tx);
if (ret) {
regcache_cache_only(tx->regmap, true);
regcache_mark_dirty(tx->regmap);
Expand All @@ -2427,16 +2457,15 @@ static int tx_macro_runtime_resume(struct device *dev)
if (ret) {
regcache_cache_only(tx->regmap, true);
regcache_mark_dirty(tx->regmap);
pm_clk_suspend(dev);
tx_macro_disable_clocks(tx);
return ret;
}

return 0;
}

static const struct dev_pm_ops tx_macro_pm_ops = {
RUNTIME_PM_OPS(tx_macro_runtime_suspend, tx_macro_runtime_resume, NULL)
};
static DEFINE_RUNTIME_DEV_PM_OPS(tx_macro_pm_ops, tx_macro_runtime_suspend,
tx_macro_runtime_resume, NULL);

static const struct tx_macro_data lpass_ver_9 = {
.flags = LPASS_MACRO_FLAG_HAS_NPL_CLOCK |
Expand Down
Loading