clk: mediatek: use mtk_clk_simple_probe to simplify
Subsystems (2)
PATCH v3 1/7 clk: mediatek: mt2701: use mtk_clk_simple_probe to simplify driver
In reply to Miles Chenmtk_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.
--- drivers/clk/mediatek/clk-mt2701-bdp.c | 36 ++++++++++---------------- drivers/clk/mediatek/clk-mt2701-img.c | 36 ++++++++++---------------- drivers/clk/mediatek/clk-mt2701-vdec.c | 36 ++++++++++---------------- 3 files changed, 39 insertions(+), 69 deletions(-)
drivers/clk/mediatek/clk-mt2701-bdp.c +13 -23
@@ -94,33 +94,23 @@ static const struct mtk_gate bdp_clks[] = { GATE_BDP1(CLK_BDP_HDMI_MON, "hdmi_mon", "hdmi_0_pll340m", 16), }; -static const struct of_device_id of_match_clk_mt2701_bdp[] = { - { .compatible ="mediatek,mt2701-bdpsys" , }, - {} +static const struct mtk_clk_desc bdp_desc = { + .clks = bdp_clks, + .num_clks =ARRAY_SIZE (bdp_clks), }; -static int clk_mt2701_bdp_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_BDP_NR ); - -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) -dev_err (&pdev->dev, -"could not register clock provider: %s: %d\n" , - pdev->name, r); - -return r; -} +static const struct of_device_id of_match_clk_mt2701_bdp[] = { + { + .compatible ="mediatek,mt2701-bdpsys" , + .data = &bdp_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt2701_bdp_drv = { - .probe = clk_mt2701_bdp_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2701-bdp" , .of_match_table = of_match_clk_mt2701_bdp,
drivers/clk/mediatek/clk-mt2701-img.c +13 -23
@@ -36,33 +36,23 @@ static const struct mtk_gate img_clks[] = { GATE_IMG(CLK_IMG_VENC, "img_venc", "mm_sel", 9), }; -static const struct of_device_id of_match_clk_mt2701_img[] = { - { .compatible ="mediatek,mt2701-imgsys" , }, - {} +static const struct mtk_clk_desc img_desc = { + .clks = img_clks, + .num_clks =ARRAY_SIZE (img_clks), }; -static int clk_mt2701_img_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_IMG_NR ); - -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) -dev_err (&pdev->dev, -"could not register clock provider: %s: %d\n" , - pdev->name, r); - -return r; -} +static const struct of_device_id of_match_clk_mt2701_img[] = { + { + .compatible ="mediatek,mt2701-imgsys" , + .data = &img_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt2701_img_drv = { - .probe = clk_mt2701_img_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2701-img" , .of_match_table = of_match_clk_mt2701_img,
drivers/clk/mediatek/clk-mt2701-vdec.c +13 -23
@@ -47,33 +47,23 @@ static const struct mtk_gate vdec_clks[] = { GATE_VDEC1(CLK_VDEC_LARB, "vdec_larb_cken", "mm_sel", 0), }; -static const struct of_device_id of_match_clk_mt2701_vdec[] = { - { .compatible ="mediatek,mt2701-vdecsys" , }, - {} +static const struct mtk_clk_desc vdec_desc = { + .clks = vdec_clks, + .num_clks =ARRAY_SIZE (vdec_clks), }; -static int clk_mt2701_vdec_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_VDEC_NR ); - -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) -dev_err (&pdev->dev, -"could not register clock provider: %s: %d\n" , - pdev->name, r); - -return r; -} +static const struct of_device_id of_match_clk_mt2701_vdec[] = { + { + .compatible ="mediatek,mt2701-vdecsys" , + .data = &vdec_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt2701_vdec_drv = { - .probe = clk_mt2701_vdec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2701-vdec" , .of_match_table = of_match_clk_mt2701_vdec,
Signature · 1 line
2.18.0
PATCH v3 2/7 clk: mediatek: mt2712: use mtk_clk_simple_probe to simplify driver
In reply to Miles Chenmtk_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.
--- drivers/clk/mediatek/clk-mt2712-bdp.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt2712-img.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt2712-jpgdec.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt2712-mfg.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt2712-vdec.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt2712-venc.c | 34 +++++++++--------------- 6 files changed, 72 insertions(+), 132 deletions(-)
drivers/clk/mediatek/clk-mt2712-bdp.c +12 -22
@@ -58,33 +58,23 @@ static const struct mtk_gate bdp_clks[] = { GATE_BDP(CLK_BDP_TVD_CBUS, "bdp_tvd_cbus", "mm_sel", 30), }; -static int clk_mt2712_bdp_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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 mtk_clk_desc bdp_desc = { + .clks = bdp_clks, + .num_clks =ARRAY_SIZE (bdp_clks), +};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 = { - .probe = clk_mt2712_bdp_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2712-bdp" , .of_match_table = of_match_clk_mt2712_bdp,
drivers/clk/mediatek/clk-mt2712-img.c +12 -22
@@ -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), }; -static int clk_mt2712_img_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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 mtk_clk_desc img_desc = { + .clks = img_clks, + .num_clks =ARRAY_SIZE (img_clks), +};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 = { - .probe = clk_mt2712_img_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2712-img" , .of_match_table = of_match_clk_mt2712_img,
drivers/clk/mediatek/clk-mt2712-jpgdec.c +12 -22
@@ -32,33 +32,23 @@ static const struct mtk_gate jpgdec_clks[] = { GATE_JPGDEC(CLK_JPGDEC_JPGDEC, "jpgdec_jpgdec", "jpgdec_sel", 4), }; -static int clk_mt2712_jpgdec_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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 mtk_clk_desc jpgdec_desc = { + .clks = jpgdec_clks, + .num_clks =ARRAY_SIZE (jpgdec_clks), +};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 = { - .probe = clk_mt2712_jpgdec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2712-jpgdec" , .of_match_table = of_match_clk_mt2712_jpgdec,
drivers/clk/mediatek/clk-mt2712-mfg.c +12 -22
@@ -31,33 +31,23 @@ static const struct mtk_gate mfg_clks[] = { GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0), }; -static int clk_mt2712_mfg_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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 mtk_clk_desc mfg_desc = { + .clks = mfg_clks, + .num_clks =ARRAY_SIZE (mfg_clks), +};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 = { - .probe = clk_mt2712_mfg_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2712-mfg" , .of_match_table = of_match_clk_mt2712_mfg,
drivers/clk/mediatek/clk-mt2712-vdec.c +12 -22
@@ -50,33 +50,23 @@ static const struct mtk_gate vdec_clks[] = { GATE_VDEC1(CLK_VDEC_IMGRZ_CKEN, "vdec_imgrz_cken", "vdec_sel", 1), }; -static int clk_mt2712_vdec_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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 mtk_clk_desc vdec_desc = { + .clks = vdec_clks, + .num_clks =ARRAY_SIZE (vdec_clks), +};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 = { - .probe = clk_mt2712_vdec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2712-vdec" , .of_match_table = of_match_clk_mt2712_vdec,
drivers/clk/mediatek/clk-mt2712-venc.c +12 -22
@@ -33,33 +33,23 @@ static const struct mtk_gate venc_clks[] = { GATE_VENC(CLK_VENC_SMI_LARB6, "venc_smi_larb6", "jpgdec_sel", 12), }; -static int clk_mt2712_venc_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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 mtk_clk_desc venc_desc = { + .clks = venc_clks, + .num_clks =ARRAY_SIZE (venc_clks), +};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 = { - .probe = clk_mt2712_venc_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt2712-venc" , .of_match_table = of_match_clk_mt2712_venc,
Signature · 1 line
2.18.0
v3 cover clk: mediatek: use mtk_clk_simple_probe to simplify
Hi everyone,
This is v3 patches to use mtk_clk_simple_probe to simplify driver. It is almost a RESEND patch, the only difference is adding reviewed-by tags and a tested-by tag to the commit messages.
I tested the series on MT8192 and MT6779.
This patch is based on next-20220921 and [1].
Change since v1:
- Angelo's patch [1] already exported mtk_clk_simple_probe and mtk_clk_simple_remove, so drop this part from my v1 and depends on [1].
- add a reviewed-by tag
Change since v2:
- add reviewed-by tags and a tested-by tag
mtk_clk_simple_probe() was introduced by Chun-Jie in commitc58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers") and mtk_clk_simple_remove() was added in commit
commit 2204d96b1919 ("clk: mediatek: Add mtk_clk_simple_remove()")
With mtk_clk_simple_probe and mtk_clk_simple_remove,
we can get rid of defining the same probe function in clk drivers. mtk_clk_simple_probe and mtk_clk_simple_remove are used in new platforms now, let's apply them to old SoCs.
The process is quite straightforward:
a. Look up probe functions which can be replaced by mtk_clk_simple_probe() b. Add mtk_clk_desc and add .data
c. Replace the probe function with mtk_clk_simple_probe and mtk_clk_simple_remove
Thanks,
Miles
[1] https://lore.kernel.org/lkml/[email protected]/
Miles Chen (7):
clk: mediatek: mt2701: use mtk_clk_simple_probe to simplify driver
clk: mediatek: mt2712: use mtk_clk_simple_probe to simplify driver
clk: mediatek: mt6765: use mtk_clk_simple_probe to simplify driver
clk: mediatek: mt6779: use mtk_clk_simple_probe to simplify driver
clk: mediatek: mt6797: use mtk_clk_simple_probe to simplify driver
clk: mediatek: mt8183: use mtk_clk_simple_probe to simplify driver
clk: mediatek: mt8192: add mtk_clk_simple_remove
drivers/clk/mediatek/clk-mt2701-bdp.c | 36 +++++++------------ drivers/clk/mediatek/clk-mt2701-img.c | 36 +++++++------------ drivers/clk/mediatek/clk-mt2701-vdec.c | 36 +++++++------------ drivers/clk/mediatek/clk-mt2712-bdp.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt2712-img.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt2712-jpgdec.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt2712-mfg.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt2712-vdec.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt2712-venc.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt6765-audio.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt6765-cam.c | 33 +++++++---------- drivers/clk/mediatek/clk-mt6765-img.c | 33 +++++++---------- drivers/clk/mediatek/clk-mt6765-mipi0a.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt6765-mm.c | 33 +++++++---------- drivers/clk/mediatek/clk-mt6765-vcodec.c | 34 +++++++----------- drivers/clk/mediatek/clk-mt6779-aud.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt6779-cam.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt6779-img.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt6779-ipe.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt6779-mfg.c | 27 +++++++------- drivers/clk/mediatek/clk-mt6779-vdec.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt6779-venc.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt6797-img.c | 36 +++++++------------ drivers/clk/mediatek/clk-mt6797-vdec.c | 36 +++++++------------ drivers/clk/mediatek/clk-mt6797-venc.c | 36 +++++++------------ drivers/clk/mediatek/clk-mt8183-cam.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-img.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-ipu0.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-ipu1.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-ipu_adl.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-ipu_conn.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-mfgcfg.c | 29 +++++++-------- drivers/clk/mediatek/clk-mt8183-vdec.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8183-venc.c | 27 +++++++------- drivers/clk/mediatek/clk-mt8192-cam.c | 1 + drivers/clk/mediatek/clk-mt8192-img.c | 1 + .../clk/mediatek/clk-mt8192-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8192-ipe.c | 1 + drivers/clk/mediatek/clk-mt8192-mdp.c | 1 + drivers/clk/mediatek/clk-mt8192-mfg.c | 1 + drivers/clk/mediatek/clk-mt8192-msdc.c | 1 + drivers/clk/mediatek/clk-mt8192-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8192-vdec.c | 1 + drivers/clk/mediatek/clk-mt8192-venc.c | 1 + 44 files changed, 430 insertions(+), 647 deletions(-)
Signature · 1 line
2.18.0
PATCH v3 3/7 clk: mediatek: mt6765: 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.
--- drivers/clk/mediatek/clk-mt6765-audio.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt6765-cam.c | 33 +++++++++-------------- drivers/clk/mediatek/clk-mt6765-img.c | 33 +++++++++-------------- drivers/clk/mediatek/clk-mt6765-mipi0a.c | 34 +++++++++--------------- drivers/clk/mediatek/clk-mt6765-mm.c | 33 +++++++++-------------- drivers/clk/mediatek/clk-mt6765-vcodec.c | 34 +++++++++--------------- 6 files changed, 72 insertions(+), 129 deletions(-)
drivers/clk/mediatek/clk-mt6765-audio.c +12 -22
@@ -64,33 +64,23 @@ static const struct mtk_gate audio_clks[] = { "audio_ck", 7), }; -static int clk_mt6765_audio_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_AUDIO_NR_CLK ); - -mtk_clk_register_gates (node, audio_clks, -ARRAY_SIZE (audio_clks), clk_data); - - r =of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); - -if (r) -pr_err ("%s(): could not register clock provider: %d\n" , - __func__, r); - -return r; -} +static const struct mtk_clk_desc audio_desc = { + .clks = audio_clks, + .num_clks =ARRAY_SIZE (audio_clks), +};static const struct of_device_id of_match_clk_mt6765_audio[] = { - { .compatible ="mediatek,mt6765-audsys" , }, - {} + { + .compatible ="mediatek,mt6765-audsys" , + .data = &audio_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6765_audio_drv = { - .probe = clk_mt6765_audio_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6765-audio" , .of_match_table = of_match_clk_mt6765_audio,
drivers/clk/mediatek/clk-mt6765-cam.c +12 -21
@@ -39,32 +39,23 @@ static const struct mtk_gate cam_clks[] = { GATE_CAM(CLK_CAM_CCU, "cam_ccu", "mm_ck", 12), }; -static int clk_mt6765_cam_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -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); - - r =of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); - -if (r) -pr_err ("%s(): could not register clock provider: %d\n" , - __func__, r); - -return r; -} +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_mt6765_cam[] = { - { .compatible ="mediatek,mt6765-camsys" , }, - {} + { + .compatible ="mediatek,mt6765-camsys" , + .data = &cam_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6765_cam_drv = { - .probe = clk_mt6765_cam_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6765-cam" , .of_match_table = of_match_clk_mt6765_cam,
drivers/clk/mediatek/clk-mt6765-img.c +12 -21
@@ -35,32 +35,23 @@ static const struct mtk_gate img_clks[] = { GATE_IMG(CLK_IMG_RSC, "img_rsc", "mm_ck", 5), }; -static int clk_mt6765_img_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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) -pr_err ("%s(): could not register clock provider: %d\n" , - __func__, r); - -return r; -} +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_mt6765_img[] = { - { .compatible ="mediatek,mt6765-imgsys" , }, - {} + { + .compatible ="mediatek,mt6765-imgsys" , + .data = &img_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6765_img_drv = { - .probe = clk_mt6765_img_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6765-img" , .of_match_table = of_match_clk_mt6765_img,
drivers/clk/mediatek/clk-mt6765-mipi0a.c +12 -22
@@ -32,33 +32,23 @@ static const struct mtk_gate mipi0a_clks[] = { "mipi0a_csr_0a", "f_fseninf_ck", 1), }; -static int clk_mt6765_mipi0a_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_MIPI0A_NR_CLK ); - -mtk_clk_register_gates (node, mipi0a_clks, -ARRAY_SIZE (mipi0a_clks), clk_data); - - r =of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); - -if (r) -pr_err ("%s(): could not register clock provider: %d\n" , - __func__, r); - -return r; -} +static const struct mtk_clk_desc mipi0a_desc = { + .clks = mipi0a_clks, + .num_clks =ARRAY_SIZE (mipi0a_clks), +};static const struct of_device_id of_match_clk_mt6765_mipi0a[] = { - { .compatible ="mediatek,mt6765-mipi0a" , }, - {} + { + .compatible ="mediatek,mt6765-mipi0a" , + .data = &mipi0a_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6765_mipi0a_drv = { - .probe = clk_mt6765_mipi0a_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6765-mipi0a" , .of_match_table = of_match_clk_mt6765_mipi0a,
drivers/clk/mediatek/clk-mt6765-mm.c +12 -21
@@ -61,32 +61,23 @@ static const struct mtk_gate mm_clks[] = { GATE_MM(CLK_MM_F26M_HRTWT, "mm_hrtwt", "f_f26m_ck", 29), }; -static int clk_mt6765_mm_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_MM_NR_CLK ); - -mtk_clk_register_gates (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) -pr_err ("%s(): could not register clock provider: %d\n" , - __func__, r); - -return r; -} +static const struct mtk_clk_desc mm_desc = { + .clks = mm_clks, + .num_clks =ARRAY_SIZE (mm_clks), +};static const struct of_device_id of_match_clk_mt6765_mm[] = { - { .compatible ="mediatek,mt6765-mmsys" , }, - {} + { + .compatible ="mediatek,mt6765-mmsys" , + .data = &mm_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6765_mm_drv = { - .probe = clk_mt6765_mm_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6765-mm" , .of_match_table = of_match_clk_mt6765_mm,
drivers/clk/mediatek/clk-mt6765-vcodec.c +12 -22
@@ -34,33 +34,23 @@ static const struct mtk_gate venc_clks[] = { GATE_VENC(CLK_VENC_SET3_VDEC, "venc_set3_vdec", "mm_ck", 12), }; -static int clk_mt6765_vcodec_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -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) -pr_err ("%s(): could not register clock provider: %d\n" , - __func__, r); - -return r; -} +static const struct mtk_clk_desc venc_desc = { + .clks = venc_clks, + .num_clks =ARRAY_SIZE (venc_clks), +};static const struct of_device_id of_match_clk_mt6765_vcodec[] = { - { .compatible ="mediatek,mt6765-vcodecsys" , }, - {} + { + .compatible ="mediatek,mt6765-vcodecsys" , + .data = &venc_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6765_vcodec_drv = { - .probe = clk_mt6765_vcodec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6765-vcodec" , .of_match_table = of_match_clk_mt6765_vcodec,
Signature · 1 line
2.18.0
PATCH v3 5/7 clk: mediatek: mt6797: use mtk_clk_simple_probe to simplify driver
In reply to Miles Chenmtk_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.
--- drivers/clk/mediatek/clk-mt6797-img.c | 36 ++++++++++---------------- drivers/clk/mediatek/clk-mt6797-vdec.c | 36 ++++++++++---------------- drivers/clk/mediatek/clk-mt6797-venc.c | 36 ++++++++++---------------- 3 files changed, 39 insertions(+), 69 deletions(-)
drivers/clk/mediatek/clk-mt6797-img.c +13 -23
@@ -32,33 +32,23 @@ static const struct mtk_gate img_clks[] = { GATE_IMG(CLK_IMG_LARB6, "img_larb6", "mm_sel", 0), }; -static const struct of_device_id of_match_clk_mt6797_img[] = { - { .compatible ="mediatek,mt6797-imgsys" , }, - {} +static const struct mtk_clk_desc img_desc = { + .clks = img_clks, + .num_clks =ARRAY_SIZE (img_clks), }; -static int clk_mt6797_img_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_IMG_NR ); - -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) -dev_err (&pdev->dev, -"could not register clock provider: %s: %d\n" , - pdev->name, r); - -return r; -} +static const struct of_device_id of_match_clk_mt6797_img[] = { + { + .compatible ="mediatek,mt6797-imgsys" , + .data = &img_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6797_img_drv = { - .probe = clk_mt6797_img_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6797-img" , .of_match_table = of_match_clk_mt6797_img,
drivers/clk/mediatek/clk-mt6797-vdec.c +13 -23
@@ -49,33 +49,23 @@ static const struct mtk_gate vdec_clks[] = { GATE_VDEC1(CLK_VDEC_LARB1_CKEN, "vdec_larb1_cken", "mm_sel", 0), }; -static const struct of_device_id of_match_clk_mt6797_vdec[] = { - { .compatible ="mediatek,mt6797-vdecsys" , }, - {} +static const struct mtk_clk_desc vdec_desc = { + .clks = vdec_clks, + .num_clks =ARRAY_SIZE (vdec_clks), }; -static int clk_mt6797_vdec_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_VDEC_NR ); - -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) -dev_err (&pdev->dev, -"could not register clock provider: %s: %d\n" , - pdev->name, r); - -return r; -} +static const struct of_device_id of_match_clk_mt6797_vdec[] = { + { + .compatible ="mediatek,mt6797-vdecsys" , + .data = &vdec_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6797_vdec_drv = { - .probe = clk_mt6797_vdec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6797-vdec" , .of_match_table = of_match_clk_mt6797_vdec,
drivers/clk/mediatek/clk-mt6797-venc.c +13 -23
@@ -34,33 +34,23 @@ static const struct mtk_gate venc_clks[] = { GATE_VENC(CLK_VENC_3, "venc_3", "venc_sel", 12), }; -static const struct of_device_id of_match_clk_mt6797_venc[] = { - { .compatible ="mediatek,mt6797-vencsys" , }, - {} +static const struct mtk_clk_desc venc_desc = { + .clks = venc_clks, + .num_clks =ARRAY_SIZE (venc_clks), }; -static int clk_mt6797_venc_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -int r; -struct device_node *node = pdev->dev.of_node; - - clk_data =mtk_alloc_clk_data (CLK_VENC_NR ); - -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) -dev_err (&pdev->dev, -"could not register clock provider: %s: %d\n" , - pdev->name, r); - -return r; -} +static const struct of_device_id of_match_clk_mt6797_venc[] = { + { + .compatible ="mediatek,mt6797-vencsys" , + .data = &venc_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6797_venc_drv = { - .probe = clk_mt6797_venc_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6797-venc" , .of_match_table = of_match_clk_mt6797_venc,
Signature · 1 line
2.18.0
PATCH v3 6/7 clk: mediatek: mt8183: use mtk_clk_simple_probe to simplify driver
In reply to Miles Chenmtk_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.
--- drivers/clk/mediatek/clk-mt8183-cam.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-img.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-ipu0.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-ipu1.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-ipu_adl.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-ipu_conn.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-mfgcfg.c | 29 +++++++++------------- drivers/clk/mediatek/clk-mt8183-vdec.c | 27 +++++++++----------- drivers/clk/mediatek/clk-mt8183-venc.c | 27 +++++++++----------- 9 files changed, 108 insertions(+), 137 deletions(-)
drivers/clk/mediatek/clk-mt8183-cam.c +12 -15
@@ -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,
drivers/clk/mediatek/clk-mt8183-img.c +12 -15
@@ -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,
drivers/clk/mediatek/clk-mt8183-ipu0.c +12 -15
@@ -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,
drivers/clk/mediatek/clk-mt8183-ipu1.c +12 -15
@@ -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,
drivers/clk/mediatek/clk-mt8183-ipu_adl.c +12 -15
@@ -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,
drivers/clk/mediatek/clk-mt8183-ipu_conn.c +12 -15
@@ -94,26 +94,23 @@ static const struct mtk_gate ipu_conn_clks[] = { "ipu_conn_cab3to1_slice", "dsp1_sel", 17), }; -static int clk_mt8183_ipu_conn_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_CONN_NR_CLK ); - -mtk_clk_register_gates (node, ipu_conn_clks,ARRAY_SIZE (ipu_conn_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct mtk_clk_desc ipu_conn_desc = { + .clks = ipu_conn_clks, + .num_clks =ARRAY_SIZE (ipu_conn_clks), +};static const struct of_device_id of_match_clk_mt8183_ipu_conn[] = { - { .compatible ="mediatek,mt8183-ipu_conn" , }, - {} + { + .compatible ="mediatek,mt8183-ipu_conn" , + .data = &ipu_conn_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt8183_ipu_conn_drv = { - .probe = clk_mt8183_ipu_conn_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8183-ipu_conn" , .of_match_table = of_match_clk_mt8183_ipu_conn,
drivers/clk/mediatek/clk-mt8183-mfgcfg.c +12 -17
@@ -26,28 +26,23 @@ static const struct mtk_gate mfg_clks[] = {GATE_MFG (CLK_MFG_BG3D ,"mfg_bg3d" ,"mfg_sel" ,0 ) }; -static int clk_mt8183_mfg_probe (struct platform_device *pdev) -{ -struct clk_hw_onecell_data *clk_data; -struct device_node *node = pdev->dev.of_node; - -pm_runtime_enable (&pdev->dev); - - clk_data =mtk_alloc_clk_data (CLK_MFG_NR_CLK ); - -mtk_clk_register_gates_with_dev (node, mfg_clks,ARRAY_SIZE (mfg_clks), - clk_data, &pdev->dev); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct mtk_clk_desc mfg_desc = { + .clks = mfg_clks, + .num_clks =ARRAY_SIZE (mfg_clks), +};static const struct of_device_id of_match_clk_mt8183_mfg[] = { - { .compatible ="mediatek,mt8183-mfgcfg" , }, - {} + { + .compatible ="mediatek,mt8183-mfgcfg" , + .data = &mfg_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt8183_mfg_drv = { - .probe = clk_mt8183_mfg_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8183-mfg" , .of_match_table = of_match_clk_mt8183_mfg,
drivers/clk/mediatek/clk-mt8183-vdec.c +12 -15
@@ -38,26 +38,23 @@ static const struct mtk_gate vdec_clks[] = { GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1", "mm_sel", 0), }; -static int clk_mt8183_vdec_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_VDEC_NR_CLK ); - -mtk_clk_register_gates (node, vdec_clks,ARRAY_SIZE (vdec_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct mtk_clk_desc vdec_desc = { + .clks = vdec_clks, + .num_clks =ARRAY_SIZE (vdec_clks), +};static const struct of_device_id of_match_clk_mt8183_vdec[] = { - { .compatible ="mediatek,mt8183-vdecsys" , }, - {} + { + .compatible ="mediatek,mt8183-vdecsys" , + .data = &vdec_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt8183_vdec_drv = { - .probe = clk_mt8183_vdec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8183-vdec" , .of_match_table = of_match_clk_mt8183_vdec,
drivers/clk/mediatek/clk-mt8183-venc.c +12 -15
@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = { "mm_sel", 8), }; -static int clk_mt8183_venc_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_VENC_NR_CLK ); - -mtk_clk_register_gates (node, venc_clks,ARRAY_SIZE (venc_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct mtk_clk_desc venc_desc = { + .clks = venc_clks, + .num_clks =ARRAY_SIZE (venc_clks), +};static const struct of_device_id of_match_clk_mt8183_venc[] = { - { .compatible ="mediatek,mt8183-vencsys" , }, - {} + { + .compatible ="mediatek,mt8183-vencsys" , + .data = &venc_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt8183_venc_drv = { - .probe = clk_mt8183_venc_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8183-venc" , .of_match_table = of_match_clk_mt8183_venc,
Signature · 1 line
2.18.0
PATCH v3 4/7 clk: mediatek: mt6779: use mtk_clk_simple_probe to simplify driver
In reply to Miles Chenmtk_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.
--- drivers/clk/mediatek/clk-mt6779-aud.c | 29 ++++++++++++-------------- drivers/clk/mediatek/clk-mt6779-cam.c | 29 ++++++++++++-------------- drivers/clk/mediatek/clk-mt6779-img.c | 29 ++++++++++++-------------- drivers/clk/mediatek/clk-mt6779-ipe.c | 29 ++++++++++++-------------- drivers/clk/mediatek/clk-mt6779-mfg.c | 27 +++++++++++------------- drivers/clk/mediatek/clk-mt6779-vdec.c | 29 ++++++++++++-------------- drivers/clk/mediatek/clk-mt6779-venc.c | 29 ++++++++++++-------------- 7 files changed, 90 insertions(+), 111 deletions(-)
drivers/clk/mediatek/clk-mt6779-aud.c +13 -16
@@ -89,26 +89,23 @@ static const struct mtk_gate audio_clks[] = { "audio_h_sel", 31), }; -static const struct of_device_id of_match_clk_mt6779_aud[] = { - { .compatible ="mediatek,mt6779-audio" , }, - {} +static const struct mtk_clk_desc audio_desc = { + .clks = audio_clks, + .num_clks =ARRAY_SIZE (audio_clks), }; -static int clk_mt6779_aud_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_AUD_NR_CLK ); - -mtk_clk_register_gates (node, audio_clks,ARRAY_SIZE (audio_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct of_device_id of_match_clk_mt6779_aud[] = { + { + .compatible ="mediatek,mt6779-audio" , + .data = &audio_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6779_aud_drv = { - .probe = clk_mt6779_aud_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-aud" , .of_match_table = of_match_clk_mt6779_aud,
drivers/clk/mediatek/clk-mt6779-cam.c +13 -16
@@ -38,26 +38,23 @@ static const struct mtk_gate cam_clks[] = { GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14), }; -static const struct of_device_id of_match_clk_mt6779_cam[] = { - { .compatible ="mediatek,mt6779-camsys" , }, - {} +static const struct mtk_clk_desc cam_desc = { + .clks = cam_clks, + .num_clks =ARRAY_SIZE (cam_clks), }; -static int clk_mt6779_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 of_device_id of_match_clk_mt6779_cam[] = { + { + .compatible ="mediatek,mt6779-camsys" , + .data = &cam_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6779_cam_drv = { - .probe = clk_mt6779_cam_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-cam" , .of_match_table = of_match_clk_mt6779_cam,
drivers/clk/mediatek/clk-mt6779-img.c +13 -16
@@ -30,26 +30,23 @@ static const struct mtk_gate img_clks[] = { GATE_IMG(CLK_IMG_WPE_A, "imgsys_wpe_a", "img_sel", 7), }; -static const struct of_device_id of_match_clk_mt6779_img[] = { - { .compatible ="mediatek,mt6779-imgsys" , }, - {} +static const struct mtk_clk_desc img_desc = { + .clks = img_clks, + .num_clks =ARRAY_SIZE (img_clks), }; -static int clk_mt6779_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 of_device_id of_match_clk_mt6779_img[] = { + { + .compatible ="mediatek,mt6779-imgsys" , + .data = &img_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6779_img_drv = { - .probe = clk_mt6779_img_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-img" , .of_match_table = of_match_clk_mt6779_img,
drivers/clk/mediatek/clk-mt6779-ipe.c +13 -16
@@ -32,26 +32,23 @@ static const struct mtk_gate ipe_clks[] = { GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6), }; -static const struct of_device_id of_match_clk_mt6779_ipe[] = { - { .compatible ="mediatek,mt6779-ipesys" , }, - {} +static const struct mtk_clk_desc ipe_desc = { + .clks = ipe_clks, + .num_clks =ARRAY_SIZE (ipe_clks), }; -static int clk_mt6779_ipe_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_IPE_NR_CLK ); - -mtk_clk_register_gates (node, ipe_clks,ARRAY_SIZE (ipe_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct of_device_id of_match_clk_mt6779_ipe[] = { + { + .compatible ="mediatek,mt6779-ipesys" , + .data = &ipe_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6779_ipe_drv = { - .probe = clk_mt6779_ipe_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-ipe" , .of_match_table = of_match_clk_mt6779_ipe,
drivers/clk/mediatek/clk-mt6779-mfg.c +12 -15
@@ -27,26 +27,23 @@ static const struct mtk_gate mfg_clks[] = { GATE_MFG(CLK_MFGCFG_BG3D, "mfg_bg3d", "mfg_sel", 0), }; -static int clk_mt6779_mfg_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_MFGCFG_NR_CLK ); - -mtk_clk_register_gates (node, mfg_clks,ARRAY_SIZE (mfg_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct mtk_clk_desc mfg_desc = { + .clks = mfg_clks, + .num_clks =ARRAY_SIZE (mfg_clks), +};static const struct of_device_id of_match_clk_mt6779_mfg[] = { - { .compatible ="mediatek,mt6779-mfgcfg" , }, - {} + { + .compatible ="mediatek,mt6779-mfgcfg" , + .data = &mfg_desc, + }, { +/* sentinel */ + } };static struct platform_driver clk_mt6779_mfg_drv = { - .probe = clk_mt6779_mfg_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-mfg" , .of_match_table = of_match_clk_mt6779_mfg,
drivers/clk/mediatek/clk-mt6779-vdec.c +13 -16
@@ -39,26 +39,23 @@ static const struct mtk_gate vdec_clks[] = { GATE_VDEC1_I(CLK_VDEC_LARB1, "vdec_larb1_cken", "vdec_sel", 0), }; -static const struct of_device_id of_match_clk_mt6779_vdec[] = { - { .compatible ="mediatek,mt6779-vdecsys" , }, - {} +static const struct mtk_clk_desc vdec_desc = { + .clks = vdec_clks, + .num_clks =ARRAY_SIZE (vdec_clks), }; -static int clk_mt6779_vdec_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_VDEC_GCON_NR_CLK ); - -mtk_clk_register_gates (node, vdec_clks,ARRAY_SIZE (vdec_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct of_device_id of_match_clk_mt6779_vdec[] = { + { + .compatible ="mediatek,mt6779-vdecsys" , + .data = &vdec_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6779_vdec_drv = { - .probe = clk_mt6779_vdec_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-vdec" , .of_match_table = of_match_clk_mt6779_vdec,
drivers/clk/mediatek/clk-mt6779-venc.c +13 -16
@@ -30,26 +30,23 @@ static const struct mtk_gate venc_clks[] = { GATE_VENC_I(CLK_VENC_GCON_GALS, "venc_gals", "venc_sel", 28), }; -static const struct of_device_id of_match_clk_mt6779_venc[] = { - { .compatible ="mediatek,mt6779-vencsys" , }, - {} +static const struct mtk_clk_desc venc_desc = { + .clks = venc_clks, + .num_clks =ARRAY_SIZE (venc_clks), }; -static int clk_mt6779_venc_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_VENC_GCON_NR_CLK ); - -mtk_clk_register_gates (node, venc_clks,ARRAY_SIZE (venc_clks), - clk_data); - -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); -} +static const struct of_device_id of_match_clk_mt6779_venc[] = { + { + .compatible ="mediatek,mt6779-vencsys" , + .data = &venc_desc, + }, { +/* sentinel */ + } +};static struct platform_driver clk_mt6779_venc_drv = { - .probe = clk_mt6779_venc_probe, + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt6779-venc" , .of_match_table = of_match_clk_mt6779_venc,
Signature · 1 line
2.18.0
PATCH v3 7/7 clk: mediatek: mt8192: add mtk_clk_simple_remove
In reply to Miles Chenmt8192 is already using mtk_clk_simple_probe,
but not mtk_clk_simple_remove.
Let's add mtk_clk_simple_remove for mt8192.
--- drivers/clk/mediatek/clk-mt8192-cam.c | 1 + drivers/clk/mediatek/clk-mt8192-img.c | 1 + drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8192-ipe.c | 1 + drivers/clk/mediatek/clk-mt8192-mdp.c | 1 + drivers/clk/mediatek/clk-mt8192-mfg.c | 1 + drivers/clk/mediatek/clk-mt8192-msdc.c | 1 + drivers/clk/mediatek/clk-mt8192-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8192-vdec.c | 1 + drivers/clk/mediatek/clk-mt8192-venc.c | 1 + 10 files changed, 10 insertions(+)
drivers/clk/mediatek/clk-mt8192-cam.c +1 -0
@@ -98,6 +98,7 @@ static const struct of_device_id of_match_clk_mt8192_cam[] = {static struct platform_driver clk_mt8192_cam_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-cam" , .of_match_table = of_match_clk_mt8192_cam,
drivers/clk/mediatek/clk-mt8192-img.c +1 -0
@@ -61,6 +61,7 @@ static const struct of_device_id of_match_clk_mt8192_img[] = {static struct platform_driver clk_mt8192_img_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-img" , .of_match_table = of_match_clk_mt8192_img,
drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c +1 -0
@@ -110,6 +110,7 @@ static const struct of_device_id of_match_clk_mt8192_imp_iic_wrap[] = {static struct platform_driver clk_mt8192_imp_iic_wrap_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-imp_iic_wrap" , .of_match_table = of_match_clk_mt8192_imp_iic_wrap,
drivers/clk/mediatek/clk-mt8192-ipe.c +1 -0
@@ -48,6 +48,7 @@ static const struct of_device_id of_match_clk_mt8192_ipe[] = {static struct platform_driver clk_mt8192_ipe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-ipe" , .of_match_table = of_match_clk_mt8192_ipe,
drivers/clk/mediatek/clk-mt8192-mdp.c +1 -0
@@ -73,6 +73,7 @@ static const struct of_device_id of_match_clk_mt8192_mdp[] = {static struct platform_driver clk_mt8192_mdp_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-mdp" , .of_match_table = of_match_clk_mt8192_mdp,
drivers/clk/mediatek/clk-mt8192-mfg.c +1 -0
@@ -41,6 +41,7 @@ static const struct of_device_id of_match_clk_mt8192_mfg[] = {static struct platform_driver clk_mt8192_mfg_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-mfg" , .of_match_table = of_match_clk_mt8192_mfg,
drivers/clk/mediatek/clk-mt8192-msdc.c +1 -0
@@ -55,6 +55,7 @@ static const struct of_device_id of_match_clk_mt8192_msdc[] = {static struct platform_driver clk_mt8192_msdc_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-msdc" , .of_match_table = of_match_clk_mt8192_msdc,
drivers/clk/mediatek/clk-mt8192-scp_adsp.c +1 -0
@@ -41,6 +41,7 @@ static const struct of_device_id of_match_clk_mt8192_scp_adsp[] = {static struct platform_driver clk_mt8192_scp_adsp_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-scp_adsp" , .of_match_table = of_match_clk_mt8192_scp_adsp,
drivers/clk/mediatek/clk-mt8192-vdec.c +1 -0
@@ -85,6 +85,7 @@ static const struct of_device_id of_match_clk_mt8192_vdec[] = {static struct platform_driver clk_mt8192_vdec_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-vdec" , .of_match_table = of_match_clk_mt8192_vdec,
drivers/clk/mediatek/clk-mt8192-venc.c +1 -0
@@ -44,6 +44,7 @@ static const struct of_device_id of_match_clk_mt8192_venc[] = {static struct platform_driver clk_mt8192_venc_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8192-venc" , .of_match_table = of_match_clk_mt8192_venc,
Signature · 1 line
2.18.0
Re: [PATCH 1/7] clk: mediatek: mt2701: use mtk_clk_simple_probe to simplify driver
In reply to Miles ChenQuoted 10 lines · Miles Chen
mtk_clk_simple_probewas added by Chun-Jie to simply common flow of MediaTek clock drivers and ChenYu enhanced the error path ofmtk_clk_simple_probeand addedmtk_clk_simple_remove.Let's use
mtk_clk_simple_probeandmtk_clk_simple_probein other MediaTek clock drivers as well.Signed-off-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>
Just FYI, but you should have your patch subject contain the proper version tag, and not just on the cover letter. Patchwork gets confused otherwise.
ChenYu
Quoted 40 lines · Miles Chen
Hi everyone,
This is v3 patches to use
mtk_clk_simple_probeto simplify driver. It is almost a RESEND patch, the only difference is adding reviewed-by tags and a tested-by tag to the commit messages.I tested the series on MT8192 and MT6779.
This patch is based on next-20220921 and [1].Change since v1:
- Angelo's patch [1] already exportedmtk_clk_simple_probeandmtk_clk_simple_remove, so drop this part from my v1 and depends on [1].
- add a reviewed-by tagChange since v2:
- add reviewed-by tags and a tested-by tag
mtk_clk_simple_probe()was introduced by Chun-Jie in commitc58cd0e40ffa("clk: mediatek: Addmtk_clk_simple_probe()to simplify clock providers") andmtk_clk_simple_remove()was added in commit
commit2204d96b1919("clk: mediatek: Addmtk_clk_simple_remove()")With
mtk_clk_simple_probeandmtk_clk_simple_remove,
we can get rid of defining the same probe function in clk drivers.mtk_clk_simple_probeandmtk_clk_simple_removeare used in new platforms now, let's apply them to old SoCs.The process is quite straightforward:
a. Look up probe functions which can be replaced bymtk_clk_simple_probe()b. Addmtk_clk_descand add .data
c. Replace the probe function withmtk_clk_simple_probeandmtk_clk_simple_removeThanks,
Miles
Quoted 8 lines
Miles Chen (7):
clk: mediatek: mt2701: usemtk_clk_simple_probeto simplify driver
clk: mediatek: mt2712: usemtk_clk_simple_probeto simplify driver
clk: mediatek: mt6765: usemtk_clk_simple_probeto simplify driver
clk: mediatek: mt6779: usemtk_clk_simple_probeto simplify driver
clk: mediatek: mt6797: usemtk_clk_simple_probeto simplify driver
clk: mediatek: mt8183: usemtk_clk_simple_probeto simplify driver
clk: mediatek: mt8192: addmtk_clk_simple_remove
I've queued this series up here [1] and will send a pull request to the clock maintainer later this week.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/wens/linux.git/log/?h=clk-mtk-for-6.1