clk: mediatek: mt8183: use mtk_clk_simple_probe to simplify driver
authorMiles Chen <miles.chen@mediatek.com>
Thu, 22 Sep 2022 09:18:34 +0000 (17:18 +0800)
committerChen-Yu Tsai <wenst@chromium.org>
Mon, 26 Sep 2022 03:13:45 +0000 (11:13 +0800)
mtk_clk_simple_probe was added by Chun-Jie to simply common flow
of MediaTek clock drivers and ChenYu enhanced the error path of
mtk_clk_simple_probe and added mtk_clk_simple_remove.

Let's use mtk_clk_simple_probe and mtk_clk_simple_probe in other
MediaTek clock drivers as well.

Signed-off-by: Miles Chen <miles.chen@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220922091841.4099-7-miles.chen@mediatek.com
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
drivers/clk/mediatek/clk-mt8183-cam.c
drivers/clk/mediatek/clk-mt8183-img.c
drivers/clk/mediatek/clk-mt8183-ipu0.c
drivers/clk/mediatek/clk-mt8183-ipu1.c
drivers/clk/mediatek/clk-mt8183-ipu_adl.c
drivers/clk/mediatek/clk-mt8183-ipu_conn.c
drivers/clk/mediatek/clk-mt8183-mfgcfg.c
drivers/clk/mediatek/clk-mt8183-vdec.c
drivers/clk/mediatek/clk-mt8183-venc.c

index fcc598a45165c313a1c92a881a3419546e58d0b0..6907b1a6a8247cf4ea388e5ca4a5512d04b249cd 100644 (file)
@@ -34,26 +34,23 @@ static const struct mtk_gate cam_clks[] = {
        GATE_CAM(CLK_CAM_CCU, "cam_ccu", "cam_sel", 12),
 };
 
