Skip to content

Commit cf8a482

Browse files
wensbebarino
authored andcommitted
clk: mediatek: mt8195: Implement remove functions
Until now the mediatek clk driver library did not have any way to unregister clks, and so none of the drivers implemented remove functions. Now that the library does have APIs to unregister clks, use them to implement remove functions for the mt8195 clk drivers. Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Miles Chen <miles.chen@mediatek.com> Link: https://lore.kernel.org/r/20220208124034.414635-31-wenst@chromium.org Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent f3e690b commit cf8a482

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
132132
if (r)
133133
goto unregister_gates;
134134

135+
platform_set_drvdata(pdev, clk_data);
136+
135137
return r;
136138

137139
unregister_gates:
@@ -143,8 +145,22 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
143145
return r;
144146
}
145147

148+
static int clk_mt8195_apmixed_remove(struct platform_device *pdev)
149+
{
150+
struct device_node *node = pdev->dev.of_node;
151+
struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
152+
153+
of_clk_del_provider(node);
154+
mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
155+
mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
156+
mtk_free_clk_data(clk_data);
157+
158+
return 0;
159+
}
160+
146161
static struct platform_driver clk_mt8195_apmixed_drv = {
147162
.probe = clk_mt8195_apmixed_probe,
163+
.remove = clk_mt8195_apmixed_remove,
148164
.driver = {
149165
.name = "clk-mt8195-apmixed",
150166
.of_match_table = of_match_clk_mt8195_apmixed,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev)
7474
if (r)
7575
goto unregister_plls;
7676

77+
platform_set_drvdata(pdev, clk_data);
78+
7779
return r;
7880

7981
unregister_plls:
@@ -83,13 +85,26 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev)
8385
return r;
8486
}
8587

88+
static int clk_mt8195_apusys_pll_remove(struct platform_device *pdev)
89+
{
90+
struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
91+
struct device_node *node = pdev->dev.of_node;
92+
93+
of_clk_del_provider(node);
94+
mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data);
95+
mtk_free_clk_data(clk_data);
96+
97+
return 0;
98+
}
99+
86100
static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = {
87101
{ .compatible = "mediatek,mt8195-apusys_pll", },
88102
{}
89103
};
90104

91105
static struct platform_driver clk_mt8195_apusys_pll_drv = {
92106
.probe = clk_mt8195_apusys_pll_probe,
107+
.remove = clk_mt8195_apusys_pll_remove,
93108
.driver = {
94109
.name = "clk-mt8195-apusys_pll",
95110
.of_match_table = of_match_clk_mt8195_apusys_pll,

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,8 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev)
12711271
if (r)
12721272
goto unregister_gates;
12731273

1274+
platform_set_drvdata(pdev, top_clk_data);
1275+
12741276
return r;
12751277

12761278
unregister_gates:
@@ -1290,8 +1292,26 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev)
12901292
return r;
12911293
}
12921294

1295+
static int clk_mt8195_topck_remove(struct platform_device *pdev)
1296+
{
1297+
struct clk_onecell_data *top_clk_data = platform_get_drvdata(pdev);
1298+
struct device_node *node = pdev->dev.of_node;
1299+
1300+
of_clk_del_provider(node);
1301+
mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data);
1302+
mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data);
1303+
mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_data);
1304+
mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data);
1305+
mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
1306+
mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data);
1307+
mtk_free_clk_data(top_clk_data);
1308+
1309+
return 0;
1310+
}
1311+
12931312
static struct platform_driver clk_mt8195_topck_drv = {
12941313
.probe = clk_mt8195_topck_probe,
1314+
.remove = clk_mt8195_topck_remove,
12951315
.driver = {
12961316
.name = "clk-mt8195-topck",
12971317
.of_match_table = of_match_clk_mt8195_topck,

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev)
107107
if (r)
108108
goto unregister_gates;
109109

110+
platform_set_drvdata(pdev, clk_data);
111+
110112
return r;
111113

112114
unregister_gates:
@@ -116,8 +118,22 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev)
116118
return r;
117119
}
118120

121+
static int clk_mt8195_vdo0_remove(struct platform_device *pdev)
122+
{
123+
struct device *dev = &pdev->dev;
124+
struct device_node *node = dev->parent->of_node;
125+
struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
126+
127+
of_clk_del_provider(node);
128+
mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);
129+
mtk_free_clk_data(clk_data);
130+
131+
return 0;
132+
}
133+
119134
static struct platform_driver clk_mt8195_vdo0_drv = {
120135
.probe = clk_mt8195_vdo0_probe,
136+
.remove = clk_mt8195_vdo0_remove,
121137
.driver = {
122138
.name = "clk-mt8195-vdo0",
123139
},

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev)
124124
if (r)
125125
goto unregister_gates;
126126

127+
platform_set_drvdata(pdev, clk_data);
128+
127129
return r;
128130

129131
unregister_gates:
@@ -133,8 +135,22 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev)
133135
return r;
134136
}
135137

138+
static int clk_mt8195_vdo1_remove(struct platform_device *pdev)
139+
{
140+
struct device *dev = &pdev->dev;
141+
struct device_node *node = dev->parent->of_node;
142+
struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
143+
144+
of_clk_del_provider(node);
145+
mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
146+
mtk_free_clk_data(clk_data);
147+
148+
return 0;
149+
}
150+
136151
static struct platform_driver clk_mt8195_vdo1_drv = {
137152
.probe = clk_mt8195_vdo1_probe,
153+
.remove = clk_mt8195_vdo1_remove,
138154
.driver = {
139155
.name = "clk-mt8195-vdo1",
140156
},

0 commit comments

Comments
 (0)