Skip to content

Commit b132c2a

Browse files
MoudyHobebarino
authored andcommitted
clk: mediatek: remove MT8195 vppsys/0/1 simple_probe
MT8195 VPPSYS0/1 will be probed by the compatible name in the mtk-mmsys driver and then probe its own clock driver as a platform driver. Signed-off-by: Moudy Ho <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent dfea6ae commit b132c2a

File tree

2 files changed

+86
-30
lines changed

2 files changed

+86
-30
lines changed

drivers/clk/mediatek/clk-mt8195-vpp0.c

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,54 @@ static const struct mtk_gate vpp0_clks[] = {
8686
GATE_VPP0_2(CLK_VPP0_WARP1_MDP_DL_ASYNC, "vpp0_warp1_mdp_dl_async", "top_wpe_vpp", 3),
8787
};
8888

89-
static const struct mtk_clk_desc vpp0_desc = {
90-
.clks = vpp0_clks,
91-
.num_clks = ARRAY_SIZE(vpp0_clks),
92-
};
89+
static int clk_mt8195_vpp0_probe(struct platform_device *pdev)
90+
{
91+
struct device *dev = &pdev->dev;
92+
struct device_node *node = dev->parent->of_node;
93+
struct clk_hw_onecell_data *clk_data;
94+
int r;
9395

94-
static const struct of_device_id of_match_clk_mt8195_vpp0[] = {
95-
{
96-
.compatible = "mediatek,mt8195-vppsys0",
97-
.data = &vpp0_desc,
98-
}, {
99-
/* sentinel */
100-
}
101-
};
96+
clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
97+
if (!clk_data)
98+
return -ENOMEM;
99+
100+
r = mtk_clk_register_gates(dev, node, vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
101+
if (r)
102+
goto free_vpp0_data;
103+
104+
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
105+
if (r)
106+
goto unregister_gates;
107+
108+
platform_set_drvdata(pdev, clk_data);
109+
110+
return r;
111+
112+
unregister_gates:
113+
mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
114+
free_vpp0_data:
115+
mtk_free_clk_data(clk_data);
116+
return r;
117+
}
118+
119+
static int clk_mt8195_vpp0_remove(struct platform_device *pdev)
120+
{
121+
struct device *dev = &pdev->dev;
122+
struct device_node *node = dev->parent->of_node;
123+
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
124+
125+
of_clk_del_provider(node);
126+
mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
127+
mtk_free_clk_data(clk_data);
128+
129+
return 0;
130+
}
102131

103132
static struct platform_driver clk_mt8195_vpp0_drv = {
104-
.probe = mtk_clk_simple_probe,
105-
.remove = mtk_clk_simple_remove,
133+
.probe = clk_mt8195_vpp0_probe,
134+
.remove = clk_mt8195_vpp0_remove,
106135
.driver = {
107136
.name = "clk-mt8195-vpp0",
108-
.of_match_table = of_match_clk_mt8195_vpp0,
109137
},
110138
};
111139
builtin_platform_driver(clk_mt8195_vpp0_drv);

drivers/clk/mediatek/clk-mt8195-vpp1.c

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,54 @@ static const struct mtk_gate vpp1_clks[] = {
8484
GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26),
8585
};
8686

87-
static const struct mtk_clk_desc vpp1_desc = {
88-
.clks = vpp1_clks,
89-
.num_clks = ARRAY_SIZE(vpp1_clks),
90-
};
87+
static int clk_mt8195_vpp1_probe(struct platform_device *pdev)
88+
{
89+
struct device *dev = &pdev->dev;
90+
struct device_node *node = dev->parent->of_node;
91+
struct clk_hw_onecell_data *clk_data;
92+
int r;
9193

92-
static const struct of_device_id of_match_clk_mt8195_vpp1[] = {
93-
{
94-
.compatible = "mediatek,mt8195-vppsys1",
95-
.data = &vpp1_desc,
96-
}, {
97-
/* sentinel */
98-
}
99-
};
94+
clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK);
95+
if (!clk_data)
96+
return -ENOMEM;
97+
98+
r = mtk_clk_register_gates(dev, node, vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
99+
if (r)
100+
goto free_vpp1_data;
101+
102+
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
103+
if (r)
104+
goto unregister_gates;
105+
106+
platform_set_drvdata(pdev, clk_data);
107+
108+
return r;
109+
110+
unregister_gates:
111+
mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
112+
free_vpp1_data:
113+
mtk_free_clk_data(clk_data);
114+
return r;
115+
}
116+
117+
static int clk_mt8195_vpp1_remove(struct platform_device *pdev)
118+
{
119+
struct device *dev = &pdev->dev;
120+
struct device_node *node = dev->parent->of_node;
121+
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
122+
123+
of_clk_del_provider(node);
124+
mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
125+
mtk_free_clk_data(clk_data);
126+
127+
return 0;
128+
}
100129

101130
static struct platform_driver clk_mt8195_vpp1_drv = {
102-
.probe = mtk_clk_simple_probe,
103-
.remove = mtk_clk_simple_remove,
131+
.probe = clk_mt8195_vpp1_probe,
132+
.remove = clk_mt8195_vpp1_remove,
104133
.driver = {
105134
.name = "clk-mt8195-vpp1",
106-
.of_match_table = of_match_clk_mt8195_vpp1,
107135
},
108136
};
109137
builtin_platform_driver(clk_mt8195_vpp1_drv);

0 commit comments

Comments
 (0)