Lines Matching +full:imx6q +full:- +full:iomuxc +full:- +full:gpr
1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
12 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
50 struct snd_soc_component *component = dai->component; in fsl_mqs_hw_params()
56 mclk_rate = clk_get_rate(mqs_priv->mclk); in fsl_mqs_hw_params()
68 if (mqs_priv->use_gpr) { in fsl_mqs_hw_params()
69 regmap_update_bits(mqs_priv->regmap, IOMUXC_GPR2, in fsl_mqs_hw_params()
71 (div - 1) << IMX6SX_GPR2_MQS_CLK_DIV_SHIFT); in fsl_mqs_hw_params()
72 regmap_update_bits(mqs_priv->regmap, IOMUXC_GPR2, in fsl_mqs_hw_params()
75 regmap_update_bits(mqs_priv->regmap, REG_MQS_CTRL, in fsl_mqs_hw_params()
77 (div - 1) << MQS_CLK_DIV_SHIFT); in fsl_mqs_hw_params()
78 regmap_update_bits(mqs_priv->regmap, REG_MQS_CTRL, in fsl_mqs_hw_params()
82 dev_err(component->dev, "can't get proper divider\n"); in fsl_mqs_hw_params()
95 return -EINVAL; in fsl_mqs_set_dai_fmt()
102 return -EINVAL; in fsl_mqs_set_dai_fmt()
109 return -EINVAL; in fsl_mqs_set_dai_fmt()
118 struct snd_soc_component *component = dai->component; in fsl_mqs_startup()
121 if (mqs_priv->use_gpr) in fsl_mqs_startup()
122 regmap_update_bits(mqs_priv->regmap, IOMUXC_GPR2, in fsl_mqs_startup()
126 regmap_update_bits(mqs_priv->regmap, REG_MQS_CTRL, in fsl_mqs_startup()
135 struct snd_soc_component *component = dai->component; in fsl_mqs_shutdown()
138 if (mqs_priv->use_gpr) in fsl_mqs_shutdown()
139 regmap_update_bits(mqs_priv->regmap, IOMUXC_GPR2, in fsl_mqs_shutdown()
142 regmap_update_bits(mqs_priv->regmap, REG_MQS_CTRL, in fsl_mqs_shutdown()
159 .name = "fsl-mqs-dai",
180 struct device_node *np = pdev->dev.of_node; in fsl_mqs_probe()
186 mqs_priv = devm_kzalloc(&pdev->dev, sizeof(*mqs_priv), GFP_KERNEL); in fsl_mqs_probe()
188 return -ENOMEM; in fsl_mqs_probe()
190 /* On i.MX6sx the MQS control register is in GPR domain in fsl_mqs_probe()
194 if (of_device_is_compatible(np, "fsl,imx8qm-mqs")) in fsl_mqs_probe()
195 mqs_priv->use_gpr = false; in fsl_mqs_probe()
197 mqs_priv->use_gpr = true; in fsl_mqs_probe()
199 if (mqs_priv->use_gpr) { in fsl_mqs_probe()
200 gpr_np = of_parse_phandle(np, "gpr", 0); in fsl_mqs_probe()
202 dev_err(&pdev->dev, "failed to get gpr node by phandle\n"); in fsl_mqs_probe()
203 return -EINVAL; in fsl_mqs_probe()
206 mqs_priv->regmap = syscon_node_to_regmap(gpr_np); in fsl_mqs_probe()
207 if (IS_ERR(mqs_priv->regmap)) { in fsl_mqs_probe()
208 dev_err(&pdev->dev, "failed to get gpr regmap\n"); in fsl_mqs_probe()
209 ret = PTR_ERR(mqs_priv->regmap); in fsl_mqs_probe()
217 mqs_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, in fsl_mqs_probe()
221 if (IS_ERR(mqs_priv->regmap)) { in fsl_mqs_probe()
222 dev_err(&pdev->dev, "failed to init regmap: %ld\n", in fsl_mqs_probe()
223 PTR_ERR(mqs_priv->regmap)); in fsl_mqs_probe()
224 return PTR_ERR(mqs_priv->regmap); in fsl_mqs_probe()
227 mqs_priv->ipg = devm_clk_get(&pdev->dev, "core"); in fsl_mqs_probe()
228 if (IS_ERR(mqs_priv->ipg)) { in fsl_mqs_probe()
229 dev_err(&pdev->dev, "failed to get the clock: %ld\n", in fsl_mqs_probe()
230 PTR_ERR(mqs_priv->ipg)); in fsl_mqs_probe()
231 return PTR_ERR(mqs_priv->ipg); in fsl_mqs_probe()
235 mqs_priv->mclk = devm_clk_get(&pdev->dev, "mclk"); in fsl_mqs_probe()
236 if (IS_ERR(mqs_priv->mclk)) { in fsl_mqs_probe()
237 dev_err(&pdev->dev, "failed to get the clock: %ld\n", in fsl_mqs_probe()
238 PTR_ERR(mqs_priv->mclk)); in fsl_mqs_probe()
239 ret = PTR_ERR(mqs_priv->mclk); in fsl_mqs_probe()
243 dev_set_drvdata(&pdev->dev, mqs_priv); in fsl_mqs_probe()
244 pm_runtime_enable(&pdev->dev); in fsl_mqs_probe()
246 ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs, in fsl_mqs_probe()
260 pm_runtime_disable(&pdev->dev); in fsl_mqs_remove()
270 ret = clk_prepare_enable(mqs_priv->ipg); in fsl_mqs_runtime_resume()
276 ret = clk_prepare_enable(mqs_priv->mclk); in fsl_mqs_runtime_resume()
279 clk_disable_unprepare(mqs_priv->ipg); in fsl_mqs_runtime_resume()
283 if (mqs_priv->use_gpr) in fsl_mqs_runtime_resume()
284 regmap_write(mqs_priv->regmap, IOMUXC_GPR2, in fsl_mqs_runtime_resume()
285 mqs_priv->reg_iomuxc_gpr2); in fsl_mqs_runtime_resume()
287 regmap_write(mqs_priv->regmap, REG_MQS_CTRL, in fsl_mqs_runtime_resume()
288 mqs_priv->reg_mqs_ctrl); in fsl_mqs_runtime_resume()
296 if (mqs_priv->use_gpr) in fsl_mqs_runtime_suspend()
297 regmap_read(mqs_priv->regmap, IOMUXC_GPR2, in fsl_mqs_runtime_suspend()
298 &mqs_priv->reg_iomuxc_gpr2); in fsl_mqs_runtime_suspend()
300 regmap_read(mqs_priv->regmap, REG_MQS_CTRL, in fsl_mqs_runtime_suspend()
301 &mqs_priv->reg_mqs_ctrl); in fsl_mqs_runtime_suspend()
303 clk_disable_unprepare(mqs_priv->mclk); in fsl_mqs_runtime_suspend()
304 clk_disable_unprepare(mqs_priv->ipg); in fsl_mqs_runtime_suspend()
319 { .compatible = "fsl,imx8qm-mqs", },
320 { .compatible = "fsl,imx6sx-mqs", },
329 .name = "fsl-mqs",
340 MODULE_ALIAS("platform: fsl-mqs");