Commit f3e4e735 authored by Miles Chen's avatar Miles Chen Committed by Chen-Yu Tsai

clk: mediatek: mt2712: 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-3-miles.chen@mediatek.comSigned-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
parent 973d1607
...@@ -58,33 +58,23 @@ static const struct mtk_gate bdp_clks[] = { ...@@ -58,33 +58,23 @@ static const struct mtk_gate bdp_clks[] = {
GATE_BDP(CLK_BDP_TVD_CBUS, "bdp_tvd_cbus", "mm_sel", 30), GATE_BDP(CLK_BDP_TVD_CBUS, "bdp_tvd_cbus", "mm_sel", 30),
}; };
static int clk_mt2712_bdp_probe(struct platform_device *pdev) static const struct mtk_clk_desc bdp_desc = {
{ .clks = bdp_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(bdp_clks),
int r; };
struct device_node *node = pdev->dev.of_node;
clk_data = mtk_alloc_clk_data(CLK_BDP_NR_CLK);
mtk_clk_register_gates(node, bdp_clks, ARRAY_SIZE(bdp_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 of_device_id of_match_clk_mt2712_bdp[] = { static const struct of_device_id of_match_clk_mt2712_bdp[] = {
{ .compatible = "mediatek,mt2712-bdpsys", }, {
{} .compatible = "mediatek,mt2712-bdpsys",
.data = &bdp_desc,
}, {
/* sentinel */
}
}; };
static struct platform_driver clk_mt2712_bdp_drv = { static struct platform_driver clk_mt2712_bdp_drv = {
.probe = clk_mt2712_bdp_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt2712-bdp", .name = "clk-mt2712-bdp",
.of_match_table = of_match_clk_mt2712_bdp, .of_match_table = of_match_clk_mt2712_bdp,
......
...@@ -36,33 +36,23 @@ static const struct mtk_gate img_clks[] = { ...@@ -36,33 +36,23 @@ static const struct mtk_gate img_clks[] = {
GATE_IMG(CLK_IMG_CAM_SV2_EN, "img_cam_sv2_en", "mm_sel", 11), GATE_IMG(CLK_IMG_CAM_SV2_EN, "img_cam_sv2_en", "mm_sel", 11),
}; };
static int clk_mt2712_img_probe(struct platform_device *pdev) static const struct mtk_clk_desc img_desc = {
{ .clks = img_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(img_clks),
int r; };
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);
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 of_device_id of_match_clk_mt2712_img[] = { static const struct of_device_id of_match_clk_mt2712_img[] = {
{ .compatible = "mediatek,mt2712-imgsys", }, {
{} .compatible = "mediatek,mt2712-imgsys",
.data = &img_desc,
}, {
/* sentinel */
}
}; };
static struct platform_driver clk_mt2712_img_drv = { static struct platform_driver clk_mt2712_img_drv = {
.probe = clk_mt2712_img_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt2712-img", .name = "clk-mt2712-img",
.of_match_table = of_match_clk_mt2712_img, .of_match_table = of_match_clk_mt2712_img,
......
...@@ -32,33 +32,23 @@ static const struct mtk_gate jpgdec_clks[] = { ...@@ -32,33 +32,23 @@ static const struct mtk_gate jpgdec_clks[] = {
GATE_JPGDEC(CLK_JPGDEC_JPGDEC, "jpgdec_jpgdec", "jpgdec_sel", 4), GATE_JPGDEC(CLK_JPGDEC_JPGDEC, "jpgdec_jpgdec", "jpgdec_sel", 4),
}; };
static int clk_mt2712_jpgdec_probe(struct platform_device *pdev) static const struct mtk_clk_desc jpgdec_desc = {
{ .clks = jpgdec_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(jpgdec_clks),
int r; };
struct device_node *node = pdev->dev.of_node;
clk_data = mtk_alloc_clk_data(CLK_JPGDEC_NR_CLK);
mtk_clk_register_gates(node, jpgdec_clks, ARRAY_SIZE(jpgdec_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 of_device_id of_match_clk_mt2712_jpgdec[] = { static const struct of_device_id of_match_clk_mt2712_jpgdec[] = {
{ .compatible = "mediatek,mt2712-jpgdecsys", }, {
{} .compatible = "mediatek,mt2712-jpgdecsys",
.data = &jpgdec_desc,
}, {
/* sentinel */
}
}; };
static struct platform_driver clk_mt2712_jpgdec_drv = { static struct platform_driver clk_mt2712_jpgdec_drv = {
.probe = clk_mt2712_jpgdec_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt2712-jpgdec", .name = "clk-mt2712-jpgdec",
.of_match_table = of_match_clk_mt2712_jpgdec, .of_match_table = of_match_clk_mt2712_jpgdec,
......
...@@ -31,33 +31,23 @@ static const struct mtk_gate mfg_clks[] = { ...@@ -31,33 +31,23 @@ static const struct mtk_gate mfg_clks[] = {
GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0), GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0),
}; };
static int clk_mt2712_mfg_probe(struct platform_device *pdev) static const struct mtk_clk_desc mfg_desc = {
{ .clks = mfg_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(mfg_clks),
int r; };
struct device_node *node = pdev->dev.of_node;
clk_data = mtk_alloc_clk_data(CLK_MFG_NR_CLK);
mtk_clk_register_gates(node, mfg_clks, ARRAY_SIZE(mfg_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 of_device_id of_match_clk_mt2712_mfg[] = { static const struct of_device_id of_match_clk_mt2712_mfg[] = {
{ .compatible = "mediatek,mt2712-mfgcfg", }, {
{} .compatible = "mediatek,mt2712-mfgcfg",
.data = &mfg_desc,
}, {
/* sentinel */
}
}; };
static struct platform_driver clk_mt2712_mfg_drv = { static struct platform_driver clk_mt2712_mfg_drv = {
.probe = clk_mt2712_mfg_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt2712-mfg", .name = "clk-mt2712-mfg",
.of_match_table = of_match_clk_mt2712_mfg, .of_match_table = of_match_clk_mt2712_mfg,
......
...@@ -50,33 +50,23 @@ static const struct mtk_gate vdec_clks[] = { ...@@ -50,33 +50,23 @@ static const struct mtk_gate vdec_clks[] = {
GATE_VDEC1(CLK_VDEC_IMGRZ_CKEN, "vdec_imgrz_cken", "vdec_sel", 1), GATE_VDEC1(CLK_VDEC_IMGRZ_CKEN, "vdec_imgrz_cken", "vdec_sel", 1),
}; };
static int clk_mt2712_vdec_probe(struct platform_device *pdev) static const struct mtk_clk_desc vdec_desc = {
{ .clks = vdec_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(vdec_clks),
int r; };
struct device_node *node = pdev->dev.of_node;
clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_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 of_device_id of_match_clk_mt2712_vdec[] = { static const struct of_device_id of_match_clk_mt2712_vdec[] = {
{ .compatible = "mediatek,mt2712-vdecsys", }, {
{} .compatible = "mediatek,mt2712-vdecsys",
.data = &vdec_desc,
}, {
/* sentinel */
}
}; };
static struct platform_driver clk_mt2712_vdec_drv = { static struct platform_driver clk_mt2712_vdec_drv = {
.probe = clk_mt2712_vdec_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt2712-vdec", .name = "clk-mt2712-vdec",
.of_match_table = of_match_clk_mt2712_vdec, .of_match_table = of_match_clk_mt2712_vdec,
......
...@@ -33,33 +33,23 @@ static const struct mtk_gate venc_clks[] = { ...@@ -33,33 +33,23 @@ static const struct mtk_gate venc_clks[] = {
GATE_VENC(CLK_VENC_SMI_LARB6, "venc_smi_larb6", "jpgdec_sel", 12), GATE_VENC(CLK_VENC_SMI_LARB6, "venc_smi_larb6", "jpgdec_sel", 12),
}; };
static int clk_mt2712_venc_probe(struct platform_device *pdev) static const struct mtk_clk_desc venc_desc = {
{ .clks = venc_clks,
struct clk_hw_onecell_data *clk_data; .num_clks = ARRAY_SIZE(venc_clks),
int r; };
struct device_node *node = pdev->dev.of_node;
clk_data = mtk_alloc_clk_data(CLK_VENC_NR_CLK);
mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_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 of_device_id of_match_clk_mt2712_venc[] = { static const struct of_device_id of_match_clk_mt2712_venc[] = {
{ .compatible = "mediatek,mt2712-vencsys", }, {
{} .compatible = "mediatek,mt2712-vencsys",
.data = &venc_desc,
}, {
/* sentinel */
}
}; };
static struct platform_driver clk_mt2712_venc_drv = { static struct platform_driver clk_mt2712_venc_drv = {
.probe = clk_mt2712_venc_probe, .probe = mtk_clk_simple_probe,
.remove = mtk_clk_simple_remove,
.driver = { .driver = {
.name = "clk-mt2712-venc", .name = "clk-mt2712-venc",
.of_match_table = of_match_clk_mt2712_venc, .of_match_table = of_match_clk_mt2712_venc,
......
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