xref: /linux/sound/soc/fsl/fsl_mqs.c (revision 4ff299cb33ae40367d38e66c5cba15242cbbe33c)
19e28f653SShengjiu Wang // SPDX-License-Identifier: GPL-2.0
29e28f653SShengjiu Wang //
39e28f653SShengjiu Wang // ALSA SoC IMX MQS driver
49e28f653SShengjiu Wang //
59e28f653SShengjiu Wang // Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
69e28f653SShengjiu Wang // Copyright 2019 NXP
79e28f653SShengjiu Wang 
89e28f653SShengjiu Wang #include <linux/clk.h>
99e28f653SShengjiu Wang #include <linux/module.h>
109e28f653SShengjiu Wang #include <linux/moduleparam.h>
119e28f653SShengjiu Wang #include <linux/mfd/syscon.h>
129e28f653SShengjiu Wang #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
13063c9155SShengjiu Wang #include <linux/of_device.h>
149e28f653SShengjiu Wang #include <linux/pm_runtime.h>
159e28f653SShengjiu Wang #include <linux/of.h>
169e28f653SShengjiu Wang #include <linux/pm.h>
179e28f653SShengjiu Wang #include <linux/slab.h>
189e28f653SShengjiu Wang #include <sound/soc.h>
199e28f653SShengjiu Wang #include <sound/pcm.h>
209e28f653SShengjiu Wang #include <sound/initval.h>
219e28f653SShengjiu Wang 
229e28f653SShengjiu Wang #define REG_MQS_CTRL		0x00
239e28f653SShengjiu Wang 
249e28f653SShengjiu Wang #define MQS_EN_MASK			(0x1 << 28)
259e28f653SShengjiu Wang #define MQS_EN_SHIFT			(28)
269e28f653SShengjiu Wang #define MQS_SW_RST_MASK			(0x1 << 24)
279e28f653SShengjiu Wang #define MQS_SW_RST_SHIFT		(24)
289e28f653SShengjiu Wang #define MQS_OVERSAMPLE_MASK		(0x1 << 20)
299e28f653SShengjiu Wang #define MQS_OVERSAMPLE_SHIFT		(20)
309e28f653SShengjiu Wang #define MQS_CLK_DIV_MASK		(0xFF << 0)
319e28f653SShengjiu Wang #define MQS_CLK_DIV_SHIFT		(0)
329e28f653SShengjiu Wang 
33063c9155SShengjiu Wang /**
34063c9155SShengjiu Wang  * struct fsl_mqs_soc_data - soc specific data
35063c9155SShengjiu Wang  *
36063c9155SShengjiu Wang  * @use_gpr: control register is in General Purpose Register group
37063c9155SShengjiu Wang  * @ctrl_off: control register offset
38063c9155SShengjiu Wang  * @en_mask: enable bit mask
39063c9155SShengjiu Wang  * @en_shift: enable bit shift
40063c9155SShengjiu Wang  * @rst_mask: reset bit mask
41063c9155SShengjiu Wang  * @rst_shift: reset bit shift
42063c9155SShengjiu Wang  * @osr_mask: oversample bit mask
43063c9155SShengjiu Wang  * @osr_shift: oversample bit shift
44063c9155SShengjiu Wang  * @div_mask: clock divider mask
45063c9155SShengjiu Wang  * @div_shift: clock divider bit shift
46063c9155SShengjiu Wang  */
47063c9155SShengjiu Wang struct fsl_mqs_soc_data {
48063c9155SShengjiu Wang 	bool use_gpr;
49063c9155SShengjiu Wang 	int  ctrl_off;
50063c9155SShengjiu Wang 	int  en_mask;
51063c9155SShengjiu Wang 	int  en_shift;
52063c9155SShengjiu Wang 	int  rst_mask;
53063c9155SShengjiu Wang 	int  rst_shift;
54063c9155SShengjiu Wang 	int  osr_mask;
55063c9155SShengjiu Wang 	int  osr_shift;
56063c9155SShengjiu Wang 	int  div_mask;
57063c9155SShengjiu Wang 	int  div_shift;
58063c9155SShengjiu Wang };
59063c9155SShengjiu Wang 
609e28f653SShengjiu Wang /* codec private data */
619e28f653SShengjiu Wang struct fsl_mqs {
629e28f653SShengjiu Wang 	struct regmap *regmap;
639e28f653SShengjiu Wang 	struct clk *mclk;
649e28f653SShengjiu Wang 	struct clk *ipg;
65063c9155SShengjiu Wang 	const struct fsl_mqs_soc_data *soc;
669e28f653SShengjiu Wang 
679e28f653SShengjiu Wang 	unsigned int reg_mqs_ctrl;
689e28f653SShengjiu Wang };
699e28f653SShengjiu Wang 
709e28f653SShengjiu Wang #define FSL_MQS_RATES	(SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
719e28f653SShengjiu Wang #define FSL_MQS_FORMATS	SNDRV_PCM_FMTBIT_S16_LE
729e28f653SShengjiu Wang 
739e28f653SShengjiu Wang static int fsl_mqs_hw_params(struct snd_pcm_substream *substream,
749e28f653SShengjiu Wang 			     struct snd_pcm_hw_params *params,
759e28f653SShengjiu Wang 			     struct snd_soc_dai *dai)
769e28f653SShengjiu Wang {
779e28f653SShengjiu Wang 	struct snd_soc_component *component = dai->component;
789e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = snd_soc_component_get_drvdata(component);
799e28f653SShengjiu Wang 	unsigned long mclk_rate;
809e28f653SShengjiu Wang 	int div, res;
81e9e8fc9eSYueHaibing 	int lrclk;
829e28f653SShengjiu Wang 
839e28f653SShengjiu Wang 	mclk_rate = clk_get_rate(mqs_priv->mclk);
849e28f653SShengjiu Wang 	lrclk = params_rate(params);
859e28f653SShengjiu Wang 
869e28f653SShengjiu Wang 	/*
879e28f653SShengjiu Wang 	 * mclk_rate / (oversample(32,64) * FS * 2 * divider ) = repeat_rate;
889e28f653SShengjiu Wang 	 * if repeat_rate is 8, mqs can achieve better quality.
899e28f653SShengjiu Wang 	 * oversample rate is fix to 32 currently.
909e28f653SShengjiu Wang 	 */
919e28f653SShengjiu Wang 	div = mclk_rate / (32 * lrclk * 2 * 8);
929e28f653SShengjiu Wang 	res = mclk_rate % (32 * lrclk * 2 * 8);
939e28f653SShengjiu Wang 
949e28f653SShengjiu Wang 	if (res == 0 && div > 0 && div <= 256) {
95063c9155SShengjiu Wang 		regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
96063c9155SShengjiu Wang 				   mqs_priv->soc->div_mask,
97063c9155SShengjiu Wang 				   (div - 1) << mqs_priv->soc->div_shift);
98063c9155SShengjiu Wang 		regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
99063c9155SShengjiu Wang 				   mqs_priv->soc->osr_mask, 0);
1009e28f653SShengjiu Wang 	} else {
1019e28f653SShengjiu Wang 		dev_err(component->dev, "can't get proper divider\n");
1029e28f653SShengjiu Wang 	}
1039e28f653SShengjiu Wang 
1049e28f653SShengjiu Wang 	return 0;
1059e28f653SShengjiu Wang }
1069e28f653SShengjiu Wang 
1079e28f653SShengjiu Wang static int fsl_mqs_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1089e28f653SShengjiu Wang {
1099e28f653SShengjiu Wang 	/* Only LEFT_J & SLAVE mode is supported. */
1109e28f653SShengjiu Wang 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1119e28f653SShengjiu Wang 	case SND_SOC_DAIFMT_LEFT_J:
1129e28f653SShengjiu Wang 		break;
1139e28f653SShengjiu Wang 	default:
1149e28f653SShengjiu Wang 		return -EINVAL;
1159e28f653SShengjiu Wang 	}
1169e28f653SShengjiu Wang 
1179e28f653SShengjiu Wang 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1189e28f653SShengjiu Wang 	case SND_SOC_DAIFMT_NB_NF:
1199e28f653SShengjiu Wang 		break;
1209e28f653SShengjiu Wang 	default:
1219e28f653SShengjiu Wang 		return -EINVAL;
1229e28f653SShengjiu Wang 	}
1239e28f653SShengjiu Wang 
124a51da9dcSMark Brown 	switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
1251faa6f82SShengjiu Wang 	case SND_SOC_DAIFMT_CBC_CFC:
1269e28f653SShengjiu Wang 		break;
1279e28f653SShengjiu Wang 	default:
1289e28f653SShengjiu Wang 		return -EINVAL;
1299e28f653SShengjiu Wang 	}
1309e28f653SShengjiu Wang 
1319e28f653SShengjiu Wang 	return 0;
1329e28f653SShengjiu Wang }
1339e28f653SShengjiu Wang 
1349e28f653SShengjiu Wang static int fsl_mqs_startup(struct snd_pcm_substream *substream,
1359e28f653SShengjiu Wang 			   struct snd_soc_dai *dai)
1369e28f653SShengjiu Wang {
1379e28f653SShengjiu Wang 	struct snd_soc_component *component = dai->component;
1389e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = snd_soc_component_get_drvdata(component);
1399e28f653SShengjiu Wang 
140063c9155SShengjiu Wang 	regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
141063c9155SShengjiu Wang 			   mqs_priv->soc->en_mask,
142063c9155SShengjiu Wang 			   1 << mqs_priv->soc->en_shift);
1439e28f653SShengjiu Wang 	return 0;
1449e28f653SShengjiu Wang }
1459e28f653SShengjiu Wang 
1469e28f653SShengjiu Wang static void fsl_mqs_shutdown(struct snd_pcm_substream *substream,
1479e28f653SShengjiu Wang 			     struct snd_soc_dai *dai)
1489e28f653SShengjiu Wang {
1499e28f653SShengjiu Wang 	struct snd_soc_component *component = dai->component;
1509e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = snd_soc_component_get_drvdata(component);
1519e28f653SShengjiu Wang 
152063c9155SShengjiu Wang 	regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
153063c9155SShengjiu Wang 			   mqs_priv->soc->en_mask, 0);
1549e28f653SShengjiu Wang }
1559e28f653SShengjiu Wang 
156dd79841cSYueHaibing static const struct snd_soc_component_driver soc_codec_fsl_mqs = {
1579e28f653SShengjiu Wang 	.idle_bias_on = 1,
1589e28f653SShengjiu Wang };
1599e28f653SShengjiu Wang 
1609e28f653SShengjiu Wang static const struct snd_soc_dai_ops fsl_mqs_dai_ops = {
1619e28f653SShengjiu Wang 	.startup = fsl_mqs_startup,
1629e28f653SShengjiu Wang 	.shutdown = fsl_mqs_shutdown,
1639e28f653SShengjiu Wang 	.hw_params = fsl_mqs_hw_params,
1649e28f653SShengjiu Wang 	.set_fmt = fsl_mqs_set_dai_fmt,
1659e28f653SShengjiu Wang };
1669e28f653SShengjiu Wang 
1679e28f653SShengjiu Wang static struct snd_soc_dai_driver fsl_mqs_dai = {
1689e28f653SShengjiu Wang 	.name		= "fsl-mqs-dai",
1699e28f653SShengjiu Wang 	.playback	= {
1709e28f653SShengjiu Wang 		.stream_name	= "Playback",
1719e28f653SShengjiu Wang 		.channels_min	= 2,
1729e28f653SShengjiu Wang 		.channels_max	= 2,
1739e28f653SShengjiu Wang 		.rates		= FSL_MQS_RATES,
1749e28f653SShengjiu Wang 		.formats	= FSL_MQS_FORMATS,
1759e28f653SShengjiu Wang 	},
1769e28f653SShengjiu Wang 	.ops = &fsl_mqs_dai_ops,
1779e28f653SShengjiu Wang };
1789e28f653SShengjiu Wang 
1799e28f653SShengjiu Wang static const struct regmap_config fsl_mqs_regmap_config = {
1809e28f653SShengjiu Wang 	.reg_bits = 32,
1819e28f653SShengjiu Wang 	.reg_stride = 4,
1829e28f653SShengjiu Wang 	.val_bits = 32,
1839e28f653SShengjiu Wang 	.max_register = REG_MQS_CTRL,
1849e28f653SShengjiu Wang 	.cache_type = REGCACHE_NONE,
1859e28f653SShengjiu Wang };
1869e28f653SShengjiu Wang 
1879e28f653SShengjiu Wang static int fsl_mqs_probe(struct platform_device *pdev)
1889e28f653SShengjiu Wang {
1899e28f653SShengjiu Wang 	struct device_node *np = pdev->dev.of_node;
190a9d27367SDan Carpenter 	struct device_node *gpr_np = NULL;
1919e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv;
1929e28f653SShengjiu Wang 	void __iomem *regs;
193a9d27367SDan Carpenter 	int ret;
1949e28f653SShengjiu Wang 
1959e28f653SShengjiu Wang 	mqs_priv = devm_kzalloc(&pdev->dev, sizeof(*mqs_priv), GFP_KERNEL);
1969e28f653SShengjiu Wang 	if (!mqs_priv)
1979e28f653SShengjiu Wang 		return -ENOMEM;
1989e28f653SShengjiu Wang 
1999e28f653SShengjiu Wang 	/* On i.MX6sx the MQS control register is in GPR domain
2009e28f653SShengjiu Wang 	 * But in i.MX8QM/i.MX8QXP the control register is moved
2019e28f653SShengjiu Wang 	 * to its own domain.
2029e28f653SShengjiu Wang 	 */
203063c9155SShengjiu Wang 	mqs_priv->soc = of_device_get_match_data(&pdev->dev);
2049e28f653SShengjiu Wang 
205063c9155SShengjiu Wang 	if (mqs_priv->soc->use_gpr) {
2069e28f653SShengjiu Wang 		gpr_np = of_parse_phandle(np, "gpr", 0);
207a9d27367SDan Carpenter 		if (!gpr_np) {
2089e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to get gpr node by phandle\n");
209a9d27367SDan Carpenter 			return -EINVAL;
2109e28f653SShengjiu Wang 		}
2119e28f653SShengjiu Wang 
2129e28f653SShengjiu Wang 		mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
2139e28f653SShengjiu Wang 		if (IS_ERR(mqs_priv->regmap)) {
2149e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to get gpr regmap\n");
2159e28f653SShengjiu Wang 			ret = PTR_ERR(mqs_priv->regmap);
216a9d27367SDan Carpenter 			goto err_free_gpr_np;
2179e28f653SShengjiu Wang 		}
2189e28f653SShengjiu Wang 	} else {
2199e28f653SShengjiu Wang 		regs = devm_platform_ioremap_resource(pdev, 0);
2209e28f653SShengjiu Wang 		if (IS_ERR(regs))
2219e28f653SShengjiu Wang 			return PTR_ERR(regs);
2229e28f653SShengjiu Wang 
2239e28f653SShengjiu Wang 		mqs_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev,
2249e28f653SShengjiu Wang 							     "core",
2259e28f653SShengjiu Wang 							     regs,
2269e28f653SShengjiu Wang 							     &fsl_mqs_regmap_config);
2279e28f653SShengjiu Wang 		if (IS_ERR(mqs_priv->regmap)) {
2289e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to init regmap: %ld\n",
2299e28f653SShengjiu Wang 				PTR_ERR(mqs_priv->regmap));
2309e28f653SShengjiu Wang 			return PTR_ERR(mqs_priv->regmap);
2319e28f653SShengjiu Wang 		}
2329e28f653SShengjiu Wang 
2339e28f653SShengjiu Wang 		mqs_priv->ipg = devm_clk_get(&pdev->dev, "core");
2349e28f653SShengjiu Wang 		if (IS_ERR(mqs_priv->ipg)) {
2359e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to get the clock: %ld\n",
2369e28f653SShengjiu Wang 				PTR_ERR(mqs_priv->ipg));
237a9d27367SDan Carpenter 			return PTR_ERR(mqs_priv->ipg);
2389e28f653SShengjiu Wang 		}
2399e28f653SShengjiu Wang 	}
2409e28f653SShengjiu Wang 
2419e28f653SShengjiu Wang 	mqs_priv->mclk = devm_clk_get(&pdev->dev, "mclk");
2429e28f653SShengjiu Wang 	if (IS_ERR(mqs_priv->mclk)) {
2439e28f653SShengjiu Wang 		dev_err(&pdev->dev, "failed to get the clock: %ld\n",
2449e28f653SShengjiu Wang 			PTR_ERR(mqs_priv->mclk));
245a9d27367SDan Carpenter 		ret = PTR_ERR(mqs_priv->mclk);
246a9d27367SDan Carpenter 		goto err_free_gpr_np;
2479e28f653SShengjiu Wang 	}
2489e28f653SShengjiu Wang 
2499e28f653SShengjiu Wang 	dev_set_drvdata(&pdev->dev, mqs_priv);
2509e28f653SShengjiu Wang 	pm_runtime_enable(&pdev->dev);
2519e28f653SShengjiu Wang 
252a9d27367SDan Carpenter 	ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs,
2539e28f653SShengjiu Wang 			&fsl_mqs_dai, 1);
254a9d27367SDan Carpenter 	if (ret)
255a9d27367SDan Carpenter 		goto err_free_gpr_np;
256a9d27367SDan Carpenter 	return 0;
257a9d27367SDan Carpenter 
258a9d27367SDan Carpenter err_free_gpr_np:
2599e28f653SShengjiu Wang 	of_node_put(gpr_np);
2609e28f653SShengjiu Wang 
2619e28f653SShengjiu Wang 	return ret;
2629e28f653SShengjiu Wang }
2639e28f653SShengjiu Wang 
264*4ff299cbSUwe Kleine-König static void fsl_mqs_remove(struct platform_device *pdev)
2659e28f653SShengjiu Wang {
2669e28f653SShengjiu Wang 	pm_runtime_disable(&pdev->dev);
2679e28f653SShengjiu Wang }
2689e28f653SShengjiu Wang 
2699e28f653SShengjiu Wang #ifdef CONFIG_PM
2709e28f653SShengjiu Wang static int fsl_mqs_runtime_resume(struct device *dev)
2719e28f653SShengjiu Wang {
2729e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);
27315217d17SShengjiu Wang 	int ret;
2749e28f653SShengjiu Wang 
27515217d17SShengjiu Wang 	ret = clk_prepare_enable(mqs_priv->ipg);
27615217d17SShengjiu Wang 	if (ret) {
27715217d17SShengjiu Wang 		dev_err(dev, "failed to enable ipg clock\n");
27815217d17SShengjiu Wang 		return ret;
27915217d17SShengjiu Wang 	}
2809e28f653SShengjiu Wang 
28115217d17SShengjiu Wang 	ret = clk_prepare_enable(mqs_priv->mclk);
28215217d17SShengjiu Wang 	if (ret) {
28315217d17SShengjiu Wang 		dev_err(dev, "failed to enable mclk clock\n");
28415217d17SShengjiu Wang 		clk_disable_unprepare(mqs_priv->ipg);
28515217d17SShengjiu Wang 		return ret;
28615217d17SShengjiu Wang 	}
2879e28f653SShengjiu Wang 
288063c9155SShengjiu Wang 	regmap_write(mqs_priv->regmap, mqs_priv->soc->ctrl_off, mqs_priv->reg_mqs_ctrl);
2899e28f653SShengjiu Wang 	return 0;
2909e28f653SShengjiu Wang }
2919e28f653SShengjiu Wang 
2929e28f653SShengjiu Wang static int fsl_mqs_runtime_suspend(struct device *dev)
2939e28f653SShengjiu Wang {
2949e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);
2959e28f653SShengjiu Wang 
296063c9155SShengjiu Wang 	regmap_read(mqs_priv->regmap, mqs_priv->soc->ctrl_off, &mqs_priv->reg_mqs_ctrl);
2979e28f653SShengjiu Wang 
2989e28f653SShengjiu Wang 	clk_disable_unprepare(mqs_priv->mclk);
2999e28f653SShengjiu Wang 	clk_disable_unprepare(mqs_priv->ipg);
3009e28f653SShengjiu Wang 
3019e28f653SShengjiu Wang 	return 0;
3029e28f653SShengjiu Wang }
3039e28f653SShengjiu Wang #endif
3049e28f653SShengjiu Wang 
3059e28f653SShengjiu Wang static const struct dev_pm_ops fsl_mqs_pm_ops = {
3069e28f653SShengjiu Wang 	SET_RUNTIME_PM_OPS(fsl_mqs_runtime_suspend,
3079e28f653SShengjiu Wang 			   fsl_mqs_runtime_resume,
3089e28f653SShengjiu Wang 			   NULL)
3099e28f653SShengjiu Wang 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
3109e28f653SShengjiu Wang 				pm_runtime_force_resume)
3119e28f653SShengjiu Wang };
3129e28f653SShengjiu Wang 
313063c9155SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx8qm_data = {
314063c9155SShengjiu Wang 	.use_gpr = false,
315063c9155SShengjiu Wang 	.ctrl_off = REG_MQS_CTRL,
316063c9155SShengjiu Wang 	.en_mask  = MQS_EN_MASK,
317063c9155SShengjiu Wang 	.en_shift = MQS_EN_SHIFT,
318063c9155SShengjiu Wang 	.rst_mask = MQS_SW_RST_MASK,
319063c9155SShengjiu Wang 	.rst_shift = MQS_SW_RST_SHIFT,
320063c9155SShengjiu Wang 	.osr_mask = MQS_OVERSAMPLE_MASK,
321063c9155SShengjiu Wang 	.osr_shift = MQS_OVERSAMPLE_SHIFT,
322063c9155SShengjiu Wang 	.div_mask = MQS_CLK_DIV_MASK,
323063c9155SShengjiu Wang 	.div_shift = MQS_CLK_DIV_SHIFT,
324063c9155SShengjiu Wang };
325063c9155SShengjiu Wang 
326063c9155SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx6sx_data = {
327063c9155SShengjiu Wang 	.use_gpr = true,
328063c9155SShengjiu Wang 	.ctrl_off = IOMUXC_GPR2,
329063c9155SShengjiu Wang 	.en_mask  = IMX6SX_GPR2_MQS_EN_MASK,
330063c9155SShengjiu Wang 	.en_shift = IMX6SX_GPR2_MQS_EN_SHIFT,
331063c9155SShengjiu Wang 	.rst_mask = IMX6SX_GPR2_MQS_SW_RST_MASK,
332063c9155SShengjiu Wang 	.rst_shift = IMX6SX_GPR2_MQS_SW_RST_SHIFT,
333063c9155SShengjiu Wang 	.osr_mask  = IMX6SX_GPR2_MQS_OVERSAMPLE_MASK,
334063c9155SShengjiu Wang 	.osr_shift = IMX6SX_GPR2_MQS_OVERSAMPLE_SHIFT,
335063c9155SShengjiu Wang 	.div_mask  = IMX6SX_GPR2_MQS_CLK_DIV_MASK,
336063c9155SShengjiu Wang 	.div_shift = IMX6SX_GPR2_MQS_CLK_DIV_SHIFT,
337063c9155SShengjiu Wang };
338063c9155SShengjiu Wang 
339047c69a3SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx93_data = {
340047c69a3SShengjiu Wang 	.use_gpr = true,
341047c69a3SShengjiu Wang 	.ctrl_off = 0x20,
342047c69a3SShengjiu Wang 	.en_mask  = BIT(1),
343047c69a3SShengjiu Wang 	.en_shift = 1,
344047c69a3SShengjiu Wang 	.rst_mask = BIT(2),
345047c69a3SShengjiu Wang 	.rst_shift = 2,
346047c69a3SShengjiu Wang 	.osr_mask = BIT(3),
347047c69a3SShengjiu Wang 	.osr_shift = 3,
348047c69a3SShengjiu Wang 	.div_mask = GENMASK(15, 8),
349047c69a3SShengjiu Wang 	.div_shift = 8,
350047c69a3SShengjiu Wang };
351047c69a3SShengjiu Wang 
3529e28f653SShengjiu Wang static const struct of_device_id fsl_mqs_dt_ids[] = {
353063c9155SShengjiu Wang 	{ .compatible = "fsl,imx8qm-mqs", .data = &fsl_mqs_imx8qm_data },
354063c9155SShengjiu Wang 	{ .compatible = "fsl,imx6sx-mqs", .data = &fsl_mqs_imx6sx_data },
355047c69a3SShengjiu Wang 	{ .compatible = "fsl,imx93-mqs", .data = &fsl_mqs_imx93_data },
3569e28f653SShengjiu Wang 	{}
3579e28f653SShengjiu Wang };
3589e28f653SShengjiu Wang MODULE_DEVICE_TABLE(of, fsl_mqs_dt_ids);
3599e28f653SShengjiu Wang 
3609e28f653SShengjiu Wang static struct platform_driver fsl_mqs_driver = {
3619e28f653SShengjiu Wang 	.probe		= fsl_mqs_probe,
362*4ff299cbSUwe Kleine-König 	.remove_new	= fsl_mqs_remove,
3639e28f653SShengjiu Wang 	.driver		= {
3649e28f653SShengjiu Wang 		.name	= "fsl-mqs",
3659e28f653SShengjiu Wang 		.of_match_table = fsl_mqs_dt_ids,
3669e28f653SShengjiu Wang 		.pm = &fsl_mqs_pm_ops,
3679e28f653SShengjiu Wang 	},
3689e28f653SShengjiu Wang };
3699e28f653SShengjiu Wang 
3709e28f653SShengjiu Wang module_platform_driver(fsl_mqs_driver);
3719e28f653SShengjiu Wang 
3729e28f653SShengjiu Wang MODULE_AUTHOR("Shengjiu Wang <Shengjiu.Wang@nxp.com>");
3739e28f653SShengjiu Wang MODULE_DESCRIPTION("MQS codec driver");
3749e28f653SShengjiu Wang MODULE_LICENSE("GPL v2");
3759e28f653SShengjiu Wang MODULE_ALIAS("platform:fsl-mqs");
376