xref: /linux/sound/soc/fsl/fsl_mqs.c (revision 063c915502b914a5a621458c763dfc28286f7606)
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>
13*063c9155SShengjiu 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 
33*063c9155SShengjiu Wang /**
34*063c9155SShengjiu Wang  * struct fsl_mqs_soc_data - soc specific data
35*063c9155SShengjiu Wang  *
36*063c9155SShengjiu Wang  * @use_gpr: control register is in General Purpose Register group
37*063c9155SShengjiu Wang  * @ctrl_off: control register offset
38*063c9155SShengjiu Wang  * @en_mask: enable bit mask
39*063c9155SShengjiu Wang  * @en_shift: enable bit shift
40*063c9155SShengjiu Wang  * @rst_mask: reset bit mask
41*063c9155SShengjiu Wang  * @rst_shift: reset bit shift
42*063c9155SShengjiu Wang  * @osr_mask: oversample bit mask
43*063c9155SShengjiu Wang  * @osr_shift: oversample bit shift
44*063c9155SShengjiu Wang  * @div_mask: clock divider mask
45*063c9155SShengjiu Wang  * @div_shift: clock divider bit shift
46*063c9155SShengjiu Wang  */
47*063c9155SShengjiu Wang struct fsl_mqs_soc_data {
48*063c9155SShengjiu Wang 	bool use_gpr;
49*063c9155SShengjiu Wang 	int  ctrl_off;
50*063c9155SShengjiu Wang 	int  en_mask;
51*063c9155SShengjiu Wang 	int  en_shift;
52*063c9155SShengjiu Wang 	int  rst_mask;
53*063c9155SShengjiu Wang 	int  rst_shift;
54*063c9155SShengjiu Wang 	int  osr_mask;
55*063c9155SShengjiu Wang 	int  osr_shift;
56*063c9155SShengjiu Wang 	int  div_mask;
57*063c9155SShengjiu Wang 	int  div_shift;
58*063c9155SShengjiu Wang };
59*063c9155SShengjiu 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;
65*063c9155SShengjiu 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) {
95*063c9155SShengjiu Wang 		regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
96*063c9155SShengjiu Wang 				   mqs_priv->soc->div_mask,
97*063c9155SShengjiu Wang 				   (div - 1) << mqs_priv->soc->div_shift);
98*063c9155SShengjiu Wang 		regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
99*063c9155SShengjiu 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) {
125a51da9dcSMark Brown 	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 
140*063c9155SShengjiu Wang 	regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
141*063c9155SShengjiu Wang 			   mqs_priv->soc->en_mask,
142*063c9155SShengjiu 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 
152*063c9155SShengjiu Wang 	regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off,
153*063c9155SShengjiu 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 	.non_legacy_dai_naming	= 1,
1599e28f653SShengjiu Wang };
1609e28f653SShengjiu Wang 
1619e28f653SShengjiu Wang static const struct snd_soc_dai_ops fsl_mqs_dai_ops = {
1629e28f653SShengjiu Wang 	.startup = fsl_mqs_startup,
1639e28f653SShengjiu Wang 	.shutdown = fsl_mqs_shutdown,
1649e28f653SShengjiu Wang 	.hw_params = fsl_mqs_hw_params,
1659e28f653SShengjiu Wang 	.set_fmt = fsl_mqs_set_dai_fmt,
1669e28f653SShengjiu Wang };
1679e28f653SShengjiu Wang 
1689e28f653SShengjiu Wang static struct snd_soc_dai_driver fsl_mqs_dai = {
1699e28f653SShengjiu Wang 	.name		= "fsl-mqs-dai",
1709e28f653SShengjiu Wang 	.playback	= {
1719e28f653SShengjiu Wang 		.stream_name	= "Playback",
1729e28f653SShengjiu Wang 		.channels_min	= 2,
1739e28f653SShengjiu Wang 		.channels_max	= 2,
1749e28f653SShengjiu Wang 		.rates		= FSL_MQS_RATES,
1759e28f653SShengjiu Wang 		.formats	= FSL_MQS_FORMATS,
1769e28f653SShengjiu Wang 	},
1779e28f653SShengjiu Wang 	.ops = &fsl_mqs_dai_ops,
1789e28f653SShengjiu Wang };
1799e28f653SShengjiu Wang 
1809e28f653SShengjiu Wang static const struct regmap_config fsl_mqs_regmap_config = {
1819e28f653SShengjiu Wang 	.reg_bits = 32,
1829e28f653SShengjiu Wang 	.reg_stride = 4,
1839e28f653SShengjiu Wang 	.val_bits = 32,
1849e28f653SShengjiu Wang 	.max_register = REG_MQS_CTRL,
1859e28f653SShengjiu Wang 	.cache_type = REGCACHE_NONE,
1869e28f653SShengjiu Wang };
1879e28f653SShengjiu Wang 
1889e28f653SShengjiu Wang static int fsl_mqs_probe(struct platform_device *pdev)
1899e28f653SShengjiu Wang {
1909e28f653SShengjiu Wang 	struct device_node *np = pdev->dev.of_node;
191a9d27367SDan Carpenter 	struct device_node *gpr_np = NULL;
1929e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv;
1939e28f653SShengjiu Wang 	void __iomem *regs;
194a9d27367SDan Carpenter 	int ret;
1959e28f653SShengjiu Wang 
1969e28f653SShengjiu Wang 	mqs_priv = devm_kzalloc(&pdev->dev, sizeof(*mqs_priv), GFP_KERNEL);
1979e28f653SShengjiu Wang 	if (!mqs_priv)
1989e28f653SShengjiu Wang 		return -ENOMEM;
1999e28f653SShengjiu Wang 
2009e28f653SShengjiu Wang 	/* On i.MX6sx the MQS control register is in GPR domain
2019e28f653SShengjiu Wang 	 * But in i.MX8QM/i.MX8QXP the control register is moved
2029e28f653SShengjiu Wang 	 * to its own domain.
2039e28f653SShengjiu Wang 	 */
204*063c9155SShengjiu Wang 	mqs_priv->soc = of_device_get_match_data(&pdev->dev);
2059e28f653SShengjiu Wang 
206*063c9155SShengjiu Wang 	if (mqs_priv->soc->use_gpr) {
2079e28f653SShengjiu Wang 		gpr_np = of_parse_phandle(np, "gpr", 0);
208a9d27367SDan Carpenter 		if (!gpr_np) {
2099e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to get gpr node by phandle\n");
210a9d27367SDan Carpenter 			return -EINVAL;
2119e28f653SShengjiu Wang 		}
2129e28f653SShengjiu Wang 
2139e28f653SShengjiu Wang 		mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
2149e28f653SShengjiu Wang 		if (IS_ERR(mqs_priv->regmap)) {
2159e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to get gpr regmap\n");
2169e28f653SShengjiu Wang 			ret = PTR_ERR(mqs_priv->regmap);
217a9d27367SDan Carpenter 			goto err_free_gpr_np;
2189e28f653SShengjiu Wang 		}
2199e28f653SShengjiu Wang 	} else {
2209e28f653SShengjiu Wang 		regs = devm_platform_ioremap_resource(pdev, 0);
2219e28f653SShengjiu Wang 		if (IS_ERR(regs))
2229e28f653SShengjiu Wang 			return PTR_ERR(regs);
2239e28f653SShengjiu Wang 
2249e28f653SShengjiu Wang 		mqs_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev,
2259e28f653SShengjiu Wang 							     "core",
2269e28f653SShengjiu Wang 							     regs,
2279e28f653SShengjiu Wang 							     &fsl_mqs_regmap_config);
2289e28f653SShengjiu Wang 		if (IS_ERR(mqs_priv->regmap)) {
2299e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to init regmap: %ld\n",
2309e28f653SShengjiu Wang 				PTR_ERR(mqs_priv->regmap));
2319e28f653SShengjiu Wang 			return PTR_ERR(mqs_priv->regmap);
2329e28f653SShengjiu Wang 		}
2339e28f653SShengjiu Wang 
2349e28f653SShengjiu Wang 		mqs_priv->ipg = devm_clk_get(&pdev->dev, "core");
2359e28f653SShengjiu Wang 		if (IS_ERR(mqs_priv->ipg)) {
2369e28f653SShengjiu Wang 			dev_err(&pdev->dev, "failed to get the clock: %ld\n",
2379e28f653SShengjiu Wang 				PTR_ERR(mqs_priv->ipg));
238a9d27367SDan Carpenter 			return PTR_ERR(mqs_priv->ipg);
2399e28f653SShengjiu Wang 		}
2409e28f653SShengjiu Wang 	}
2419e28f653SShengjiu Wang 
2429e28f653SShengjiu Wang 	mqs_priv->mclk = devm_clk_get(&pdev->dev, "mclk");
2439e28f653SShengjiu Wang 	if (IS_ERR(mqs_priv->mclk)) {
2449e28f653SShengjiu Wang 		dev_err(&pdev->dev, "failed to get the clock: %ld\n",
2459e28f653SShengjiu Wang 			PTR_ERR(mqs_priv->mclk));
246a9d27367SDan Carpenter 		ret = PTR_ERR(mqs_priv->mclk);
247a9d27367SDan Carpenter 		goto err_free_gpr_np;
2489e28f653SShengjiu Wang 	}
2499e28f653SShengjiu Wang 
2509e28f653SShengjiu Wang 	dev_set_drvdata(&pdev->dev, mqs_priv);
2519e28f653SShengjiu Wang 	pm_runtime_enable(&pdev->dev);
2529e28f653SShengjiu Wang 
253a9d27367SDan Carpenter 	ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs,
2549e28f653SShengjiu Wang 			&fsl_mqs_dai, 1);
255a9d27367SDan Carpenter 	if (ret)
256a9d27367SDan Carpenter 		goto err_free_gpr_np;
257a9d27367SDan Carpenter 	return 0;
258a9d27367SDan Carpenter 
259a9d27367SDan Carpenter err_free_gpr_np:
2609e28f653SShengjiu Wang 	of_node_put(gpr_np);
2619e28f653SShengjiu Wang 
2629e28f653SShengjiu Wang 	return ret;
2639e28f653SShengjiu Wang }
2649e28f653SShengjiu Wang 
2659e28f653SShengjiu Wang static int fsl_mqs_remove(struct platform_device *pdev)
2669e28f653SShengjiu Wang {
2679e28f653SShengjiu Wang 	pm_runtime_disable(&pdev->dev);
2689e28f653SShengjiu Wang 	return 0;
2699e28f653SShengjiu Wang }
2709e28f653SShengjiu Wang 
2719e28f653SShengjiu Wang #ifdef CONFIG_PM
2729e28f653SShengjiu Wang static int fsl_mqs_runtime_resume(struct device *dev)
2739e28f653SShengjiu Wang {
2749e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);
27515217d17SShengjiu Wang 	int ret;
2769e28f653SShengjiu Wang 
27715217d17SShengjiu Wang 	ret = clk_prepare_enable(mqs_priv->ipg);
27815217d17SShengjiu Wang 	if (ret) {
27915217d17SShengjiu Wang 		dev_err(dev, "failed to enable ipg clock\n");
28015217d17SShengjiu Wang 		return ret;
28115217d17SShengjiu Wang 	}
2829e28f653SShengjiu Wang 
28315217d17SShengjiu Wang 	ret = clk_prepare_enable(mqs_priv->mclk);
28415217d17SShengjiu Wang 	if (ret) {
28515217d17SShengjiu Wang 		dev_err(dev, "failed to enable mclk clock\n");
28615217d17SShengjiu Wang 		clk_disable_unprepare(mqs_priv->ipg);
28715217d17SShengjiu Wang 		return ret;
28815217d17SShengjiu Wang 	}
2899e28f653SShengjiu Wang 
290*063c9155SShengjiu Wang 	regmap_write(mqs_priv->regmap, mqs_priv->soc->ctrl_off, mqs_priv->reg_mqs_ctrl);
2919e28f653SShengjiu Wang 	return 0;
2929e28f653SShengjiu Wang }
2939e28f653SShengjiu Wang 
2949e28f653SShengjiu Wang static int fsl_mqs_runtime_suspend(struct device *dev)
2959e28f653SShengjiu Wang {
2969e28f653SShengjiu Wang 	struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);
2979e28f653SShengjiu Wang 
298*063c9155SShengjiu Wang 	regmap_read(mqs_priv->regmap, mqs_priv->soc->ctrl_off, &mqs_priv->reg_mqs_ctrl);
2999e28f653SShengjiu Wang 
3009e28f653SShengjiu Wang 	clk_disable_unprepare(mqs_priv->mclk);
3019e28f653SShengjiu Wang 	clk_disable_unprepare(mqs_priv->ipg);
3029e28f653SShengjiu Wang 
3039e28f653SShengjiu Wang 	return 0;
3049e28f653SShengjiu Wang }
3059e28f653SShengjiu Wang #endif
3069e28f653SShengjiu Wang 
3079e28f653SShengjiu Wang static const struct dev_pm_ops fsl_mqs_pm_ops = {
3089e28f653SShengjiu Wang 	SET_RUNTIME_PM_OPS(fsl_mqs_runtime_suspend,
3099e28f653SShengjiu Wang 			   fsl_mqs_runtime_resume,
3109e28f653SShengjiu Wang 			   NULL)
3119e28f653SShengjiu Wang 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
3129e28f653SShengjiu Wang 				pm_runtime_force_resume)
3139e28f653SShengjiu Wang };
3149e28f653SShengjiu Wang 
315*063c9155SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx8qm_data = {
316*063c9155SShengjiu Wang 	.use_gpr = false,
317*063c9155SShengjiu Wang 	.ctrl_off = REG_MQS_CTRL,
318*063c9155SShengjiu Wang 	.en_mask  = MQS_EN_MASK,
319*063c9155SShengjiu Wang 	.en_shift = MQS_EN_SHIFT,
320*063c9155SShengjiu Wang 	.rst_mask = MQS_SW_RST_MASK,
321*063c9155SShengjiu Wang 	.rst_shift = MQS_SW_RST_SHIFT,
322*063c9155SShengjiu Wang 	.osr_mask = MQS_OVERSAMPLE_MASK,
323*063c9155SShengjiu Wang 	.osr_shift = MQS_OVERSAMPLE_SHIFT,
324*063c9155SShengjiu Wang 	.div_mask = MQS_CLK_DIV_MASK,
325*063c9155SShengjiu Wang 	.div_shift = MQS_CLK_DIV_SHIFT,
326*063c9155SShengjiu Wang };
327*063c9155SShengjiu Wang 
328*063c9155SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx6sx_data = {
329*063c9155SShengjiu Wang 	.use_gpr = true,
330*063c9155SShengjiu Wang 	.ctrl_off = IOMUXC_GPR2,
331*063c9155SShengjiu Wang 	.en_mask  = IMX6SX_GPR2_MQS_EN_MASK,
332*063c9155SShengjiu Wang 	.en_shift = IMX6SX_GPR2_MQS_EN_SHIFT,
333*063c9155SShengjiu Wang 	.rst_mask = IMX6SX_GPR2_MQS_SW_RST_MASK,
334*063c9155SShengjiu Wang 	.rst_shift = IMX6SX_GPR2_MQS_SW_RST_SHIFT,
335*063c9155SShengjiu Wang 	.osr_mask  = IMX6SX_GPR2_MQS_OVERSAMPLE_MASK,
336*063c9155SShengjiu Wang 	.osr_shift = IMX6SX_GPR2_MQS_OVERSAMPLE_SHIFT,
337*063c9155SShengjiu Wang 	.div_mask  = IMX6SX_GPR2_MQS_CLK_DIV_MASK,
338*063c9155SShengjiu Wang 	.div_shift = IMX6SX_GPR2_MQS_CLK_DIV_SHIFT,
339*063c9155SShengjiu Wang };
340*063c9155SShengjiu Wang 
3419e28f653SShengjiu Wang static const struct of_device_id fsl_mqs_dt_ids[] = {
342*063c9155SShengjiu Wang 	{ .compatible = "fsl,imx8qm-mqs", .data = &fsl_mqs_imx8qm_data },
343*063c9155SShengjiu Wang 	{ .compatible = "fsl,imx6sx-mqs", .data = &fsl_mqs_imx6sx_data },
3449e28f653SShengjiu Wang 	{}
3459e28f653SShengjiu Wang };
3469e28f653SShengjiu Wang MODULE_DEVICE_TABLE(of, fsl_mqs_dt_ids);
3479e28f653SShengjiu Wang 
3489e28f653SShengjiu Wang static struct platform_driver fsl_mqs_driver = {
3499e28f653SShengjiu Wang 	.probe		= fsl_mqs_probe,
3509e28f653SShengjiu Wang 	.remove		= fsl_mqs_remove,
3519e28f653SShengjiu Wang 	.driver		= {
3529e28f653SShengjiu Wang 		.name	= "fsl-mqs",
3539e28f653SShengjiu Wang 		.of_match_table = fsl_mqs_dt_ids,
3549e28f653SShengjiu Wang 		.pm = &fsl_mqs_pm_ops,
3559e28f653SShengjiu Wang 	},
3569e28f653SShengjiu Wang };
3579e28f653SShengjiu Wang 
3589e28f653SShengjiu Wang module_platform_driver(fsl_mqs_driver);
3599e28f653SShengjiu Wang 
3609e28f653SShengjiu Wang MODULE_AUTHOR("Shengjiu Wang <Shengjiu.Wang@nxp.com>");
3619e28f653SShengjiu Wang MODULE_DESCRIPTION("MQS codec driver");
3629e28f653SShengjiu Wang MODULE_LICENSE("GPL v2");
3639e28f653SShengjiu Wang MODULE_ALIAS("platform:fsl-mqs");
364