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> 139e28f653SShengjiu Wang #include <linux/pm_runtime.h> 149e28f653SShengjiu Wang #include <linux/pm.h> 159e28f653SShengjiu Wang #include <linux/slab.h> 169e28f653SShengjiu Wang #include <sound/soc.h> 179e28f653SShengjiu Wang #include <sound/pcm.h> 189e28f653SShengjiu Wang #include <sound/initval.h> 199e28f653SShengjiu Wang 209e28f653SShengjiu Wang #define REG_MQS_CTRL 0x00 219e28f653SShengjiu Wang 229e28f653SShengjiu Wang #define MQS_EN_MASK (0x1 << 28) 239e28f653SShengjiu Wang #define MQS_EN_SHIFT (28) 249e28f653SShengjiu Wang #define MQS_SW_RST_MASK (0x1 << 24) 259e28f653SShengjiu Wang #define MQS_SW_RST_SHIFT (24) 269e28f653SShengjiu Wang #define MQS_OVERSAMPLE_MASK (0x1 << 20) 279e28f653SShengjiu Wang #define MQS_OVERSAMPLE_SHIFT (20) 289e28f653SShengjiu Wang #define MQS_CLK_DIV_MASK (0xFF << 0) 299e28f653SShengjiu Wang #define MQS_CLK_DIV_SHIFT (0) 309e28f653SShengjiu Wang 31*401a1f02SShengjiu Wang enum reg_type { 32*401a1f02SShengjiu Wang TYPE_REG_OWN, /* module own register space */ 33*401a1f02SShengjiu Wang TYPE_REG_GPR, /* register in GPR space */ 34*401a1f02SShengjiu Wang TYPE_REG_SM, /* System Manager controls the register */ 35*401a1f02SShengjiu Wang }; 36*401a1f02SShengjiu Wang 37063c9155SShengjiu Wang /** 38063c9155SShengjiu Wang * struct fsl_mqs_soc_data - soc specific data 39063c9155SShengjiu Wang * 40*401a1f02SShengjiu Wang * @type: control register space type 41063c9155SShengjiu Wang * @ctrl_off: control register offset 42063c9155SShengjiu Wang * @en_mask: enable bit mask 43063c9155SShengjiu Wang * @en_shift: enable bit shift 44063c9155SShengjiu Wang * @rst_mask: reset bit mask 45063c9155SShengjiu Wang * @rst_shift: reset bit shift 46063c9155SShengjiu Wang * @osr_mask: oversample bit mask 47063c9155SShengjiu Wang * @osr_shift: oversample bit shift 48063c9155SShengjiu Wang * @div_mask: clock divider mask 49063c9155SShengjiu Wang * @div_shift: clock divider bit shift 50063c9155SShengjiu Wang */ 51063c9155SShengjiu Wang struct fsl_mqs_soc_data { 52*401a1f02SShengjiu Wang enum reg_type type; 53063c9155SShengjiu Wang int ctrl_off; 54063c9155SShengjiu Wang int en_mask; 55063c9155SShengjiu Wang int en_shift; 56063c9155SShengjiu Wang int rst_mask; 57063c9155SShengjiu Wang int rst_shift; 58063c9155SShengjiu Wang int osr_mask; 59063c9155SShengjiu Wang int osr_shift; 60063c9155SShengjiu Wang int div_mask; 61063c9155SShengjiu Wang int div_shift; 62063c9155SShengjiu Wang }; 63063c9155SShengjiu Wang 649e28f653SShengjiu Wang /* codec private data */ 659e28f653SShengjiu Wang struct fsl_mqs { 669e28f653SShengjiu Wang struct regmap *regmap; 679e28f653SShengjiu Wang struct clk *mclk; 689e28f653SShengjiu Wang struct clk *ipg; 69063c9155SShengjiu Wang const struct fsl_mqs_soc_data *soc; 709e28f653SShengjiu Wang 719e28f653SShengjiu Wang unsigned int reg_mqs_ctrl; 729e28f653SShengjiu Wang }; 739e28f653SShengjiu Wang 749e28f653SShengjiu Wang #define FSL_MQS_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 759e28f653SShengjiu Wang #define FSL_MQS_FORMATS SNDRV_PCM_FMTBIT_S16_LE 769e28f653SShengjiu Wang 779e28f653SShengjiu Wang static int fsl_mqs_hw_params(struct snd_pcm_substream *substream, 789e28f653SShengjiu Wang struct snd_pcm_hw_params *params, 799e28f653SShengjiu Wang struct snd_soc_dai *dai) 809e28f653SShengjiu Wang { 819e28f653SShengjiu Wang struct snd_soc_component *component = dai->component; 829e28f653SShengjiu Wang struct fsl_mqs *mqs_priv = snd_soc_component_get_drvdata(component); 839e28f653SShengjiu Wang unsigned long mclk_rate; 849e28f653SShengjiu Wang int div, res; 85e9e8fc9eSYueHaibing int lrclk; 869e28f653SShengjiu Wang 879e28f653SShengjiu Wang mclk_rate = clk_get_rate(mqs_priv->mclk); 889e28f653SShengjiu Wang lrclk = params_rate(params); 899e28f653SShengjiu Wang 909e28f653SShengjiu Wang /* 919e28f653SShengjiu Wang * mclk_rate / (oversample(32,64) * FS * 2 * divider ) = repeat_rate; 929e28f653SShengjiu Wang * if repeat_rate is 8, mqs can achieve better quality. 939e28f653SShengjiu Wang * oversample rate is fix to 32 currently. 949e28f653SShengjiu Wang */ 959e28f653SShengjiu Wang div = mclk_rate / (32 * lrclk * 2 * 8); 969e28f653SShengjiu Wang res = mclk_rate % (32 * lrclk * 2 * 8); 979e28f653SShengjiu Wang 989e28f653SShengjiu Wang if (res == 0 && div > 0 && div <= 256) { 99063c9155SShengjiu Wang regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, 100063c9155SShengjiu Wang mqs_priv->soc->div_mask, 101063c9155SShengjiu Wang (div - 1) << mqs_priv->soc->div_shift); 102063c9155SShengjiu Wang regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, 103063c9155SShengjiu Wang mqs_priv->soc->osr_mask, 0); 1049e28f653SShengjiu Wang } else { 1059e28f653SShengjiu Wang dev_err(component->dev, "can't get proper divider\n"); 1069e28f653SShengjiu Wang } 1079e28f653SShengjiu Wang 1089e28f653SShengjiu Wang return 0; 1099e28f653SShengjiu Wang } 1109e28f653SShengjiu Wang 1119e28f653SShengjiu Wang static int fsl_mqs_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 1129e28f653SShengjiu Wang { 1139e28f653SShengjiu Wang /* Only LEFT_J & SLAVE mode is supported. */ 1149e28f653SShengjiu Wang switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 1159e28f653SShengjiu Wang case SND_SOC_DAIFMT_LEFT_J: 1169e28f653SShengjiu Wang break; 1179e28f653SShengjiu Wang default: 1189e28f653SShengjiu Wang return -EINVAL; 1199e28f653SShengjiu Wang } 1209e28f653SShengjiu Wang 1219e28f653SShengjiu Wang switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 1229e28f653SShengjiu Wang case SND_SOC_DAIFMT_NB_NF: 1239e28f653SShengjiu Wang break; 1249e28f653SShengjiu Wang default: 1259e28f653SShengjiu Wang return -EINVAL; 1269e28f653SShengjiu Wang } 1279e28f653SShengjiu Wang 128a51da9dcSMark Brown switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { 1291faa6f82SShengjiu Wang case SND_SOC_DAIFMT_CBC_CFC: 1309e28f653SShengjiu Wang break; 1319e28f653SShengjiu Wang default: 1329e28f653SShengjiu Wang return -EINVAL; 1339e28f653SShengjiu Wang } 1349e28f653SShengjiu Wang 1359e28f653SShengjiu Wang return 0; 1369e28f653SShengjiu Wang } 1379e28f653SShengjiu Wang 1389e28f653SShengjiu Wang static int fsl_mqs_startup(struct snd_pcm_substream *substream, 1399e28f653SShengjiu Wang struct snd_soc_dai *dai) 1409e28f653SShengjiu Wang { 1419e28f653SShengjiu Wang struct snd_soc_component *component = dai->component; 1429e28f653SShengjiu Wang struct fsl_mqs *mqs_priv = snd_soc_component_get_drvdata(component); 1439e28f653SShengjiu Wang 144063c9155SShengjiu Wang regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, 145063c9155SShengjiu Wang mqs_priv->soc->en_mask, 146063c9155SShengjiu Wang 1 << mqs_priv->soc->en_shift); 1479e28f653SShengjiu Wang return 0; 1489e28f653SShengjiu Wang } 1499e28f653SShengjiu Wang 1509e28f653SShengjiu Wang static void fsl_mqs_shutdown(struct snd_pcm_substream *substream, 1519e28f653SShengjiu Wang struct snd_soc_dai *dai) 1529e28f653SShengjiu Wang { 1539e28f653SShengjiu Wang struct snd_soc_component *component = dai->component; 1549e28f653SShengjiu Wang struct fsl_mqs *mqs_priv = snd_soc_component_get_drvdata(component); 1559e28f653SShengjiu Wang 156063c9155SShengjiu Wang regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, 157063c9155SShengjiu Wang mqs_priv->soc->en_mask, 0); 1589e28f653SShengjiu Wang } 1599e28f653SShengjiu Wang 160dd79841cSYueHaibing static const struct snd_soc_component_driver soc_codec_fsl_mqs = { 1619e28f653SShengjiu Wang .idle_bias_on = 1, 1629e28f653SShengjiu Wang }; 1639e28f653SShengjiu Wang 1649e28f653SShengjiu Wang static const struct snd_soc_dai_ops fsl_mqs_dai_ops = { 1659e28f653SShengjiu Wang .startup = fsl_mqs_startup, 1669e28f653SShengjiu Wang .shutdown = fsl_mqs_shutdown, 1679e28f653SShengjiu Wang .hw_params = fsl_mqs_hw_params, 1689e28f653SShengjiu Wang .set_fmt = fsl_mqs_set_dai_fmt, 1699e28f653SShengjiu Wang }; 1709e28f653SShengjiu Wang 1719e28f653SShengjiu Wang static struct snd_soc_dai_driver fsl_mqs_dai = { 1729e28f653SShengjiu Wang .name = "fsl-mqs-dai", 1739e28f653SShengjiu Wang .playback = { 1749e28f653SShengjiu Wang .stream_name = "Playback", 1759e28f653SShengjiu Wang .channels_min = 2, 1769e28f653SShengjiu Wang .channels_max = 2, 1779e28f653SShengjiu Wang .rates = FSL_MQS_RATES, 1789e28f653SShengjiu Wang .formats = FSL_MQS_FORMATS, 1799e28f653SShengjiu Wang }, 1809e28f653SShengjiu Wang .ops = &fsl_mqs_dai_ops, 1819e28f653SShengjiu Wang }; 1829e28f653SShengjiu Wang 1839e28f653SShengjiu Wang static const struct regmap_config fsl_mqs_regmap_config = { 1849e28f653SShengjiu Wang .reg_bits = 32, 1859e28f653SShengjiu Wang .reg_stride = 4, 1869e28f653SShengjiu Wang .val_bits = 32, 1879e28f653SShengjiu Wang .max_register = REG_MQS_CTRL, 1889e28f653SShengjiu Wang .cache_type = REGCACHE_NONE, 1899e28f653SShengjiu Wang }; 1909e28f653SShengjiu Wang 1919e28f653SShengjiu Wang static int fsl_mqs_probe(struct platform_device *pdev) 1929e28f653SShengjiu Wang { 1939e28f653SShengjiu Wang struct device_node *np = pdev->dev.of_node; 194a9d27367SDan Carpenter struct device_node *gpr_np = NULL; 1959e28f653SShengjiu Wang struct fsl_mqs *mqs_priv; 1969e28f653SShengjiu Wang void __iomem *regs; 197a9d27367SDan Carpenter int ret; 1989e28f653SShengjiu Wang 1999e28f653SShengjiu Wang mqs_priv = devm_kzalloc(&pdev->dev, sizeof(*mqs_priv), GFP_KERNEL); 2009e28f653SShengjiu Wang if (!mqs_priv) 2019e28f653SShengjiu Wang return -ENOMEM; 2029e28f653SShengjiu Wang 2039e28f653SShengjiu Wang /* On i.MX6sx the MQS control register is in GPR domain 2049e28f653SShengjiu Wang * But in i.MX8QM/i.MX8QXP the control register is moved 2059e28f653SShengjiu Wang * to its own domain. 2069e28f653SShengjiu Wang */ 207063c9155SShengjiu Wang mqs_priv->soc = of_device_get_match_data(&pdev->dev); 2089e28f653SShengjiu Wang 209*401a1f02SShengjiu Wang if (mqs_priv->soc->type == TYPE_REG_GPR) { 2109e28f653SShengjiu Wang gpr_np = of_parse_phandle(np, "gpr", 0); 211a9d27367SDan Carpenter if (!gpr_np) { 2129e28f653SShengjiu Wang dev_err(&pdev->dev, "failed to get gpr node by phandle\n"); 213a9d27367SDan Carpenter return -EINVAL; 2149e28f653SShengjiu Wang } 2159e28f653SShengjiu Wang 2169e28f653SShengjiu Wang mqs_priv->regmap = syscon_node_to_regmap(gpr_np); 2171c348902SLiliang Ye of_node_put(gpr_np); 2189e28f653SShengjiu Wang if (IS_ERR(mqs_priv->regmap)) { 2199e28f653SShengjiu Wang dev_err(&pdev->dev, "failed to get gpr regmap\n"); 2201c348902SLiliang Ye return PTR_ERR(mqs_priv->regmap); 2219e28f653SShengjiu Wang } 2229e28f653SShengjiu Wang } else { 2239e28f653SShengjiu Wang regs = devm_platform_ioremap_resource(pdev, 0); 2249e28f653SShengjiu Wang if (IS_ERR(regs)) 2259e28f653SShengjiu Wang return PTR_ERR(regs); 2269e28f653SShengjiu Wang 2279e28f653SShengjiu Wang mqs_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, 2289e28f653SShengjiu Wang "core", 2299e28f653SShengjiu Wang regs, 2309e28f653SShengjiu Wang &fsl_mqs_regmap_config); 2319e28f653SShengjiu Wang if (IS_ERR(mqs_priv->regmap)) { 2329e28f653SShengjiu Wang dev_err(&pdev->dev, "failed to init regmap: %ld\n", 2339e28f653SShengjiu Wang PTR_ERR(mqs_priv->regmap)); 2349e28f653SShengjiu Wang return PTR_ERR(mqs_priv->regmap); 2359e28f653SShengjiu Wang } 2369e28f653SShengjiu Wang 2379e28f653SShengjiu Wang mqs_priv->ipg = devm_clk_get(&pdev->dev, "core"); 2389e28f653SShengjiu Wang if (IS_ERR(mqs_priv->ipg)) { 2399e28f653SShengjiu Wang dev_err(&pdev->dev, "failed to get the clock: %ld\n", 2409e28f653SShengjiu Wang PTR_ERR(mqs_priv->ipg)); 241a9d27367SDan Carpenter return PTR_ERR(mqs_priv->ipg); 2429e28f653SShengjiu Wang } 2439e28f653SShengjiu Wang } 2449e28f653SShengjiu Wang 2459e28f653SShengjiu Wang mqs_priv->mclk = devm_clk_get(&pdev->dev, "mclk"); 2469e28f653SShengjiu Wang if (IS_ERR(mqs_priv->mclk)) { 2479e28f653SShengjiu Wang dev_err(&pdev->dev, "failed to get the clock: %ld\n", 2489e28f653SShengjiu Wang PTR_ERR(mqs_priv->mclk)); 2491c348902SLiliang Ye return PTR_ERR(mqs_priv->mclk); 2509e28f653SShengjiu Wang } 2519e28f653SShengjiu Wang 2529e28f653SShengjiu Wang dev_set_drvdata(&pdev->dev, mqs_priv); 2539e28f653SShengjiu Wang pm_runtime_enable(&pdev->dev); 2549e28f653SShengjiu Wang 255a9d27367SDan Carpenter ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs, 2569e28f653SShengjiu Wang &fsl_mqs_dai, 1); 257a9d27367SDan Carpenter if (ret) 2589e28f653SShengjiu Wang return ret; 2591c348902SLiliang Ye 2601c348902SLiliang Ye return 0; 2619e28f653SShengjiu Wang } 2629e28f653SShengjiu Wang 2634ff299cbSUwe Kleine-König static void fsl_mqs_remove(struct platform_device *pdev) 2649e28f653SShengjiu Wang { 2659e28f653SShengjiu Wang pm_runtime_disable(&pdev->dev); 2669e28f653SShengjiu Wang } 2679e28f653SShengjiu Wang 2689e28f653SShengjiu Wang #ifdef CONFIG_PM 2699e28f653SShengjiu Wang static int fsl_mqs_runtime_resume(struct device *dev) 2709e28f653SShengjiu Wang { 2719e28f653SShengjiu Wang struct fsl_mqs *mqs_priv = dev_get_drvdata(dev); 27215217d17SShengjiu Wang int ret; 2739e28f653SShengjiu Wang 27415217d17SShengjiu Wang ret = clk_prepare_enable(mqs_priv->ipg); 27515217d17SShengjiu Wang if (ret) { 27615217d17SShengjiu Wang dev_err(dev, "failed to enable ipg clock\n"); 27715217d17SShengjiu Wang return ret; 27815217d17SShengjiu Wang } 2799e28f653SShengjiu Wang 28015217d17SShengjiu Wang ret = clk_prepare_enable(mqs_priv->mclk); 28115217d17SShengjiu Wang if (ret) { 28215217d17SShengjiu Wang dev_err(dev, "failed to enable mclk clock\n"); 28315217d17SShengjiu Wang clk_disable_unprepare(mqs_priv->ipg); 28415217d17SShengjiu Wang return ret; 28515217d17SShengjiu Wang } 2869e28f653SShengjiu Wang 287063c9155SShengjiu Wang regmap_write(mqs_priv->regmap, mqs_priv->soc->ctrl_off, mqs_priv->reg_mqs_ctrl); 2889e28f653SShengjiu Wang return 0; 2899e28f653SShengjiu Wang } 2909e28f653SShengjiu Wang 2919e28f653SShengjiu Wang static int fsl_mqs_runtime_suspend(struct device *dev) 2929e28f653SShengjiu Wang { 2939e28f653SShengjiu Wang struct fsl_mqs *mqs_priv = dev_get_drvdata(dev); 2949e28f653SShengjiu Wang 295063c9155SShengjiu Wang regmap_read(mqs_priv->regmap, mqs_priv->soc->ctrl_off, &mqs_priv->reg_mqs_ctrl); 2969e28f653SShengjiu Wang 2979e28f653SShengjiu Wang clk_disable_unprepare(mqs_priv->mclk); 2989e28f653SShengjiu Wang clk_disable_unprepare(mqs_priv->ipg); 2999e28f653SShengjiu Wang 3009e28f653SShengjiu Wang return 0; 3019e28f653SShengjiu Wang } 3029e28f653SShengjiu Wang #endif 3039e28f653SShengjiu Wang 3049e28f653SShengjiu Wang static const struct dev_pm_ops fsl_mqs_pm_ops = { 3059e28f653SShengjiu Wang SET_RUNTIME_PM_OPS(fsl_mqs_runtime_suspend, 3069e28f653SShengjiu Wang fsl_mqs_runtime_resume, 3079e28f653SShengjiu Wang NULL) 3089e28f653SShengjiu Wang SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 3099e28f653SShengjiu Wang pm_runtime_force_resume) 3109e28f653SShengjiu Wang }; 3119e28f653SShengjiu Wang 312063c9155SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx8qm_data = { 313*401a1f02SShengjiu Wang .type = TYPE_REG_OWN, 314063c9155SShengjiu Wang .ctrl_off = REG_MQS_CTRL, 315063c9155SShengjiu Wang .en_mask = MQS_EN_MASK, 316063c9155SShengjiu Wang .en_shift = MQS_EN_SHIFT, 317063c9155SShengjiu Wang .rst_mask = MQS_SW_RST_MASK, 318063c9155SShengjiu Wang .rst_shift = MQS_SW_RST_SHIFT, 319063c9155SShengjiu Wang .osr_mask = MQS_OVERSAMPLE_MASK, 320063c9155SShengjiu Wang .osr_shift = MQS_OVERSAMPLE_SHIFT, 321063c9155SShengjiu Wang .div_mask = MQS_CLK_DIV_MASK, 322063c9155SShengjiu Wang .div_shift = MQS_CLK_DIV_SHIFT, 323063c9155SShengjiu Wang }; 324063c9155SShengjiu Wang 325063c9155SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx6sx_data = { 326*401a1f02SShengjiu Wang .type = TYPE_REG_GPR, 327063c9155SShengjiu Wang .ctrl_off = IOMUXC_GPR2, 328063c9155SShengjiu Wang .en_mask = IMX6SX_GPR2_MQS_EN_MASK, 329063c9155SShengjiu Wang .en_shift = IMX6SX_GPR2_MQS_EN_SHIFT, 330063c9155SShengjiu Wang .rst_mask = IMX6SX_GPR2_MQS_SW_RST_MASK, 331063c9155SShengjiu Wang .rst_shift = IMX6SX_GPR2_MQS_SW_RST_SHIFT, 332063c9155SShengjiu Wang .osr_mask = IMX6SX_GPR2_MQS_OVERSAMPLE_MASK, 333063c9155SShengjiu Wang .osr_shift = IMX6SX_GPR2_MQS_OVERSAMPLE_SHIFT, 334063c9155SShengjiu Wang .div_mask = IMX6SX_GPR2_MQS_CLK_DIV_MASK, 335063c9155SShengjiu Wang .div_shift = IMX6SX_GPR2_MQS_CLK_DIV_SHIFT, 336063c9155SShengjiu Wang }; 337063c9155SShengjiu Wang 338047c69a3SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx93_data = { 339*401a1f02SShengjiu Wang .type = TYPE_REG_GPR, 340047c69a3SShengjiu Wang .ctrl_off = 0x20, 341047c69a3SShengjiu Wang .en_mask = BIT(1), 342047c69a3SShengjiu Wang .en_shift = 1, 343047c69a3SShengjiu Wang .rst_mask = BIT(2), 344047c69a3SShengjiu Wang .rst_shift = 2, 345047c69a3SShengjiu Wang .osr_mask = BIT(3), 346047c69a3SShengjiu Wang .osr_shift = 3, 347047c69a3SShengjiu Wang .div_mask = GENMASK(15, 8), 348047c69a3SShengjiu Wang .div_shift = 8, 349047c69a3SShengjiu Wang }; 350047c69a3SShengjiu Wang 351*401a1f02SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx95_aon_data = { 352*401a1f02SShengjiu Wang .type = TYPE_REG_SM, 353*401a1f02SShengjiu Wang .ctrl_off = 0x88, 354*401a1f02SShengjiu Wang .en_mask = BIT(1), 355*401a1f02SShengjiu Wang .en_shift = 1, 356*401a1f02SShengjiu Wang .rst_mask = BIT(2), 357*401a1f02SShengjiu Wang .rst_shift = 2, 358*401a1f02SShengjiu Wang .osr_mask = BIT(3), 359*401a1f02SShengjiu Wang .osr_shift = 3, 360*401a1f02SShengjiu Wang .div_mask = GENMASK(15, 8), 361*401a1f02SShengjiu Wang .div_shift = 8, 362*401a1f02SShengjiu Wang }; 363*401a1f02SShengjiu Wang 364*401a1f02SShengjiu Wang static const struct fsl_mqs_soc_data fsl_mqs_imx95_netc_data = { 365*401a1f02SShengjiu Wang .type = TYPE_REG_GPR, 366*401a1f02SShengjiu Wang .ctrl_off = 0x0, 367*401a1f02SShengjiu Wang .en_mask = BIT(2), 368*401a1f02SShengjiu Wang .en_shift = 2, 369*401a1f02SShengjiu Wang .rst_mask = BIT(3), 370*401a1f02SShengjiu Wang .rst_shift = 3, 371*401a1f02SShengjiu Wang .osr_mask = BIT(4), 372*401a1f02SShengjiu Wang .osr_shift = 4, 373*401a1f02SShengjiu Wang .div_mask = GENMASK(16, 9), 374*401a1f02SShengjiu Wang .div_shift = 9, 375*401a1f02SShengjiu Wang }; 376*401a1f02SShengjiu Wang 3779e28f653SShengjiu Wang static const struct of_device_id fsl_mqs_dt_ids[] = { 378063c9155SShengjiu Wang { .compatible = "fsl,imx8qm-mqs", .data = &fsl_mqs_imx8qm_data }, 379063c9155SShengjiu Wang { .compatible = "fsl,imx6sx-mqs", .data = &fsl_mqs_imx6sx_data }, 380047c69a3SShengjiu Wang { .compatible = "fsl,imx93-mqs", .data = &fsl_mqs_imx93_data }, 381*401a1f02SShengjiu Wang { .compatible = "fsl,imx95-aonmix-mqs", .data = &fsl_mqs_imx95_aon_data }, 382*401a1f02SShengjiu Wang { .compatible = "fsl,imx95-netcmix-mqs", .data = &fsl_mqs_imx95_netc_data }, 3839e28f653SShengjiu Wang {} 3849e28f653SShengjiu Wang }; 3859e28f653SShengjiu Wang MODULE_DEVICE_TABLE(of, fsl_mqs_dt_ids); 3869e28f653SShengjiu Wang 3879e28f653SShengjiu Wang static struct platform_driver fsl_mqs_driver = { 3889e28f653SShengjiu Wang .probe = fsl_mqs_probe, 3894ff299cbSUwe Kleine-König .remove_new = fsl_mqs_remove, 3909e28f653SShengjiu Wang .driver = { 3919e28f653SShengjiu Wang .name = "fsl-mqs", 3929e28f653SShengjiu Wang .of_match_table = fsl_mqs_dt_ids, 3939e28f653SShengjiu Wang .pm = &fsl_mqs_pm_ops, 3949e28f653SShengjiu Wang }, 3959e28f653SShengjiu Wang }; 3969e28f653SShengjiu Wang 3979e28f653SShengjiu Wang module_platform_driver(fsl_mqs_driver); 3989e28f653SShengjiu Wang 3999e28f653SShengjiu Wang MODULE_AUTHOR("Shengjiu Wang <Shengjiu.Wang@nxp.com>"); 4009e28f653SShengjiu Wang MODULE_DESCRIPTION("MQS codec driver"); 4019e28f653SShengjiu Wang MODULE_LICENSE("GPL v2"); 4029e28f653SShengjiu Wang MODULE_ALIAS("platform:fsl-mqs"); 403