Commit 65c10c50 authored by AngeloGioacchino Del Regno's avatar AngeloGioacchino Del Regno Committed by Stephen Boyd

clk: mediatek: Migrate to mtk_clk_pdev_probe() for multimedia clocks

Reduce duplication and simplify all MediaTek multimedia clock drivers
by migrating away from defining custom probe functions for each driver
and instead use mtk_clk_pdev_probe().

While at it, also add a .remove() callback to all of the multimedia
clock drivers where missing.
Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarChen-Yu Tsai <wenst@chromium.org>
Tested-by: default avatarMiles Chen <miles.chen@mediatek.com>
Tested-by: default avatarChen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/20230306140543.1813621-4-angelogioacchino.delregno@collabora.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 25209124
...@@ -79,32 +79,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -79,32 +79,23 @@ static const struct mtk_gate mm_clks[] = {
GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14), GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14),
}; };
static int clk_mt2701_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_MM_NR);
mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r)
dev_err(&pdev->dev,
"could not register clock provider: %s: %d\n",
pdev->name, r);
return r; static const struct platform_device_id clk_mt2701_mm_id_table[] = {
} { .name = "clk-mt2701-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt2701_mm_drv = { static struct platform_driver clk_mt2701_mm_drv = {
.probe = clk_mt2701_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt2701-mm", .name = "clk-mt2701-mm",
}, },
.id_table = clk_mt2701_mm_id_table,
}; };
builtin_platform_driver(clk_mt2701_mm_drv); builtin_platform_driver(clk_mt2701_mm_drv);
...@@ -126,32 +126,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -126,32 +126,23 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM2(CLK_MM_DSI3_DIGITAL, "mm_dsi3_digital", "dsi1_lntc", 6), GATE_MM2(CLK_MM_DSI3_DIGITAL, "mm_dsi3_digital", "dsi1_lntc", 6),
}; };
static int clk_mt2712_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r != 0)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);
return r; static const struct platform_device_id clk_mt2712_mm_id_table[] = {
} { .name = "clk-mt2712-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt2712_mm_drv = { static struct platform_driver clk_mt2712_mm_drv = {
.probe = clk_mt2712_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt2712-mm", .name = "clk-mt2712-mm",
}, },
.id_table = clk_mt2712_mm_id_table,
}; };
builtin_platform_driver(clk_mt2712_mm_drv); builtin_platform_driver(clk_mt2712_mm_drv);
...@@ -85,25 +85,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -85,25 +85,23 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16), GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16),
}; };
static int clk_mt6779_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); static const struct platform_device_id clk_mt6779_mm_id_table[] = {
} { .name = "clk-mt6779-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt6779_mm_drv = { static struct platform_driver clk_mt6779_mm_drv = {
.probe = clk_mt6779_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt6779-mm", .name = "clk-mt6779-mm",
}, },
.id_table = clk_mt6779_mm_id_table,
}; };
module_platform_driver(clk_mt6779_mm_drv); module_platform_driver(clk_mt6779_mm_drv);
......
...@@ -76,56 +76,23 @@ static const struct mtk_gate mm_gates[] = { ...@@ -76,56 +76,23 @@ static const struct mtk_gate mm_gates[] = {
GATE_MM1(CLK_MM_DPI_ENGINE, "mm_dpi_engine", "mm_sel", 9), GATE_MM1(CLK_MM_DPI_ENGINE, "mm_dpi_engine", "mm_sel", 9),
}; };
static int clk_mt6795_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_gates,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_gates),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int ret;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
if (!clk_data)
return -ENOMEM;
ret = mtk_clk_register_gates(&pdev->dev, node, mm_gates,
ARRAY_SIZE(mm_gates), clk_data);
if (ret)
goto free_clk_data;
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (ret)
goto unregister_gates;
platform_set_drvdata(pdev, clk_data);
return 0;
unregister_gates:
mtk_clk_unregister_gates(mm_gates, ARRAY_SIZE(mm_gates), clk_data);
free_clk_data:
mtk_free_clk_data(clk_data);
return ret;
}
static int clk_mt6795_mm_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(mm_gates, ARRAY_SIZE(mm_gates), clk_data);
mtk_free_clk_data(clk_data);
return 0; static const struct platform_device_id clk_mt6795_mm_id_table[] = {
} { .name = "clk-mt6795-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt6795_mm_drv = { static struct platform_driver clk_mt6795_mm_drv = {
.driver = { .driver = {
.name = "clk-mt6795-mm", .name = "clk-mt6795-mm",
}, },
.probe = clk_mt6795_mm_probe, .id_table = clk_mt6795_mm_id_table,
.remove = clk_mt6795_mm_remove, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
}; };
module_platform_driver(clk_mt6795_mm_drv); module_platform_driver(clk_mt6795_mm_drv);
......
...@@ -92,32 +92,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -92,32 +92,23 @@ static const struct mtk_gate mm_clks[] = {
"clk26m", 3), "clk26m", 3),
}; };
static int clk_mt6797_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_MM_NR);
mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r)
dev_err(&pdev->dev,
"could not register clock provider: %s: %d\n",
pdev->name, r);
return r; static const struct platform_device_id clk_mt6797_mm_id_table[] = {
} { .name = "clk-mt6797-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt6797_mm_drv = { static struct platform_driver clk_mt6797_mm_drv = {
.probe = clk_mt6797_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt6797-mm", .name = "clk-mt6797-mm",
}, },
.id_table = clk_mt6797_mm_id_table,
}; };
builtin_platform_driver(clk_mt6797_mm_drv); builtin_platform_driver(clk_mt6797_mm_drv);
...@@ -86,47 +86,22 @@ static const struct mtk_gate mm_clks[] = { ...@@ -86,47 +86,22 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM1(CLK_MM_HDMI_PLL, "mm_hdmi_pll", "hdmtx_dig_cts", 21), GATE_MM1(CLK_MM_HDMI_PLL, "mm_hdmi_pll", "hdmtx_dig_cts", 21),
}; };
struct clk_mt8167_mm_driver_data { static const struct mtk_clk_desc mm_desc = {
const struct mtk_gate *gates_clk; .clks = mm_clks,
int gates_num; .num_clks = ARRAY_SIZE(mm_clks),
}; };
static const struct clk_mt8167_mm_driver_data mt8167_mmsys_driver_data = { static const struct platform_device_id clk_mt8167_mm_id_table[] = {
.gates_clk = mm_clks, { .name = "clk-mt8167-mm", .driver_data = (kernel_ulong_t)&mm_desc },
.gates_num = ARRAY_SIZE(mm_clks), { /* sentinel */ }
}; };
static int clk_mt8167_mm_probe(struct platform_device *pdev) static struct platform_driver clk_mt8167_mm_drv = {
{ .probe = mtk_clk_pdev_probe,
struct device *dev = &pdev->dev; .remove = mtk_clk_pdev_remove,
struct device_node *node = dev->parent->of_node;
const struct clk_mt8167_mm_driver_data *data;
struct clk_hw_onecell_data *clk_data;
int ret;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
if (!clk_data)
return -ENOMEM;
data = &mt8167_mmsys_driver_data;
ret = mtk_clk_register_gates(&pdev->dev, node, data->gates_clk,
data->gates_num, clk_data);
if (ret)
return ret;
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (ret)
return ret;
return 0;
}
static struct platform_driver clk_mt8173_mm_drv = {
.driver = { .driver = {
.name = "clk-mt8167-mm", .name = "clk-mt8167-mm",
}, },
.probe = clk_mt8167_mm_probe, .id_table = clk_mt8167_mm_id_table,
}; };
builtin_platform_driver(clk_mt8167_mm_drv);
builtin_platform_driver(clk_mt8173_mm_drv);
...@@ -44,6 +44,7 @@ static const struct mtk_gate_regs mm1_cg_regs = { ...@@ -44,6 +44,7 @@ static const struct mtk_gate_regs mm1_cg_regs = {
} }
static const struct mtk_gate mt8173_mm_clks[] = { static const struct mtk_gate mt8173_mm_clks[] = {
GATE_DUMMY(CLK_DUMMY, "mm_dummy"),
/* MM0 */ /* MM0 */
GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0), GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0),
GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1), GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1),
...@@ -100,62 +101,23 @@ static const struct mtk_gate mt8173_mm_clks[] = { ...@@ -100,62 +101,23 @@ static const struct mtk_gate mt8173_mm_clks[] = {
GATE_MM1(CLK_MM_HDMI_HDCP24M, "mm_hdmi_hdcp24m", "hdcp_24m_sel", 20), GATE_MM1(CLK_MM_HDMI_HDCP24M, "mm_hdmi_hdcp24m", "hdcp_24m_sel", 20),
}; };
struct clk_mt8173_mm_driver_data { static const struct mtk_clk_desc mm_desc = {
const struct mtk_gate *gates_clk; .clks = mt8173_mm_clks,
int gates_num; .num_clks = ARRAY_SIZE(mt8173_mm_clks),
}; };
static const struct clk_mt8173_mm_driver_data mt8173_mmsys_driver_data = { static const struct platform_device_id clk_mt8173_mm_id_table[] = {
.gates_clk = mt8173_mm_clks, { .name = "clk-mt8173-mm", .driver_data = (kernel_ulong_t)&mm_desc },
.gates_num = ARRAY_SIZE(mt8173_mm_clks), { /* sentinel */ }
}; };
static int clk_mt8173_mm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->parent->of_node;
const struct clk_mt8173_mm_driver_data *data;
struct clk_hw_onecell_data *clk_data;
int ret;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
if (!clk_data)
return -ENOMEM;
data = &mt8173_mmsys_driver_data;
ret = mtk_clk_register_gates(&pdev->dev, node, data->gates_clk,
data->gates_num, clk_data);
if (ret)
return ret;
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (ret)
return ret;
return 0;
}
static int clk_mt8173_mm_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);
const struct clk_mt8173_mm_driver_data *data = &mt8173_mmsys_driver_data;
of_clk_del_provider(node);
mtk_clk_unregister_gates(data->gates_clk, data->gates_num, clk_data);
mtk_free_clk_data(clk_data);
return 0;
}
static struct platform_driver clk_mt8173_mm_drv = { static struct platform_driver clk_mt8173_mm_drv = {
.driver = { .driver = {
.name = "clk-mt8173-mm", .name = "clk-mt8173-mm",
}, },
.probe = clk_mt8173_mm_probe, .id_table = clk_mt8173_mm_id_table,
.remove = clk_mt8173_mm_remove, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
}; };
builtin_platform_driver(clk_mt8173_mm_drv); builtin_platform_driver(clk_mt8173_mm_drv);
......
...@@ -82,25 +82,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -82,25 +82,23 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM1(CLK_MM_DBI_IF, "mm_dbi_if", "dpi0_sel", 13), GATE_MM1(CLK_MM_DBI_IF, "mm_dbi_if", "dpi0_sel", 13),
}; };
static int clk_mt8183_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); static const struct platform_device_id clk_mt8183_mm_id_table[] = {
} { .name = "clk-mt8183-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8183_mm_drv = { static struct platform_driver clk_mt8183_mm_drv = {
.probe = clk_mt8183_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8183-mm", .name = "clk-mt8183-mm",
}, },
.id_table = clk_mt8183_mm_id_table,
}; };
builtin_platform_driver(clk_mt8183_mm_drv); builtin_platform_driver(clk_mt8183_mm_drv);
...@@ -58,55 +58,21 @@ static const struct mtk_gate mm_clks[] = { ...@@ -58,55 +58,21 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM1(CLK_MM_DISP_26M, "mm_disp_26m_ck", "top_disp", 10), GATE_MM1(CLK_MM_DISP_26M, "mm_disp_26m_ck", "top_disp", 10),
}; };
static int clk_mt8186_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
if (!clk_data)
return -ENOMEM;
r = mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
if (r)
goto free_mm_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(mm_clks, ARRAY_SIZE(mm_clks), clk_data);
free_mm_data:
mtk_free_clk_data(clk_data);
return r;
}
static int clk_mt8186_mm_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(mm_clks, ARRAY_SIZE(mm_clks), clk_data);
mtk_free_clk_data(clk_data);
return 0;
}
static const struct platform_device_id clk_mt8186_mm_id_table[] = {
{ .name = "clk-mt8186-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8186_mm_drv = { static struct platform_driver clk_mt8186_mm_drv = {
.probe = clk_mt8186_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = clk_mt8186_mm_remove, .remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8186-mm", .name = "clk-mt8186-mm",
}, },
.id_table = clk_mt8186_mm_id_table,
}; };
builtin_platform_driver(clk_mt8186_mm_drv); builtin_platform_driver(clk_mt8186_mm_drv);
...@@ -80,30 +80,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -80,30 +80,23 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM2(CLK_MM_32KHZ, "mm_32khz", "clk32k", 25), GATE_MM2(CLK_MM_32KHZ, "mm_32khz", "clk32k", 25),
}; };
static int clk_mt8192_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
if (!clk_data)
return -ENOMEM;
r = mtk_clk_register_gates(&pdev->dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
if (r)
return r;
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); static const struct platform_device_id clk_mt8192_mm_id_table[] = {
} { .name = "clk-mt8192-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8192_mm_drv = { static struct platform_driver clk_mt8192_mm_drv = {
.probe = clk_mt8192_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8192-mm", .name = "clk-mt8192-mm",
}, },
.id_table = clk_mt8192_mm_id_table,
}; };
builtin_platform_driver(clk_mt8192_mm_drv); builtin_platform_driver(clk_mt8192_mm_drv);
...@@ -93,55 +93,22 @@ static const struct mtk_gate vdo0_clks[] = { ...@@ -93,55 +93,22 @@ static const struct mtk_gate vdo0_clks[] = {
"top_edp", 16, CLK_SET_RATE_PARENT), "top_edp", 16, CLK_SET_RATE_PARENT),
}; };
static int clk_mt8195_vdo0_probe(struct platform_device *pdev) static const struct mtk_clk_desc vdo0_desc = {
{ .clks = vdo0_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(vdo0_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
if (!clk_data)
return -ENOMEM;
r = mtk_clk_register_gates(&pdev->dev, node, vdo0_clks,
ARRAY_SIZE(vdo0_clks), clk_data);
if (r)
goto free_vdo0_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(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);
free_vdo0_data:
mtk_free_clk_data(clk_data);
return r;
}
static int clk_mt8195_vdo0_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(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);
mtk_free_clk_data(clk_data);
return 0; static const struct platform_device_id clk_mt8195_vdo0_id_table[] = {
} { .name = "clk-mt8195-vdo0", .driver_data = (kernel_ulong_t)&vdo0_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8195_vdo0_drv = { static struct platform_driver clk_mt8195_vdo0_drv = {
.probe = clk_mt8195_vdo0_probe, .probe = mtk_clk_pdev_probe,
.remove = clk_mt8195_vdo0_remove, .remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8195-vdo0", .name = "clk-mt8195-vdo0",
}, },
.id_table = clk_mt8195_vdo0_id_table,
}; };
builtin_platform_driver(clk_mt8195_vdo0_drv); builtin_platform_driver(clk_mt8195_vdo0_drv);
...@@ -120,55 +120,22 @@ static const struct mtk_gate vdo1_clks[] = { ...@@ -120,55 +120,22 @@ static const struct mtk_gate vdo1_clks[] = {
GATE_VDO1_4(CLK_VDO1_DPI1_HDMI, "vdo1_dpi1_hdmi", "hdmi_txpll", 0), GATE_VDO1_4(CLK_VDO1_DPI1_HDMI, "vdo1_dpi1_hdmi", "hdmi_txpll", 0),
}; };
static int clk_mt8195_vdo1_probe(struct platform_device *pdev) static const struct mtk_clk_desc vdo1_desc = {
{ .clks = vdo1_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(vdo1_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r; static const struct platform_device_id clk_mt8195_vdo1_id_table[] = {
{ .name = "clk-mt8195-vdo1", .driver_data = (kernel_ulong_t)&vdo1_desc },
clk_data = mtk_alloc_clk_data(CLK_VDO1_NR_CLK); { /* sentinel */ }
if (!clk_data) };
return -ENOMEM;
r = mtk_clk_register_gates(&pdev->dev, node, vdo1_clks,
ARRAY_SIZE(vdo1_clks), clk_data);
if (r)
goto free_vdo1_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(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
free_vdo1_data:
mtk_free_clk_data(clk_data);
return r;
}
static int clk_mt8195_vdo1_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(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
mtk_free_clk_data(clk_data);
return 0;
}
static struct platform_driver clk_mt8195_vdo1_drv = { static struct platform_driver clk_mt8195_vdo1_drv = {
.probe = clk_mt8195_vdo1_probe, .probe = mtk_clk_pdev_probe,
.remove = clk_mt8195_vdo1_remove, .remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8195-vdo1", .name = "clk-mt8195-vdo1",
}, },
.id_table = clk_mt8195_vdo1_id_table,
}; };
builtin_platform_driver(clk_mt8195_vdo1_drv); builtin_platform_driver(clk_mt8195_vdo1_drv);
...@@ -86,54 +86,22 @@ static const struct mtk_gate vpp0_clks[] = { ...@@ -86,54 +86,22 @@ 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), GATE_VPP0_2(CLK_VPP0_WARP1_MDP_DL_ASYNC, "vpp0_warp1_mdp_dl_async", "top_wpe_vpp", 3),
}; };
static int clk_mt8195_vpp0_probe(struct platform_device *pdev) static const struct mtk_clk_desc vpp0_desc = {
{ .clks = vpp0_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(vpp0_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
if (!clk_data)
return -ENOMEM;
r = mtk_clk_register_gates(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 const struct platform_device_id clk_mt8195_vpp0_id_table[] = {
} { .name = "clk-mt8195-vpp0", .driver_data = (kernel_ulong_t)&vpp0_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8195_vpp0_drv = { static struct platform_driver clk_mt8195_vpp0_drv = {
.probe = clk_mt8195_vpp0_probe, .probe = mtk_clk_pdev_probe,
.remove = clk_mt8195_vpp0_remove, .remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8195-vpp0", .name = "clk-mt8195-vpp0",
}, },
.id_table = clk_mt8195_vpp0_id_table,
}; };
builtin_platform_driver(clk_mt8195_vpp0_drv); builtin_platform_driver(clk_mt8195_vpp0_drv);
...@@ -84,54 +84,22 @@ static const struct mtk_gate vpp1_clks[] = { ...@@ -84,54 +84,22 @@ static const struct mtk_gate vpp1_clks[] = {
GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26), GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26),
}; };
static int clk_mt8195_vpp1_probe(struct platform_device *pdev) static const struct mtk_clk_desc vpp1_desc = {
{ .clks = vpp1_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(vpp1_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int r;
clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK);
if (!clk_data)
return -ENOMEM;
r = mtk_clk_register_gates(dev, node, vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
if (r)
goto free_vpp1_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(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
free_vpp1_data:
mtk_free_clk_data(clk_data);
return r;
}
static int clk_mt8195_vpp1_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(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
mtk_free_clk_data(clk_data);
return 0; static const struct platform_device_id clk_mt8195_vpp1_id_table[] = {
} { .name = "clk-mt8195-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8195_vpp1_drv = { static struct platform_driver clk_mt8195_vpp1_drv = {
.probe = clk_mt8195_vpp1_probe, .probe = mtk_clk_pdev_probe,
.remove = clk_mt8195_vpp1_remove, .remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8195-vpp1", .name = "clk-mt8195-vpp1",
}, },
.id_table = clk_mt8195_vpp1_id_table,
}; };
builtin_platform_driver(clk_mt8195_vpp1_drv); builtin_platform_driver(clk_mt8195_vpp1_drv);
...@@ -72,40 +72,23 @@ static const struct mtk_gate mm_clks[] = { ...@@ -72,40 +72,23 @@ static const struct mtk_gate mm_clks[] = {
GATE_MM1(CLK_MM_LVDSTX_CTS, "mm_flvdstx_cts", "lvdstx_dig_cts", 3), GATE_MM1(CLK_MM_LVDSTX_CTS, "mm_flvdstx_cts", "lvdstx_dig_cts", 3),
}; };
static int clk_mt8365_mm_probe(struct platform_device *pdev) static const struct mtk_clk_desc mm_desc = {
{ .clks = mm_clks,
struct device *dev = &pdev->dev; .num_clks = ARRAY_SIZE(mm_clks),
struct device_node *node = dev->parent->of_node; };
struct clk_hw_onecell_data *clk_data;
int ret;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
ret = mtk_clk_register_gates(dev, node, mm_clks,
ARRAY_SIZE(mm_clks), clk_data);
if (ret)
goto err_free_clk_data;
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (ret)
goto err_unregister_gates;
return 0;
err_unregister_gates:
mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data);
err_free_clk_data:
mtk_free_clk_data(clk_data);
return ret; static const struct platform_device_id clk_mt8365_mm_id_table[] = {
} { .name = "clk-mt8365-mm", .driver_data = (kernel_ulong_t)&mm_desc },
{ /* sentinel */ }
};
static struct platform_driver clk_mt8365_mm_drv = { static struct platform_driver clk_mt8365_mm_drv = {
.probe = clk_mt8365_mm_probe, .probe = mtk_clk_pdev_probe,
.remove = mtk_clk_pdev_remove,
.driver = { .driver = {
.name = "clk-mt8365-mm", .name = "clk-mt8365-mm",
}, },
.id_table = clk_mt8365_mm_id_table,
}; };
builtin_platform_driver(clk_mt8365_mm_drv); builtin_platform_driver(clk_mt8365_mm_drv);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment