Skip to content

Commit 101c902

Browse files
TE-N-ShengjiuWangbroonie
authored andcommitted
ASoC: fsl_mqs: Support accessing registers by scmi interface
On i.MX95, the MQS module in Always-on (AON) domain only can be accessed by System Controller Management Interface (SCMI) MISC Protocol. So define a specific regmap_config for the case. Signed-off-by: Shengjiu Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 28f7aa0 commit 101c902

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

sound/soc/fsl/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ config SND_SOC_FSL_MQS
3030
tristate "Medium Quality Sound (MQS) module support"
3131
depends on SND_SOC_FSL_SAI
3232
select REGMAP_MMIO
33+
select IMX_SCMI_MISC_DRV if IMX_SCMI_MISC_EXT !=n
3334
help
3435
Say Y if you want to add Medium Quality Sound (MQS)
3536
support for the Freescale CPUs.

sound/soc/fsl/fsl_mqs.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright 2019 NXP
77

88
#include <linux/clk.h>
9+
#include <linux/firmware/imx/sm.h>
910
#include <linux/module.h>
1011
#include <linux/moduleparam.h>
1112
#include <linux/mfd/syscon.h>
@@ -74,6 +75,29 @@ struct fsl_mqs {
7475
#define FSL_MQS_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
7576
#define FSL_MQS_FORMATS SNDRV_PCM_FMTBIT_S16_LE
7677

78+
static int fsl_mqs_sm_read(void *context, unsigned int reg, unsigned int *val)
79+
{
80+
struct fsl_mqs *mqs_priv = context;
81+
int num = 1;
82+
83+
if (IS_ENABLED(CONFIG_IMX_SCMI_MISC_DRV) &&
84+
mqs_priv->soc->ctrl_off == reg)
85+
return scmi_imx_misc_ctrl_get(SCMI_IMX_CTRL_MQS1_SETTINGS, &num, val);
86+
87+
return -EINVAL;
88+
};
89+
90+
static int fsl_mqs_sm_write(void *context, unsigned int reg, unsigned int val)
91+
{
92+
struct fsl_mqs *mqs_priv = context;
93+
94+
if (IS_ENABLED(CONFIG_IMX_SCMI_MISC_DRV) &&
95+
mqs_priv->soc->ctrl_off == reg)
96+
return scmi_imx_misc_ctrl_set(SCMI_IMX_CTRL_MQS1_SETTINGS, val);
97+
98+
return -EINVAL;
99+
};
100+
77101
static int fsl_mqs_hw_params(struct snd_pcm_substream *substream,
78102
struct snd_pcm_hw_params *params,
79103
struct snd_soc_dai *dai)
@@ -188,6 +212,13 @@ static const struct regmap_config fsl_mqs_regmap_config = {
188212
.cache_type = REGCACHE_NONE,
189213
};
190214

215+
static const struct regmap_config fsl_mqs_sm_regmap = {
216+
.reg_bits = 32,
217+
.val_bits = 32,
218+
.reg_read = fsl_mqs_sm_read,
219+
.reg_write = fsl_mqs_sm_write,
220+
};
221+
191222
static int fsl_mqs_probe(struct platform_device *pdev)
192223
{
193224
struct device_node *np = pdev->dev.of_node;
@@ -219,6 +250,16 @@ static int fsl_mqs_probe(struct platform_device *pdev)
219250
dev_err(&pdev->dev, "failed to get gpr regmap\n");
220251
return PTR_ERR(mqs_priv->regmap);
221252
}
253+
} else if (mqs_priv->soc->type == TYPE_REG_SM) {
254+
mqs_priv->regmap = devm_regmap_init(&pdev->dev,
255+
NULL,
256+
mqs_priv,
257+
&fsl_mqs_sm_regmap);
258+
if (IS_ERR(mqs_priv->regmap)) {
259+
dev_err(&pdev->dev, "failed to init regmap: %ld\n",
260+
PTR_ERR(mqs_priv->regmap));
261+
return PTR_ERR(mqs_priv->regmap);
262+
}
222263
} else {
223264
regs = devm_platform_ioremap_resource(pdev, 0);
224265
if (IS_ERR(regs))

0 commit comments

Comments
 (0)