Commit 46c81702 authored by Mark Brown's avatar Mark Brown

ASoC: Add power domains support for digital macro codecs

Merge series from Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>:

This patch set is to add power domains support for RX, TX and VA macros.
parents 316cd941 6619c7d4
...@@ -39,6 +39,14 @@ properties: ...@@ -39,6 +39,14 @@ properties:
items: items:
- const: mclk - const: mclk
power-domains:
maxItems: 2
power-domain-names:
items:
- const: macro
- const: dcodec
required: required:
- compatible - compatible
- reg - reg
......
...@@ -39,6 +39,14 @@ properties: ...@@ -39,6 +39,14 @@ properties:
items: items:
- const: mclk - const: mclk
power-domains:
maxItems: 2
power-domain-names:
items:
- const: macro
- const: dcodec
qcom,dmic-sample-rate: qcom,dmic-sample-rate:
description: dmic sample rate description: dmic sample rate
$ref: /schemas/types.yaml#/definitions/uint32 $ref: /schemas/types.yaml#/definitions/uint32
......
...@@ -37,6 +37,14 @@ properties: ...@@ -37,6 +37,14 @@ properties:
items: items:
- const: fsgen - const: fsgen
power-domains:
maxItems: 2
power-domain-names:
items:
- const: macro
- const: dcodec
qcom,dmic-sample-rate: qcom,dmic-sample-rate:
description: dmic sample rate description: dmic sample rate
$ref: /schemas/types.yaml#/definitions/uint32 $ref: /schemas/types.yaml#/definitions/uint32
......
...@@ -244,6 +244,7 @@ config SND_SOC_ALL_CODECS ...@@ -244,6 +244,7 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_WCD9335 imply SND_SOC_WCD9335
imply SND_SOC_WCD934X imply SND_SOC_WCD934X
imply SND_SOC_WCD938X_SDW imply SND_SOC_WCD938X_SDW
imply SND_SOC_LPASS_MACRO_COMMON
imply SND_SOC_LPASS_RX_MACRO imply SND_SOC_LPASS_RX_MACRO
imply SND_SOC_LPASS_TX_MACRO imply SND_SOC_LPASS_TX_MACRO
imply SND_SOC_WL1273 imply SND_SOC_WL1273
...@@ -2008,6 +2009,9 @@ config SND_SOC_TPA6130A2 ...@@ -2008,6 +2009,9 @@ config SND_SOC_TPA6130A2
tristate "Texas Instruments TPA6130A2 headphone amplifier" tristate "Texas Instruments TPA6130A2 headphone amplifier"
depends on I2C depends on I2C
config SND_SOC_LPASS_MACRO_COMMON
tristate
config SND_SOC_LPASS_WSA_MACRO config SND_SOC_LPASS_WSA_MACRO
depends on COMMON_CLK depends on COMMON_CLK
select REGMAP_MMIO select REGMAP_MMIO
...@@ -2016,16 +2020,19 @@ config SND_SOC_LPASS_WSA_MACRO ...@@ -2016,16 +2020,19 @@ config SND_SOC_LPASS_WSA_MACRO
config SND_SOC_LPASS_VA_MACRO config SND_SOC_LPASS_VA_MACRO
depends on COMMON_CLK depends on COMMON_CLK
select REGMAP_MMIO select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm VA Macro in LPASS(Low Power Audio SubSystem)" tristate "Qualcomm VA Macro in LPASS(Low Power Audio SubSystem)"
config SND_SOC_LPASS_RX_MACRO config SND_SOC_LPASS_RX_MACRO
depends on COMMON_CLK depends on COMMON_CLK
select REGMAP_MMIO select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm RX Macro in LPASS(Low Power Audio SubSystem)" tristate "Qualcomm RX Macro in LPASS(Low Power Audio SubSystem)"
config SND_SOC_LPASS_TX_MACRO config SND_SOC_LPASS_TX_MACRO
depends on COMMON_CLK depends on COMMON_CLK
select REGMAP_MMIO select REGMAP_MMIO
select SND_SOC_LPASS_MACRO_COMMON
tristate "Qualcomm TX Macro in LPASS(Low Power Audio SubSystem)" tristate "Qualcomm TX Macro in LPASS(Low Power Audio SubSystem)"
endmenu endmenu
...@@ -112,6 +112,7 @@ snd-soc-l3-objs := l3.o ...@@ -112,6 +112,7 @@ snd-soc-l3-objs := l3.o
snd-soc-lm4857-objs := lm4857.o snd-soc-lm4857-objs := lm4857.o
snd-soc-lm49453-objs := lm49453.o snd-soc-lm49453-objs := lm49453.o
snd-soc-lochnagar-sc-objs := lochnagar-sc.o snd-soc-lochnagar-sc-objs := lochnagar-sc.o
snd-soc-lpass-macro-common-objs := lpass-macro-common.o
snd-soc-lpass-rx-macro-objs := lpass-rx-macro.o snd-soc-lpass-rx-macro-objs := lpass-rx-macro.o
snd-soc-lpass-tx-macro-objs := lpass-tx-macro.o snd-soc-lpass-tx-macro-objs := lpass-tx-macro.o
snd-soc-lpass-wsa-macro-objs := lpass-wsa-macro.o snd-soc-lpass-wsa-macro-objs := lpass-wsa-macro.o
...@@ -676,6 +677,7 @@ obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o ...@@ -676,6 +677,7 @@ obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o
obj-$(CONFIG_SND_SOC_MAX98504) += snd-soc-max98504.o obj-$(CONFIG_SND_SOC_MAX98504) += snd-soc-max98504.o
obj-$(CONFIG_SND_SOC_SIMPLE_AMPLIFIER) += snd-soc-simple-amplifier.o obj-$(CONFIG_SND_SOC_SIMPLE_AMPLIFIER) += snd-soc-simple-amplifier.o
obj-$(CONFIG_SND_SOC_TPA6130A2) += snd-soc-tpa6130a2.o obj-$(CONFIG_SND_SOC_TPA6130A2) += snd-soc-tpa6130a2.o
obj-$(CONFIG_SND_SOC_LPASS_MACRO_COMMON) += snd-soc-lpass-macro-common.o
obj-$(CONFIG_SND_SOC_LPASS_WSA_MACRO) += snd-soc-lpass-wsa-macro.o obj-$(CONFIG_SND_SOC_LPASS_WSA_MACRO) += snd-soc-lpass-wsa-macro.o
obj-$(CONFIG_SND_SOC_LPASS_VA_MACRO) += snd-soc-lpass-va-macro.o obj-$(CONFIG_SND_SOC_LPASS_VA_MACRO) += snd-soc-lpass-va-macro.o
obj-$(CONFIG_SND_SOC_LPASS_RX_MACRO) += snd-soc-lpass-rx-macro.o obj-$(CONFIG_SND_SOC_LPASS_RX_MACRO) += snd-soc-lpass-rx-macro.o
......
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2022, The Linux Foundation. All rights reserved.
#include <linux/export.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
#include "lpass-macro-common.h"
struct lpass_macro *lpass_macro_pds_init(struct device *dev)
{
struct lpass_macro *l_pds;
int ret;
if (!of_find_property(dev->of_node, "power-domains", NULL))
return NULL;
l_pds = devm_kzalloc(dev, sizeof(*l_pds), GFP_KERNEL);
if (!l_pds)
return ERR_PTR(-ENOMEM);
l_pds->macro_pd = dev_pm_domain_attach_by_name(dev, "macro");
if (IS_ERR_OR_NULL(l_pds->macro_pd))
return NULL;
ret = pm_runtime_get_sync(l_pds->macro_pd);
if (ret < 0) {
pm_runtime_put_noidle(l_pds->macro_pd);
goto macro_err;
}
l_pds->dcodec_pd = dev_pm_domain_attach_by_name(dev, "dcodec");
if (IS_ERR_OR_NULL(l_pds->dcodec_pd))
goto dcodec_err;
ret = pm_runtime_get_sync(l_pds->dcodec_pd);
if (ret < 0) {
pm_runtime_put_noidle(l_pds->dcodec_pd);
goto dcodec_sync_err;
}
return l_pds;
dcodec_sync_err:
dev_pm_domain_detach(l_pds->dcodec_pd, false);
dcodec_err:
pm_runtime_put(l_pds->macro_pd);
macro_err:
dev_pm_domain_detach(l_pds->macro_pd, false);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(lpass_macro_pds_init);
void lpass_macro_pds_exit(struct lpass_macro *pds)
{
pm_runtime_put(pds->macro_pd);
dev_pm_domain_detach(pds->macro_pd, false);
pm_runtime_put(pds->dcodec_pd);
dev_pm_domain_detach(pds->dcodec_pd, false);
}
EXPORT_SYMBOL_GPL(lpass_macro_pds_exit);
MODULE_DESCRIPTION("Common macro driver");
MODULE_LICENSE("GPL");
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, The Linux Foundation. All rights reserved.
*/
#ifndef __LPASS_MACRO_COMMON_H__
#define __LPASS_MACRO_COMMON_H__
struct lpass_macro {
struct device *macro_pd;
struct device *dcodec_pd;
};
struct lpass_macro *lpass_macro_pds_init(struct device *dev);
void lpass_macro_pds_exit(struct lpass_macro *pds);
#endif /* __LPASS_MACRO_COMMON_H__ */
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include <linux/of_clk.h> #include <linux/of_clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include "lpass-macro-common.h"
#define CDC_RX_TOP_TOP_CFG0 (0x0000) #define CDC_RX_TOP_TOP_CFG0 (0x0000)
#define CDC_RX_TOP_SWR_CTRL (0x0008) #define CDC_RX_TOP_SWR_CTRL (0x0008)
#define CDC_RX_TOP_DEBUG (0x000C) #define CDC_RX_TOP_DEBUG (0x000C)
...@@ -607,7 +609,7 @@ struct rx_macro { ...@@ -607,7 +609,7 @@ struct rx_macro {
int is_softclip_on; int is_softclip_on;
int is_aux_hpf_on; int is_aux_hpf_on;
int softclip_clk_users; int softclip_clk_users;
struct lpass_macro *pds;
struct regmap *regmap; struct regmap *regmap;
struct clk *mclk; struct clk *mclk;
struct clk *npl; struct clk *npl;
...@@ -3555,6 +3557,10 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3555,6 +3557,10 @@ static int rx_macro_probe(struct platform_device *pdev)
if (IS_ERR(rx->fsgen)) if (IS_ERR(rx->fsgen))
return PTR_ERR(rx->fsgen); return PTR_ERR(rx->fsgen);
rx->pds = lpass_macro_pds_init(dev);
if (IS_ERR(rx->pds))
return PTR_ERR(rx->pds);
base = devm_platform_ioremap_resource(pdev, 0); base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
...@@ -3635,6 +3641,8 @@ static int rx_macro_remove(struct platform_device *pdev) ...@@ -3635,6 +3641,8 @@ static int rx_macro_remove(struct platform_device *pdev)
clk_disable_unprepare(rx->macro); clk_disable_unprepare(rx->macro);
clk_disable_unprepare(rx->dcodec); clk_disable_unprepare(rx->dcodec);
lpass_macro_pds_exit(rx->pds);
return 0; return 0;
} }
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/of_clk.h> #include <linux/of_clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include "lpass-macro-common.h"
#define CDC_TX_CLK_RST_CTRL_MCLK_CONTROL (0x0000) #define CDC_TX_CLK_RST_CTRL_MCLK_CONTROL (0x0000)
#define CDC_TX_MCLK_EN_MASK BIT(0) #define CDC_TX_MCLK_EN_MASK BIT(0)
#define CDC_TX_MCLK_ENABLE BIT(0) #define CDC_TX_MCLK_ENABLE BIT(0)
...@@ -271,6 +273,7 @@ struct tx_macro { ...@@ -271,6 +273,7 @@ struct tx_macro {
u16 dmic_clk_div; u16 dmic_clk_div;
bool bcs_enable; bool bcs_enable;
int dec_mode[NUM_DECIMATORS]; int dec_mode[NUM_DECIMATORS];
struct lpass_macro *pds;
bool bcs_clk_en; bool bcs_clk_en;
}; };
#define to_tx_macro(_hw) container_of(_hw, struct tx_macro, hw) #define to_tx_macro(_hw) container_of(_hw, struct tx_macro, hw)
...@@ -1820,6 +1823,10 @@ static int tx_macro_probe(struct platform_device *pdev) ...@@ -1820,6 +1823,10 @@ static int tx_macro_probe(struct platform_device *pdev)
if (IS_ERR(tx->fsgen)) if (IS_ERR(tx->fsgen))
return PTR_ERR(tx->fsgen); return PTR_ERR(tx->fsgen);
tx->pds = lpass_macro_pds_init(dev);
if (IS_ERR(tx->pds))
return PTR_ERR(tx->pds);
base = devm_platform_ioremap_resource(pdev, 0); base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
...@@ -1957,6 +1964,8 @@ static int __maybe_unused tx_macro_runtime_resume(struct device *dev) ...@@ -1957,6 +1964,8 @@ static int __maybe_unused tx_macro_runtime_resume(struct device *dev)
regcache_sync(tx->regmap); regcache_sync(tx->regmap);
tx->reset_swr = true; tx->reset_swr = true;
lpass_macro_pds_exit(tx->pds);
return 0; return 0;
err_fsgen: err_fsgen:
clk_disable_unprepare(tx->npl); clk_disable_unprepare(tx->npl);
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include "lpass-macro-common.h"
/* VA macro registers */ /* VA macro registers */
#define CDC_VA_CLK_RST_CTRL_MCLK_CONTROL (0x0000) #define CDC_VA_CLK_RST_CTRL_MCLK_CONTROL (0x0000)
#define CDC_VA_MCLK_CONTROL_EN BIT(0) #define CDC_VA_MCLK_CONTROL_EN BIT(0)
...@@ -198,6 +200,7 @@ struct va_macro { ...@@ -198,6 +200,7 @@ struct va_macro {
struct clk *macro; struct clk *macro;
struct clk *dcodec; struct clk *dcodec;
struct clk_hw hw; struct clk_hw hw;
struct lpass_macro *pds;
s32 dmic_0_1_clk_cnt; s32 dmic_0_1_clk_cnt;
s32 dmic_2_3_clk_cnt; s32 dmic_2_3_clk_cnt;
...@@ -1420,6 +1423,10 @@ static int va_macro_probe(struct platform_device *pdev) ...@@ -1420,6 +1423,10 @@ static int va_macro_probe(struct platform_device *pdev)
if (IS_ERR(va->mclk)) if (IS_ERR(va->mclk))
return PTR_ERR(va->mclk); return PTR_ERR(va->mclk);
va->pds = lpass_macro_pds_init(dev);
if (IS_ERR(va->pds))
return PTR_ERR(va->pds);
ret = of_property_read_u32(dev->of_node, "qcom,dmic-sample-rate", ret = of_property_read_u32(dev->of_node, "qcom,dmic-sample-rate",
&sample_rate); &sample_rate);
if (ret) { if (ret) {
...@@ -1524,6 +1531,9 @@ static int __maybe_unused va_macro_runtime_resume(struct device *dev) ...@@ -1524,6 +1531,9 @@ static int __maybe_unused va_macro_runtime_resume(struct device *dev)
regcache_cache_only(va->regmap, false); regcache_cache_only(va->regmap, false);
regcache_sync(va->regmap); regcache_sync(va->regmap);
lpass_macro_pds_exit(va->pds);
return 0; return 0;
} }
......
...@@ -194,6 +194,7 @@ config SND_SOC_SC7280 ...@@ -194,6 +194,7 @@ config SND_SOC_SC7280
select SND_SOC_LPASS_SC7280 select SND_SOC_LPASS_SC7280
select SND_SOC_MAX98357A select SND_SOC_MAX98357A
select SND_SOC_WCD938X select SND_SOC_WCD938X
select SND_SOC_LPASS_MACRO_COMMON
select SND_SOC_LPASS_RX_MACRO select SND_SOC_LPASS_RX_MACRO
select SND_SOC_LPASS_TX_MACRO select SND_SOC_LPASS_TX_MACRO
help help
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment