Skip to contentSkip to conversation

Migrate MT8195 VPPSYS 0/1 to mtk-mmsys drive

PATCH Superseded Moudy Ho 3 participants 4 messages Feb 7, 2023 – Feb 11, 2023

Subsystems (2)

v7 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Moudy Ho

author
#0 lore raw

v7 cover Migrate MT8195 VPPSYS 0/1 to mtk-mmsys drive

Change since v6:
- Rebase on linux-next.
- Drop applied patches [1/4], [2/4] and [4/4].
- In response to the API changes of "mtk_clk_register_gates" and "mtk_alloc_clk_data", the patch [3/4] has been modified accordingly.

Change since v5:
- Rebase on linux-next.
- Correct the compatible enumeration order in "mediatek,mmsys.yaml".

Hi,

This series splits patches from the original mailing list below:
https://patchwork.kernel.org/project/linux-mediatek/list/?series=711592

Refer to the comments of 0/8 and 1/8 in the following series:
https://patchwork.kernel.org/project/linux-mediatek/list/?series=702518
All about the MT8195 VPPSYS 0/1 should be probed from the "mtk-mmsys" driver, which then starts its own clock driver as the platform driver.

Moudy Ho (1):
clk: mediatek: remove MT8195 vppsys/0/1 simple_probe

 drivers/clk/mediatek/clk-mt8195-vpp0.c | 58 +++++++++++++++++++-------
 drivers/clk/mediatek/clk-mt8195-vpp1.c | 58 +++++++++++++++++++-------
 2 files changed, 86 insertions(+), 30 deletions(-)
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v7 1/1 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.

---
 drivers/clk/mediatek/clk-mt8195-vpp0.c | 58 +++++++++++++++++++-------
 drivers/clk/mediatek/clk-mt8195-vpp1.c | 58 +++++++++++++++++++-------
 2 files changed, 86 insertions(+), 30 deletions(-)
drivers/clk/mediatek/clk-mt8195-vpp0.c +43 -15
index bf2939c3a0230..debff9a8c071a 100644
@@ -86,26 +86,54 @@ static const struct mtk_gate vpp0_clks[] = {
 	GATE_VPP0_2(CLK_VPP0_WARP1_MDP_DL_ASYNC, "vpp0_warp1_mdp_dl_async", "top_wpe_vpp", 3),
 };
 
-static const struct mtk_clk_desc vpp0_desc = {
-	.clks = vpp0_clks,
-	.num_clks = ARRAY_SIZE(vpp0_clks),
-};
+static int clk_mt8195_vpp0_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->parent->of_node;
+	struct clk_hw_onecell_data *clk_data;
+	int r;
 
-static const struct of_device_id of_match_clk_mt8195_vpp0[] = {
-	{
-		.compatible = "mediatek,mt8195-vppsys0",
-		.data = &vpp0_desc,
-	}, {
-		/* sentinel */
-	}
-};
+	clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
+	if (!clk_data)
+		return -ENOMEM;
+
+	r = mtk_clk_register_gates(&pdev->dev, node, vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
+	if (r)
+		goto free_vpp0_data;
+
+	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+	if (r)
+		goto unregister_gates;
+
+	platform_set_drvdata(pdev, clk_data);
+
+	return r;
+
+unregister_gates:
+	mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
+free_vpp0_data:
+	mtk_free_clk_data(clk_data);
+	return r;
+}
+
+static int clk_mt8195_vpp0_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->parent->of_node;
+	struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	of_clk_del_provider(node);
+	mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
+	mtk_free_clk_data(clk_data);
+
+	return 0;
+}
 
 static struct platform_driver clk_mt8195_vpp0_drv = {
-	.probe = mtk_clk_simple_probe,
-	.remove = mtk_clk_simple_remove,
+	.probe = clk_mt8195_vpp0_probe,
+	.remove = clk_mt8195_vpp0_remove,
 	.driver = {
 		.name = "clk-mt8195-vpp0",
-		.of_match_table = of_match_clk_mt8195_vpp0,
 	},
 };
 builtin_platform_driver(clk_mt8195_vpp0_drv);
drivers/clk/mediatek/clk-mt8195-vpp1.c +43 -15

69 lines not on this page · raw message

Signature · 1 line
2.18.0
Reviewed-by Tested-by on v7 1/1
#2 lore raw

Re: [PATCH v7 1/1] clk: mediatek: remove MT8195 vppsys/0/1 simple_probe

Quoted 8 lines · Moudy Ho

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.

Stephen, could you pick this up for v6.3? Otherwise we'll end up with two drivers targeting the same compatible strings.

Thanks

maintainer
#3 lore raw

Re: [PATCH v7 1/1] clk: mediatek: remove MT8195 vppsys/0/1 simple_probe

Quoting Chen-Yu Tsai (2023-02-06 20:29:21)

Quoted 10 lines · Moudy Ho
Quoted 8 lines

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.

Quoted 6 lines

Stephen, could you pick this up for v6.3? Otherwise we'll end up with two drivers targeting the same compatible strings.

I applied v6 after fixing it by hand.