Skip to content

Commit d36d697

Browse files
milesdotchenwens
authored andcommitted
clk: mediatek: mt8183: 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: Miles Chen <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Chen-Yu Tsai <[email protected]>
1 parent a481c6c commit d36d697

File tree

9 files changed

+108
-137
lines changed

9 files changed

+108
-137
lines changed

drivers/clk/mediatek/clk-mt8183-cam.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,23 @@ static const struct mtk_gate cam_clks[] = {
3434
GATE_CAM(CLK_CAM_CCU, "cam_ccu", "cam_sel", 12),
3535
};
3636

37-
static int clk_mt8183_cam_probe(struct platform_device *pdev)
38-
{
39-
struct clk_hw_onecell_data *clk_data;
40-
struct device_node *node = pdev->dev.of_node;
41-
42-
clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
43-
44-
mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks),
45-
clk_data);
46-
47-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
48-
}
37+
static const struct mtk_clk_desc cam_desc = {
38+
.clks = cam_clks,
39+
.num_clks = ARRAY_SIZE(cam_clks),
40+
};
4941

5042
static const struct of_device_id of_match_clk_mt8183_cam[] = {
51-
{ .compatible = "mediatek,mt8183-camsys", },
52-
{}
43+
{
44+
.compatible = "mediatek,mt8183-camsys",
45+
.data = &cam_desc,
46+
}, {
47+
/* sentinel */
48+
}
5349
};
5450