-static int clk_mt8183_cam_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
-
-       mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc cam_desc = {
+       .clks = cam_clks,
+       .num_clks = ARRAY_SIZE(cam_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_cam[] = {
-       { .compatible = "mediatek,mt8183-camsys", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-camsys",
+               .data = &cam_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_cam_drv = {
-       .probe = clk_mt8183_cam_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-cam",
                .of_match_table = of_match_clk_mt8183_cam,
index eb2def2cf0ae54a394febdde08c65574610b4bd3..8d884425d79f27c7b124ddab0017c67bb8b8f7b0 100644 (file)
@@ -34,26 +34,23 @@ static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_OWE, "img_owe", "img_sel", 9),
 };
 
-static int clk_mt8183_img_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
-
-       mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc img_desc = {
+       .clks = img_clks,
+       .num_clks = ARRAY_SIZE(img_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_img[] = {
-       { .compatible = "mediatek,mt8183-imgsys", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-imgsys",
+               .data = &img_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_img_drv = {
-       .probe = clk_mt8183_img_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-img",
                .of_match_table = of_match_clk_mt8183_img,
index b30fc9f47518e9ac3013cd76738f44e7bb761da7..953a8a33d0487feb753f57c77a108ab1dc3f0e16 100644 (file)
@@ -27,26 +27,23 @@ static const struct mtk_gate ipu_core0_clks[] = {
        GATE_IPU_CORE0(CLK_IPU_CORE0_IPU, "ipu_core0_ipu", "dsp_sel", 2),
 };
 
-static int clk_mt8183_ipu_core0_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_IPU_CORE0_NR_CLK);
-
-       mtk_clk_register_gates(node, ipu_core0_clks, ARRAY_SIZE(ipu_core0_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc ipu_core0_desc = {
+       .clks = ipu_core0_clks,
+       .num_clks = ARRAY_SIZE(ipu_core0_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_ipu_core0[] = {
-       { .compatible = "mediatek,mt8183-ipu_core0", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-ipu_core0",
+               .data = &ipu_core0_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_ipu_core0_drv = {
-       .probe = clk_mt8183_ipu_core0_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-ipu_core0",
                .of_match_table = of_match_clk_mt8183_ipu_core0,
index b378957e11d0f74032d3fc3e90f37fa4803db2d2..221d1226597457344b8abea1df16d40b046976bf 100644 (file)
@@ -27,26 +27,23 @@ static const struct mtk_gate ipu_core1_clks[] = {
        GATE_IPU_CORE1(CLK_IPU_CORE1_IPU, "ipu_core1_ipu", "dsp_sel", 2),
 };
 
-static int clk_mt8183_ipu_core1_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_IPU_CORE1_NR_CLK);
-
-       mtk_clk_register_gates(node, ipu_core1_clks, ARRAY_SIZE(ipu_core1_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc ipu_core1_desc = {
+       .clks = ipu_core1_clks,
+       .num_clks = ARRAY_SIZE(ipu_core1_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_ipu_core1[] = {
-       { .compatible = "mediatek,mt8183-ipu_core1", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-ipu_core1",
+               .data = &ipu_core1_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_ipu_core1_drv = {
-       .probe = clk_mt8183_ipu_core1_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-ipu_core1",
                .of_match_table = of_match_clk_mt8183_ipu_core1,
index 941b43ac8bec6cb61d164128a28c5b93fcd3e6e9..8c4fd96df821e1d631f4e92544856b32faf0e9dc 100644 (file)
@@ -25,26 +25,23 @@ static const struct mtk_gate ipu_adl_clks[] = {
        GATE_IPU_ADL_I(CLK_IPU_ADL_CABGEN, "ipu_adl_cabgen", "dsp_sel", 24),
 };
 
-static int clk_mt8183_ipu_adl_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_IPU_ADL_NR_CLK);
-
-       mtk_clk_register_gates(node, ipu_adl_clks, ARRAY_SIZE(ipu_adl_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc ipu_adl_desc = {
+       .clks = ipu_adl_clks,
+       .num_clks = ARRAY_SIZE(ipu_adl_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_ipu_adl[] = {
-       { .compatible = "mediatek,mt8183-ipu_adl", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-ipu_adl",
+               .data = &ipu_adl_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_ipu_adl_drv = {
-       .probe = clk_mt8183_ipu_adl_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-ipu_adl",
                .of_match_table = of_match_clk_mt8183_ipu_adl,
index ae82c2e17110f3ed2f792974c640b0e58b6cdd35..14a4c3ff82a1bcde3d715c6e69be91596a81d287 100644 (file)
@@ -94,26 +94,23 @@ static const struct mtk_gate ipu_conn_clks[] = {
                "ipu_conn_cab3to1_slice", "dsp1_sel", 17),
 };
 
-static int clk_mt8183_ipu_conn_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_IPU_CONN_NR_CLK);
-
-       mtk_clk_register_gates(node, ipu_conn_clks, ARRAY_SIZE(ipu_conn_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc ipu_conn_desc = {
+       .clks = ipu_conn_clks,
+       .num_clks = ARRAY_SIZE(ipu_conn_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_ipu_conn[] = {
-       { .compatible = "mediatek,mt8183-ipu_conn", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-ipu_conn",
+               .data = &ipu_conn_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_ipu_conn_drv = {
-       .probe = clk_mt8183_ipu_conn_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-ipu_conn",
                .of_match_table = of_match_clk_mt8183_ipu_conn,
index d774edaf760be73b08e3a24b3155da1d465bed6e..f578b393f41ed795bdf948e3dab138efff70dfb8 100644 (file)
@@ -26,28 +26,23 @@ static const struct mtk_gate mfg_clks[] = {
        GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0)
 };
 
-static int clk_mt8183_mfg_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       pm_runtime_enable(&pdev->dev);
-
-       clk_data = mtk_alloc_clk_data(CLK_MFG_NR_CLK);
-
-       mtk_clk_register_gates_with_dev(node, mfg_clks, ARRAY_SIZE(mfg_clks),
-                       clk_data, &pdev->dev);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc mfg_desc = {
+       .clks = mfg_clks,
+       .num_clks = ARRAY_SIZE(mfg_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_mfg[] = {
-       { .compatible = "mediatek,mt8183-mfgcfg", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-mfgcfg",
+               .data = &mfg_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_mfg_drv = {
-       .probe = clk_mt8183_mfg_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-mfg",
                .of_match_table = of_match_clk_mt8183_mfg,
index 0548cde159d09aba75e3bc0116d7807eb14769ad..c294e50b96b74bc84f256907945ee2f10c5a7b61 100644 (file)
@@ -38,26 +38,23 @@ static const struct mtk_gate vdec_clks[] = {
        GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1", "mm_sel", 0),
 };
 
-static int clk_mt8183_vdec_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
-
-       mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc vdec_desc = {
+       .clks = vdec_clks,
+       .num_clks = ARRAY_SIZE(vdec_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_vdec[] = {
-       { .compatible = "mediatek,mt8183-vdecsys", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-vdecsys",
+               .data = &vdec_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_vdec_drv = {
-       .probe = clk_mt8183_vdec_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-vdec",
                .of_match_table = of_match_clk_mt8183_vdec,
index f86ec607d87a999213c7722edc2a2e7c67e82b9d..0051c5d92fc5d1f1dd33ad42dc6f9246f81f98db 100644 (file)
@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = {
                "mm_sel", 8),
 };
 
-static int clk_mt8183_venc_probe(struct platform_device *pdev)
-{
-       struct clk_hw_onecell_data *clk_data;
-       struct device_node *node = pdev->dev.of_node;
-
-       clk_data = mtk_alloc_clk_data(CLK_VENC_NR_CLK);
-
-       mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_clks),
-                       clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct mtk_clk_desc venc_desc = {
+       .clks = venc_clks,
+       .num_clks = ARRAY_SIZE(venc_clks),
+};
 
 static const struct of_device_id of_match_clk_mt8183_venc[] = {
-       { .compatible = "mediatek,mt8183-vencsys", },
-       {}
+       {
+               .compatible = "mediatek,mt8183-vencsys",
+               .data = &venc_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt8183_venc_drv = {
-       .probe = clk_mt8183_venc_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt8183-venc",
                .of_match_table = of_match_clk_mt8183_venc,