Merge tag 'asoc-v6.10' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[sfrench/cifs-2.6.git] / sound / soc / sof / imx / imx8m.c
index 222cd1467da67ea1635d6dc8de0550d6ce762477..4ed415f0434544c3d01a8119b1c0c020a06dbca8 100644 (file)
 #define MBOX_OFFSET    0x800000
 #define MBOX_SIZE      0x1000
 
-static struct clk_bulk_data imx8m_dsp_clks[] = {
-       { .id = "ipg" },
-       { .id = "ocram" },
-       { .id = "core" },
-};
-
 /* DAP registers */
 #define IMX8M_DAP_DEBUG                0x28800000
 #define IMX8M_DAP_DEBUG_SIZE   (64 * 1024)
@@ -54,7 +48,8 @@ struct imx8m_priv {
        struct imx_dsp_ipc *dsp_ipc;
        struct platform_device *ipc_dev;
 
-       struct imx_clocks *clks;
+       struct clk_bulk_data *clks;
+       int clk_num;
 
        void __iomem *dap;
        struct regmap *regmap;
@@ -163,10 +158,6 @@ static int imx8m_probe(struct snd_sof_dev *sdev)
        if (!priv)
                return -ENOMEM;
 
-       priv->clks = devm_kzalloc(&pdev->dev, sizeof(*priv->clks), GFP_KERNEL);
-       if (!priv->clks)
-               return -ENOMEM;
-
        sdev->num_cores = 1;
        sdev->pdata->hw_pdata = priv;
        priv->dev = sdev->dev;
@@ -250,17 +241,18 @@ static int imx8m_probe(struct snd_sof_dev *sdev)
                goto exit_pdev_unregister;
        }
 
-       /* init clocks info */
-       priv->clks->dsp_clks = imx8m_dsp_clks;
-       priv->clks->num_dsp_clks = ARRAY_SIZE(imx8m_dsp_clks);
-
-       ret = imx8_parse_clocks(sdev, priv->clks);
-       if (ret < 0)
+       ret = devm_clk_bulk_get_all(sdev->dev, &priv->clks);
+       if (ret < 0) {
+               dev_err(sdev->dev, "failed to fetch clocks: %d\n", ret);
                goto exit_pdev_unregister;
+       }
+       priv->clk_num = ret;
 
-       ret = imx8_enable_clocks(sdev, priv->clks);
-       if (ret < 0)
+       ret = clk_bulk_prepare_enable(priv->clk_num, priv->clks);
+       if (ret < 0) {
+               dev_err(sdev->dev, "failed to enable clocks: %d\n", ret);
                goto exit_pdev_unregister;
+       }
 
        return 0;
 
@@ -273,7 +265,7 @@ static void imx8m_remove(struct snd_sof_dev *sdev)
 {
        struct imx8m_priv *priv = sdev->pdata->hw_pdata;
 
-       imx8_disable_clocks(sdev, priv->clks);
+       clk_bulk_disable_unprepare(priv->clk_num, priv->clks);
        platform_device_unregister(priv->ipc_dev);
 }
 
@@ -336,9 +328,11 @@ static int imx8m_resume(struct snd_sof_dev *sdev)
        int ret;
        int i;
 
-       ret = imx8_enable_clocks(sdev, priv->clks);
-       if (ret < 0)
+       ret = clk_bulk_prepare_enable(priv->clk_num, priv->clks);
+       if (ret < 0) {
+               dev_err(sdev->dev, "failed to enable clocks: %d\n", ret);
                return ret;
+       }
 
        for (i = 0; i < DSP_MU_CHAN_NUM; i++)
                imx_dsp_request_channel(priv->dsp_ipc, i);
@@ -354,7 +348,7 @@ static void imx8m_suspend(struct snd_sof_dev *sdev)
        for (i = 0; i < DSP_MU_CHAN_NUM; i++)
                imx_dsp_free_channel(priv->dsp_ipc, i);
 
-       imx8_disable_clocks(sdev, priv->clks);
+       clk_bulk_disable_unprepare(priv->clk_num, priv->clks);
 }
 
 static int imx8m_dsp_runtime_resume(struct snd_sof_dev *sdev)
@@ -417,7 +411,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state
 }
 
 /* i.MX8 ops */
-static struct snd_sof_dsp_ops sof_imx8m_ops = {
+static const struct snd_sof_dsp_ops sof_imx8m_ops = {
        /* probe and remove */
        .probe          = imx8m_probe,
        .remove         = imx8m_remove,