]> git.dujemihanovic.xyz Git - linux.git/commitdiff
clk: mediatek: mt6779: use mtk_clk_simple_probe to simplify driver
authorMiles Chen <miles.chen@mediatek.com>
Thu, 22 Sep 2022 09:18:32 +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-5-miles.chen@mediatek.com
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
drivers/clk/mediatek/clk-mt6779-aud.c
drivers/clk/mediatek/clk-mt6779-cam.c
drivers/clk/mediatek/clk-mt6779-img.c
drivers/clk/mediatek/clk-mt6779-ipe.c
drivers/clk/mediatek/clk-mt6779-mfg.c
drivers/clk/mediatek/clk-mt6779-vdec.c
drivers/clk/mediatek/clk-mt6779-venc.c

index 97e44abb7e8798d42e6b912430f2093fcd7cde99..6e473ae1fd903c3b02db25861515592bd9170a4a 100644 (file)
@@ -89,26 +89,23 @@ static const struct mtk_gate audio_clks[] = {
                    "audio_h_sel", 31),
 };
 
-static const struct of_device_id of_match_clk_mt6779_aud[] = {
-       { .compatible = "mediatek,mt6779-audio", },
-       {}
+static const struct mtk_clk_desc audio_desc = {
+       .clks = audio_clks,
+       .num_clks = ARRAY_SIZE(audio_clks),
 };
 
-static int clk_mt6779_aud_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_AUD_NR_CLK);
-
-       mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clks),
-                              clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct of_device_id of_match_clk_mt6779_aud[] = {
+       {
+               .compatible = "mediatek,mt6779-audio",
+               .data = &audio_desc,
+       }, {
+               /* sentinel */
+       }
+};
 
 static struct platform_driver clk_mt6779_aud_drv = {
-       .probe = clk_mt6779_aud_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-aud",
                .of_match_table = of_match_clk_mt6779_aud,
index 9c5117aae14689ca01acdc1a477bbc24bd97ec79..7be3db90fa4a8a28174b9d068ee6468376c0db85 100644 (file)
@@ -38,26 +38,23 @@ static const struct mtk_gate cam_clks[] = {
        GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14),
 };
 
