Commit dc6fdd8a authored by Miles Chen's avatar Miles Chen Committed by Chen-Yu Tsai

clk: mediatek: mt6779: use mtk_clk_simple_probe to simplify driver

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: default avatarMiles Chen <miles.chen@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220922091841.4099-5-miles.chen@mediatek.comSigned-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
parent 2b74c1f6
...@@ -89,26 +89,23 @@ static const struct mtk_gate audio_clks[] = { ...@@ -89,26 +89,23 @@ static const struct mtk_gate audio_clks[] = {
"audio_h_sel", 31), "audio_h_sel", 31),
}; };
static const struct of_device_id of_match_clk_mt6779_aud[] = { static const struct mtk_clk_desc audio_desc = {
{ .compatible = "mediatek,mt6779-audio", }, .clks = audio_clks,
{} .num_clks = ARRAY_SIZE(audio_clks),
}; };
static int clk_mt6779_aud_probe(struct platform_device *pdev) static const struct of_device_id of_match_clk_mt6779_aud[] = {
{ {
struct clk_hw_onecell_data *clk_data; .compatible = "mediatek,mt6779-audio",
struct device_node *node = pdev->dev.of_node; .data = &audio_desc,
}, {
clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK); /* sentinel */
}
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 struct platform_driver clk_mt6779_aud_drv = { static struct platform_driver clk_mt6779_aud_drv = {
.probe = clk_mt6779_aud_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-aud", .name = "clk-mt6779-aud",
.of_match_table = of_match_clk_mt6779_aud, .of_match_table = of_match_clk_mt6779_aud,
......
...@@ -38,26 +38,23 @@ static const struct mtk_gate cam_clks[] = { ...@@ -38,26 +38,23 @@ static const struct mtk_gate cam_clks[] = {
GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14), GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14),
}; };
static const struct of_device_id of_match_clk_mt6779_cam[] = { static const struct mtk_clk_desc cam_desc = {
{ .compatible = "mediatek,mt6779-camsys", }, .clks = cam_clks,
{} .num_clks = ARRAY_SIZE(cam_clks),
}; };
static int clk_mt6779_cam_probe(struct platform_device *pdev) static const struct of_device_id of_match_clk_mt6779_cam[] = {
{ {
struct clk_hw_onecell_data *clk_data; .compatible = "mediatek,mt6779-camsys",
struct device_node *node = pdev->dev.of_node; .data = &cam_desc,
}, {
clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK); /* sentinel */
}
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 struct platform_driver clk_mt6779_cam_drv = { static struct platform_driver clk_mt6779_cam_drv = {
.probe = clk_mt6779_cam_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-cam", .name = "clk-mt6779-cam",
.of_match_table = of_match_clk_mt6779_cam, .of_match_table = of_match_clk_mt6779_cam,
......
...@@ -30,26 +30,23 @@ static const struct mtk_gate img_clks[] = { ...@@ -30,26 +30,23 @@ static const struct mtk_gate img_clks[] = {
GATE_IMG(CLK_IMG_WPE_A, "imgsys_wpe_a", "img_sel", 7), GATE_IMG(CLK_IMG_WPE_A, "imgsys_wpe_a", "img_sel", 7),
}; };
static const struct of_device_id of_match_clk_mt6779_img[] = { static const struct mtk_clk_desc img_desc = {
{ .compatible = "mediatek,mt6779-imgsys", }, .clks = img_clks,
{} .num_clks = ARRAY_SIZE(img_clks),
}; };
static int clk_mt6779_img_probe(struct platform_device *pdev) static const struct of_device_id of_match_clk_mt6779_img[] = {
{ {
struct clk_hw_onecell_data *clk_data; .compatible = "mediatek,mt6779-imgsys",
struct device_node *node = pdev->dev.of_node; .data = &img_desc,
}, {
clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK); /* sentinel */
}
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 struct platform_driver clk_mt6779_img_drv = { static struct platform_driver clk_mt6779_img_drv = {
.probe = clk_mt6779_img_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-img", .name = "clk-mt6779-img",
.of_match_table = of_match_clk_mt6779_img, .of_match_table = of_match_clk_mt6779_img,
......
...@@ -32,26 +32,23 @@ static const struct mtk_gate ipe_clks[] = { ...@@ -32,26 +32,23 @@ static const struct mtk_gate ipe_clks[] = {
GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6), GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
}; };
static const struct of_device_id of_match_clk_mt6779_ipe[] = { static const struct mtk_clk_desc ipe_desc = {
{ .compatible = "mediatek,mt6779-ipesys", }, .clks = ipe_clks,
{} .num_clks = ARRAY_SIZE(ipe_clks),
}; };
static int clk_mt6779_ipe_probe(struct platform_device *pdev) static const struct of_device_id of_match_clk_mt6779_ipe[] = {
{ {
struct clk_hw_onecell_data *clk_data; .compatible = "mediatek,mt6779-ipesys",
struct device_node *node = pdev->dev.of_node; .data = &ipe_desc,
}, {
clk_data = mtk_alloc_clk_data(CLK_IPE_NR_CLK); /* sentinel */
}
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 struct platform_driver clk_mt6779_ipe_drv = { static struct platform_driver clk_mt6779_ipe_drv = {
.probe = clk_mt6779_ipe_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-ipe", .name = "clk-mt6779-ipe",
.of_match_table = of_match_clk_mt6779_ipe, .of_match_table = of_match_clk_mt6779_ipe,
......
...@@ -27,26 +27,23 @@ static const struct mtk_gate mfg_clks[] = { ...@@ -27,26 +27,23 @@ static const struct mtk_gate mfg_clks[] = {
GATE_MFG(CLK_MFGCFG_BG3D, "mfg_bg3d", "mfg_sel", 0), GATE_MFG(CLK_MFGCFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
}; };
static int clk_mt6779_mfg_probe(struct platform_device *pdev) static const struct mtk_clk_desc mfg_desc = {
{ .clks = mfg_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(mfg_clks),
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 of_device_id of_match_clk_mt6779_mfg[] = { 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 = { static struct platform_driver clk_mt6779_mfg_drv = {
.probe = clk_mt6779_mfg_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-mfg", .name = "clk-mt6779-mfg",
.of_match_table = of_match_clk_mt6779_mfg, .of_match_table = of_match_clk_mt6779_mfg,
......
...@@ -39,26 +39,23 @@ static const struct mtk_gate vdec_clks[] = { ...@@ -39,26 +39,23 @@ static const struct mtk_gate vdec_clks[] = {
GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1_cken", "vdec_sel", 0), GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1_cken", "vdec_sel", 0),
}; };
static const struct of_device_id of_match_clk_mt6779_vdec[] = { static const struct mtk_clk_desc vdec_desc = {
{ .compatible = "mediatek,mt6779-vdecsys", }, .clks = vdec_clks,
{} .num_clks = ARRAY_SIZE(vdec_clks),
}; };
static int clk_mt6779_vdec_probe(struct platform_device *pdev) static const struct of_device_id of_match_clk_mt6779_vdec[] = {
{ {
struct clk_hw_onecell_data *clk_data; .compatible = "mediatek,mt6779-vdecsys",
struct device_node *node = pdev->dev.of_node; .data = &vdec_desc,
}, {
clk_data = mtk_alloc_clk_data(CLK_VDEC_GCON_NR_CLK); /* sentinel */
}
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 struct platform_driver clk_mt6779_vdec_drv = { static struct platform_driver clk_mt6779_vdec_drv = {
.probe = clk_mt6779_vdec_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-vdec", .name = "clk-mt6779-vdec",
.of_match_table = of_match_clk_mt6779_vdec, .of_match_table = of_match_clk_mt6779_vdec,
......
...@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = { ...@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = {
GATE_VENC_I(CLK_VENC_GCON_GALS, "venc_gals", "venc_sel", 28), GATE_VENC_I(CLK_VENC_GCON_GALS, "venc_gals", "venc_sel", 28),
}; };
static const struct of_device_id of_match_clk_mt6779_venc[] = { static const struct mtk_clk_desc venc_desc = {
{ .compatible = "mediatek,mt6779-vencsys", }, .clks = venc_clks,
{} .num_clks = ARRAY_SIZE(venc_clks),
}; };
static int clk_mt6779_venc_probe(struct platform_device *pdev) static const struct of_device_id of_match_clk_mt6779_venc[] = {
{ {
struct clk_hw_onecell_data *clk_data; .compatible = "mediatek,mt6779-vencsys",
struct device_node *node = pdev->dev.of_node; .data = &venc_desc,
}, {
clk_data = mtk_alloc_clk_data(CLK_VENC_GCON_NR_CLK); /* sentinel */
}
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 struct platform_driver clk_mt6779_venc_drv = { static struct platform_driver clk_mt6779_venc_drv = {
.probe = clk_mt6779_venc_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt6779-venc", .name = "clk-mt6779-venc",
.of_match_table = of_match_clk_mt6779_venc, .of_match_table = of_match_clk_mt6779_venc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment