spi: mtk-snfi: Add optional nfi_hclk which is needed for MT7986
authorXiangsheng Hou <xiangsheng.hou@mediatek.com>
Wed, 1 Feb 2023 02:09:18 +0000 (10:09 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 9 Feb 2023 17:07:19 +0000 (17:07 +0000)
Add optional nfi_hclk which is needed for MT7986.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230201020921.26712-3-xiangsheng.hou@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-mtk-snfi.c

index 719fc6f53ab18f2545688ea75b64e8dfaf24bc6d..85644308df23e7ad2c637c0c5666d6a8145cf429 100644 (file)
@@ -297,6 +297,7 @@ struct mtk_snand {
        struct device *dev;
        struct clk *nfi_clk;
        struct clk *pad_clk;
+       struct clk *nfi_hclk;
        void __iomem *nfi_base;
        int irq;
        struct completion op_done;
@@ -1339,7 +1340,16 @@ static int mtk_snand_enable_clk(struct mtk_snand *ms)
                dev_err(ms->dev, "unable to enable pad clk\n");
                goto err1;
        }
+       ret = clk_prepare_enable(ms->nfi_hclk);
+       if (ret) {
+               dev_err(ms->dev, "unable to enable nfi hclk\n");
+               goto err2;
+       }
+
        return 0;
+
+err2:
+       clk_disable_unprepare(ms->pad_clk);
 err1:
        clk_disable_unprepare(ms->nfi_clk);
        return ret;
@@ -1347,6 +1357,7 @@ err1:
 
 static void mtk_snand_disable_clk(struct mtk_snand *ms)
 {
+       clk_disable_unprepare(ms->nfi_hclk);
        clk_disable_unprepare(ms->pad_clk);
        clk_disable_unprepare(ms->nfi_clk);
 }
@@ -1401,6 +1412,13 @@ static int mtk_snand_probe(struct platform_device *pdev)
                goto release_ecc;
        }
 
+       ms->nfi_hclk = devm_clk_get_optional(&pdev->dev, "nfi_hclk");
+       if (IS_ERR(ms->nfi_hclk)) {
+               ret = PTR_ERR(ms->nfi_hclk);
+               dev_err(&pdev->dev, "unable to get nfi_hclk, err = %d\n", ret);
+               goto release_ecc;
+       }
+
        ret = mtk_snand_enable_clk(ms);
        if (ret)
                goto release_ecc;