-static const struct of_device_id of_match_clk_mt6779_cam[] = {
-       { .compatible = "mediatek,mt6779-camsys", },
-       {}
+static const struct mtk_clk_desc cam_desc = {
+       .clks = cam_clks,
+       .num_clks = ARRAY_SIZE(cam_clks),
 };
 
-static int clk_mt6779_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 of_device_id of_match_clk_mt6779_cam[] = {
+       {
+               .compatible = "mediatek,mt6779-camsys",
+               .data = &cam_desc,
+       }, {
+               /* sentinel */
+       }
+};
 
 static struct platform_driver clk_mt6779_cam_drv = {
-       .probe = clk_mt6779_cam_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-cam",
                .of_match_table = of_match_clk_mt6779_cam,
index 801271477d46ba2364cee4e2487e5dd425a2558f..9bc51fc82dbd2bb250fc419a96a6d8b7f6e61ddc 100644 (file)
@@ -30,26 +30,23 @@ static const struct mtk_gate img_clks[] = {
        GATE_IMG(CLK_IMG_WPE_A, "imgsys_wpe_a", "img_sel", 7),
 };
 
-static const struct of_device_id of_match_clk_mt6779_img[] = {
-       { .compatible = "mediatek,mt6779-imgsys", },
-       {}
+static const struct mtk_clk_desc img_desc = {
+       .clks = img_clks,
+       .num_clks = ARRAY_SIZE(img_clks),
 };
 
-static int clk_mt6779_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 of_device_id of_match_clk_mt6779_img[] = {
+       {
+               .compatible = "mediatek,mt6779-imgsys",
+               .data = &img_desc,
+       }, {
+               /* sentinel */
+       }
+};
 
 static struct platform_driver clk_mt6779_img_drv = {
-       .probe = clk_mt6779_img_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-img",
                .of_match_table = of_match_clk_mt6779_img,
index f67814ca7dfba7abdf6f76e65562592043645f75..92e9d1ade42215087d28dbe2a022a9dff22b990a 100644 (file)
@@ -32,26 +32,23 @@ static const struct mtk_gate ipe_clks[] = {
        GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
 };
 
-static const struct of_device_id of_match_clk_mt6779_ipe[] = {
-       { .compatible = "mediatek,mt6779-ipesys", },
-       {}
+static const struct mtk_clk_desc ipe_desc = {
+       .clks = ipe_clks,
+       .num_clks = ARRAY_SIZE(ipe_clks),
 };
 
-static int clk_mt6779_ipe_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_IPE_NR_CLK);
-
-       mtk_clk_register_gates(node, ipe_clks, ARRAY_SIZE(ipe_clks),
-                              clk_data);
-
-       return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-}
+static const struct of_device_id of_match_clk_mt6779_ipe[] = {
+       {
+               .compatible = "mediatek,mt6779-ipesys",
+               .data = &ipe_desc,
+       }, {
+               /* sentinel */
+       }
+};
 
 static struct platform_driver clk_mt6779_ipe_drv = {
-       .probe = clk_mt6779_ipe_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-ipe",
                .of_match_table = of_match_clk_mt6779_ipe,
index fc7387b59758d36220c11f24ab7eea41b3abdb16..efc793a1969a21c4a0ba819372e9fc84b5c2169f 100644 (file)
@@ -27,26 +27,23 @@ static const struct mtk_gate mfg_clks[] = {
        GATE_MFG(CLK_MFGCFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
 };
 
-static int clk_mt6779_mfg_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_MFGCFG_NR_CLK);
-
-       mtk_clk_register_gates(node, mfg_clks, ARRAY_SIZE(mfg_clks),
-                              clk_data);
-
-       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_mt6779_mfg[] = {
-       { .compatible = "mediatek,mt6779-mfgcfg", },
-       {}
+       {
+               .compatible = "mediatek,mt6779-mfgcfg",
+               .data = &mfg_desc,
+       }, {
+               /* sentinel */
+       }
 };
 
 static struct platform_driver clk_mt6779_mfg_drv = {
-       .probe = clk_mt6779_mfg_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-mfg",
                .of_match_table = of_match_clk_mt6779_mfg,
index 7e195b082e86754420e59da6492e7baed6ec0fb6..3209a6518d5b1e35c00ca1a5f12ba6b8d5d8cd15 100644 (file)
@@ -39,26 +39,23 @@ static const struct mtk_gate vdec_clks[] = {
        GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1_cken", "vdec_sel", 0),
 };
 
-static const struct of_device_id of_match_clk_mt6779_vdec[] = {
-       { .compatible = "mediatek,mt6779-vdecsys", },
-       {}
+static const struct mtk_clk_desc vdec_desc = {
+       .clks = vdec_clks,
+       .num_clks = ARRAY_SIZE(vdec_clks),
 };
 
-static int clk_mt6779_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_GCON_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 of_device_id of_match_clk_mt6779_vdec[] = {
+       {
+               .compatible = "mediatek,mt6779-vdecsys",
+               .data = &vdec_desc,
+       }, {
+               /* sentinel */
+       }
+};
 
 static struct platform_driver clk_mt6779_vdec_drv = {
-       .probe = clk_mt6779_vdec_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-vdec",
                .of_match_table = of_match_clk_mt6779_vdec,
index 573efa87c9bdc0d79a0f61f33406e2f393642439..c25035c0f334c18173f2a2497d0261053699cdc7 100644 (file)
@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = {
        GATE_VENC_I(CLK_VENC_GCON_GALS, "venc_gals", "venc_sel", 28),
 };
 
-static const struct of_device_id of_match_clk_mt6779_venc[] = {
-       { .compatible = "mediatek,mt6779-vencsys", },
-       {}
+static const struct mtk_clk_desc venc_desc = {
+       .clks = venc_clks,
+       .num_clks = ARRAY_SIZE(venc_clks),
 };
 
-static int clk_mt6779_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_GCON_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 of_device_id of_match_clk_mt6779_venc[] = {
+       {
+               .compatible = "mediatek,mt6779-vencsys",
+               .data = &venc_desc,
+       }, {
+               /* sentinel */
+       }
+};
 
 static struct platform_driver clk_mt6779_venc_drv = {
-       .probe = clk_mt6779_venc_probe,
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
        .driver = {
                .name = "clk-mt6779-venc",
                .of_match_table = of_match_clk_mt6779_venc,