5551
static struct platform_driver clk_mt8183_cam_drv = {
56-
.probe = clk_mt8183_cam_probe,
52+
.probe = mtk_clk_simple_probe,
53+
.remove = mtk_clk_simple_remove,
5754
.driver = {
5855
.name = "clk-mt8183-cam",
5956
.of_match_table = of_match_clk_mt8183_cam,

drivers/clk/mediatek/clk-mt8183-img.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,23 @@ static const struct mtk_gate img_clks[] = {
3434
GATE_IMG(CLK_IMG_OWE, "img_owe", "img_sel", 9),
3535
};
3636

37-
static int clk_mt8183_img_probe(struct platform_device *pdev)
38-
{
39-
struct clk_hw_onecell_data *clk_data;
40-
struct device_node *node = pdev->dev.of_node;
41-
42-
clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
43-
44-
mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
45-
clk_data);
46-
47-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
48-
}
37+
static const struct mtk_clk_desc img_desc = {
38+
.clks = img_clks,
39+
.num_clks = ARRAY_SIZE(img_clks),
40+
};
4941

5042
static const struct of_device_id of_match_clk_mt8183_img[] = {
51-
{ .compatible = "mediatek,mt8183-imgsys", },
52-
{}
43+
{
44+
.compatible = "mediatek,mt8183-imgsys",
45+
.data = &img_desc,
46+
}, {
47+
/* sentinel */
48+
}
5349
};
5450

5551
static struct platform_driver clk_mt8183_img_drv = {
56-
.probe = clk_mt8183_img_probe,
52+
.probe = mtk_clk_simple_probe,
53+
.remove = mtk_clk_simple_remove,
5754
.driver = {
5855
.name = "clk-mt8183-img",
5956
.of_match_table = of_match_clk_mt8183_img,

drivers/clk/mediatek/clk-mt8183-ipu0.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,23 @@ static const struct mtk_gate ipu_core0_clks[] = {
2727
GATE_IPU_CORE0(CLK_IPU_CORE0_IPU, "ipu_core0_ipu", "dsp_sel", 2),
2828
};
2929

30-
static int clk_mt8183_ipu_core0_probe(struct platform_device *pdev)
31-
{
32-
struct clk_hw_onecell_data *clk_data;
33-
struct device_node *node = pdev->dev.of_node;
34-
35-
clk_data = mtk_alloc_clk_data(CLK_IPU_CORE0_NR_CLK);
36-
37-
mtk_clk_register_gates(node, ipu_core0_clks, ARRAY_SIZE(ipu_core0_clks),
38-
clk_data);
39-
40-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
41-
}
30+
static const struct mtk_clk_desc ipu_core0_desc = {
31+
.clks = ipu_core0_clks,
32+
.num_clks = ARRAY_SIZE(ipu_core0_clks),
33+
};
4234

4335
static const struct of_device_id of_match_clk_mt8183_ipu_core0[] = {
44-
{ .compatible = "mediatek,mt8183-ipu_core0", },
45-
{}
36+
{
37+
.compatible = "mediatek,mt8183-ipu_core0",
38+
.data = &ipu_core0_desc,
39+
}, {
40+
/* sentinel */
41+
}
4642
};
4743

4844
static struct platform_driver clk_mt8183_ipu_core0_drv = {
49-
.probe = clk_mt8183_ipu_core0_probe,
45+
.probe = mtk_clk_simple_probe,
46+
.remove = mtk_clk_simple_remove,
5047
.driver = {
5148
.name = "clk-mt8183-ipu_core0",
5249
.of_match_table = of_match_clk_mt8183_ipu_core0,

drivers/clk/mediatek/clk-mt8183-ipu1.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,23 @@ static const struct mtk_gate ipu_core1_clks[] = {
2727
GATE_IPU_CORE1(CLK_IPU_CORE1_IPU, "ipu_core1_ipu", "dsp_sel", 2),
2828
};
2929

30-
static int clk_mt8183_ipu_core1_probe(struct platform_device *pdev)
31-
{
32-
struct clk_hw_onecell_data *clk_data;
33-
struct device_node *node = pdev->dev.of_node;
34-
35-
clk_data = mtk_alloc_clk_data(CLK_IPU_CORE1_NR_CLK);
36-
37-
mtk_clk_register_gates(node, ipu_core1_clks, ARRAY_SIZE(ipu_core1_clks),
38-
clk_data);
39-
40-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
41-
}
30+
static const struct mtk_clk_desc ipu_core1_desc = {
31+
.clks = ipu_core1_clks,
32+
.num_clks = ARRAY_SIZE(ipu_core1_clks),
33+
};
4234

4335
static const struct of_device_id of_match_clk_mt8183_ipu_core1[] = {
44-
{ .compatible = "mediatek,mt8183-ipu_core1", },
45-
{}
36+
{
37+
.compatible = "mediatek,mt8183-ipu_core1",
38+
.data = &ipu_core1_desc,
39+
}, {
40+
/* sentinel */
41+
}
4642
};
4743

4844
static struct platform_driver clk_mt8183_ipu_core1_drv = {
49-
.probe = clk_mt8183_ipu_core1_probe,
45+
.probe = mtk_clk_simple_probe,
46+
.remove = mtk_clk_simple_remove,
5047
.driver = {
5148
.name = "clk-mt8183-ipu_core1",
5249
.of_match_table = of_match_clk_mt8183_ipu_core1,

drivers/clk/mediatek/clk-mt8183-ipu_adl.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,23 @@ static const struct mtk_gate ipu_adl_clks[] = {
2525
GATE_IPU_ADL_I(CLK_IPU_ADL_CABGEN, "ipu_adl_cabgen", "dsp_sel", 24),
2626
};
2727

28-
static int clk_mt8183_ipu_adl_probe(struct platform_device *pdev)
29-
{
30-
struct clk_hw_onecell_data *clk_data;
31-
struct device_node *node = pdev->dev.of_node;
32-
33-
clk_data = mtk_alloc_clk_data(CLK_IPU_ADL_NR_CLK);
34-
35-
mtk_clk_register_gates(node, ipu_adl_clks, ARRAY_SIZE(ipu_adl_clks),
36-
clk_data);
37-
38-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
39-
}
28+
static const struct mtk_clk_desc ipu_adl_desc = {
29+
.clks = ipu_adl_clks,
30+
.num_clks = ARRAY_SIZE(ipu_adl_clks),
31+
};
4032

4133
static const struct of_device_id of_match_clk_mt8183_ipu_adl[] = {
42-
{ .compatible = "mediatek,mt8183-ipu_adl", },
43-
{}
34+
{
35+
.compatible = "mediatek,mt8183-ipu_adl",
36+
.data = &ipu_adl_desc,
37+
}, {
38+
/* sentinel */
39+
}
4440
};
4541

4642
static struct platform_driver clk_mt8183_ipu_adl_drv = {
47-
.probe = clk_mt8183_ipu_adl_probe,
43+
.probe = mtk_clk_simple_probe,
44+
.remove = mtk_clk_simple_remove,
4845
.driver = {
4946
.name = "clk-mt8183-ipu_adl",
5047
.of_match_table = of_match_clk_mt8183_ipu_adl,

drivers/clk/mediatek/clk-mt8183-ipu_conn.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,23 @@ static const struct mtk_gate ipu_conn_clks[] = {
9494
"ipu_conn_cab3to1_slice", "dsp1_sel", 17),
9595
};
9696

97-
static int clk_mt8183_ipu_conn_probe(struct platform_device *pdev)
98-
{
99-
struct clk_hw_onecell_data *clk_data;
100-
struct device_node *node = pdev->dev.of_node;
101-
102-
clk_data = mtk_alloc_clk_data(CLK_IPU_CONN_NR_CLK);
103-
104-
mtk_clk_register_gates(node, ipu_conn_clks, ARRAY_SIZE(ipu_conn_clks),
105-
clk_data);
106-
107-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
108-
}
97+
static const struct mtk_clk_desc ipu_conn_desc = {
98+
.clks = ipu_conn_clks,
99+
.num_clks = ARRAY_SIZE(ipu_conn_clks),
100+
};
109101

110102
static const struct of_device_id of_match_clk_mt8183_ipu_conn[] = {
111-
{ .compatible = "mediatek,mt8183-ipu_conn", },
112-
{}
103+
{
104+
.compatible = "mediatek,mt8183-ipu_conn",
105+
.data = &ipu_conn_desc,
106+
}, {
107+
/* sentinel */
108+
}
113109
};
114110

115111
static struct platform_driver clk_mt8183_ipu_conn_drv = {
116-
.probe = clk_mt8183_ipu_conn_probe,
112+
.probe = mtk_clk_simple_probe,
113+
.remove = mtk_clk_simple_remove,
117114
.driver = {
118115
.name = "clk-mt8183-ipu_conn",
119116
.of_match_table = of_match_clk_mt8183_ipu_conn,

drivers/clk/mediatek/clk-mt8183-mfgcfg.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,23 @@ static const struct mtk_gate mfg_clks[] = {
2626
GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0)
2727
};
2828

29-
static int clk_mt8183_mfg_probe(struct platform_device *pdev)
30-
{
31-
struct clk_hw_onecell_data *clk_data;
32-
struct device_node *node = pdev->dev.of_node;
33-
34-
pm_runtime_enable(&pdev->dev);
35-
36-
clk_data = mtk_alloc_clk_data(CLK_MFG_NR_CLK);
37-
38-
mtk_clk_register_gates_with_dev(node, mfg_clks, ARRAY_SIZE(mfg_clks),
39-
clk_data, &pdev->dev);
40-
41-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
42-
}
29+
static const struct mtk_clk_desc mfg_desc = {
30+
.clks = mfg_clks,
31+
.num_clks = ARRAY_SIZE(mfg_clks),
32+
};
4333

4434
static const struct of_device_id of_match_clk_mt8183_mfg[] = {
45-
{ .compatible = "mediatek,mt8183-mfgcfg", },
46-
{}
35+
{
36+
.compatible = "mediatek,mt8183-mfgcfg",
37+
.data = &mfg_desc,
38+
}, {
39+
/* sentinel */
40+
}
4741
};
4842

4943
static struct platform_driver clk_mt8183_mfg_drv = {
50-
.probe = clk_mt8183_mfg_probe,
44+
.probe = mtk_clk_simple_probe,
45+
.remove = mtk_clk_simple_remove,
5146
.driver = {
5247
.name = "clk-mt8183-mfg",
5348
.of_match_table = of_match_clk_mt8183_mfg,

drivers/clk/mediatek/clk-mt8183-vdec.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,23 @@ static const struct mtk_gate vdec_clks[] = {
3838
GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1", "mm_sel", 0),
3939
};
4040

41-
static int clk_mt8183_vdec_probe(struct platform_device *pdev)
42-
{
43-
struct clk_hw_onecell_data *clk_data;
44-
struct device_node *node = pdev->dev.of_node;
45-
46-
clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
47-
48-
mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
49-
clk_data);
50-
51-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
52-
}
41+
static const struct mtk_clk_desc vdec_desc = {
42+
.clks = vdec_clks,
43+
.num_clks = ARRAY_SIZE(vdec_clks),
44+
};
5345

5446
static const struct of_device_id of_match_clk_mt8183_vdec[] = {
55-
{ .compatible = "mediatek,mt8183-vdecsys", },
56-
{}
47+
{
48+
.compatible = "mediatek,mt8183-vdecsys",
49+
.data = &vdec_desc,
50+
}, {
51+
/* sentinel */
52+
}
5753
};
5854

5955
static struct platform_driver clk_mt8183_vdec_drv = {
60-
.probe = clk_mt8183_vdec_probe,
56+
.probe = mtk_clk_simple_probe,
57+
.remove = mtk_clk_simple_remove,
6158
.driver = {
6259
.name = "clk-mt8183-vdec",
6360
.of_match_table = of_match_clk_mt8183_vdec,

drivers/clk/mediatek/clk-mt8183-venc.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = {
3030
"mm_sel", 8),
3131
};
3232

33-
static int clk_mt8183_venc_probe(struct platform_device *pdev)
34-
{
35-
struct clk_hw_onecell_data *clk_data;
36-
struct device_node *node = pdev->dev.of_node;
37-
38-
clk_data = mtk_alloc_clk_data(CLK_VENC_NR_CLK);
39-
40-
mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_clks),
41-
clk_data);
42-
43-
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
44-
}
33+
static const struct mtk_clk_desc venc_desc = {
34+
.clks = venc_clks,
35+
.num_clks = ARRAY_SIZE(venc_clks),
36+
};
4537

4638
static const struct of_device_id of_match_clk_mt8183_venc[] = {
47-
{ .compatible = "mediatek,mt8183-vencsys", },
48-
{}
39+
{
40+
.compatible = "mediatek,mt8183-vencsys",
41+
.data = &venc_desc,
42+
}, {
43+
/* sentinel */
44+
}
4945
};
5046

5147
static struct platform_driver clk_mt8183_venc_drv = {
52-
.probe = clk_mt8183_venc_probe,
48+
.probe = mtk_clk_simple_probe,
49+
.remove = mtk_clk_simple_remove,
5350
.driver = {
5451
.name = "clk-mt8183-venc",
5552
.of_match_table = of_match_clk_mt8183_venc,

0 commit comments

Comments
 (0)