Lines Matching +full:mclk +full:- +full:div
1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
12 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
38 * struct fsl_mqs_soc_data - soc specific data
67 struct clk *mclk; member
81 struct snd_soc_component *component = dai->component; in fsl_mqs_hw_params()
84 int div, res; in fsl_mqs_hw_params() local
87 mclk_rate = clk_get_rate(mqs_priv->mclk); in fsl_mqs_hw_params()
95 div = mclk_rate / (32 * lrclk * 2 * 8); in fsl_mqs_hw_params()
98 if (res == 0 && div > 0 && div <= 256) { in fsl_mqs_hw_params()
99 regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, in fsl_mqs_hw_params()
100 mqs_priv->soc->div_mask, in fsl_mqs_hw_params()
101 (div - 1) << mqs_priv->soc->div_shift); in fsl_mqs_hw_params()
102 regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, in fsl_mqs_hw_params()
103 mqs_priv->soc->osr_mask, 0); in fsl_mqs_hw_params()
105 dev_err(component->dev, "can't get proper divider\n"); in fsl_mqs_hw_params()
118 return -EINVAL; in fsl_mqs_set_dai_fmt()
125 return -EINVAL; in fsl_mqs_set_dai_fmt()
132 return -EINVAL; in fsl_mqs_set_dai_fmt()
141 struct snd_soc_component *component = dai->component; in fsl_mqs_startup()
144 regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, in fsl_mqs_startup()
145 mqs_priv->soc->en_mask, in fsl_mqs_startup()
146 1 << mqs_priv->soc->en_shift); in fsl_mqs_startup()
153 struct snd_soc_component *component = dai->component; in fsl_mqs_shutdown()
156 regmap_update_bits(mqs_priv->regmap, mqs_priv->soc->ctrl_off, in fsl_mqs_shutdown()
157 mqs_priv->soc->en_mask, 0); in fsl_mqs_shutdown()
172 .name = "fsl-mqs-dai",
193 struct device_node *np = pdev->dev.of_node; in fsl_mqs_probe()
199 mqs_priv = devm_kzalloc(&pdev->dev, sizeof(*mqs_priv), GFP_KERNEL); in fsl_mqs_probe()
201 return -ENOMEM; in fsl_mqs_probe()
207 mqs_priv->soc = of_device_get_match_data(&pdev->dev); in fsl_mqs_probe()
209 if (mqs_priv->soc->type == TYPE_REG_GPR) { in fsl_mqs_probe()
212 dev_err(&pdev->dev, "failed to get gpr node by phandle\n"); in fsl_mqs_probe()
213 return -EINVAL; in fsl_mqs_probe()
216 mqs_priv->regmap = syscon_node_to_regmap(gpr_np); in fsl_mqs_probe()
218 if (IS_ERR(mqs_priv->regmap)) { in fsl_mqs_probe()
219 dev_err(&pdev->dev, "failed to get gpr regmap\n"); in fsl_mqs_probe()
220 return PTR_ERR(mqs_priv->regmap); in fsl_mqs_probe()
227 mqs_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, in fsl_mqs_probe()
231 if (IS_ERR(mqs_priv->regmap)) { in fsl_mqs_probe()
232 dev_err(&pdev->dev, "failed to init regmap: %ld\n", in fsl_mqs_probe()
233 PTR_ERR(mqs_priv->regmap)); in fsl_mqs_probe()
234 return PTR_ERR(mqs_priv->regmap); in fsl_mqs_probe()
237 mqs_priv->ipg = devm_clk_get(&pdev->dev, "core"); in fsl_mqs_probe()
238 if (IS_ERR(mqs_priv->ipg)) { in fsl_mqs_probe()
239 dev_err(&pdev->dev, "failed to get the clock: %ld\n", in fsl_mqs_probe()
240 PTR_ERR(mqs_priv->ipg)); in fsl_mqs_probe()
241 return PTR_ERR(mqs_priv->ipg); in fsl_mqs_probe()
245 mqs_priv->mclk = devm_clk_get(&pdev->dev, "mclk"); in fsl_mqs_probe()
246 if (IS_ERR(mqs_priv->mclk)) { in fsl_mqs_probe()
247 dev_err(&pdev->dev, "failed to get the clock: %ld\n", in fsl_mqs_probe()
248 PTR_ERR(mqs_priv->mclk)); in fsl_mqs_probe()
249 return PTR_ERR(mqs_priv->mclk); in fsl_mqs_probe()
252 dev_set_drvdata(&pdev->dev, mqs_priv); in fsl_mqs_probe()
253 pm_runtime_enable(&pdev->dev); in fsl_mqs_probe()
255 ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs, in fsl_mqs_probe()
265 pm_runtime_disable(&pdev->dev); in fsl_mqs_remove()
273 ret = clk_prepare_enable(mqs_priv->ipg); in fsl_mqs_runtime_resume()
279 ret = clk_prepare_enable(mqs_priv->mclk); in fsl_mqs_runtime_resume()
281 dev_err(dev, "failed to enable mclk clock\n"); in fsl_mqs_runtime_resume()
282 clk_disable_unprepare(mqs_priv->ipg); in fsl_mqs_runtime_resume()
286 regmap_write(mqs_priv->regmap, mqs_priv->soc->ctrl_off, mqs_priv->reg_mqs_ctrl); in fsl_mqs_runtime_resume()
294 regmap_read(mqs_priv->regmap, mqs_priv->soc->ctrl_off, &mqs_priv->reg_mqs_ctrl); in fsl_mqs_runtime_suspend()
296 clk_disable_unprepare(mqs_priv->mclk); in fsl_mqs_runtime_suspend()
297 clk_disable_unprepare(mqs_priv->ipg); in fsl_mqs_runtime_suspend()
373 { .compatible = "fsl,imx8qm-mqs", .data = &fsl_mqs_imx8qm_data },
374 { .compatible = "fsl,imx6sx-mqs", .data = &fsl_mqs_imx6sx_data },
375 { .compatible = "fsl,imx93-mqs", .data = &fsl_mqs_imx93_data },
376 { .compatible = "fsl,imx95-aonmix-mqs", .data = &fsl_mqs_imx95_aon_data },
377 { .compatible = "fsl,imx95-netcmix-mqs", .data = &fsl_mqs_imx95_netc_data },
386 .name = "fsl-mqs",
397 MODULE_ALIAS("platform:fsl-mqs");