Commit d36d697a authored by Miles Chen's avatar Miles Chen Committed by Chen-Yu Tsai
Browse files

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: 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-7-miles.chen@mediatek.com


Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
parent a481c6c7
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -34,26 +34,23 @@ static const struct mtk_gate cam_clks[] = {
	GATE_CAM(CLK_CAM_CCU, "cam_ccu", "cam_sel", 12),
};

static int clk_mt8183_cam_probe(struct platform_device *pdev)
{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);

	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 const struct mtk_clk_desc cam_desc = {
	.clks = cam_clks,
	.num_clks = ARRAY_SIZE(cam_clks),
};

static const struct of_device_id of_match_clk_mt8183_cam[] = {
	{ .compatible = "mediatek,mt8183-camsys", },
	{}
	{
		.compatible = "mediatek,mt8183-camsys",
		.data = &cam_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt8183_cam_drv = {
	.probe = clk_mt8183_cam_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt8183-cam",
		.of_match_table = of_match_clk_mt8183_cam,
+12 −15
Original line number Diff line number Diff line
@@ -34,26 +34,23 @@ static const struct mtk_gate img_clks[] = {
	GATE_IMG(CLK_IMG_OWE, "img_owe", "img_sel", 9),
};

static int clk_mt8183_img_probe(struct platform_device *pdev)
{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);

	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 const struct mtk_clk_desc img_desc = {
	.clks = img_clks,
	.num_clks = ARRAY_SIZE(img_clks),
};

static const struct of_device_id of_match_clk_mt8183_img[] = {
	{ .compatible = "mediatek,mt8183-imgsys", },
	{}
	{
		.compatible = "mediatek,mt8183-imgsys",
		.data = &img_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt8183_img_drv = {
	.probe = clk_mt8183_img_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt8183-img",
		.of_match_table = of_match_clk_mt8183_img,
+12 −15
Original line number Diff line number Diff line
@@ -27,26 +27,23 @@ static const struct mtk_gate ipu_core0_clks[] = {
	GATE_IPU_CORE0(CLK_IPU_CORE0_IPU, "ipu_core0_ipu", "dsp_sel", 2),
};

static int clk_mt8183_ipu_core0_probe(struct platform_device *pdev)
{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_IPU_CORE0_NR_CLK);

	mtk_clk_register_gates(node, ipu_core0_clks, ARRAY_SIZE(ipu_core0_clks),
			clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
}
static const struct mtk_clk_desc ipu_core0_desc = {
	.clks = ipu_core0_clks,
	.num_clks = ARRAY_SIZE(ipu_core0_clks),
};

static const struct of_device_id of_match_clk_mt8183_ipu_core0[] = {
	{ .compatible = "mediatek,mt8183-ipu_core0", },
	{}
	{
		.compatible = "mediatek,mt8183-ipu_core0",
		.data = &ipu_core0_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt8183_ipu_core0_drv = {
	.probe = clk_mt8183_ipu_core0_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt8183-ipu_core0",
		.of_match_table = of_match_clk_mt8183_ipu_core0,
+12 −15
Original line number Diff line number Diff line
@@ -27,26 +27,23 @@ static const struct mtk_gate ipu_core1_clks[] = {
	GATE_IPU_CORE1(CLK_IPU_CORE1_IPU, "ipu_core1_ipu", "dsp_sel", 2),
};

static int clk_mt8183_ipu_core1_probe(struct platform_device *pdev)
{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_IPU_CORE1_NR_CLK);

	mtk_clk_register_gates(node, ipu_core1_clks, ARRAY_SIZE(ipu_core1_clks),
			clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
}
static const struct mtk_clk_desc ipu_core1_desc = {
	.clks = ipu_core1_clks,
	.num_clks = ARRAY_SIZE(ipu_core1_clks),
};

static const struct of_device_id of_match_clk_mt8183_ipu_core1[] = {
	{ .compatible = "mediatek,mt8183-ipu_core1", },
	{}
	{
		.compatible = "mediatek,mt8183-ipu_core1",
		.data = &ipu_core1_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt8183_ipu_core1_drv = {
	.probe = clk_mt8183_ipu_core1_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt8183-ipu_core1",
		.of_match_table = of_match_clk_mt8183_ipu_core1,
+12 −15
Original line number Diff line number Diff line
@@ -25,26 +25,23 @@ static const struct mtk_gate ipu_adl_clks[] = {
	GATE_IPU_ADL_I(CLK_IPU_ADL_CABGEN, "ipu_adl_cabgen", "dsp_sel", 24),
};

static int clk_mt8183_ipu_adl_probe(struct platform_device *pdev)
{
	struct clk_hw_onecell_data *clk_data;
	struct device_node *node = pdev->dev.of_node;

	clk_data = mtk_alloc_clk_data(CLK_IPU_ADL_NR_CLK);

	mtk_clk_register_gates(node, ipu_adl_clks, ARRAY_SIZE(ipu_adl_clks),
			clk_data);

	return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
}
static const struct mtk_clk_desc ipu_adl_desc = {
	.clks = ipu_adl_clks,
	.num_clks = ARRAY_SIZE(ipu_adl_clks),
};

static const struct of_device_id of_match_clk_mt8183_ipu_adl[] = {
	{ .compatible = "mediatek,mt8183-ipu_adl", },
	{}
	{
		.compatible = "mediatek,mt8183-ipu_adl",
		.data = &ipu_adl_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt8183_ipu_adl_drv = {
	.probe = clk_mt8183_ipu_adl_probe,
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt8183-ipu_adl",
		.of_match_table = of_match_clk_mt8183_ipu_adl,
Loading