clk: mediatek: Cleanups and Improvements - Part 1
Subsystems (2)
v3 cover clk: mediatek: Cleanups and Improvements - Part 1
Hi everyone,
This is version 3 of part 1 of planned work to cleanup, improve, and modernize the MediaTek clk drivers. The full proposal can be found here:
https://lore.kernel.org/linux-clk/[email protected]/
Changes since version 2:
- Collected review tags
- Moved platform_set_drvdata() in clk_mt8195_apusys_pll_probe() to the correct patch (patch 30)
- Corrected error path for clk_mt8195_apmixed_probe() in patch "clk: mediatek: mt8195: Implement error handling in probe functions"
- Also dropped review tag for this patch
Changes since version 1:
- Added NULL pointer check against __clk_get_hw() return value in mtk_clk_unregister_pll()
- Added NULL pointer check against __clk_get_hw() return value in mtk_clk_unregister_composite()
- Copied MHZ macro into clk-pll.c and restored its usage
- Dropped extra semicolon in mtk_clk_register_plls()
- Reported by kernel test robot <[email protected]>
I also wanted to ask, what would be a good way to do the "struct clk" to "struct clk_hw" API conversion?
A. Add new register/unregister APIs that use "struct clk_hw" instead of
"struct clk". This would result in a lot of patches and a lot of churn though.
B. Replace "struct clk" with "struct clk_hw" (and "struct clk_onecell_data"
with "struct clk_hw_onecell_data") and work around existing code with __clk_get_hw() or its opposite. This would result in a few huge pages, as to not break bisection, but would likely cause less churn. And it would cover all existing platforms in one go.
Thanks
ChenYu
Original cover letter sans full proposal as follows:
Part 1 involves cleaning up various parts of the MediaTek common clk driver library:
- Code style cleanups in places touched by other changes
- Code for a given clk type that happened to be split between different files is consolidated
- Parts of the implementation, such as the internal data structures and registration/unregistration of a single clk, are internalized and no longer exported to other parts of the library
- Unregister APIs for all clk types in the library are added
- Remove function added for the simple driver case
- Error handling is added for all clk types
- MT8195 clk drivers cleaned up with error handling and removal support added
Adding error handling to the clk driver library results is a change in its behavior, and might cause some breakage where the affected system was originally somewhat working, but not completely. The failure would result from a duplicated clk, either in name or ID. Old behavior was to skip over these and ignore the error, whereas the new behavior is to restore changes and error out.
To detect duplicate IDs, an additional warning will now be printed when such occurrences happen. In a correct driver such things should not happen though, so maybe we could consider wrapping that in some debug Kconfig option. That's why I put it as the last patch in this series.
This series was tested on MT8195 with the series applied on the downstream ChromeOS v5.10 kernel. Some other patches were applied to make this series apply cleanly, but nothing The cpumux clk type changes were not tested due to lack of related hardware. However the changes are very similar to the other types, and I am confident there are no issues.
Chen-Yu Tsai (31):
clk: mediatek: Use %pe to print errors
clk: mediatek: gate: Consolidate gate type clk related code
clk: mediatek: gate: Internalize clk implementation
clk: mediatek: gate: Implement unregister API
clk: mediatek: gate: Clean up included headers
clk: mediatek: cpumux: Implement unregister API
clk: mediatek: cpumux: Internalize struct mtk_clk_cpumux
clk: mediatek: cpumux: Clean up included headers
clk: mediatek: mux: Implement unregister API
clk: mediatek: mux: Internalize struct mtk_clk_mux
clk: mediatek: mux: Clean up included headers
clk: mediatek: pll: Split definitions into separate header file
clk: mediatek: pll: Implement unregister API
clk: mediatek: pll: Clean up included headers
clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
clk: mediatek: Implement mtk_clk_unregister_factors() API
clk: mediatek: Implement mtk_clk_unregister_divider_clks() API
clk: mediatek: Implement mtk_clk_unregister_composites() API
clk: mediatek: Add mtk_clk_simple_remove()
clk: mediatek: mtk: Clean up included headers
clk: mediatek: cpumux: Implement error handling in register API
clk: mediatek: gate: Implement error handling in register API
clk: mediatek: mux: Reverse check for existing clk to reduce nesting
level
clk: mediatek: mux: Implement error handling in register API
clk: mediatek: pll: Implement error handling in register API
clk: mediatek: mtk: Implement error handling in register APIs
clk: mediatek: Unregister clks in mtk_clk_simple_probe() error path
clk: mediatek: mt8195: Hook up mtk_clk_simple_remove()
clk: mediatek: mt8195: Implement error handling in probe functions
clk: mediatek: mt8195: Implement remove functions
clk: mediatek: Warn if clk IDs are duplicated
drivers/clk/mediatek/clk-apmixed.c | 2 +- drivers/clk/mediatek/clk-cpumux.c | 69 +++- drivers/clk/mediatek/clk-cpumux.h | 13 +- drivers/clk/mediatek/clk-gate.c | 148 +++++++-- drivers/clk/mediatek/clk-gate.h | 59 ++-- drivers/clk/mediatek/clk-mt2701.c | 5 +- drivers/clk/mediatek/clk-mt2712.c | 3 +- drivers/clk/mediatek/clk-mt6765.c | 3 +- drivers/clk/mediatek/clk-mt6779.c | 3 +- drivers/clk/mediatek/clk-mt6797.c | 3 +- drivers/clk/mediatek/clk-mt7622.c | 5 +- drivers/clk/mediatek/clk-mt7629.c | 5 +- drivers/clk/mediatek/clk-mt7986-apmixed.c | 4 +- drivers/clk/mediatek/clk-mt8135.c | 3 +- drivers/clk/mediatek/clk-mt8167.c | 3 +- drivers/clk/mediatek/clk-mt8173.c | 5 +- drivers/clk/mediatek/clk-mt8183.c | 3 +- drivers/clk/mediatek/clk-mt8192.c | 3 +- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 30 +- drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 25 +- drivers/clk/mediatek/clk-mt8195-cam.c | 1 + drivers/clk/mediatek/clk-mt8195-ccu.c | 1 + drivers/clk/mediatek/clk-mt8195-img.c | 1 + .../clk/mediatek/clk-mt8195-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8195-infra_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-ipe.c | 1 + drivers/clk/mediatek/clk-mt8195-mfg.c | 1 + drivers/clk/mediatek/clk-mt8195-peri_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8195-topckgen.c | 69 +++- drivers/clk/mediatek/clk-mt8195-vdec.c | 1 + drivers/clk/mediatek/clk-mt8195-vdo0.c | 20 +- drivers/clk/mediatek/clk-mt8195-vdo1.c | 20 +- drivers/clk/mediatek/clk-mt8195-venc.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp0.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp1.c | 1 + drivers/clk/mediatek/clk-mt8195-wpe.c | 1 + drivers/clk/mediatek/clk-mt8516.c | 3 +- drivers/clk/mediatek/clk-mtk.c | 304 +++++++++++++----- drivers/clk/mediatek/clk-mtk.h | 105 ++---- drivers/clk/mediatek/clk-mux.c | 89 ++++- drivers/clk/mediatek/clk-mux.h | 17 +- drivers/clk/mediatek/clk-pll.c | 100 +++++- drivers/clk/mediatek/clk-pll.h | 57 ++++ drivers/clk/mediatek/reset.c | 3 +- 45 files changed, 903 insertions(+), 292 deletions(-) create mode 100644 drivers/clk/mediatek/clk-pll.h
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v3 1/31 clk: mediatek: Use %pe to print errors
If %pe is used to print errors, a string representation of the error would be printed instead of a number as with %ld. Also, all the sites printing errors are deriving the error code from a pointer. Using %pe is more straightforward.
--- drivers/clk/mediatek/clk-apmixed.c | 2 +- drivers/clk/mediatek/clk-cpumux.c | 6 ++---- drivers/clk/mediatek/clk-mtk.c | 18 ++++++------------ drivers/clk/mediatek/clk-mux.c | 6 ++---- drivers/clk/mediatek/clk-pll.c | 3 +-- drivers/clk/mediatek/reset.c | 3 +-- 6 files changed, 13 insertions(+), 25 deletions(-)
drivers/clk/mediatek/clk-apmixed.c +1 -1
@@ -92,7 +92,7 @@ struct clk * __init mtk_clk_register_ref2usb_tx(const char *name, clk =clk_register (NULL , &tx->hw);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , name, clk);kfree (tx); }
drivers/clk/mediatek/clk-cpumux.c +2 -4
@@ -87,8 +87,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, regmap =device_node_to_regmap (node);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , node, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap);return PTR_ERR (regmap); }
@@ -97,8 +96,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, clk =mtk_clk_register_cpumux (mux, regmap);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mux->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk);continue ; }
drivers/clk/mediatek/clk-mtk.c +6 -12
@@ -70,8 +70,7 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, rc->rate);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - rc->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , rc->name, clk);continue ; }
@@ -97,8 +96,7 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, CLK_SET_RATE_PARENT, ff->mult, ff->div);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - ff->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , ff->name, clk);continue ; }
@@ -122,8 +120,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, regmap =device_node_to_regmap (node);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , node, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap);return PTR_ERR (regmap); }
@@ -141,8 +138,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, gate->shift, gate->ops, gate->flags, dev);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - gate->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , gate->name, clk);continue ; }
@@ -264,8 +260,7 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, clk =mtk_clk_register_composite (mc, base, lock);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mc->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mc->name, clk);continue ; }
@@ -293,8 +288,7 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, mcd->div_width, mcd->clk_divider_flags, lock);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mcd->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mcd->name, clk);continue ; }
drivers/clk/mediatek/clk-mux.c +2 -4
@@ -175,8 +175,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, regmap =device_node_to_regmap (node);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , node, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap);return PTR_ERR (regmap); }
@@ -187,8 +186,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, clk =mtk_clk_register_mux (mux, regmap, lock);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mux->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk);continue ; }
drivers/clk/mediatek/clk-pll.c +1 -2
@@ -378,8 +378,7 @@ void mtk_clk_register_plls(struct device_node *node, clk =mtk_clk_register_pll (pll, base);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - pll->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , pll->name, clk);continue ; }
drivers/clk/mediatek/reset.c +1 -2
@@ -100,8 +100,7 @@ static void mtk_register_reset_controller_common(struct device_node *np, regmap =device_node_to_regmap (np);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , np, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , np, regmap);return ; }
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 01/31] clk: mediatek: Use %pe to print errors
Quoted 10 lines · Chen-Yu Tsai
If %pe is used to print errors, a string representation of the error would be printed instead of a number as with %ld. Also, all the sites printing errors are deriving the error code from a pointer. Using %pe is more straightforward.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 197 lines
--- drivers/clk/mediatek/clk-apmixed.c | 2 +- drivers/clk/mediatek/clk-cpumux.c | 6 ++---- drivers/clk/mediatek/clk-mtk.c | 18 ++++++------------ drivers/clk/mediatek/clk-mux.c | 6 ++---- drivers/clk/mediatek/clk-pll.c | 3 +-- drivers/clk/mediatek/reset.c | 3 +-- 6 files changed, 13 insertions(+), 25 deletions(-)drivers/clk/mediatek/clk-apmixed.c +1
-1@@ -92,7 +92,7 @@ struct clk * __init mtk_clk_register_ref2usb_tx(const char *name, clk =clk_register (NULL , &tx->hw);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , name, PTR_ERR(clk)); +pr_err ("Failed to register clk %s: %pe\n" , name, clk);kfree (tx);drivers/clk/mediatek/clk-apmixed.c +0
-0}drivers/clk/mediatek/clk-cpumux.c +1
-2@@ -87,8 +87,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, regmap =device_node_to_regmap (node);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , node, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap);return PTR_ERR (regmap);drivers/clk/mediatek/clk-cpumux.c +1
-2}@@ -97,8 +96,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, clk =mtk_clk_register_cpumux (mux, regmap);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mux->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mux- >name, clk);continue ;drivers/clk/mediatek/clk-cpumux.c +0
-0}drivers/clk/mediatek/clk-mtk.c +1
-2@@ -70,8 +70,7 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, rc->rate);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - rc->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , rc- >name, clk);continue ;drivers/clk/mediatek/clk-mtk.c +1
-2}@@ -97,8 +96,7 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,CLK_SET_RATE_PARENT , ff->mult, ff- >div);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - ff->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , ff- >name, clk);drivers/clk/mediatek/clk-mtk.c +1
-2continue ; }@@ -122,8 +120,7 @@ int mtk_clk_register_gates_with_dev(structdevice_node *node, regmap =device_node_to_regmap (node);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , node, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap);return PTR_ERR (regmap);drivers/clk/mediatek/clk-mtk.c +1
-2}@@ -141,8 +138,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, gate->shift, gate->ops, gate->flags, dev);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - gate->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , gate->name, clk);drivers/clk/mediatek/clk-mtk.c +1
-2continue ; }@@ -264,8 +260,7 @@ void mtk_clk_register_composites(const structmtk_composite *mcs, clk =mtk_clk_register_composite (mc, base, lock);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mc->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mc- >name, clk);continue ;drivers/clk/mediatek/clk-mtk.c +1
-2}@@ -293,8 +288,7 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, mcd->div_width, mcd->clk_divider_flags, lock);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - mcd->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , mcd- >name, clk);continue ;drivers/clk/mediatek/clk-mtk.c +0
-0}drivers/clk/mediatek/clk-mux.c +1
-2@@ -175,8 +175,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, regmap =device_node_to_regmap (node);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , node, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap);return PTR_ERR (regmap);drivers/clk/mediatek/clk-mux.c +1
-2}@@ -187,8 +186,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, clk =mtk_clk_register_mux (mux, regmap, lock);if (IS_ERR (clk)) { - pr_err("Failed to register clk %s: %ld\n", - mux->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mux->name, clk);drivers/clk/mediatek/clk-mux.c +0
-0continue ; }drivers/clk/mediatek/clk-pll.c +1
-2@@ -378,8 +378,7 @@ void mtk_clk_register_plls(struct device_node *node, clk =mtk_clk_register_pll (pll, base);if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %ld\n" , - pll->name,PTR_ERR (clk)); +pr_err ("Failed to register clk %s: %pe\n" , pll- >name, clk);continue ;drivers/clk/mediatek/clk-pll.c +0
-0}drivers/clk/mediatek/reset.c +1
-2@@ -100,8 +100,7 @@ static void mtk_register_reset_controller_common(struct device_node *np, regmap =device_node_to_regmap (np);if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %ld\n" , np, -PTR_ERR (regmap)); +pr_err ("Cannot find regmap for %pOF: %pe\n" , np, regmap);return ;}
Re: [PATCH v3 01/31] clk: mediatek: Use %pe to print errors
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:04)
Quoted 9 lines
If %pe is used to print errors, a string representation of the error would be printed instead of a number as with %ld. Also, all the sites printing errors are deriving the error code from a pointer. Using %pe is more straightforward.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 2/31 clk: mediatek: gate: Consolidate gate type clk related code
In reply to Chen-Yu TsaiRight now some bits of the gate type clk code are in clk-gate.[ch], but other bits are in clk-mtk.[ch]. This is different from the cpumux and mux type clks, for which all of the code are found in the same files.
Move the functions that register multiple clks from a given list, mtk_clk_register_gates_with_dev() and mtk_clk_register_gates(), to clk-gate.[ch] to consolidate all the code for the gate type clks.
This commit only moves code with minor whitespace fixups to correct the code style. Further improvements, such as internalizing various functions and structures will be done in later commits.
--- drivers/clk/mediatek/clk-gate.c | 53 ++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-gate.h | 25 ++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 51 ------------------------------- drivers/clk/mediatek/clk-mtk.h | 25 ---------------- 4 files changed, 77 insertions(+), 77 deletions(-)
drivers/clk/mediatek/clk-gate.c +52 -1
@@ -11,9 +11,9 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/clkdev.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> -#include "clk-mtk.h" #include "clk-gate.h" static u32 mtk_get_clockgating (struct clk_hw *hw)
@@ -182,4 +182,55 @@ struct clk *mtk_clk_register_gate( }EXPORT_SYMBOL_GPL (mtk_clk_register_gate); +int mtk_clk_register_gates_with_dev (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data, +struct device *dev) +{ +int i; +struct clk *clk; +struct regmap *regmap; + +if (!clk_data) +return -ENOMEM ; + + regmap =device_node_to_regmap (node); +if (IS_ERR (regmap)) { +pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap); +return PTR_ERR (regmap); + } + +for (i =0 ; i < num; i++) { +const struct mtk_gate *gate = &clks[i]; + +if (!IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + + clk =mtk_clk_register_gate (gate->name, gate->parent_name, + regmap, + gate->regs->set_ofs, + gate->regs->clr_ofs, + gate->regs->sta_ofs, + gate->shift, gate->ops, + gate->flags, dev); + +if (IS_ERR (clk)) { +pr_err ("Failed to register clk %s: %pe\n" , gate->name, clk); +continue ; + } + + clk_data->clks[gate->id] = clk; + } + +return 0 ; +} + +int mtk_clk_register_gates (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data) +{ +return mtk_clk_register_gates_with_dev (node, clks, num, clk_data,NULL ); +} +EXPORT_SYMBOL_GPL (mtk_clk_register_gates); +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-gate.h +25 -0
@@ -43,6 +43,22 @@ struct clk *mtk_clk_register_gate(unsigned long flags, struct device *dev); +struct mtk_gate_regs { +u32 sta_ofs; +u32 clr_ofs; +u32 set_ofs; +}; + +struct mtk_gate { +int id; +const char *name; +const char *parent_name; +const struct mtk_gate_regs *regs; +int shift; +const struct clk_ops *ops; +unsigned long flags; +}; +#define GATE_MTK_FLAGS (_id, _name, _parent, _regs, _shift, \ _ops, _flags) { \ .id = _id, \
@@ -57,4 +73,13 @@ struct clk *mtk_clk_register_gate(#define GATE_MTK (_id, _name, _parent, _regs, _shift, _ops) \ GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0) +int mtk_clk_register_gates (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data); + +int mtk_clk_register_gates_with_dev (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data, +struct device *dev); +#endif /* __DRV_CLK_GATE_H */
drivers/clk/mediatek/clk-mtk.c +0 -51
57 lines not on this page · raw message
drivers/clk/mediatek/clk-mtk.h +0 -25
@@ -150,31 +150,6 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); -struct mtk_gate_regs { -u32 sta_ofs; -u32 clr_ofs; -u32 set_ofs; -}; - -struct mtk_gate { -int id; -const char *name; -const char *parent_name; -const struct mtk_gate_regs *regs; -int shift; -const struct clk_ops *ops; -unsigned long flags; -}; - -int mtk_clk_register_gates (struct device_node *node, -const struct mtk_gate *clks,int num, -struct clk_onecell_data *clk_data); - -int mtk_clk_register_gates_with_dev (struct device_node *node, -const struct mtk_gate *clks, -int num,struct clk_onecell_data *clk_data, -struct device *dev); -struct mtk_clk_divider {int id;const char *name;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 02/31] clk: mediatek: gate: Consolidate gate type clk related code
Quoted 9 lines · Chen-Yu Tsai
Right now some bits of the gate type clk code are in clk-gate.[ch], but
other bits are in clk-mtk.[ch]. This is different from the cpumux and mux type clks, for which all of the code are found in the same files.Move the functions that register multiple clks from a given list,
mtk_clk_register_gates_with_dev()andmtk_clk_register_gates(), to clk-gate.[ch] to consolidate all the code for the gate type clks.
Quoted 9 lines
This commit only moves code with minor whitespace fixups to correct the code style. Further improvements, such as internalizing various functions and structures will be done in later commits.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 236 lines
--- drivers/clk/mediatek/clk-gate.c | 53 ++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-gate.h | 25 ++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 51 ------------------------------- drivers/clk/mediatek/clk-mtk.h | 25 ---------------- 4 files changed, 77 insertions(+), 77 deletions(-)drivers/clk/mediatek/clk-gate.c +16
-1@@ -11,9 +11,9 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/clkdev.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> -#include "clk-mtk.h" #include "clk-gate.h" static u32 mtk_get_clockgating (struct clk_hw *hw)@@ -182,4 +182,55 @@ struct clk *mtk_clk_register_gate( }EXPORT_SYMBOL_GPL (mtk_clk_register_gate); +int mtk_clk_register_gates_with_dev (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data, +struct device *dev) +{ +int i; +struct clk *clk; +struct regmap *regmap; + +if (!clk_data) +return -ENOMEM ; + + regmap =device_node_to_regmap (node); +if (IS_ERR (regmap)) { + pr_err("Cannot find regmap for %pOF: %pe\n", node,regmap);
drivers/clk/mediatek/clk-gate.c +10
-0+return PTR_ERR (regmap); + } + +for (i =0 ; i < num; i++) { +const struct mtk_gate *gate = &clks[i]; + +if (!IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + + clk = mtk_clk_register_gate(gate->name, gate-Quoted 1 line
parent_name,drivers/clk/mediatek/clk-gate.c +9
-0+ regmap, + gate->regs->set_ofs, + gate->regs->clr_ofs, + gate->regs->sta_ofs, + gate->shift, gate->ops, + gate->flags, dev); + +if (IS_ERR (clk)) { + pr_err("Failed to register clk %s: %pe\n",
gate->name, clk);drivers/clk/mediatek/clk-gate.c +14
-0+continue ; + } + + clk_data->clks[gate->id] = clk; + } + +return 0 ; +} + +int mtk_clk_register_gates (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data) +{ + return mtk_clk_register_gates_with_dev(node, clks, num,
clk_data, NULL);drivers/clk/mediatek/clk-gate.c +3
-0+} +EXPORT_SYMBOL_GPL (mtk_clk_register_gates); +MODULE_LICENSE ("GPL" );drivers/clk/mediatek/clk-gate.h +22
-0@@ -43,6 +43,22 @@ struct clk *mtk_clk_register_gate(unsigned long flags, struct device *dev); +struct mtk_gate_regs { +u32 sta_ofs; +u32 clr_ofs; +u32 set_ofs; +}; + +struct mtk_gate { +int id; +const char *name; +const char *parent_name; +const struct mtk_gate_regs *regs; +int shift; +const struct clk_ops *ops; +unsigned long flags; +}; +#define GATE_MTK_FLAGS (_id, _name, _parent, _regs, _shift, \ _ops, _flags) { \ .id = _id, \@@ -57,4 +73,13 @@ struct clk *mtk_clk_register_gate(#define GATE_MTK (_id, _name, _parent, _regs, _shift, _ops) \ GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0) +int mtk_clk_register_gates (struct device_node *node, +const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data); + +int mtk_clk_register_gates_with_dev (struct device_node *node, + const struct mtk_gate *clks, intnum,
drivers/clk/mediatek/clk-gate.h +3
-0+struct clk_onecell_data *clk_data, + struct device *dev); +#endif /* __DRV_CLK_GATE_H */ drivers/clk/mediatek/clk-mtk.c +0
-30@@ -106,57 +106,6 @@ void mtk_clk_register_factors(const structmtk_fixed_factor *clks, }EXPORT_SYMBOL_GPL (mtk_clk_register_factors ); -int mtk_clk_register_gates_with_dev (struct device_node *node, -const struct mtk_gate *clks, -int num,struct clk_onecell_data *clk_data, -struct device *dev) -{ -int i; -struct clk *clk; -struct regmap *regmap; - -if (!clk_data) -return -ENOMEM ; - - regmap =device_node_to_regmap (node); -if (IS_ERR (regmap)) { -pr_err ("Cannot find regmap for %pOF: %pe\n" , node, regmap); -return PTR_ERR (regmap); - } - -for (i =0 ; i < num; i++) { -const struct mtk_gate *gate = &clks[i]; - -if (!IS_ERR_OR_NULL (clk_data->clks[gate->id])) -continue ; - - clk = mtk_clk_register_gate(gate->name, gate- >parent_name, - regmap, - gate->regs->set_ofs, - gate->regs->clr_ofs, - gate->regs->sta_ofs, - gate->shift, gate->ops, gate->flags,dev);
drivers/clk/mediatek/clk-mtk.c +0
-3- -if (IS_ERR (clk)) { - pr_err("Failed to register clk %s: %pe\n",
gate->name, clk);drivers/clk/mediatek/clk-mtk.c +0
-18-continue ; - } - - clk_data->clks[gate->id] = clk; - } - -return 0 ; -} - -int mtk_clk_register_gates (struct device_node *node, -const struct mtk_gate *clks, -int num,struct clk_onecell_data *clk_data) -{ -return mtk_clk_register_gates_with_dev (node, - clks, num, clk_data,NULL ); -} -EXPORT_SYMBOL_GPL (mtk_clk_register_gates); - struct clk *mtk_clk_register_composite(const struct mtk_composite*mc,
drivers/clk/mediatek/clk-mtk.c +0
-0void __iomem *base, spinlock_t *lock) {drivers/clk/mediatek/clk-mtk.h +0
-25@@ -150,31 +150,6 @@ void mtk_clk_register_composites(const structmtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); -struct mtk_gate_regs { -u32 sta_ofs; -u32 clr_ofs; -u32 set_ofs; -}; - -struct mtk_gate { -int id; -const char *name; -const char *parent_name; -const struct mtk_gate_regs *regs; -int shift; -const struct clk_ops *ops; -unsigned long flags; -}; - -int mtk_clk_register_gates (struct device_node *node, -const struct mtk_gate *clks,int num, -struct clk_onecell_data *clk_data); - -int mtk_clk_register_gates_with_dev (struct device_node *node, -const struct mtk_gate *clks, -int num,struct clk_onecell_data *clk_data, -struct device *dev); -struct mtk_clk_divider {int id;const char *name;
Re: [PATCH v3 02/31] clk: mediatek: gate: Consolidate gate type clk related code
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:05)
Quoted 8 lines
Right now some bits of the gate type clk code are in clk-gate.[ch], but other bits are in clk-mtk.[ch]. This is different from the cpumux and mux type clks, for which all of the code are found in the same files.
Move the functions that register multiple clks from a given list,
mtk_clk_register_gates_with_dev()andmtk_clk_register_gates(), to clk-gate.[ch] to consolidate all the code for the gate type clks.
Quoted 8 lines
This commit only moves code with minor whitespace fixups to correct the code style. Further improvements, such as internalizing various functions and structures will be done in later commits.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 3/31 clk: mediatek: gate: Internalize clk implementation
In reply to Chen-Yu Tsaistruct mtk_clk_gate and mtk_clk_register_gate() are not used outside of the gate clk library. Only the API that handles a list of clks is used by the individual platform clk drivers.
Internalize the parts that aren't used outside of the implementation.
--- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++++++++++++----------- drivers/clk/mediatek/clk-gate.h | 31 ++--------------------------- 2 files changed, 25 insertions(+), 41 deletions(-)
drivers/clk/mediatek/clk-gate.c +23 -12
@@ -11,11 +11,28 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/clkdev.h> +#include <linux/clk-provider.h> +#include <linux/container_of.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/regmap.h> #include "clk-gate.h" +struct mtk_clk_gate { +struct clk_hw hw; +struct regmap *regmap; +int set_ofs; +int clr_ofs; +int sta_ofs; +u8 bit; +}; + +static inline struct mtk_clk_gate *to_mtk_clk_gate (struct clk_hw *hw) +{ + return container_of(hw, struct mtk_clk_gate, hw); +} +static u32 mtk_get_clockgating (struct clk_hw *hw) {struct mtk_clk_gate *cg =to_mtk_clk_gate (hw);
@@ -140,17 +157,12 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv); -struct clk *mtk_clk_register_gate ( -const char *name, -const char *parent_name, -struct regmap *regmap, -int set_ofs, -int clr_ofs, -int sta_ofs, -u8 bit, -const struct clk_ops *ops, -unsigned long flags, -struct device *dev) +static struct clk *mtk_clk_register_gate (const char *name, +const char *parent_name, +struct regmap *regmap,int set_ofs, +int clr_ofs,int sta_ofs,u8 bit, +const struct clk_ops *ops, +unsigned long flags,struct device *dev) {struct mtk_clk_gate *cg;struct clk *clk;
@@ -180,7 +192,6 @@ struct clk *mtk_clk_register_gate(return clk; } -EXPORT_SYMBOL_GPL (mtk_clk_register_gate); int mtk_clk_register_gates_with_dev(struct device_node *node, const struct mtk_gate *clks, int num,
drivers/clk/mediatek/clk-gate.h +2 -29
@@ -7,42 +7,15 @@ #ifndef __DRV_CLK_GATE_H #define __DRV_CLK_GATE_H -#include <linux/regmap.h> #include <linux/clk-provider.h> - -struct clk; - -struct mtk_clk_gate { - struct clk_hw hw; - struct regmap *regmap; - int set_ofs; - int clr_ofs; - int sta_ofs; - u8 bit; -}; - -static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw) -{ - return container_of(hw, struct mtk_clk_gate, hw); -} +#include <linux/device.h> +#include <linux/of.h> extern const struct clk_ops mtk_clk_gate_ops_setclr; extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; extern const struct clk_ops mtk_clk_gate_ops_no_setclr; extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv; -struct clk *mtk_clk_register_gate( - const char *name, - const char *parent_name, - struct regmap *regmap, - int set_ofs, - int clr_ofs, - int sta_ofs, - u8 bit, - const struct clk_ops *ops, - unsigned long flags, - struct device *dev); - struct mtk_gate_regs { u32 sta_ofs; u32 clr_ofs;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 03/31] clk: mediatek: gate: Internalize clk implementation
Quoted 6 lines · Chen-Yu Tsai
struct
mtk_clk_gateandmtk_clk_register_gate()are not used outside of
the gate clk library. Only the API that handles a list of clks is used
by the individual platform clk drivers.
Quoted 6 lines
Internalize the parts that aren't used outside of the implementation.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 129 lines
--- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++++++++++++--------- -- drivers/clk/mediatek/clk-gate.h | 31 ++--------------------------- 2 files changed, 25 insertions(+), 41 deletions(-)drivers/clk/mediatek/clk-gate.c +17
-0@@ -11,11 +11,28 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/clkdev.h> +#include <linux/clk-provider.h> +#include <linux/container_of.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/regmap.h> #include "clk-gate.h" +struct mtk_clk_gate { +struct clk_hw hw; +struct regmap *regmap; +int set_ofs; +int clr_ofs; +int sta_ofs; +u8 bit; +}; + +static inline struct mtk_clk_gate *to_mtk_clk_gate (struct clk_hw *hw) +{ + return container_of(hw, struct mtk_clk_gate, hw); +} +static u32 mtk_get_clockgating (struct clk_hw *hw) {drivers/clk/mediatek/clk-gate.c +6
-11struct mtk_clk_gate *cg =to_mtk_clk_gate (hw);@@ -140,17 +157,12 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv); -struct clk *mtk_clk_register_gate ( -const char *name, -const char *parent_name, -struct regmap *regmap, -int set_ofs, -int clr_ofs, -int sta_ofs, -u8 bit, -const struct clk_ops *ops, -unsigned long flags, -struct device *dev) +static struct clk *mtk_clk_register_gate(const char *name, + const char *parent_name, + struct regmap *regmap, int set_ofs, + int clr_ofs, int sta_ofs, u8 bit, + const struct clk_ops *ops, + unsigned long flags, structdevice *dev)
{drivers/clk/mediatek/clk-gate.c +0
-1struct mtk_clk_gate *cg;struct clk *clk;@@ -180,7 +192,6 @@ struct clk *mtk_clk_register_gate(return clk; } -EXPORT_SYMBOL_GPL (mtk_clk_register_gate);int mtk_clk_register_gates_with_dev (struct device_node *node, const struct mtk_gate *clks, intnum,
drivers/clk/mediatek/clk-gate.h +2
-29@@ -7,42 +7,15 @@ #ifndef __DRV_CLK_GATE_H #define __DRV_CLK_GATE_H -#include <linux/regmap.h> #include <linux/clk-provider.h> - -struct clk; - -struct mtk_clk_gate { - struct clk_hw hw; - struct regmap *regmap; - int set_ofs; - int clr_ofs; - int sta_ofs; - u8 bit; -}; - -static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw) -{ - return container_of(hw, struct mtk_clk_gate, hw); -} +#include <linux/device.h> +#include <linux/of.h> extern const struct clk_ops mtk_clk_gate_ops_setclr; extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; extern const struct clk_ops mtk_clk_gate_ops_no_setclr; extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv; -struct clk *mtk_clk_register_gate( - const char *name, - const char *parent_name, - struct regmap *regmap, - int set_ofs, - int clr_ofs, - int sta_ofs, - u8 bit, - const struct clk_ops *ops, - unsigned long flags, - struct device *dev); - struct mtk_gate_regs { u32 sta_ofs;u32
clr_ofs;
Re: [PATCH v3 03/31] clk: mediatek: gate: Internalize clk implementation
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:06)
Quoted 10 lines
struct
mtk_clk_gateandmtk_clk_register_gate()are not used outside of the gate clk library. Only the API that handles a list of clks is used by the individual platform clk drivers.Internalize the parts that aren't used outside of the implementation.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 4/31 clk: mediatek: gate: Implement unregister API
In reply to Chen-Yu TsaiThe gate clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the gate type clk.
--- drivers/clk/mediatek/clk-gate.c | 35 +++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-gate.h | 3 +++ 2 files changed, 38 insertions(+)
drivers/clk/mediatek/clk-gate.c +35 -0
@@ -193,6 +193,21 @@ static struct clk *mtk_clk_register_gate(const char *name,return clk; } +static void mtk_clk_unregister_gate (struct clk *clk) +{ +struct mtk_clk_gate *cg; +struct clk_hw *hw; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + cg =to_mtk_clk_gate (hw); + +clk_unregister (clk); +kfree (cg); +} + int mtk_clk_register_gates_with_dev(struct device_node *node, const struct mtk_gate *clks, int num, struct clk_onecell_data *clk_data,
@@ -244,4 +259,24 @@ int mtk_clk_register_gates(struct device_node *node, }EXPORT_SYMBOL_GPL (mtk_clk_register_gates); +void mtk_clk_unregister_gates (const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_gate *gate = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + +mtk_clk_unregister_gate (clk_data->clks[gate->id]); + clk_data->clks[gate->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_gates); +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-gate.h +3 -0
@@ -55,4 +55,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node,struct clk_onecell_data *clk_data, struct device *dev); +void mtk_clk_unregister_gates (const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data); +#endif /* __DRV_CLK_GATE_H */
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 04/31] clk: mediatek: gate: Implement unregister API
Quoted 11 lines · Chen-Yu Tsai
The gate clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the gate type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 75 lines
--- drivers/clk/mediatek/clk-gate.c | 35 +++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-gate.h | 3 +++ 2 files changed, 38 insertions(+)drivers/clk/mediatek/clk-gate.c +15
-0@@ -193,6 +193,21 @@ static struct clk *mtk_clk_register_gate(constchar *name, return clk; } +static void mtk_clk_unregister_gate (struct clk *clk) +{ +struct mtk_clk_gate *cg; +struct clk_hw *hw; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + cg =to_mtk_clk_gate (hw); + +clk_unregister (clk); +kfree (cg); +} +int mtk_clk_register_gates_with_dev (struct device_node *node, const struct mtk_gate *clks, intnum,
drivers/clk/mediatek/clk-gate.c +20
-0struct clk_onecell_data *clk_data,@@ -244,4 +259,24 @@ int mtk_clk_register_gates(struct device_node *node, }EXPORT_SYMBOL_GPL (mtk_clk_register_gates); +void mtk_clk_unregister_gates (const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_gate *gate = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + +mtk_clk_unregister_gate (clk_data->clks[gate->id]); + clk_data->clks[gate->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_gates); +
MODULE_LICENSE("GPL");drivers/clk/mediatek/clk-gate.h +3
-0@@ -55,4 +55,7 @@ int mtk_clk_register_gates_with_dev(structdevice_node *node, struct clk_onecell_data *clk_data, struct device *dev); +void mtk_clk_unregister_gates (const struct mtk_gate *clks,int num, +struct clk_onecell_data *clk_data); +#endif /*
__DRV_CLK_GATE_H*/
Re: [PATCH v3 04/31] clk: mediatek: gate: Implement unregister API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:07)
Quoted 11 lines
The gate clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the gate type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 5/31 clk: mediatek: gate: Clean up included headers
In reply to Chen-Yu TsaiSome included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
--- drivers/clk/mediatek/clk-gate.c | 11 +++-------- drivers/clk/mediatek/clk-gate.h | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/clk/mediatek/clk-gate.c +3 -8
@@ -4,18 +4,13 @@* Author: James Liao <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> - -#include <linux/io.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/clkdev.h> #include <linux/clk-provider.h> -#include <linux/container_of.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/printk.h> #include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/types.h> #include "clk-gate.h"
drivers/clk/mediatek/clk-gate.h +7 -3
@@ -7,9 +7,13 @@#ifndef __DRV_CLK_GATE_H#define __DRV_CLK_GATE_H -#include <linux/clk-provider.h> -#include <linux/device.h> -#include <linux/of.h> +#include <linux/types.h> + +struct clk ; +struct clk_onecell_data ; +struct clk_ops ; +struct device ; +struct device_node ;extern const struct clk_ops mtk_clk_gate_ops_setclr;extern const struct clk_ops mtk_clk_gate_ops_setclr_inv;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 05/31] clk: mediatek: gate: Clean up included headers
Quoted 13 lines · Chen-Yu Tsai
Some included headers aren't actually used anywhere, while other headers
with the declaration of functions and structures aren't directly included.Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 54 lines
--- drivers/clk/mediatek/clk-gate.c | 11 +++-------- drivers/clk/mediatek/clk-gate.h | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-)drivers/clk/mediatek/clk-gate.c +3
-8@@ -4,18 +4,13 @@* Author: James Liao <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> - -#include <linux/io.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/clkdev.h> #include <linux/clk-provider.h> -#include <linux/container_of.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/printk.h> #include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/types.h> #include "clk-gate.h" drivers/clk/mediatek/clk-gate.h +7
-3@@ -7,9 +7,13 @@#ifndef __DRV_CLK_GATE_H#define __DRV_CLK_GATE_H -#include <linux/clk-provider.h> -#include <linux/device.h> -#include <linux/of.h> +#include <linux/types.h> + +struct clk ; +struct clk_onecell_data ; +struct clk_ops ; +struct device ; +struct device_node ;extern const struct clk_ops mtk_clk_gate_ops_setclr;extern const struct clk_ops mtk_clk_gate_ops_setclr_inv;
Re: [PATCH v3 05/31] clk: mediatek: gate: Clean up included headers
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:08)
Quoted 12 lines
Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 6/31 clk: mediatek: cpumux: Implement unregister API
In reply to Chen-Yu TsaiThe cpumux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the cpumux type clk.
--- drivers/clk/mediatek/clk-cpumux.c | 31 +++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-cpumux.h | 3 +++ 2 files changed, 34 insertions(+)
drivers/clk/mediatek/clk-cpumux.c +31 -0
@@ -77,6 +77,21 @@ mtk_clk_register_cpumux(const struct mtk_composite *mux,return clk; } +static void mtk_clk_unregister_cpumux (struct clk *clk) +{ +struct mtk_clk_cpumux *cpumux; +struct clk_hw *hw; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + cpumux =to_mtk_clk_cpumux (hw); + +clk_unregister (clk); +kfree (cpumux); +} +int mtk_clk_register_cpumuxes (struct device_node *node,const struct mtk_composite *clks,int num,struct clk_onecell_data *clk_data)
@@ -106,4 +121,20 @@ int mtk_clk_register_cpumuxes(struct device_node *node,return 0 ; } +void mtk_clk_unregister_cpumuxes (const struct mtk_composite *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +for (i = num; i >0 ; i--) { +const struct mtk_composite *mux = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_cpumux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } +} +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-cpumux.h +3 -0
@@ -19,4 +19,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_cpumuxes (const struct mtk_composite *clks,int num, +struct clk_onecell_data *clk_data); +#endif /* __DRV_CLK_CPUMUX_H */
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 06/31] clk: mediatek: cpumux: Implement unregister API
Quoted 11 lines · Chen-Yu Tsai
The cpumux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the cpumux type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 74 lines
--- drivers/clk/mediatek/clk-cpumux.c | 31 +++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-cpumux.h | 3 +++ 2 files changed, 34 insertions(+)drivers/clk/mediatek/clk-cpumux.c +15
-0@@ -77,6 +77,21 @@ mtk_clk_register_cpumux(const struct mtk_composite *mux, return clk; } +static void mtk_clk_unregister_cpumux (struct clk *clk) +{ +struct mtk_clk_cpumux *cpumux; +struct clk_hw *hw; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + cpumux =to_mtk_clk_cpumux (hw); + +clk_unregister (clk); +kfree (cpumux); +} +int mtk_clk_register_cpumuxes (struct device_node *node, const struct mtk_composite *clks, intnum,
drivers/clk/mediatek/clk-cpumux.c +1
-0struct clk_onecell_data *clk_data)@@ -106,4 +121,20 @@ int mtk_clk_register_cpumuxes(struct device_node *node, return 0; } +void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks,int num,
drivers/clk/mediatek/clk-cpumux.c +15
-0+ struct clk_onecell_data *clk_data) +{ +int i; + +for (i = num; i >0 ; i--) { +const struct mtk_composite *mux = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_cpumux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } +} +MODULE_LICENSE ("GPL" );drivers/clk/mediatek/clk-cpumux.h +1
-0@@ -19,4 +19,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks,int num,
drivers/clk/mediatek/clk-cpumux.h +2
-0+ struct clk_onecell_data *clk_data); +#endif /* __DRV_CLK_CPUMUX_H */
Re: [PATCH v3 06/31] clk: mediatek: cpumux: Implement unregister API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:09)
Quoted 11 lines
The cpumux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the cpumux type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 7/31 clk: mediatek: cpumux: Internalize struct mtk_clk_cpumux
In reply to Chen-Yu Tsaistruct mtk_clk_cpumux is an implementation detail of the cpumux clk type, and is not used outside of the implementation.
Internalize the definition to minimize leakage of details and shrink the header file.
--- drivers/clk/mediatek/clk-cpumux.c | 8 ++++++++ drivers/clk/mediatek/clk-cpumux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/clk/mediatek/clk-cpumux.c +8 -0
@@ -12,6 +12,14 @@#include "clk-mtk.h" #include "clk-cpumux.h" +struct mtk_clk_cpumux { +struct clk_hw hw; +struct regmap *regmap; +u32 reg; +u32 mask; +u8 shift; +}; +static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux (struct clk_hw *_hw) { return container_of(_hw, struct mtk_clk_cpumux, hw);
drivers/clk/mediatek/clk-cpumux.h +0 -8
@@ -7,14 +7,6 @@#ifndef __DRV_CLK_CPUMUX_H#define __DRV_CLK_CPUMUX_H -struct mtk_clk_cpumux { -struct clk_hw hw; -struct regmap *regmap; -u32 reg; -u32 mask; -u8 shift; -}; -int mtk_clk_register_cpumuxes (struct device_node *node,const struct mtk_composite *clks,int num,struct clk_onecell_data *clk_data);
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 07/31] clk: mediatek: cpumux: Internalize struct mtk_clk_cpumux
Quoted 10 lines · Chen-Yu Tsai
struct
mtk_clk_cpumuxis an implementation detail of the cpumux clk type, and is not used outside of the implementation.Internalize the definition to minimize leakage of details and shrink the header file.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 47 lines
--- drivers/clk/mediatek/clk-cpumux.c | 8 ++++++++ drivers/clk/mediatek/clk-cpumux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)drivers/clk/mediatek/clk-cpumux.c +8
-0@@ -12,6 +12,14 @@#include "clk-mtk.h" #include "clk-cpumux.h" +struct mtk_clk_cpumux { +struct clk_hw hw; +struct regmap *regmap; +u32 reg; +u32 mask; +u8 shift; +}; +static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux (struct clk_hw *_hw) {drivers/clk/mediatek/clk-cpumux.c +0
-0return container_of(_hw, struct mtk_clk_cpumux, hw);drivers/clk/mediatek/clk-cpumux.h +0
-8@@ -7,14 +7,6 @@#ifndef __DRV_CLK_CPUMUX_H#define __DRV_CLK_CPUMUX_H -struct mtk_clk_cpumux { -struct clk_hw hw; -struct regmap *regmap; -u32 reg; -u32 mask; -u8 shift; -}; - int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num,struct
clk_onecell_data*clk_data);
Re: [PATCH v3 07/31] clk: mediatek: cpumux: Internalize struct mtk_clk_cpumux
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:10)
Quoted 10 lines
struct
mtk_clk_cpumuxis an implementation detail of the cpumux clk type, and is not used outside of the implementation.Internalize the definition to minimize leakage of details and shrink the header file.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 8/31 clk: mediatek: cpumux: Clean up included headers
In reply to Chen-Yu TsaiSome headers with the declaration of functions and structures aren't directly included. Explicitly include them so that future changes to other headers would not result in an unexpected build break.
On the header side, add forward declarations for any data structures whose pointers are used in function signatures. No headers are required.
--- drivers/clk/mediatek/clk-cpumux.c | 3 +++ drivers/clk/mediatek/clk-cpumux.h | 4 ++++ 2 files changed, 7 insertions(+)
drivers/clk/mediatek/clk-cpumux.c +3 -0
@@ -5,8 +5,11 @@*/ #include <linux/clk-provider.h> +#include <linux/container_of.h> +#include <linux/err.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/regmap.h> #include <linux/slab.h> #include "clk-mtk.h"
drivers/clk/mediatek/clk-cpumux.h +4 -0
@@ -7,6 +7,10 @@#ifndef __DRV_CLK_CPUMUX_H#define __DRV_CLK_CPUMUX_H +struct clk_onecell_data ; +struct device_node ; +struct mtk_composite ; +int mtk_clk_register_cpumuxes (struct device_node *node,const struct mtk_composite *clks,int num,struct clk_onecell_data *clk_data);
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 08/31] clk: mediatek: cpumux: Clean up included headers
Quoted 4 lines · Chen-Yu Tsai
Some headers with the declaration of functions and structures aren't directly included. Explicitly include them so that future changes to other headers would not result in an unexpected build break.
Quoted 8 lines
On the header side, add forward declarations for any data structures whose pointers are used in function signatures. No headers are required.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 39 lines
--- drivers/clk/mediatek/clk-cpumux.c | 3 +++ drivers/clk/mediatek/clk-cpumux.h | 4 ++++ 2 files changed, 7 insertions(+)drivers/clk/mediatek/clk-cpumux.c +3
-0@@ -5,8 +5,11 @@*/ #include <linux/clk-provider.h> +#include <linux/container_of.h> +#include <linux/err.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/regmap.h> #include <linux/slab.h> #include "clk-mtk.h" drivers/clk/mediatek/clk-cpumux.h +4
-0@@ -7,6 +7,10 @@#ifndef __DRV_CLK_CPUMUX_H#define __DRV_CLK_CPUMUX_H +struct clk_onecell_data ; +struct device_node ; +struct mtk_composite ; + int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num,struct
clk_onecell_data*clk_data);
Re: [PATCH v3 08/31] clk: mediatek: cpumux: Clean up included headers
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:11)
Quoted 4 lines
Some headers with the declaration of functions and structures aren't directly included. Explicitly include them so that future changes to other headers would not result in an unexpected build break.
Quoted 8 lines
On the header side, add forward declarations for any data structures whose pointers are used in function signatures. No headers are required.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 9/31 clk: mediatek: mux: Implement unregister API
In reply to Chen-Yu TsaiThe mux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the mux type clk.
--- drivers/clk/mediatek/clk-mux.c | 35 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mux.h | 3 +++ 2 files changed, 38 insertions(+)
drivers/clk/mediatek/clk-mux.c +35 -0
@@ -164,6 +164,21 @@ static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,return clk; } +static void mtk_clk_unregister_mux (struct clk *clk) +{ +struct mtk_clk_mux *mux; +struct clk_hw *hw; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + mux =to_mtk_clk_mux (hw); + +clk_unregister (clk); +kfree (mux); +} + int mtk_clk_register_muxes(const struct mtk_mux *muxes, int num, struct device_node *node, spinlock_t *lock,
@@ -198,4 +213,24 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, }EXPORT_SYMBOL_GPL (mtk_clk_register_muxes); +void mtk_clk_unregister_muxes (const struct mtk_mux *muxes,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_mux *mux = &muxes[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_mux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_muxes); +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-mux.h +3 -0
@@ -88,4 +88,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes,spinlock_t *lock, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_muxes (const struct mtk_mux *muxes,int num, +struct clk_onecell_data *clk_data); +#endif /* __DRV_CLK_MTK_MUX_H */
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 09/31] clk: mediatek: mux: Implement unregister API
Quoted 11 lines · Chen-Yu Tsai
The mux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the mux type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 74 lines
--- drivers/clk/mediatek/clk-mux.c | 35 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mux.h | 3 +++ 2 files changed, 38 insertions(+)drivers/clk/mediatek/clk-mux.c +15
-0@@ -164,6 +164,21 @@ static struct clk *mtk_clk_register_mux(conststruct mtk_mux *mux, return clk; } +static void mtk_clk_unregister_mux (struct clk *clk) +{ +struct mtk_clk_mux *mux; +struct clk_hw *hw; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + mux =to_mtk_clk_mux (hw); + +clk_unregister (clk); +kfree (mux); +} + int mtk_clk_register_muxes(const struct mtk_mux *muxes, int num, struct device_node *node,drivers/clk/mediatek/clk-mux.c +20
-0spinlock_t *lock,@@ -198,4 +213,24 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, }EXPORT_SYMBOL_GPL (mtk_clk_register_muxes); +void mtk_clk_unregister_muxes (const struct mtk_mux *muxes,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_mux *mux = &muxes[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_mux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_muxes); +
MODULE_LICENSE("GPL");drivers/clk/mediatek/clk-mux.h +3
-0@@ -88,4 +88,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, spinlock_t *lock, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_muxes (const struct mtk_mux *muxes,int num, +struct clk_onecell_data *clk_data); +#endif /*
__DRV_CLK_MTK_MUX_H*/
Re: [PATCH v3 09/31] clk: mediatek: mux: Implement unregister API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:12)
Quoted 11 lines
The mux clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the mux type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 10/31 clk: mediatek: mux: Internalize struct mtk_clk_mux
In reply to Chen-Yu Tsaistruct mtk_clk_mux is an implementation detail of the mux clk type, and is not used outside of the implementation.
Internalize the definition to minimize leakage of details and shrink the header file.
--- drivers/clk/mediatek/clk-mux.c | 8 ++++++++ drivers/clk/mediatek/clk-mux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/clk/mediatek/clk-mux.c +8 -0
@@ -13,6 +13,14 @@#include "clk-mtk.h" #include "clk-mux.h" +struct mtk_clk_mux { +struct clk_hw hw; +struct regmap *regmap; +const struct mtk_mux *data; +spinlock_t *lock; +bool reparent; +}; +static inline struct mtk_clk_mux *to_mtk_clk_mux (struct clk_hw *hw) { return container_of(hw, struct mtk_clk_mux, hw);
drivers/clk/mediatek/clk-mux.h +0 -8
@@ -9,14 +9,6 @@#include <linux/clk-provider.h> -struct mtk_clk_mux { -struct clk_hw hw; -struct regmap *regmap; -const struct mtk_mux *data; -spinlock_t *lock; -bool reparent; -}; -struct mtk_mux {int id;const char *name;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 10/31] clk: mediatek: mux: Internalize struct mtk_clk_mux
Quoted 10 lines · Chen-Yu Tsai
struct
mtk_clk_muxis an implementation detail of the mux clk type, and is not used outside of the implementation.Internalize the definition to minimize leakage of details and shrink the header file.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 45 lines
--- drivers/clk/mediatek/clk-mux.c | 8 ++++++++ drivers/clk/mediatek/clk-mux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)drivers/clk/mediatek/clk-mux.c +8
-0@@ -13,6 +13,14 @@#include "clk-mtk.h" #include "clk-mux.h" +struct mtk_clk_mux { +struct clk_hw hw; +struct regmap *regmap; +const struct mtk_mux *data; +spinlock_t *lock; +bool reparent; +}; +static inline struct mtk_clk_mux *to_mtk_clk_mux (struct clk_hw *hw) { return container_of(hw, struct mtk_clk_mux, hw);drivers/clk/mediatek/clk-mux.h +0
-8@@ -9,14 +9,6 @@#include <linux/clk-provider.h> -struct mtk_clk_mux { -struct clk_hw hw; -struct regmap *regmap; -const struct mtk_mux *data; -spinlock_t *lock; -bool reparent; -}; -struct mtk_mux {int id;const char *name;
Re: [PATCH v3 10/31] clk: mediatek: mux: Internalize struct mtk_clk_mux
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:13)
Quoted 10 lines
struct
mtk_clk_muxis an implementation detail of the mux clk type, and is not used outside of the implementation.Internalize the definition to minimize leakage of details and shrink the header file.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 11/31 clk: mediatek: mux: Clean up included headers
In reply to Chen-Yu TsaiSome included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
--- drivers/clk/mediatek/clk-mux.c | 11 +++++++---- drivers/clk/mediatek/clk-mux.h | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/clk/mediatek/clk-mux.c +7 -4
@@ -4,13 +4,16 @@* Author: Owen Chen <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/slab.h> +#include <linux/clk-provider.h> +#include <linux/compiler_types.h> +#include <linux/container_of.h> +#include <linux/err.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/regmap.h> +#include <linux/spinlock.h> +#include <linux/slab.h> -#include "clk-mtk.h" #include "clk-mux.h" struct mtk_clk_mux {
drivers/clk/mediatek/clk-mux.h +7 -1
@@ -7,7 +7,13 @@ #ifndef __DRV_CLK_MTK_MUX_H #define __DRV_CLK_MTK_MUX_H -#include <linux/clk-provider.h> +#include <linux/spinlock.h> +#include <linux/types.h> + +struct clk; +struct clk_onecell_data; +struct clk_ops; +struct device_node; struct mtk_mux { int id;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 11/31] clk: mediatek: mux: Clean up included headers
Quoted 13 lines · Chen-Yu Tsai
Some included headers aren't actually used anywhere, while other headers
with the declaration of functions and structures aren't directly included.Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 51 lines
--- drivers/clk/mediatek/clk-mux.c | 11 +++++++---- drivers/clk/mediatek/clk-mux.h | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-)drivers/clk/mediatek/clk-mux.c +7
-4@@ -4,13 +4,16 @@* Author: Owen Chen <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/slab.h> +#include <linux/clk-provider.h> +#include <linux/compiler_types.h> +#include <linux/container_of.h> +#include <linux/err.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/regmap.h> +#include <linux/spinlock.h> +#include <linux/slab.h> -#include "clk-mtk.h" #include "clk-mux.h" struct mtk_clk_mux {drivers/clk/mediatek/clk-mux.h +7
-1@@ -7,7 +7,13 @@ #ifndef __DRV_CLK_MTK_MUX_H #define __DRV_CLK_MTK_MUX_H -#include <linux/clk-provider.h> +#include <linux/spinlock.h> +#include <linux/types.h> + +struct clk; +struct clk_onecell_data; +struct clk_ops; +struct device_node; struct mtk_mux { int id;
Re: [PATCH v3 11/31] clk: mediatek: mux: Clean up included headers
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:14)
Quoted 12 lines
Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 12/31 clk: mediatek: pll: Split definitions into separate header file
In reply to Chen-Yu TsaiWhen the PLL type clk was implemented in the MediaTek clk driver library, the data structure definitions and function declaration were put in the common header file.
Since it is its own type of clk, and not all platform clk drivers utilize it, having the definitions in the common header results in wasted cycles during compilation.
Split out the related definitions and declarations into its own header file, and include that only in the platform clk drivers that need it.
--- drivers/clk/mediatek/clk-mt2701.c | 5 +- drivers/clk/mediatek/clk-mt2712.c | 3 +- drivers/clk/mediatek/clk-mt6765.c | 3 +- drivers/clk/mediatek/clk-mt6779.c | 3 +- drivers/clk/mediatek/clk-mt6797.c | 3 +- drivers/clk/mediatek/clk-mt7622.c | 5 +- drivers/clk/mediatek/clk-mt7629.c | 5 +- drivers/clk/mediatek/clk-mt7986-apmixed.c | 4 +- drivers/clk/mediatek/clk-mt8135.c | 3 +- drivers/clk/mediatek/clk-mt8167.c | 3 +- drivers/clk/mediatek/clk-mt8173.c | 5 +- drivers/clk/mediatek/clk-mt8183.c | 3 +- drivers/clk/mediatek/clk-mt8192.c | 3 +- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 1 + drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 1 + drivers/clk/mediatek/clk-mt8516.c | 3 +- drivers/clk/mediatek/clk-mtk.h | 39 -------------- drivers/clk/mediatek/clk-pll.c | 1 + drivers/clk/mediatek/clk-pll.h | 55 ++++++++++++++++++++ 19 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 drivers/clk/mediatek/clk-pll.h
drivers/clk/mediatek/clk-mt2701.c +3 -2
@@ -10,9 +10,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt2701-clk.h>
drivers/clk/mediatek/clk-mt2712.c +2 -1
@@ -13,8 +13,9 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-pll.h" +#include "clk-mtk.h" #include <dt-bindings/clock/mt2712-clk.h>
drivers/clk/mediatek/clk-mt6765.c +2 -1
@@ -12,9 +12,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt6765-clk.h>
drivers/clk/mediatek/clk-mt6779.c +2 -1
@@ -10,9 +10,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt6779-clk.h>
drivers/clk/mediatek/clk-mt6797.c +2 -1
@@ -9,8 +9,9 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt6797-clk.h>
drivers/clk/mediatek/clk-mt7622.c +3 -2
@@ -11,9 +11,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt7622-clk.h> #include <linux/clk.h> /* for consumer */
drivers/clk/mediatek/clk-mt7629.c +3 -2
@@ -12,9 +12,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt7629-clk.h>
drivers/clk/mediatek/clk-mt7986-apmixed.c +3 -1
@@ -10,9 +10,11 @@#include <linux/of_address.h> #include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" +#include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt7986-clk.h> #include <linux/clk.h>
drivers/clk/mediatek/clk-mt8135.c +2 -1
@@ -11,8 +11,9 @@#include <linux/mfd/syscon.h> #include <dt-bindings/clock/mt8135-clk.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" static DEFINE_SPINLOCK (mt8135_clk_lock);
drivers/clk/mediatek/clk-mt8167.c +2 -1
@@ -12,8 +12,9 @@#include <linux/slab.h> #include <linux/mfd/syscon.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8167-clk.h>
drivers/clk/mediatek/clk-mt8173.c +3 -2
@@ -8,9 +8,10 @@#include <linux/of.h> #include <linux/of_address.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8173-clk.h>
drivers/clk/mediatek/clk-mt8183.c +2 -1
@@ -11,9 +11,10 @@#include <linux/platform_device.h> #include <linux/slab.h> +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8183-clk.h>
drivers/clk/mediatek/clk-mt8192.c +2 -1
@@ -12,9 +12,10 @@#include <linux/platform_device.h> #include <linux/slab.h> +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8192-clk.h>
drivers/clk/mediatek/clk-mt8195-apmixedsys.c +1 -0
@@ -5,6 +5,7 @@#include "clk-gate.h" #include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8195-clk.h> #include <linux/of_device.h>
drivers/clk/mediatek/clk-mt8195-apusys_pll.c +1 -0
@@ -4,6 +4,7 @@// Author: Chun-Jie Chen <[email protected]> #include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8195-clk.h> #include <linux/clk-provider.h>
drivers/clk/mediatek/clk-mt8516.c +2 -1
@@ -11,8 +11,9 @@#include <linux/slab.h> #include <linux/mfd/syscon.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8516-clk.h>
drivers/clk/mediatek/clk-mtk.h +0 -39
@@ -179,45 +179,6 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds,struct clk_onecell_data *mtk_alloc_clk_data (unsigned int clk_num);void mtk_free_clk_data (struct clk_onecell_data *clk_data); -#define HAVE_RST_BAR BIT(0) -#define PLL_AO BIT(1) - -struct mtk_pll_div_table { -u32 div; -unsigned long freq; -}; - -struct mtk_pll_data { -int id; -const char *name; -u32 reg; -u32 pwr_reg; -u32 en_mask; -u32 pd_reg; -u32 tuner_reg; -u32 tuner_en_reg; -u8 tuner_en_bit; -int pd_shift; -unsigned int flags; -const struct clk_ops *ops; -u32 rst_bar_mask; -unsigned long fmin; -unsigned long fmax; -int pcwbits; -int pcwibits; -u32 pcw_reg; -int pcw_shift; -u32 pcw_chg_reg; -const struct mtk_pll_div_table *div_table; -const char *parent_name; -u32 en_reg; -u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ -}; - -void mtk_clk_register_plls (struct device_node *node, -const struct mtk_pll_data *plls,int num_plls, -struct clk_onecell_data *clk_data); -struct clk *mtk_clk_register_ref2usb_tx (const char *name,const char *parent_name,void __iomem *reg);
drivers/clk/mediatek/clk-pll.c +1 -0
@@ -13,6 +13,7 @@#include <linux/delay.h> #include "clk-mtk.h" +#include "clk-pll.h" #define REG_CON0 0#define REG_CON1 4
drivers/clk/mediatek/clk-pll.h new file +55 -0
55 lines not on this page · raw message
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 12/31] clk: mediatek: pll: Split definitions into separate header file
Quoted 8 lines · Chen-Yu Tsai
When the PLL type clk was implemented in the MediaTek clk driver library, the data structure definitions and function declaration were put in the common header file.
Since it is its own type of clk, and not all platform clk drivers utilize it, having the definitions in the common header results in wasted cycles during compilation.
Quoted 8 lines
Split out the related definitions and declarations into its own header file, and include that only in the platform clk drivers that need it.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 416 lines
--- drivers/clk/mediatek/clk-mt2701.c | 5 +- drivers/clk/mediatek/clk-mt2712.c | 3 +- drivers/clk/mediatek/clk-mt6765.c | 3 +- drivers/clk/mediatek/clk-mt6779.c | 3 +- drivers/clk/mediatek/clk-mt6797.c | 3 +- drivers/clk/mediatek/clk-mt7622.c | 5 +- drivers/clk/mediatek/clk-mt7629.c | 5 +- drivers/clk/mediatek/clk-mt7986-apmixed.c | 4 +- drivers/clk/mediatek/clk-mt8135.c | 3 +- drivers/clk/mediatek/clk-mt8167.c | 3 +- drivers/clk/mediatek/clk-mt8173.c | 5 +- drivers/clk/mediatek/clk-mt8183.c | 3 +- drivers/clk/mediatek/clk-mt8192.c | 3 +- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 1 + drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 1 + drivers/clk/mediatek/clk-mt8516.c | 3 +- drivers/clk/mediatek/clk-mtk.h | 39 -------------- drivers/clk/mediatek/clk-pll.c | 1 + drivers/clk/mediatek/clk-pll.h | 55 ++++++++++++++++++++ 19 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 drivers/clk/mediatek/clk-pll.hdrivers/clk/mediatek/clk-mt2701.c +3
-2@@ -10,9 +10,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt2701-clk.h> drivers/clk/mediatek/clk-mt2712.c +2
-1@@ -13,8 +13,9 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-pll.h" +#include "clk-mtk.h" #include <dt-bindings/clock/mt2712-clk.h> drivers/clk/mediatek/clk-mt6765.c +2
-1@@ -12,9 +12,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt6765-clk.h> drivers/clk/mediatek/clk-mt6779.c +2
-1@@ -10,9 +10,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt6779-clk.h> drivers/clk/mediatek/clk-mt6797.c +2
-1@@ -9,8 +9,9 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt6797-clk.h> drivers/clk/mediatek/clk-mt7622.c +3
-2@@ -11,9 +11,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt7622-clk.h> #include <linux/clk.h> /* for consumer */ drivers/clk/mediatek/clk-mt7629.c +3
-2@@ -12,9 +12,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt7629-clk.h> drivers/clk/mediatek/clk-mt7986-apmixed.c +3
-1@@ -10,9 +10,11 @@#include <linux/of_address.h> #include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-mtk.h" +#include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt7986-clk.h> #include <linux/clk.h> drivers/clk/mediatek/clk-mt8135.c +2
-1@@ -11,8 +11,9 @@#include <linux/mfd/syscon.h> #include <dt-bindings/clock/mt8135-clk.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" static DEFINE_SPINLOCK (mt8135_clk_lock);drivers/clk/mediatek/clk-mt8167.c +2
-1@@ -12,8 +12,9 @@#include <linux/slab.h> #include <linux/mfd/syscon.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8167-clk.h> drivers/clk/mediatek/clk-mt8173.c +3
-2@@ -8,9 +8,10 @@#include <linux/of.h> #include <linux/of_address.h> -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8173-clk.h> drivers/clk/mediatek/clk-mt8183.c +2
-1@@ -11,9 +11,10 @@#include <linux/platform_device.h> #include <linux/slab.h> +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8183-clk.h> drivers/clk/mediatek/clk-mt8192.c +2
-1@@ -12,9 +12,10 @@#include <linux/platform_device.h> #include <linux/slab.h> +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8192-clk.h> drivers/clk/mediatek/clk-mt8195-apmixedsys.c +1
-0@@ -5,6 +5,7 @@#include "clk-gate.h" #include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8195-clk.h> #include <linux/of_device.h> drivers/clk/mediatek/clk-mt8195-apusys_pll.c +1
-0@@ -4,6 +4,7 @@// Author: Chun-Jie Chen <[email protected]> #include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8195-clk.h> #include <linux/clk-provider.h> drivers/clk/mediatek/clk-mt8516.c +2
-1@@ -11,8 +11,9 @@#include <linux/slab.h> #include <linux/mfd/syscon.h> -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" #include <dt-bindings/clock/mt8516-clk.h> drivers/clk/mediatek/clk-mtk.h +0
-39@@ -179,45 +179,6 @@ void mtk_clk_register_dividers(const structmtk_clk_divider *mcds, struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num);void mtk_free_clk_data (struct clk_onecell_data *clk_data); -#define HAVE_RST_BAR BIT(0) -#define PLL_AO BIT(1) - -struct mtk_pll_div_table { -u32 div; -unsigned long freq; -}; - -struct mtk_pll_data { -int id; -const char *name; -u32 reg; -u32 pwr_reg; -u32 en_mask; -u32 pd_reg; -u32 tuner_reg; -u32 tuner_en_reg; -u8 tuner_en_bit; -int pd_shift; -unsigned int flags; -const struct clk_ops *ops; -u32 rst_bar_mask; -unsigned long fmin; -unsigned long fmax; -int pcwbits; -int pcwibits; -u32 pcw_reg; -int pcw_shift; -u32 pcw_chg_reg; -const struct mtk_pll_div_table *div_table; -const char *parent_name; -u32 en_reg; -u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ -}; - -void mtk_clk_register_plls (struct device_node *node, -const struct mtk_pll_data *plls,int num_plls, -struct clk_onecell_data *clk_data); -struct clk *mtk_clk_register_ref2usb_tx (const char *name,const char *parent_name,void __iomem *reg);drivers/clk/mediatek/clk-pll.c +1
-0@@ -13,6 +13,7 @@#include <linux/delay.h> #include "clk-mtk.h" +#include "clk-pll.h" #define REG_CON0 0#define REG_CON1 4drivers/clk/mediatek/clk-pll.h new file +52
-0@@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2014 MediaTek Inc. +* Author: James Liao <[email protected]> +*/ + +#ifndef __DRV_CLK_MTK_PLL_H +#define __DRV_CLK_MTK_PLL_H + +#include <linux/types.h> + +struct clk_ops ; +struct clk_onecell_data ; +struct device_node ; + +struct mtk_pll_div_table { +u32 div; +unsigned long freq; +}; + +#define HAVE_RST_BAR BIT(0) +#define PLL_AO BIT(1) + +struct mtk_pll_data { +int id; +const char *name; +u32 reg; +u32 pwr_reg; +u32 en_mask; +u32 pd_reg; +u32 tuner_reg; +u32 tuner_en_reg; +u8 tuner_en_bit; +int pd_shift; +unsigned int flags; +const struct clk_ops *ops; +u32 rst_bar_mask; +unsigned long fmin; +unsigned long fmax; +int pcwbits; +int pcwibits; +u32 pcw_reg; +int pcw_shift; +u32 pcw_chg_reg; +const struct mtk_pll_div_table *div_table; +const char *parent_name; +u32 en_reg; +u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ +}; + +void mtk_clk_register_plls (struct device_node *node, + const struct mtk_pll_data *plls, int
num_plls,drivers/clk/mediatek/clk-pll.h new file +3
-0+ struct clk_onecell_data *clk_data); + +#endif /* __DRV_CLK_MTK_PLL_H */
Re: [PATCH v3 12/31] clk: mediatek: pll: Split definitions into separate header file
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:15)
Quoted 8 lines
When the PLL type clk was implemented in the MediaTek clk driver library, the data structure definitions and function declaration were put in the common header file.
Since it is its own type of clk, and not all platform clk drivers utilize it, having the definitions in the common header results in wasted cycles during compilation.
Quoted 8 lines
Split out the related definitions and declarations into its own header file, and include that only in the platform clk drivers that need it.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 13/31 clk: mediatek: pll: Implement unregister API
In reply to Chen-Yu TsaiThe PLL clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the PLL type clk.
--- drivers/clk/mediatek/clk-pll.c | 55 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-pll.h | 2 ++ 2 files changed, 57 insertions(+)
drivers/clk/mediatek/clk-pll.c +55 -0
@@ -360,6 +360,21 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data,return clk; } +static void mtk_clk_unregister_pll (struct clk *clk) +{ +struct clk_hw *hw; +struct mtk_clk_pll *pll; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + pll =to_mtk_clk_pll (hw); + +clk_unregister (clk); +kfree (pll); +} +void mtk_clk_register_plls (struct device_node *node,const struct mtk_pll_data *plls,int num_plls,struct clk_onecell_data *clk_data) {
@@ -388,4 +403,44 @@ void mtk_clk_register_plls(struct device_node *node, }EXPORT_SYMBOL_GPL (mtk_clk_register_plls); +static __iomem void *mtk_clk_pll_get_base (struct clk *clk, +const struct mtk_pll_data *data) +{ +struct clk_hw *hw =__clk_get_hw (clk); +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +return pll->base_addr - data->reg; +} + +void mtk_clk_unregister_plls (const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data) +{ +__iomem void *base =NULL ; +int i; + +if (!clk_data) +return ; + +for (i = num_plls; i >0 ; i--) { +const struct mtk_pll_data *pll = &plls[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[pll->id])) +continue ; + +/* +* This is quite ugly but unfortunately the clks don't have +* any device tied to them, so there's no place to store the +* pointer to the I/O region base address. We have to fetch +* it from one of the registered clks. +*/ + base =mtk_clk_pll_get_base (clk_data->clks[pll->id], pll); + +mtk_clk_unregister_pll (clk_data->clks[pll->id]); + clk_data->clks[pll->id] =ERR_PTR (-ENOENT ); + } + +iounmap (base); +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_plls); +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-pll.h +2 -0
@@ -51,5 +51,7 @@ struct mtk_pll_data {void mtk_clk_register_plls (struct device_node *node,const struct mtk_pll_data *plls,int num_plls,struct clk_onecell_data *clk_data); +void mtk_clk_unregister_plls (const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data);#endif /* __DRV_CLK_MTK_PLL_H */
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 13/31] clk: mediatek: pll: Implement unregister API
Quoted 11 lines · Chen-Yu Tsai
The PLL clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the PLL type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 101 lines
--- drivers/clk/mediatek/clk-pll.c | 55 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-pll.h | 2 ++ 2 files changed, 57 insertions(+)drivers/clk/mediatek/clk-pll.c +15
-0@@ -360,6 +360,21 @@ static struct clk *mtk_clk_register_pll(conststruct mtk_pll_data *data, return clk; } +static void mtk_clk_unregister_pll (struct clk *clk) +{ +struct clk_hw *hw; +struct mtk_clk_pll *pll; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + pll =to_mtk_clk_pll (hw); + +clk_unregister (clk); +kfree (pll); +} + void mtk_clk_register_plls(struct device_node *node, const struct mtk_pll_data *plls, int num_plls, struct
clk_onecell_data*clk_data)
{drivers/clk/mediatek/clk-pll.c +2
-0@@ -388,4 +403,44 @@ void mtk_clk_register_plls(struct device_node *node, }EXPORT_SYMBOL_GPL (mtk_clk_register_plls); +static __iomem void *mtk_clk_pll_get_base (struct clk *clk, + const struct mtk_pll_data*data)
drivers/clk/mediatek/clk-pll.c +8
-0+{ +struct clk_hw *hw =__clk_get_hw (clk); +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +return pll->base_addr - data->reg; +} + +void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int
num_plls,drivers/clk/mediatek/clk-pll.c +16
-0+ struct clk_onecell_data *clk_data) +{ +__iomem void *base =NULL ; +int i; + +if (!clk_data) +return ; + +for (i = num_plls; i >0 ; i--) { +const struct mtk_pll_data *pll = &plls[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[pll->id])) +continue ; + +/* +* This is quite ugly but unfortunately the clks don't have
drivers/clk/mediatek/clk-pll.c +1
-0+* any device tied to them, so there's no place to store the
drivers/clk/mediatek/clk-pll.c +1
-0+* pointer to the I/O region base address. We have to fetch
drivers/clk/mediatek/clk-pll.c +3
-0+* it from one of the registered clks. +*/ + base = mtk_clk_pll_get_base(clk_data->clks[pll->id],pll);
drivers/clk/mediatek/clk-pll.c +9
-0+ +mtk_clk_unregister_pll (clk_data->clks[pll->id]); + clk_data->clks[pll->id] =ERR_PTR (-ENOENT ); + } + +iounmap (base); +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_plls); +MODULE_LICENSE ("GPL" );drivers/clk/mediatek/clk-pll.h +2
-0@@ -51,5 +51,7 @@ struct mtk_pll_data {void mtk_clk_register_plls (struct device_node *node,const struct mtk_pll_data *plls,int num_plls,struct clk_onecell_data *clk_data); +void mtk_clk_unregister_plls (const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data);
Quoted 1 line
#endif /*
__DRV_CLK_MTK_PLL_H*/
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 13/31] clk: mediatek: pll: Implement unregister API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:16)
Quoted 11 lines
The PLL clk type within the MediaTek clk driver library only has a register function, and no corresponding unregister function. This means there is no way for its users to properly implement cleanup and removal.
Add a matching unregister function for the PLL type clk.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 14/31 clk: mediatek: pll: Clean up included headers
In reply to Chen-Yu TsaiSome included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
Also, copy the MHZ macro from clk-mtk.h, and drop clk-mtk.h from the included headers.
--- drivers/clk/mediatek/clk-pll.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/clk/mediatek/clk-pll.c +7 -5
@@ -4,17 +4,19 @@* Author: James Liao <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> +#include <linux/clk-provider.h> +#include <linux/container_of.h> +#include <linux/delay.h> +#include <linux/err.h> #include <linux/io.h> #include <linux/module.h> +#include <linux/of_address.h> #include <linux/slab.h> -#include <linux/clkdev.h> -#include <linux/delay.h> -#include "clk-mtk.h" #include "clk-pll.h" +#define MHZ (1000 * 1000) +#define REG_CON0 0#define REG_CON1 4
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 14/31] clk: mediatek: pll: Clean up included headers
Quoted 8 lines · Chen-Yu Tsai
Some included headers aren't actually used anywhere, while other headers
with the declaration of functions and structures aren't directly included.Get rid of the unused ones, and add the ones that should be included directly.
Quoted 7 lines
Also, copy the MHZ macro from
clk-mtk.h, and dropclk-mtk.hfrom the included headers.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 34 lines
--- drivers/clk/mediatek/clk-pll.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/clk/mediatek/clk-pll.c +7
-5@@ -4,17 +4,19 @@* Author: James Liao <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> +#include <linux/clk-provider.h> +#include <linux/container_of.h> +#include <linux/delay.h> +#include <linux/err.h> #include <linux/io.h> #include <linux/module.h> +#include <linux/of_address.h> #include <linux/slab.h> -#include <linux/clkdev.h> -#include <linux/delay.h> -#include "clk-mtk.h" #include "clk-pll.h" +#define MHZ (1000 * 1000) +#define REG_CON0 0#define REG_CON1 4
Re: [PATCH v3 14/31] clk: mediatek: pll: Clean up included headers
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:17)
Quoted 7 lines
Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
Quoted 7 lines
Also, copy the MHZ macro from
clk-mtk.h, and dropclk-mtk.hfrom the included headers.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 15/31 clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
In reply to Chen-Yu Tsaimtk_clk_register_fixed_clks(), as the name suggests, is used to register a given list of fixed rate clks. However it is lacking a counterpart unregister API.
Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
--- drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
drivers/clk/mediatek/clk-mtk.c +20 -0
@@ -80,6 +80,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, }EXPORT_SYMBOL_GPL (mtk_clk_register_fixed_clks); +void mtk_clk_unregister_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_fixed_clk *rc = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[rc->id])) +continue ; + +clk_unregister_fixed_rate (clk_data->clks[rc->id]); + clk_data->clks[rc->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_fixed_clks); +void mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num,struct clk_onecell_data *clk_data) {
drivers/clk/mediatek/clk-mtk.h +4 -2
@@ -34,8 +34,10 @@ struct mtk_fixed_clk { .rate = _rate, \ } -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks, -int num,struct clk_onecell_data *clk_data); +void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data); +void mtk_clk_unregister_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data);struct mtk_fixed_factor {int id;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
Quoted 9 lines · Chen-Yu Tsai
mtk_clk_register_fixed_clks(), as the name suggests, is used to register
a given list of fixed rate clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers
can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 59 lines
--- drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-)drivers/clk/mediatek/clk-mtk.c +20
-0@@ -80,6 +80,26 @@ void mtk_clk_register_fixed_clks(const structmtk_fixed_clk *clks, }EXPORT_SYMBOL_GPL (mtk_clk_register_fixed_clks ); +void mtk_clk_unregister_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_fixed_clk *rc = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[rc->id])) +continue ; + +clk_unregister_fixed_rate (clk_data->clks[rc->id]); + clk_data->clks[rc->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_fixed_clks); + void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,drivers/clk/mediatek/clk-mtk.c +0
-0int num, struct clk_onecell_data *clk_data) {drivers/clk/mediatek/clk-mtk.h +4
-2@@ -34,8 +34,10 @@ struct mtk_fixed_clk { .rate = _rate, \ } -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks, -int num,struct clk_onecell_data *clk_data); +void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data); +void mtk_clk_unregister_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data);struct
mtk_fixed_factor{
int id;
Re: [PATCH v3 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:18)
Quoted 7 lines
mtk_clk_register_fixed_clks(), as the name suggests, is used to register a given list of fixed rate clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 16/31 clk: mediatek: Implement mtk_clk_unregister_factors() API
In reply to Chen-Yu Tsaimtk_clk_register_factors(), as the name suggests, is used to register a given list of fixed factor clks. However it is lacking a counterpart unregister API.
Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
--- drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
drivers/clk/mediatek/clk-mtk.c +20 -0
@@ -126,6 +126,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, }EXPORT_SYMBOL_GPL (mtk_clk_register_factors); +void mtk_clk_unregister_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_fixed_factor *ff = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[ff->id])) +continue ; + +clk_unregister_fixed_factor (clk_data->clks[ff->id]); + clk_data->clks[ff->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_factors); +struct clk *mtk_clk_register_composite (const struct mtk_composite *mc,void __iomem *base,spinlock_t *lock) {
drivers/clk/mediatek/clk-mtk.h +4 -2
@@ -55,8 +55,10 @@ struct mtk_fixed_factor { .div = _div, \ } -void mtk_clk_register_factors (const struct mtk_fixed_factor *clks, -int num,struct clk_onecell_data *clk_data); +void mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data); +void mtk_clk_unregister_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data);struct mtk_composite {int id;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 16/31] clk: mediatek: Implement mtk_clk_unregister_factors() API
Quoted 9 lines · Chen-Yu Tsai
mtk_clk_register_factors(), as the name suggests, is used to register a given list of fixed factor clks. However it is lacking a counterpart
unregister API.Implement said unregister API so that the various clock platform drivers
can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 60 lines
--- drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-)drivers/clk/mediatek/clk-mtk.c +20
-0@@ -126,6 +126,26 @@ void mtk_clk_register_factors(const structmtk_fixed_factor *clks, }EXPORT_SYMBOL_GPL (mtk_clk_register_factors ); +void mtk_clk_unregister_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_fixed_factor *ff = &clks[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[ff->id])) +continue ; + +clk_unregister_fixed_factor (clk_data->clks[ff->id]); + clk_data->clks[ff->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_factors); + struct clk *mtk_clk_register_composite(const struct mtk_composite*mc,
drivers/clk/mediatek/clk-mtk.c +0
-0void __iomem *base, spinlock_t *lock) {drivers/clk/mediatek/clk-mtk.h +4
-2@@ -55,8 +55,10 @@ struct mtk_fixed_factor { .div = _div, \ } -void mtk_clk_register_factors (const struct mtk_fixed_factor *clks, -int num,struct clk_onecell_data *clk_data); +void mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data); +void mtk_clk_unregister_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data);struct
mtk_composite{
int id;
Re: [PATCH v3 16/31] clk: mediatek: Implement mtk_clk_unregister_factors() API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:19)
Quoted 7 lines
mtk_clk_register_factors(), as the name suggests, is used to register a given list of fixed factor clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 17/31 clk: mediatek: Implement mtk_clk_unregister_divider_clks() API
In reply to Chen-Yu Tsaimtk_clk_register_divider_clks(), as the name suggests, is used to register a given list of divider clks. However it is lacking a counterpart unregister API.
Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
--- drivers/clk/mediatek/clk-mtk.c | 19 +++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/clk/mediatek/clk-mtk.c +19 -0
@@ -286,6 +286,25 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, } } +void mtk_clk_unregister_dividers (const struct mtk_clk_divider *mcds,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_clk_divider *mcd = &mcds[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +continue ; + +clk_unregister_divider (clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] =ERR_PTR (-ENOENT ); + } +} +int mtk_clk_simple_probe (struct platform_device *pdev) {const struct mtk_clk_desc *mcd;
drivers/clk/mediatek/clk-mtk.h +5 -3
@@ -176,9 +176,11 @@ struct mtk_clk_divider { .div_width = _width, \ } -void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data); +void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data); +void mtk_clk_unregister_dividers (const struct mtk_clk_divider *mcds,int num, +struct clk_onecell_data *clk_data);struct clk_onecell_data *mtk_alloc_clk_data (unsigned int clk_num);void mtk_free_clk_data (struct clk_onecell_data *clk_data);
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 17/31] clk: mediatek: Implement mtk_clk_unregister_divider_clks() API
Quoted 9 lines · Chen-Yu Tsai
mtk_clk_register_divider_clks(), as the name suggests, is used to register
a given list of divider clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers
can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 60 lines
--- drivers/clk/mediatek/clk-mtk.c | 19 +++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-)drivers/clk/mediatek/clk-mtk.c +19
-0@@ -286,6 +286,25 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, } } +void mtk_clk_unregister_dividers (const struct mtk_clk_divider *mcds,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_clk_divider *mcd = &mcds[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +continue ; + +clk_unregister_divider (clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] =ERR_PTR (-ENOENT ); + } +} +int mtk_clk_simple_probe (struct platform_device *pdev){
drivers/clk/mediatek/clk-mtk.c +0
-0const struct mtk_clk_desc *mcd;drivers/clk/mediatek/clk-mtk.h +5
-3@@ -176,9 +176,11 @@ struct mtk_clk_divider { .div_width = _width, \ } -void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data); +void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data); +void mtk_clk_unregister_dividers (const struct mtk_clk_divider *mcds,int num, +struct clk_onecell_data *clk_data);struct
clk_onecell_data*mtk_alloc_clk_data(unsigned intclk_num); voidmtk_free_clk_data(struct clk_onecell_data *clk_data);
Re: [PATCH v3 17/31] clk: mediatek: Implement mtk_clk_unregister_divider_clks() API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:20)
Quoted 7 lines
mtk_clk_register_divider_clks(), as the name suggests, is used to register a given list of divider clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 18/31 clk: mediatek: Implement mtk_clk_unregister_composites() API
In reply to Chen-Yu Tsaimtk_clk_register_composites(), as the name suggests, is used to register a given list of composite clks. However it is lacking a counterpart unregister API.
Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
--- drivers/clk/mediatek/clk-mtk.c | 46 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 48 insertions(+)
drivers/clk/mediatek/clk-mtk.c +46 -0
@@ -233,6 +233,32 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,return ERR_PTR (ret); } +static void mtk_clk_unregister_composite (struct clk *clk) +{ +struct clk_hw *hw; +struct clk_composite *composite; +struct clk_mux *mux =NULL ; +struct clk_gate *gate =NULL ; +struct clk_divider *div =NULL ; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + composite =to_clk_composite (hw); +if (composite->mux_hw) + mux =to_clk_mux (composite->mux_hw); +if (composite->gate_hw) + gate =to_clk_gate (composite->gate_hw); +if (composite->rate_hw) + div =to_clk_divider (composite->rate_hw); + +clk_unregister_composite (clk); +kfree (div); +kfree (gate); +kfree (mux); +} +void mtk_clk_register_composites (const struct mtk_composite *mcs,int num,void __iomem *base,spinlock_t *lock,struct clk_onecell_data *clk_data)
@@ -259,6 +285,26 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, }EXPORT_SYMBOL_GPL (mtk_clk_register_composites); +void mtk_clk_unregister_composites (const struct mtk_composite *mcs,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_composite *mc = &mcs[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mc->id])) +continue ; + +mtk_clk_unregister_composite (clk_data->clks[mc->id]); + clk_data->clks[mc->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_composites); +void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num,void __iomem *base,spinlock_t *lock,struct clk_onecell_data *clk_data)
drivers/clk/mediatek/clk-mtk.h +2 -0
@@ -153,6 +153,8 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,void mtk_clk_register_composites (const struct mtk_composite *mcs,int num,void __iomem *base,spinlock_t *lock,struct clk_onecell_data *clk_data); +void mtk_clk_unregister_composites (const struct mtk_composite *mcs,int num, +struct clk_onecell_data *clk_data);struct mtk_clk_divider {int id;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 18/31] clk: mediatek: Implement mtk_clk_unregister_composites() API
Quoted 9 lines · Chen-Yu Tsai
mtk_clk_register_composites(), as the name suggests, is used to register
a given list of composite clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers
can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by AngeloGioacchino Del Regno <Reviewed-by Miles Chen <[email protected]>
Quoted 90 lines
--- drivers/clk/mediatek/clk-mtk.c | 46 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 48 insertions(+)drivers/clk/mediatek/clk-mtk.c +26
-0@@ -233,6 +233,32 @@ struct clk *mtk_clk_register_composite(conststruct mtk_composite *mc, return ERR_PTR(ret); } +static void mtk_clk_unregister_composite (struct clk *clk) +{ +struct clk_hw *hw; +struct clk_composite *composite; +struct clk_mux *mux =NULL ; +struct clk_gate *gate =NULL ; +struct clk_divider *div =NULL ; + + hw =__clk_get_hw (clk); +if (!hw) +return ; + + composite =to_clk_composite (hw); +if (composite->mux_hw) + mux =to_clk_mux (composite->mux_hw); +if (composite->gate_hw) + gate =to_clk_gate (composite->gate_hw); +if (composite->rate_hw) + div =to_clk_divider (composite->rate_hw); + +clk_unregister_composite (clk); +kfree (div); +kfree (gate); +kfree (mux); +} + void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock,drivers/clk/mediatek/clk-mtk.c +20
-0struct clk_onecell_data *clk_data)@@ -259,6 +285,26 @@ void mtk_clk_register_composites(const structmtk_composite *mcs, }EXPORT_SYMBOL_GPL (mtk_clk_register_composites ); +void mtk_clk_unregister_composites (const struct mtk_composite *mcs,int num, +struct clk_onecell_data *clk_data) +{ +int i; + +if (!clk_data) +return ; + +for (i = num; i >0 ; i--) { +const struct mtk_composite *mc = &mcs[i -1 ]; + +if (IS_ERR_OR_NULL (clk_data->clks[mc->id])) +continue ; + +mtk_clk_unregister_composite (clk_data->clks[mc->id]); + clk_data->clks[mc->id] =ERR_PTR (-ENOENT ); + } +} +EXPORT_SYMBOL_GPL (mtk_clk_unregister_composites); + void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds,drivers/clk/mediatek/clk-mtk.c +0
-0int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data)drivers/clk/mediatek/clk-mtk.h +2
-0@@ -153,6 +153,8 @@ struct clk *mtk_clk_register_composite(conststruct mtk_composite *mc, void mtk_clk_register_composites(const struct mtk_composite *mcs,int num,void __iomem *base,spinlock_t *lock,struct clk_onecell_data *clk_data); +void mtk_clk_unregister_composites (const struct mtk_composite *mcs,int num, +struct clk_onecell_data *clk_data);struct
mtk_clk_divider{
int id;
Re: [PATCH v3 18/31] clk: mediatek: Implement mtk_clk_unregister_composites() API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:21)
Quoted 7 lines
mtk_clk_register_composites(), as the name suggests, is used to register a given list of composite clks. However it is lacking a counterpart unregister API.Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal.
Quoted 7 lines
In the header file, the register function's declaration is also reformatted to fit code style guidelines.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Reviewed-by Miles Chen <[email protected]>---
Applied to clk-next
PATCH v3 19/31 clk: mediatek: Add mtk_clk_simple_remove()
In reply to Chen-Yu TsaiIn commit c58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers"), a generic probe function was added to simplify clk drivers that only needed to support clk gates. However due to the lack of unregister APIs, a corresponding remove function was not added.
Now that the unregister APIs have been implemented, add aforementioned remove function to make it complete.
--- drivers/clk/mediatek/clk-mtk.c | 15 +++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 1 + 2 files changed, 16 insertions(+)
drivers/clk/mediatek/clk-mtk.c +15 -0
@@ -374,6 +374,8 @@ int mtk_clk_simple_probe(struct platform_device *pdev)if (r) goto free_data; +platform_set_drvdata (pdev, clk_data); +return r; free_data:
@@ -381,4 +383,17 @@ int mtk_clk_simple_probe(struct platform_device *pdev)return r; } +int mtk_clk_simple_remove (struct platform_device *pdev) +{ +const struct mtk_clk_desc *mcd =of_device_get_match_data (&pdev->dev); +struct clk_onecell_data *clk_data =platform_get_drvdata (pdev); +struct device_node *node = pdev->dev.of_node; + +of_clk_del_provider (node); +mtk_clk_unregister_gates (mcd->clks, mcd->num_clks, clk_data); +mtk_free_clk_data (clk_data); + +return 0 ; +} +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-mtk.h +1 -0
@@ -202,5 +202,6 @@ struct mtk_clk_desc { };int mtk_clk_simple_probe (struct platform_device *pdev); +int mtk_clk_simple_remove (struct platform_device *pdev);#endif /* __DRV_CLK_MTK_H */
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 19/31] clk: mediatek: Add mtk_clk_simple_remove()
Quoted 8 lines · Chen-Yu Tsai
In commit
c58cd0e40ffa("clk: mediatek: Addmtk_clk_simple_probe()to simplify clock providers"), a generic probe function was added to simplify clk drivers that only needed to support clk gates. However due
to the lack of unregister APIs, a corresponding remove function was not
added.
Quoted 8 lines
Now that the unregister APIs have been implemented, add aforementioned
remove function to make it complete.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 52 lines
--- drivers/clk/mediatek/clk-mtk.c | 15 +++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 1 + 2 files changed, 16 insertions(+)drivers/clk/mediatek/clk-mtk.c +2
-0@@ -374,6 +374,8 @@ int mtk_clk_simple_probe(struct platform_device *pdev)if (r) goto free_data; +platform_set_drvdata (pdev, clk_data); +return r;
free_data:drivers/clk/mediatek/clk-mtk.c +3
-0@@ -381,4 +383,17 @@ int mtk_clk_simple_probe(struct platform_device *pdev)return r; } +int mtk_clk_simple_remove (struct platform_device *pdev) +{ + const struct mtk_clk_desc *mcd =
of_device_get_match_data(&pdev->dev);drivers/clk/mediatek/clk-mtk.c +10
-0+struct clk_onecell_data *clk_data =platform_get_drvdata (pdev); +struct device_node *node = pdev->dev.of_node; + +of_clk_del_provider (node); +mtk_clk_unregister_gates (mcd->clks, mcd->num_clks, clk_data); +mtk_free_clk_data (clk_data); + +return 0 ; +} +MODULE_LICENSE ("GPL" );drivers/clk/mediatek/clk-mtk.h +1
-0@@ -202,5 +202,6 @@ struct mtk_clk_desc { };int mtk_clk_simple_probe (struct platform_device *pdev); +int mtk_clk_simple_remove (struct platform_device *pdev);#endif /* __DRV_CLK_MTK_H */
Re: [PATCH v3 19/31] clk: mediatek: Add mtk_clk_simple_remove()
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:22)
Quoted 6 lines
In commit
c58cd0e40ffa("clk: mediatek: Addmtk_clk_simple_probe()to simplify clock providers"), a generic probe function was added to simplify clk drivers that only needed to support clk gates. However due to the lack of unregister APIs, a corresponding remove function was not added.
Quoted 7 lines
Now that the unregister APIs have been implemented, add aforementioned remove function to make it complete.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 20/31 clk: mediatek: mtk: Clean up included headers
In reply to Chen-Yu TsaiSome included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
--- drivers/clk/mediatek/clk-mtk.c | 13 ++++++------- drivers/clk/mediatek/clk-mtk.h | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-)
drivers/clk/mediatek/clk-mtk.c +6 -7
@@ -4,17 +4,16 @@* Author: James Liao <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> +#include <linux/bitops.h> +#include <linux/clk-provider.h> #include <linux/err.h> #include <linux/io.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/clkdev.h> -#include <linux/module.h> #include <linux/mfd/syscon.h> -#include <linux/device.h> +#include <linux/module.h> +#include <linux/of.h> #include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/slab.h> #include "clk-mtk.h" #include "clk-gate.h"
drivers/clk/mediatek/clk-mtk.h +6 -6
@@ -7,19 +7,19 @@ #ifndef __DRV_CLK_MTK_H #define __DRV_CLK_MTK_H -#include <linux/regmap.h> -#include <linux/bitops.h> #include <linux/clk-provider.h> -#include <linux/platform_device.h> - -struct clk; -struct clk_onecell_data; +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/spinlock.h> +#include <linux/types.h> #define MAX_MUX_GATE_BIT 31 #define INVALID_MUX_GATE_BIT (MAX_MUX_GATE_BIT + 1) #define MHZ (1000 * 1000) +struct platform_device; + struct mtk_fixed_clk { int id; const char *name;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 20/31] clk: mediatek: mtk: Clean up included headers
Quoted 13 lines · Chen-Yu Tsai
Some included headers aren't actually used anywhere, while other headers
with the declaration of functions and structures aren't directly included.Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 65 lines
--- drivers/clk/mediatek/clk-mtk.c | 13 ++++++------- drivers/clk/mediatek/clk-mtk.h | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-)drivers/clk/mediatek/clk-mtk.c +6
-7@@ -4,17 +4,16 @@* Author: James Liao <[email protected]> */ -#include <linux/of.h> -#include <linux/of_address.h> +#include <linux/bitops.h> +#include <linux/clk-provider.h> #include <linux/err.h> #include <linux/io.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/clkdev.h> -#include <linux/module.h> #include <linux/mfd/syscon.h> -#include <linux/device.h> +#include <linux/module.h> +#include <linux/of.h> #include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/slab.h> #include "clk-mtk.h" #include "clk-gate.h" drivers/clk/mediatek/clk-mtk.h +6
-6@@ -7,19 +7,19 @@ #ifndef __DRV_CLK_MTK_H #define __DRV_CLK_MTK_H -#include <linux/regmap.h> -#include <linux/bitops.h> #include <linux/clk-provider.h> -#include <linux/platform_device.h> - -struct clk; -struct clk_onecell_data; +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/spinlock.h> +#include <linux/types.h> #define MAX_MUX_GATE_BIT 31 #define INVALID_MUX_GATE_BIT (MAX_MUX_GATE_BIT + 1) #define MHZ (1000 * 1000) +struct platform_device; + struct mtk_fixed_clk { int id; const char *name;
Re: [PATCH v3 20/31] clk: mediatek: mtk: Clean up included headers
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:23)
Quoted 12 lines
Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included.
Get rid of the unused ones, and add the ones that should be included directly.
On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 21/31 clk: mediatek: cpumux: Implement error handling in register API
In reply to Chen-Yu TsaiThe cpumux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
--- drivers/clk/mediatek/clk-cpumux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-cpumux.c +14 -1
@@ -123,13 +123,26 @@ int mtk_clk_register_cpumuxes(struct device_node *node, clk =mtk_clk_register_cpumux (mux, regmap);if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk); -continue ; + goto err; } clk_data->clks[mux->id] = clk; }return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_composite *mux = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_cpumux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); } void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num,
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 21/31] clk: mediatek: cpumux: Implement error handling in register API
Quoted 6 lines · Chen-Yu Tsai
The cpumux clk type registration function does not stop or return errors
if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Quoted 8 lines
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 40 lines
--- drivers/clk/mediatek/clk-cpumux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-cpumux.c +14
-1@@ -123,13 +123,26 @@ int mtk_clk_register_cpumuxes(structdevice_node *node, clk =mtk_clk_register_cpumux (mux, regmap);if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , mux- >name, clk); -continue ; + goto err; } clk_data->clks[mux->id] = clk; }return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_composite *mux = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_cpumux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); }void mtk_clk_unregister_cpumuxes(const struct
mtk_composite*clks,
int num,
Re: [PATCH v3 21/31] clk: mediatek: cpumux: Implement error handling in register API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:24)
Quoted 5 lines
The cpumux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Quoted 8 lines
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 22/31 clk: mediatek: gate: Implement error handling in register API
In reply to Chen-Yu TsaiThe gate clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
--- drivers/clk/mediatek/clk-gate.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-gate.c +14 -1
@@ -237,13 +237,26 @@ int mtk_clk_register_gates_with_dev(struct device_node *node,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , gate->name, clk); -continue ; + goto err; } clk_data->clks[gate->id] = clk; }return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_gate *gate = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + +mtk_clk_unregister_gate (clk_data->clks[gate->id]); + clk_data->clks[gate->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); } int mtk_clk_register_gates(struct device_node *node,
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 22/31] clk: mediatek: gate: Implement error handling in register API
Quoted 6 lines · Chen-Yu Tsai
The gate clk type registration function does not stop or return errors
if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Quoted 8 lines
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 39 lines
--- drivers/clk/mediatek/clk-gate.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-gate.c +14
-1@@ -237,13 +237,26 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , gate->name, clk); -continue ; + goto err; } clk_data->clks[gate->id] = clk; }return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_gate *gate = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + +mtk_clk_unregister_gate (clk_data->clks[gate->id]); + clk_data->clks[gate->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); }int mtk_clk_register_gates(struct
device_node*node,
Re: [PATCH v3 22/31] clk: mediatek: gate: Implement error handling in register API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:25)
Quoted 5 lines
The gate clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Quoted 8 lines
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 23/31 clk: mediatek: mux: Reverse check for existing clk to reduce nesting level
In reply to Chen-Yu TsaiThe clk registration code here currently does:
if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) {
... do clk registration ...
}This extra level of nesting wastes screen real estate.
Reduce the nesting level by reversing the conditional shown above. Other than that, functionality is not changed.
--- drivers/clk/mediatek/clk-mux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/clk/mediatek/clk-mux.c +8 -7
@@ -208,16 +208,17 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes,for (i =0 ; i < num; i++) {const struct mtk_mux *mux = &muxes[i]; -if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) { - clk =mtk_clk_register_mux (mux, regmap, lock); +if (!IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; -if (IS_ERR (clk)) { -pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk); -continue ; - } + clk =mtk_clk_register_mux (mux, regmap, lock); - clk_data->clks[mux->id] = clk; +if (IS_ERR (clk)) { +pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk); +continue ; } + + clk_data->clks[mux->id] = clk; }return 0 ;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 23/31] clk: mediatek: mux: Reverse check for existing clk to reduce nesting level
Quoted 8 lines · Chen-Yu Tsai
The clk registration code here currently does:
if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { ... do clk registration ... }This extra level of nesting wastes screen real estate.
Quoted 7 lines
Reduce the nesting level by reversing the conditional shown above. Other than that, functionality is not changed.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 37 lines
--- drivers/clk/mediatek/clk-mux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/clk/mediatek/clk-mux.c +8
-7@@ -208,16 +208,17 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, for (i = 0; i < num; i++) {const struct mtk_mux *mux = &muxes[i]; -if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) { - clk =mtk_clk_register_mux (mux, regmap, lock); +if (!IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; -if (IS_ERR (clk)) { - pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; - } + clk =mtk_clk_register_mux (mux, regmap, lock); - clk_data->clks[mux->id] = clk; +if (IS_ERR (clk)) { +pr_err ("Failed to register clk %s: %pe\n" , mux- >name, clk); +continue ; } + + clk_data->clks[mux->id] = clk;drivers/clk/mediatek/clk-mux.c +0
-0}return 0 ;
Re: [PATCH v3 23/31] clk: mediatek: mux: Reverse check for existing clk to reduce nesting level
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:26)
Quoted 8 lines
The clk registration code here currently does:
if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { ... do clk registration ... }This extra level of nesting wastes screen real estate.
Quoted 7 lines
Reduce the nesting level by reversing the conditional shown above. Other than that, functionality is not changed.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 24/31 clk: mediatek: mux: Implement error handling in register API
In reply to Chen-Yu TsaiThe mux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
--- drivers/clk/mediatek/clk-mux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mux.c +14 -1
@@ -215,13 +215,26 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk); -continue ; + goto err; } clk_data->clks[mux->id] = clk; }return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_mux *mux = &muxes[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_mux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); }EXPORT_SYMBOL_GPL (mtk_clk_register_muxes);
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 24/31] clk: mediatek: mux: Implement error handling in register API
Quoted 5 lines · Chen-Yu Tsai
The mux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Quoted 8 lines
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 39 lines
--- drivers/clk/mediatek/clk-mux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-mux.c +14
-1@@ -215,13 +215,26 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , mux- >name, clk); -continue ; + goto err; } clk_data->clks[mux->id] = clk; }return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_mux *mux = &muxes[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mux->id])) +continue ; + +mtk_clk_unregister_mux (clk_data->clks[mux->id]); + clk_data->clks[mux->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); }
EXPORT_SYMBOL_GPL(mtk_clk_register_muxes);
Re: [PATCH v3 24/31] clk: mediatek: mux: Implement error handling in register API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:27)
Quoted 5 lines
The mux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Quoted 8 lines
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 25/31 clk: mediatek: pll: Implement error handling in register API
In reply to Chen-Yu TsaiThe pll clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, and unmap the I/O space, is done in the new error path.
--- drivers/clk/mediatek/clk-pll.c | 23 +++++++++++++++++++---- drivers/clk/mediatek/clk-pll.h | 6 +++--- 2 files changed, 22 insertions(+), 7 deletions(-)
drivers/clk/mediatek/clk-pll.c +19 -4
@@ -377,8 +377,9 @@ static void mtk_clk_unregister_pll(struct clk *clk)kfree (pll); } -void mtk_clk_register_plls (struct device_node *node, -const struct mtk_pll_data *plls,int num_plls,struct clk_onecell_data *clk_data) +int mtk_clk_register_plls (struct device_node *node, +const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data) {void __iomem *base;int i;
@@ -387,7 +388,7 @@ void mtk_clk_register_plls(struct device_node *node, base =of_iomap (node,0 );if (!base) {pr_err ("%s(): ioremap failed\n" , __func__); -return ; +return -EINVAL ; }for (i =0 ; i < num_plls; i++) {
@@ -397,11 +398,25 @@ void mtk_clk_register_plls(struct device_node *node,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , pll->name, clk); -continue ; + goto err; } clk_data->clks[pll->id] = clk; } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_pll_data *pll = &plls[i]; + +mtk_clk_unregister_pll (clk_data->clks[pll->id]); + clk_data->clks[pll->id] =ERR_PTR (-ENOENT ); + } + +iounmap (base); + +return PTR_ERR (clk); }EXPORT_SYMBOL_GPL (mtk_clk_register_plls);
drivers/clk/mediatek/clk-pll.h +3 -3
@@ -48,9 +48,9 @@ struct mtk_pll_data {u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ }; -void mtk_clk_register_plls (struct device_node *node, -const struct mtk_pll_data *plls,int num_plls, -struct clk_onecell_data *clk_data); +int mtk_clk_register_plls (struct device_node *node, +const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data);void mtk_clk_unregister_plls (const struct mtk_pll_data *plls,int num_plls,struct clk_onecell_data *clk_data);
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 25/31] clk: mediatek: pll: Implement error handling in register API
Quoted 10 lines · Chen-Yu Tsai
The pll clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, and unmap the I/O space, is done in the new error path.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 85 lines
--- drivers/clk/mediatek/clk-pll.c | 23 +++++++++++++++++++---- drivers/clk/mediatek/clk-pll.h | 6 +++--- 2 files changed, 22 insertions(+), 7 deletions(-)drivers/clk/mediatek/clk-pll.c +3
-2@@ -377,8 +377,9 @@ static void mtk_clk_unregister_pll(struct clk *clk)kfree (pll); } -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data) +int mtk_clk_register_plls (struct device_node *node, +const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data){
drivers/clk/mediatek/clk-pll.c +1
-1void __iomem *base;int i;@@ -387,7 +388,7 @@ void mtk_clk_register_plls(struct device_node *node, base =of_iomap (node,0 );if (!base) {pr_err ("%s(): ioremap failed\n" , __func__); -return ; +return -EINVAL ; }drivers/clk/mediatek/clk-pll.c +15
-1for (i =0 ; i < num_plls; i++) {@@ -397,11 +398,25 @@ void mtk_clk_register_plls(struct device_node *node, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , pll- >name, clk); -continue ; + goto err; } clk_data->clks[pll->id] = clk; } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_pll_data *pll = &plls[i]; + +mtk_clk_unregister_pll (clk_data->clks[pll->id]); + clk_data->clks[pll->id] =ERR_PTR (-ENOENT ); + } + +iounmap (base); + +return PTR_ERR (clk); }
EXPORT_SYMBOL_GPL(mtk_clk_register_plls);drivers/clk/mediatek/clk-pll.h +3
-3@@ -48,9 +48,9 @@ struct mtk_pll_data {u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ }; -void mtk_clk_register_plls (struct device_node *node, -const struct mtk_pll_data *plls,int num_plls, -struct clk_onecell_data *clk_data); +int mtk_clk_register_plls (struct device_node *node, +const struct mtk_pll_data *plls,int num_plls, +struct clk_onecell_data *clk_data); void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int
num_plls,
structclk_onecell_data*clk_data);
Re: [PATCH v3 25/31] clk: mediatek: pll: Implement error handling in register API
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:28)
Quoted 10 lines
The pll clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed.
Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, and unmap the I/O space, is done in the new error path.
Quoted 4 lines
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 26/31 clk: mediatek: mtk: Implement error handling in register APIs
In reply to Chen-Yu TsaiThe remaining clk registration functions do not stop or return errors if any clk failed to be registered, nor do they implement error handling paths. This may result in a partially working device if any step fails.
Make the register functions return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
This also makes the |struct clk_data *| argument mandatory, as it is used to track the list of clks registered.
--- drivers/clk/mediatek/clk-mtk.c | 118 ++++++++++++++++++++++++++------- drivers/clk/mediatek/clk-mtk.h | 20 +++--- 2 files changed, 103 insertions(+), 35 deletions(-)
drivers/clk/mediatek/clk-mtk.c +93 -25
@@ -53,16 +53,19 @@ void mtk_free_clk_data(struct clk_onecell_data *clk_data)kfree (clk_data); } -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks, -int num,struct clk_onecell_data *clk_data) +int mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data) {int i;struct clk *clk; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_fixed_clk *rc = &clks[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[rc->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[rc->id]))continue ; clk = clk_register_fixed_rate(NULL, rc->name, rc->parent, 0,
@@ -70,12 +73,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , rc->name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[rc->id] = clk; + clk_data->clks[rc->id] = clk; } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_fixed_clk *rc = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[rc->id])) +continue ; + +clk_unregister_fixed_rate (clk_data->clks[rc->id]); + clk_data->clks[rc->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); }EXPORT_SYMBOL_GPL (mtk_clk_register_fixed_clks);
@@ -99,16 +116,19 @@ void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num, }EXPORT_SYMBOL_GPL (mtk_clk_unregister_fixed_clks); -void mtk_clk_register_factors (const struct mtk_fixed_factor *clks, -int num,struct clk_onecell_data *clk_data) +int mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data) {int i;struct clk *clk; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_fixed_factor *ff = &clks[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[ff->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[ff->id]))continue ; clk = clk_register_fixed_factor(NULL, ff->name, ff->parent_name,
@@ -116,12 +136,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , ff->name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[ff->id] = clk; + clk_data->clks[ff->id] = clk; + } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_fixed_factor *ff = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[ff->id])) +continue ; + +clk_unregister_fixed_factor (clk_data->clks[ff->id]); + clk_data->clks[ff->id] =ERR_PTR (-ENOENT ); } + +return PTR_ERR (clk); }EXPORT_SYMBOL_GPL (mtk_clk_register_factors);
@@ -258,13 +292,16 @@ static void mtk_clk_unregister_composite(struct clk *clk)kfree (mux); } -void mtk_clk_register_composites (const struct mtk_composite *mcs, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data) +int mtk_clk_register_composites (const struct mtk_composite *mcs,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data) {struct clk *clk;int i; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_composite *mc = &mcs[i];
@@ -275,12 +312,26 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , mc->name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[mc->id] = clk; + clk_data->clks[mc->id] = clk; + } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_composite *mc = &mcs[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mcs->id])) +continue ; + +mtk_clk_unregister_composite (clk_data->clks[mc->id]); + clk_data->clks[mc->id] =ERR_PTR (-ENOENT ); } + +return PTR_ERR (clk); }EXPORT_SYMBOL_GPL (mtk_clk_register_composites);
@@ -304,17 +355,20 @@ void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num, }EXPORT_SYMBOL_GPL (mtk_clk_unregister_composites); -void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data) +int mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data) {struct clk *clk;int i; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_clk_divider *mcd = &mcds[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[mcd->id]))continue ; clk = clk_register_divider(NULL, mcd->name, mcd->parent_name,
@@ -323,12 +377,26 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds,if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , mcd->name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[mcd->id] = clk; + clk_data->clks[mcd->id] = clk; + } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_clk_divider *mcd = &mcds[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +continue ; + +mtk_clk_unregister_composite (clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] =ERR_PTR (-ENOENT ); } + +return PTR_ERR (clk); } void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num,
drivers/clk/mediatek/clk-mtk.h +10 -10
@@ -34,8 +34,8 @@ struct mtk_fixed_clk { .rate = _rate, \ } -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, -struct clk_onecell_data *clk_data); +int mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data);void mtk_clk_unregister_fixed_clks (const struct mtk_fixed_clk *clks,int num,struct clk_onecell_data *clk_data);
@@ -55,8 +55,8 @@ struct mtk_fixed_factor { .div = _div, \ } -void mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, -struct clk_onecell_data *clk_data); +int mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data);void mtk_clk_unregister_factors (const struct mtk_fixed_factor *clks,int num,struct clk_onecell_data *clk_data);
@@ -150,9 +150,9 @@ struct mtk_composite {struct clk *mtk_clk_register_composite (const struct mtk_composite *mc,void __iomem *base,spinlock_t *lock); -void mtk_clk_register_composites (const struct mtk_composite *mcs, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data); +int mtk_clk_register_composites (const struct mtk_composite *mcs,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data);void mtk_clk_unregister_composites (const struct mtk_composite *mcs,int num,struct clk_onecell_data *clk_data);
@@ -178,9 +178,9 @@ struct mtk_clk_divider { .div_width = _width, \ } -void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, -void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data); +int mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data);void mtk_clk_unregister_dividers (const struct mtk_clk_divider *mcds,int num,struct clk_onecell_data *clk_data);
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 26/31] clk: mediatek: mtk: Implement error handling in register APIs
Quoted 10 lines · Chen-Yu Tsai
The remaining clk registration functions do not stop or return errors if any clk failed to be registered, nor do they implement error handling paths. This may result in a partially working device if any step fails.
Make the register functions return proper error codes, and bail out if
errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Quoted 7 lines
This also makes the |struct
clk_data*| argument mandatory, as it is used to track the list of clks registered.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 310 lines
--- drivers/clk/mediatek/clk-mtk.c | 118 ++++++++++++++++++++++++++----- -- drivers/clk/mediatek/clk-mtk.h | 20 +++--- 2 files changed, 103 insertions(+), 35 deletions(-)drivers/clk/mediatek/clk-mtk.c +6
-3@@ -53,16 +53,19 @@ void mtk_free_clk_data(struct clk_onecell_data *clk_data)kfree (clk_data); } -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks, -int num,struct clk_onecell_data *clk_data) +int mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data) {int i;struct clk *clk; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_fixed_clk *rc = &clks[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[rc- >id])) +if (!IS_ERR_OR_NULL (clk_data->clks[rc->id]))drivers/clk/mediatek/clk-mtk.c +0
-0continue ; clk = clk_register_fixed_rate(NULL, rc->name, rc-Quoted 1 line
parent, 0,
drivers/clk/mediatek/clk-mtk.c +17
-3@@ -70,12 +73,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , rc- >name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[rc->id] = clk; + clk_data->clks[rc->id] = clk; } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_fixed_clk *rc = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[rc->id])) +continue ; + +clk_unregister_fixed_rate (clk_data->clks[rc->id]); + clk_data->clks[rc->id] =ERR_PTR (-ENOENT ); + } + +return PTR_ERR (clk); }
EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks);drivers/clk/mediatek/clk-mtk.c +6
-3@@ -99,16 +116,19 @@ void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num, }EXPORT_SYMBOL_GPL (mtk_clk_unregister_fixed_clks ); -void mtk_clk_register_factors (const struct mtk_fixed_factor *clks, -int num,struct clk_onecell_data *clk_data) +int mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data) {int i;struct clk *clk; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_fixed_factor *ff = &clks[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[ff- >id])) +if (!IS_ERR_OR_NULL (clk_data->clks[ff->id]))drivers/clk/mediatek/clk-mtk.c +0
-0continue ; clk = clk_register_fixed_factor(NULL, ff->name, ff-Quoted 1 line
parent_name,drivers/clk/mediatek/clk-mtk.c +17
-3@@ -116,12 +136,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , ff- >name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[ff->id] = clk; + clk_data->clks[ff->id] = clk; + } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_fixed_factor *ff = &clks[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[ff->id])) +continue ; + +clk_unregister_fixed_factor (clk_data->clks[ff->id]); + clk_data->clks[ff->id] =ERR_PTR (-ENOENT ); } + +return PTR_ERR (clk); }
EXPORT_SYMBOL_GPL(mtk_clk_register_factors);drivers/clk/mediatek/clk-mtk.c +6
-3@@ -258,13 +292,16 @@ static void mtk_clk_unregister_composite(struct clk *clk)kfree (mux ); } -void mtk_clk_register_composites (const struct mtk_composite *mcs, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data) +int mtk_clk_register_composites (const struct mtk_composite *mcs,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data) {struct clk *clk;int i; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {drivers/clk/mediatek/clk-mtk.c +17
-3const struct mtk_composite *mc = &mcs[i];@@ -275,12 +312,26 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , mc- >name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[mc->id] = clk; + clk_data->clks[mc->id] = clk; + } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_composite *mc = &mcs[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mcs->id])) +continue ; + +mtk_clk_unregister_composite (clk_data->clks[mc->id]); + clk_data->clks[mc->id] =ERR_PTR (-ENOENT ); } + +return PTR_ERR (clk); }
EXPORT_SYMBOL_GPL(mtk_clk_register_composites);drivers/clk/mediatek/clk-mtk.c +7
-4@@ -304,17 +355,20 @@ void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num, }EXPORT_SYMBOL_GPL (mtk_clk_unregister_composites ); -void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data) +int mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data) {struct clk *clk;int i; +if (!clk_data) +return -ENOMEM ; +for (i =0 ; i < num; i++) {const struct mtk_clk_divider *mcd = &mcds[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[mcd- >id])) +if (!IS_ERR_OR_NULL (clk_data->clks[mcd->id]))drivers/clk/mediatek/clk-mtk.c +0
-0continue ; clk = clk_register_divider(NULL, mcd->name, mcd-Quoted 1 line
parent_name,drivers/clk/mediatek/clk-mtk.c +17
-3@@ -323,12 +377,26 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, if (IS_ERR(clk)) {pr_err ("Failed to register clk %s: %pe\n" , mcd- >name, clk); -continue ; + goto err; } -if (clk_data) - clk_data->clks[mcd->id] = clk; + clk_data->clks[mcd->id] = clk; + } + +return 0 ; + +err: +while (--i >=0 ) { +const struct mtk_clk_divider *mcd = &mcds[i]; + +if (IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +continue ; + +mtk_clk_unregister_composite (clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] =ERR_PTR (-ENOENT ); } + +return PTR_ERR (clk); }void mtk_clk_unregister_dividers(const struct
mtk_clk_divider*mcds,
int num,drivers/clk/mediatek/clk-mtk.h +2
-2@@ -34,8 +34,8 @@ struct mtk_fixed_clk { .rate = _rate, \ } -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num, -struct clk_onecell_data *clk_data); +int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,int num, +struct clk_onecell_data *clk_data); void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks,int num,
drivers/clk/mediatek/clk-mtk.h +2
-2struct clk_onecell_data *clk_data);@@ -55,8 +55,8 @@ struct mtk_fixed_factor { .div = _div, \ } -void mtk_clk_register_factors (const struct mtk_fixed_factor *clks,int num, -struct clk_onecell_data *clk_data); +int mtk_clk_register_factors(const struct mtk_fixed_factor *clks,int num, +struct clk_onecell_data *clk_data); void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks,int num,
drivers/clk/mediatek/clk-mtk.h +3
-3struct clk_onecell_data *clk_data);@@ -150,9 +150,9 @@ struct mtk_composite {struct clk *mtk_clk_register_composite (const struct mtk_composite *mc,void __iomem *base,spinlock_t *lock); -void mtk_clk_register_composites (const struct mtk_composite *mcs, -int num,void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data); +int mtk_clk_register_composites (const struct mtk_composite *mcs,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data); void mtk_clk_unregister_composites(const struct mtk_composite *mcs,int num,
drivers/clk/mediatek/clk-mtk.h +3
-3struct clk_onecell_data *clk_data);@@ -178,9 +178,9 @@ struct mtk_clk_divider { .div_width = _width, \ } -void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds,int num, -void __iomem *base,spinlock_t *lock, -struct clk_onecell_data *clk_data); +int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds,int num, +void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data); void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds,int num,
structclk_onecell_data*clk_data);
Re: [PATCH v3 26/31] clk: mediatek: mtk: Implement error handling in register APIs
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:29)
Quoted 9 lines
The remaining clk registration functions do not stop or return errors if any clk failed to be registered, nor do they implement error handling paths. This may result in a partially working device if any step fails.
Make the register functions return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path.
Quoted 7 lines
This also makes the |struct
clk_data*| argument mandatory, as it is used to track the list of clks registered.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 27/31 clk: mediatek: Unregister clks in mtk_clk_simple_probe() error path
In reply to Chen-Yu TsaiUntil now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths.
Now that the library does have APIs to unregister clks, use them in the error path of mtk_clk_simple_probe() to do proper cleanup.
--- drivers/clk/mediatek/clk-mtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mtk.c +3 -1
@@ -439,12 +439,14 @@ int mtk_clk_simple_probe(struct platform_device *pdev) r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r) - goto free_data; + goto unregister_clks;platform_set_drvdata (pdev, clk_data);return r; +unregister_clks: +mtk_clk_unregister_gates (mcd->clks, mcd->num_clks, clk_data); free_data:mtk_free_clk_data (clk_data);return r;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 27/31] clk: mediatek: Unregister clks in mtk_clk_simple_probe() error path
Quoted 11 lines · Chen-Yu Tsai
Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths.
Now that the library does have APIs to unregister clks, use them in the error path of
mtk_clk_simple_probe()to do proper cleanup.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <
Quoted 27 lines
--- drivers/clk/mediatek/clk-mtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-mtk.c +3
-1@@ -439,12 +439,14 @@ int mtk_clk_simple_probe(struct platform_device *pdev) r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r) - goto free_data; + goto unregister_clks;platform_set_drvdata (pdev, clk_data);return r; +unregister_clks: +mtk_clk_unregister_gates (mcd->clks, mcd->num_clks, clk_data); free_data:drivers/clk/mediatek/clk-mtk.c +0
-0mtk_free_clk_data (clk_data);return r;
Re: [PATCH v3 27/31] clk: mediatek: Unregister clks in mtk_clk_simple_probe() error path
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:30)
Quoted 11 lines
Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths.
Now that the library does have APIs to unregister clks, use them in the error path of
mtk_clk_simple_probe()to do proper cleanup.Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
PATCH v3 28/31 clk: mediatek: mt8195: Hook up mtk_clk_simple_remove()
In reply to Chen-Yu TsaiVarious small clock controllers only have clock gates, and utilize mtk_clk_simple_probe() as their driver probe function.
Now that we have a matching remove function, hook it up for the relevant drivers. This was done with the following command:
sed -i -e '/mtk_clk_simple_probe/a \
.remove = mtk_clk_simple_remove,' drivers/clk/mediatek/clk-mt8195-*.c--- drivers/clk/mediatek/clk-mt8195-cam.c | 1 + drivers/clk/mediatek/clk-mt8195-ccu.c | 1 + drivers/clk/mediatek/clk-mt8195-img.c | 1 + drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8195-infra_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-ipe.c | 1 + drivers/clk/mediatek/clk-mt8195-mfg.c | 1 + drivers/clk/mediatek/clk-mt8195-peri_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8195-vdec.c | 1 + drivers/clk/mediatek/clk-mt8195-venc.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp0.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp1.c | 1 + drivers/clk/mediatek/clk-mt8195-wpe.c | 1 + 14 files changed, 14 insertions(+)
drivers/clk/mediatek/clk-mt8195-cam.c +1 -0
@@ -134,6 +134,7 @@ static const struct of_device_id of_match_clk_mt8195_cam[] = {static struct platform_driver clk_mt8195_cam_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-cam" , .of_match_table = of_match_clk_mt8195_cam,
drivers/clk/mediatek/clk-mt8195-ccu.c +1 -0
@@ -42,6 +42,7 @@ static const struct of_device_id of_match_clk_mt8195_ccu[] = {static struct platform_driver clk_mt8195_ccu_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-ccu" , .of_match_table = of_match_clk_mt8195_ccu,
drivers/clk/mediatek/clk-mt8195-img.c +1 -0
@@ -88,6 +88,7 @@ static const struct of_device_id of_match_clk_mt8195_img[] = {static struct platform_driver clk_mt8195_img_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-img" , .of_match_table = of_match_clk_mt8195_img,
drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c +1 -0
@@ -58,6 +58,7 @@ static const struct of_device_id of_match_clk_mt8195_imp_iic_wrap[] = {static struct platform_driver clk_mt8195_imp_iic_wrap_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-imp_iic_wrap" , .of_match_table = of_match_clk_mt8195_imp_iic_wrap,
drivers/clk/mediatek/clk-mt8195-infra_ao.c +1 -0
@@ -198,6 +198,7 @@ static const struct of_device_id of_match_clk_mt8195_infra_ao[] = {static struct platform_driver clk_mt8195_infra_ao_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-infra_ao" , .of_match_table = of_match_clk_mt8195_infra_ao,
drivers/clk/mediatek/clk-mt8195-ipe.c +1 -0
@@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt8195_ipe[] = {static struct platform_driver clk_mt8195_ipe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-ipe" , .of_match_table = of_match_clk_mt8195_ipe,
drivers/clk/mediatek/clk-mt8195-mfg.c +1 -0
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_mfg[] = {static struct platform_driver clk_mt8195_mfg_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-mfg" , .of_match_table = of_match_clk_mt8195_mfg,
drivers/clk/mediatek/clk-mt8195-peri_ao.c +1 -0
@@ -54,6 +54,7 @@ static const struct of_device_id of_match_clk_mt8195_peri_ao[] = {static struct platform_driver clk_mt8195_peri_ao_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-peri_ao" , .of_match_table = of_match_clk_mt8195_peri_ao,
drivers/clk/mediatek/clk-mt8195-scp_adsp.c +1 -0
@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_scp_adsp[] = {static struct platform_driver clk_mt8195_scp_adsp_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-scp_adsp" , .of_match_table = of_match_clk_mt8195_scp_adsp,
drivers/clk/mediatek/clk-mt8195-vdec.c +1 -0
@@ -96,6 +96,7 @@ static const struct of_device_id of_match_clk_mt8195_vdec[] = {static struct platform_driver clk_mt8195_vdec_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-vdec" , .of_match_table = of_match_clk_mt8195_vdec,
drivers/clk/mediatek/clk-mt8195-venc.c +1 -0
@@ -61,6 +61,7 @@ static const struct of_device_id of_match_clk_mt8195_venc[] = {static struct platform_driver clk_mt8195_venc_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-venc" , .of_match_table = of_match_clk_mt8195_venc,
drivers/clk/mediatek/clk-mt8195-vpp0.c +1 -0
@@ -102,6 +102,7 @@ static const struct of_device_id of_match_clk_mt8195_vpp0[] = {static struct platform_driver clk_mt8195_vpp0_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-vpp0" , .of_match_table = of_match_clk_mt8195_vpp0,
drivers/clk/mediatek/clk-mt8195-vpp1.c +1 -0
@@ -100,6 +100,7 @@ static const struct of_device_id of_match_clk_mt8195_vpp1[] = {static struct platform_driver clk_mt8195_vpp1_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-vpp1" , .of_match_table = of_match_clk_mt8195_vpp1,
drivers/clk/mediatek/clk-mt8195-wpe.c +1 -0
@@ -135,6 +135,7 @@ static const struct of_device_id of_match_clk_mt8195_wpe[] = {static struct platform_driver clk_mt8195_wpe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-wpe" , .of_match_table = of_match_clk_mt8195_wpe,
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 28/31] clk: mediatek: mt8195: Hook up mtk_clk_simple_remove()
Il 08/02/22 13:40, Chen-Yu Tsai ha scritto:
Quoted 11 lines
Various small clock controllers only have clock gates, and utilize
mtk_clk_simple_probe()as their driver probe function.Now that we have a matching remove function, hook it up for the relevant drivers. This was done with the following command:
sed -i -e '/mtk_clk_simple_probe/a \ .remove = mtk_clk_simple_remove,' drivers/clk/mediatek/clk-mt8195-*.cSigned-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>
Re: [PATCH v3 28/31] clk: mediatek: mt8195: Hook up mtk_clk_simple_remove()
In reply to Chen-Yu TsaiQuoted 7 lines · Chen-Yu Tsai
Various small clock controllers only have clock gates, and utilize
mtk_clk_simple_probe()as their driver probe function.Now that we have a matching remove function, hook it up for the relevant
drivers. This was done with the following command:
Quoted 6 lines
sed -i -e '/mtk_clk_simple_probe/a \
.remove =mtk_clk_simple_remove,'drivers/clk/mediatek/clk-
mt8195-*.cSigned-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>
Quoted 213 lines
--- drivers/clk/mediatek/clk-mt8195-cam.c | 1 + drivers/clk/mediatek/clk-mt8195-ccu.c | 1 + drivers/clk/mediatek/clk-mt8195-img.c | 1 + drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8195-infra_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-ipe.c | 1 + drivers/clk/mediatek/clk-mt8195-mfg.c | 1 + drivers/clk/mediatek/clk-mt8195-peri_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8195-vdec.c | 1 + drivers/clk/mediatek/clk-mt8195-venc.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp0.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp1.c | 1 + drivers/clk/mediatek/clk-mt8195-wpe.c | 1 + 14 files changed, 14 insertions(+)drivers/clk/mediatek/clk-mt8195-cam.c +1
-0@@ -134,6 +134,7 @@ static const struct of_device_id of_match_clk_mt8195_cam[] = {static struct platform_driver clk_mt8195_cam_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-cam" ,drivers/clk/mediatek/clk-mt8195-cam.c +0
-0.of_match_table = of_match_clk_mt8195_cam,drivers/clk/mediatek/clk-mt8195-ccu.c +1
-0@@ -42,6 +42,7 @@ static const struct of_device_id of_match_clk_mt8195_ccu[] = {static struct platform_driver clk_mt8195_ccu_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-ccu" ,drivers/clk/mediatek/clk-mt8195-ccu.c +0
-0.of_match_table = of_match_clk_mt8195_ccu,drivers/clk/mediatek/clk-mt8195-img.c +1
-0@@ -88,6 +88,7 @@ static const struct of_device_id of_match_clk_mt8195_img[] = {static struct platform_driver clk_mt8195_img_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-img" ,drivers/clk/mediatek/clk-mt8195-img.c +0
-0.of_match_table = of_match_clk_mt8195_img,drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c +1
-0@@ -58,6 +58,7 @@ static const struct of_device_id of_match_clk_mt8195_imp_iic_wrap[] = {static struct platform_driver clk_mt8195_imp_iic_wrap_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-imp_iic_wrap" ,drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c +0
-0.of_match_table = of_match_clk_mt8195_imp_iic_wrap,drivers/clk/mediatek/clk-mt8195-infra_ao.c +1
-0@@ -198,6 +198,7 @@ static const struct of_device_id of_match_clk_mt8195_infra_ao[] = {static struct platform_driver clk_mt8195_infra_ao_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-infra_ao" ,drivers/clk/mediatek/clk-mt8195-infra_ao.c +0
-0.of_match_table = of_match_clk_mt8195_infra_ao,drivers/clk/mediatek/clk-mt8195-ipe.c +1
-0@@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt8195_ipe[] = {static struct platform_driver clk_mt8195_ipe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-ipe" ,drivers/clk/mediatek/clk-mt8195-ipe.c +0
-0.of_match_table = of_match_clk_mt8195_ipe,drivers/clk/mediatek/clk-mt8195-mfg.c +1
-0@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_mfg[] = {static struct platform_driver clk_mt8195_mfg_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-mfg" ,drivers/clk/mediatek/clk-mt8195-mfg.c +0
-0.of_match_table = of_match_clk_mt8195_mfg,drivers/clk/mediatek/clk-mt8195-peri_ao.c +1
-0@@ -54,6 +54,7 @@ static const struct of_device_id of_match_clk_mt8195_peri_ao[] = {static struct platform_driver clk_mt8195_peri_ao_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-peri_ao" ,drivers/clk/mediatek/clk-mt8195-peri_ao.c +0
-0.of_match_table = of_match_clk_mt8195_peri_ao,drivers/clk/mediatek/clk-mt8195-scp_adsp.c +1
-0@@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_scp_adsp[] = {static struct platform_driver clk_mt8195_scp_adsp_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-scp_adsp" ,drivers/clk/mediatek/clk-mt8195-scp_adsp.c +0
-0.of_match_table = of_match_clk_mt8195_scp_adsp,drivers/clk/mediatek/clk-mt8195-vdec.c +1
-0@@ -96,6 +96,7 @@ static const struct of_device_id of_match_clk_mt8195_vdec[] = {static struct platform_driver clk_mt8195_vdec_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-vdec" ,drivers/clk/mediatek/clk-mt8195-vdec.c +0
-0.of_match_table = of_match_clk_mt8195_vdec,drivers/clk/mediatek/clk-mt8195-venc.c +1
-0@@ -61,6 +61,7 @@ static const struct of_device_id of_match_clk_mt8195_venc[] = {static struct platform_driver clk_mt8195_venc_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-venc" ,drivers/clk/mediatek/clk-mt8195-venc.c +0
-0.of_match_table = of_match_clk_mt8195_venc,drivers/clk/mediatek/clk-mt8195-vpp0.c +1
-0@@ -102,6 +102,7 @@ static const struct of_device_id of_match_clk_mt8195_vpp0[] = {static struct platform_driver clk_mt8195_vpp0_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-vpp0" ,drivers/clk/mediatek/clk-mt8195-vpp0.c +0
-0.of_match_table = of_match_clk_mt8195_vpp0,drivers/clk/mediatek/clk-mt8195-vpp1.c +1
-0@@ -100,6 +100,7 @@ static const struct of_device_id of_match_clk_mt8195_vpp1[] = {static struct platform_driver clk_mt8195_vpp1_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-vpp1" ,drivers/clk/mediatek/clk-mt8195-vpp1.c +0
-0.of_match_table = of_match_clk_mt8195_vpp1,drivers/clk/mediatek/clk-mt8195-wpe.c +1
-0@@ -135,6 +135,7 @@ static const struct of_device_id of_match_clk_mt8195_wpe[] = {static struct platform_driver clk_mt8195_wpe_drv = { .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, .driver = { .name ="clk-mt8195-wpe" ,.of_match_table =
of_match_clk_mt8195_wpe,
Re: [PATCH v3 28/31] clk: mediatek: mt8195: Hook up mtk_clk_simple_remove()
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:31)
Quoted 6 lines
Various small clock controllers only have clock gates, and utilize
mtk_clk_simple_probe()as their driver probe function.Now that we have a matching remove function, hook it up for the relevant drivers. This was done with the following command:
Quoted 6 lines
sed -i -e '/mtk_clk_simple_probe/a \ .remove = mtk_clk_simple_remove,' drivers/clk/mediatek/clk-mt8195-*.cSigned-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>---
Applied to clk-next
PATCH v3 29/31 clk: mediatek: mt8195: Implement error handling in probe functions
In reply to Chen-Yu TsaiUntil now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths.
Now that the library does have APIs to unregister clks, use them in the error path of the probe functions for the mt8195 clk drivers to do proper cleanup.
--- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 13 ++++-- drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 9 +++- drivers/clk/mediatek/clk-mt8195-topckgen.c | 49 +++++++++++++++----- drivers/clk/mediatek/clk-mt8195-vdo0.c | 4 +- drivers/clk/mediatek/clk-mt8195-vdo1.c | 4 +- 5 files changed, 61 insertions(+), 18 deletions(-)
drivers/clk/mediatek/clk-mt8195-apmixedsys.c +10 -3
@@ -120,17 +120,24 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)if (!clk_data)return -ENOMEM ; -mtk_clk_register_plls (node, plls,ARRAY_SIZE (plls), clk_data); - r =mtk_clk_register_gates (node, apmixed_clks,ARRAY_SIZE (apmixed_clks), clk_data); + r =mtk_clk_register_plls (node, plls,ARRAY_SIZE (plls), clk_data);if (r) goto free_apmixed_data; + r =mtk_clk_register_gates (node, apmixed_clks,ARRAY_SIZE (apmixed_clks), clk_data); +if (r) + goto unregister_plls; + r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r) - goto free_apmixed_data; + goto unregister_gates;return r; +unregister_gates: +mtk_clk_unregister_gates (apmixed_clks,ARRAY_SIZE (apmixed_clks), clk_data); +unregister_plls: +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); free_apmixed_data:mtk_free_clk_data (clk_data);return r;
drivers/clk/mediatek/clk-mt8195-apusys_pll.c +7 -2
@@ -66,13 +66,18 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev)if (!clk_data)return -ENOMEM ; -mtk_clk_register_plls (node, apusys_plls,ARRAY_SIZE (apusys_plls), clk_data); - r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); + r =mtk_clk_register_plls (node, apusys_plls,ARRAY_SIZE (apusys_plls), clk_data);if (r) goto free_apusys_pll_data; + r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +if (r) + goto unregister_plls; +return r; +unregister_plls: +mtk_clk_unregister_plls (apusys_plls,ARRAY_SIZE (apusys_plls), clk_data); free_apusys_pll_data:mtk_free_clk_data (clk_data);return r;
drivers/clk/mediatek/clk-mt8195-topckgen.c +38 -11
63 lines not on this page · raw message
drivers/clk/mediatek/clk-mt8195-vdo0.c +3 -1
@@ -105,10 +105,12 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev) r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r) - goto free_vdo0_data; + goto unregister_gates;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;
drivers/clk/mediatek/clk-mt8195-vdo1.c +3 -1
@@ -122,10 +122,12 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev) r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r) - goto free_vdo1_data; + goto unregister_gates;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;
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 29/31] clk: mediatek: mt8195: Implement error handling in probe functions
Il 08/02/22 13:40, Chen-Yu Tsai ha scritto:
Quoted 9 lines
Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths.
Now that the library does have APIs to unregister clks, use them in the error path of the probe functions for the mt8195 clk drivers to do proper cleanup.
Signed-off-by Chen-Yu Tsai <[email protected]>
Re: [PATCH v3 29/31] clk: mediatek: mt8195: Implement error handling in probe functions
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:32)
Quoted 10 lines
Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths.
Now that the library does have APIs to unregister clks, use them in the error path of the probe functions for the mt8195 clk drivers to do proper cleanup.
Signed-off-by Chen-Yu Tsai <[email protected]>---
Applied to clk-next
PATCH v3 30/31 clk: mediatek: mt8195: Implement remove functions
In reply to Chen-Yu TsaiUntil now the mediatek clk driver library did not have any way to unregister clks, and so none of the drivers implemented remove functions.
Now that the library does have APIs to unregister clks, use them to implement remove functions for the mt8195 clk drivers.
--- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 15 +++++++++++++++ drivers/clk/mediatek/clk-mt8195-topckgen.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mt8195-vdo0.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mt8195-vdo1.c | 16 ++++++++++++++++ 5 files changed, 83 insertions(+)
drivers/clk/mediatek/clk-mt8195-apmixedsys.c +16 -0
@@ -132,6 +132,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)if (r) goto unregister_gates; +platform_set_drvdata (pdev, clk_data); +return r; unregister_gates:
@@ -143,8 +145,22 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)return r; } +static int clk_mt8195_apmixed_remove (struct platform_device *pdev) +{ +struct device_node *node = pdev->dev.of_node; +struct clk_onecell_data *clk_data =platform_get_drvdata (pdev); + +of_clk_del_provider (node); +mtk_clk_unregister_gates (apmixed_clks,ARRAY_SIZE (apmixed_clks), clk_data); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +mtk_free_clk_data (clk_data); + +return 0 ; +} +static struct platform_driver clk_mt8195_apmixed_drv = { .probe = clk_mt8195_apmixed_probe, + .remove = clk_mt8195_apmixed_remove, .driver = { .name ="clk-mt8195-apmixed" , .of_match_table = of_match_clk_mt8195_apmixed,
drivers/clk/mediatek/clk-mt8195-apusys_pll.c +15 -0
@@ -74,6 +74,8 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev)if (r) goto unregister_plls; +platform_set_drvdata (pdev, clk_data); +return r; unregister_plls:
@@ -83,6 +85,18 @@ static int clk_mt8195_apusys_pll_probe(struct platform_device *pdev)return r; } +static int clk_mt8195_apusys_pll_remove (struct platform_device *pdev) +{ +struct clk_onecell_data *clk_data =platform_get_drvdata (pdev); +struct device_node *node = pdev->dev.of_node; + +of_clk_del_provider (node); +mtk_clk_unregister_plls (apusys_plls,ARRAY_SIZE (apusys_plls), clk_data); +mtk_free_clk_data (clk_data); + +return 0 ; +} +static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = { { .compatible ="mediatek,mt8195-apusys_pll" , }, {}
@@ -90,6 +104,7 @@ static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = {static struct platform_driver clk_mt8195_apusys_pll_drv = { .probe = clk_mt8195_apusys_pll_probe, + .remove = clk_mt8195_apusys_pll_remove, .driver = { .name ="clk-mt8195-apusys_pll" , .of_match_table = of_match_clk_mt8195_apusys_pll,
drivers/clk/mediatek/clk-mt8195-topckgen.c +20 -0
@@ -1271,6 +1271,8 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev)if (r) goto unregister_gates; +platform_set_drvdata (pdev, top_clk_data); +return r; unregister_gates:
@@ -1290,8 +1292,26 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev)return r; } +static int clk_mt8195_topck_remove (struct platform_device *pdev) +{ +struct clk_onecell_data *top_clk_data =platform_get_drvdata (pdev); +struct device_node *node = pdev->dev.of_node; + +of_clk_del_provider (node); +mtk_clk_unregister_gates (top_clks,ARRAY_SIZE (top_clks), top_clk_data); +mtk_clk_unregister_composites (top_adj_divs,ARRAY_SIZE (top_adj_divs), top_clk_data); +mtk_clk_unregister_composites (top_muxes,ARRAY_SIZE (top_muxes), top_clk_data); +mtk_clk_unregister_muxes (top_mtk_muxes,ARRAY_SIZE (top_mtk_muxes), top_clk_data); +mtk_clk_unregister_factors (top_divs,ARRAY_SIZE (top_divs), top_clk_data); +mtk_clk_unregister_fixed_clks (top_fixed_clks,ARRAY_SIZE (top_fixed_clks), top_clk_data); +mtk_free_clk_data (top_clk_data); + +return 0 ; +} +static struct platform_driver clk_mt8195_topck_drv = { .probe = clk_mt8195_topck_probe, + .remove = clk_mt8195_topck_remove, .driver = { .name ="clk-mt8195-topck" , .of_match_table = of_match_clk_mt8195_topck,
drivers/clk/mediatek/clk-mt8195-vdo0.c +16 -0
@@ -107,6 +107,8 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev)if (r) goto unregister_gates; +platform_set_drvdata (pdev, clk_data); +return r; unregister_gates:
@@ -116,8 +118,22 @@ static int clk_mt8195_vdo0_probe(struct platform_device *pdev)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_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 struct platform_driver clk_mt8195_vdo0_drv = { .probe = clk_mt8195_vdo0_probe, + .remove = clk_mt8195_vdo0_remove, .driver = { .name ="clk-mt8195-vdo0" , },
drivers/clk/mediatek/clk-mt8195-vdo1.c +16 -0
@@ -124,6 +124,8 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev)if (r) goto unregister_gates; +platform_set_drvdata (pdev, clk_data); +return r; unregister_gates:
@@ -133,8 +135,22 @@ static int clk_mt8195_vdo1_probe(struct platform_device *pdev)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_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 = { .probe = clk_mt8195_vdo1_probe, + .remove = clk_mt8195_vdo1_remove, .driver = { .name ="clk-mt8195-vdo1" , },
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 30/31] clk: mediatek: mt8195: Implement remove functions
Il 08/02/22 13:40, Chen-Yu Tsai ha scritto:
Quoted 9 lines
Until now the mediatek clk driver library did not have any way to unregister clks, and so none of the drivers implemented remove functions.
Now that the library does have APIs to unregister clks, use them to implement remove functions for the mt8195 clk drivers.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>
Re: [PATCH v3 30/31] clk: mediatek: mt8195: Implement remove functions
In reply to Chen-Yu TsaiQuoting Chen-Yu Tsai (2022-02-08 04:40:33)
Quoted 10 lines
Until now the mediatek clk driver library did not have any way to unregister clks, and so none of the drivers implemented remove functions.
Now that the library does have APIs to unregister clks, use them to implement remove functions for the mt8195 clk drivers.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>---
Applied to clk-next
PATCH v3 31/31 clk: mediatek: Warn if clk IDs are duplicated
In reply to Chen-Yu TsaiThe Mediatek clk driver library handles duplicate clock IDs in two different ways: either ignoring the duplicate entry, or overwriting the old clk. Either way may cause unexpected behavior, and the latter also causes an orphan clk that cannot be cleaned up.
Align the behavior so that later duplicate entries are ignored, and a warning printed. The warning will also aid in making the issue noticeable.
--- drivers/clk/mediatek/clk-cpumux.c | 6 ++++++ drivers/clk/mediatek/clk-gate.c | 5 ++++- drivers/clk/mediatek/clk-mtk.c | 18 ++++++++++++++---- drivers/clk/mediatek/clk-mux.c | 5 ++++- drivers/clk/mediatek/clk-pll.c | 6 ++++++ 5 files changed, 34 insertions(+), 6 deletions(-)
drivers/clk/mediatek/clk-cpumux.c +6 -0
@@ -120,6 +120,12 @@ int mtk_clk_register_cpumuxes(struct device_node *node,for (i =0 ; i < num; i++) {const struct mtk_composite *mux = &clks[i]; +if (!IS_ERR_OR_NULL (clk_data->clks[mux->id])) { +pr_warn ("%pOF: Trying to register duplicate clock ID: %d\n" , + node, mux->id); +continue ; + } + clk =mtk_clk_register_cpumux (mux, regmap);if (IS_ERR (clk)) {pr_err ("Failed to register clk %s: %pe\n" , mux->name, clk);
drivers/clk/mediatek/clk-gate.c +4 -1
@@ -224,8 +224,11 @@ int mtk_clk_register_gates_with_dev(struct device_node *node,for (i =0 ; i < num; i++) {const struct mtk_gate *gate = &clks[i]; -if (!IS_ERR_OR_NULL (clk_data->clks[gate->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[gate->id])) { +pr_warn ("%pOF: Trying to register duplicate clock ID: %d\n" , + node, gate->id);continue ; + } clk = mtk_clk_register_gate(gate->name, gate->parent_name, regmap,
drivers/clk/mediatek/clk-mtk.c +14 -4
@@ -65,8 +65,10 @@ int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num,for (i =0 ; i < num; i++) {const struct mtk_fixed_clk *rc = &clks[i]; -if (!IS_ERR_OR_NULL (clk_data->clks[rc->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[rc->id])) { +pr_warn ("Trying to register duplicate clock ID: %d\n" , rc->id);continue ; + } clk =clk_register_fixed_rate (NULL , rc->name, rc->parent,0 , rc->rate);
@@ -128,8 +130,10 @@ int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num,for (i =0 ; i < num; i++) {const struct mtk_fixed_factor *ff = &clks[i]; -if (!IS_ERR_OR_NULL (clk_data->clks[ff->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[ff->id])) { +pr_warn ("Trying to register duplicate clock ID: %d\n" , ff->id);continue ; + } clk =clk_register_fixed_factor (NULL , ff->name, ff->parent_name,CLK_SET_RATE_PARENT , ff->mult, ff->div);
@@ -305,8 +309,11 @@ int mtk_clk_register_composites(const struct mtk_composite *mcs, int num,for (i =0 ; i < num; i++) {const struct mtk_composite *mc = &mcs[i]; -if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[mc->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[mc->id])) { +pr_warn ("Trying to register duplicate clock ID: %d\n" , + mc->id);continue ; + } clk =mtk_clk_register_composite (mc, base, lock);
@@ -368,8 +375,11 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num,for (i =0 ; i < num; i++) {const struct mtk_clk_divider *mcd = &mcds[i]; -if (!IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[mcd->id])) { +pr_warn ("Trying to register duplicate clock ID: %d\n" , + mcd->id);continue ; + } clk = clk_register_divider(NULL, mcd->name, mcd->parent_name, mcd->flags, base + mcd->div_reg, mcd->div_shift,
drivers/clk/mediatek/clk-mux.c +4 -1
@@ -208,8 +208,11 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes,for (i =0 ; i < num; i++) {const struct mtk_mux *mux = &muxes[i]; -if (!IS_ERR_OR_NULL (clk_data->clks[mux->id])) +if (!IS_ERR_OR_NULL (clk_data->clks[mux->id])) { +pr_warn ("%pOF: Trying to register duplicate clock ID: %d\n" , + node, mux->id);continue ; + } clk =mtk_clk_register_mux (mux, regmap, lock);
drivers/clk/mediatek/clk-pll.c +6 -0
@@ -394,6 +394,12 @@ int mtk_clk_register_plls(struct device_node *node,for (i =0 ; i < num_plls; i++) {const struct mtk_pll_data *pll = &plls[i]; +if (!IS_ERR_OR_NULL (clk_data->clks[pll->id])) { +pr_warn ("%pOF: Trying to register duplicate clock ID: %d\n" , + node, pll->id); +continue ; + } + clk =mtk_clk_register_pll (pll, base);if (IS_ERR (clk)) {
Signature · 7 lines
2.35.0.263.gb82422642f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 31/31] clk: mediatek: Warn if clk IDs are duplicated
Quoting Chen-Yu Tsai (2022-02-08 04:40:34)
Quoted 5 lines
The Mediatek clk driver library handles duplicate clock IDs in two different ways: either ignoring the duplicate entry, or overwriting the old clk. Either way may cause unexpected behavior, and the latter also causes an orphan clk that cannot be cleaned up.
Quoted 8 lines
Align the behavior so that later duplicate entries are ignored, and a warning printed. The warning will also aid in making the issue noticeable.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Miles Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
Applied to clk-next
Hi, I couldn't find a particular patch to reply to so I'm replying cover letter to give some input on the PLL subsystem.
Quoted 2 lines · On Tue, 8 Feb 2022 20:40:03 +0800 Chen-Yu Tsai <[email protected]> wrote:
drivers/clk/mediatek/clk-pll.c | 100 +++++- drivers/clk/mediatek/clk-pll.h | 57 ++++
In clk-pll.c there is an mtk_clk_register_pll function which at some point executes this:
Quoted 1 line
init.ops =
&mtk_pll_ops;
In my opinion there should be a possibility to define a custom mtk_pll_ops for a given SoC instead of using a hardcoded one because not all Mediatek SoCs share the same PLL startup/powerdown flow. For example, the existing mtk_pll_prepare implementation won't work for the entire Mediatek Cortex-A9 SoC family (this includes but not limited to mt6515, mt6517, mt6575, and mt6577).
Quoted 8 lines
static int
mtk_pll_prepare(struct clk_hw *hw){ struct mtk_clk_pll *pll = to_mtk_clk_pll(hw); u32 r; u32 div_en_mask; r = readl(pll->pwr_addr) | CON0_PWR_ON; writel(r, pll->pwr_addr);
This code sets a bit to 1 to start a PLL but the SoCs I mentioned above would need to have that bit cleared (set to 0) [1] [2].
Another interesting thing in mtk_pll_prepare is
Quoted 1 line
udelay(20);
Is 20 ms a settle time for PLL? If yes then it would also be cool to specify an arbitrary value easily as some PLLs have longer settle time [3] [4].
Worth noting the SoCs I mentioned aren't in mainline yet, and I think there are more modern mainline-worthy Mediatek SoCs that might also need these changes in the future.
Thanks.
[1] MT6577 HSPA Smartphone Application Processor Datasheet, pages 1212-1227 (*_CON0 registers).
[2] MT6515 GSM/EDGE Smartphone Application Processor Datasheet, pages 1202-1216 (*_CON0 registers).
[3] pages 1303-1306 of [1]
[4] MT6589 HSPA+ Smartphone Application Processor Datasheet, page 1344 (MDPLL1 & MDPLL2)
Hi,
Quoted 12 lines · Boris Lysov
Hi, I couldn't find a particular patch to reply to so I'm replying cover letter to give some input on the PLL subsystem.
Quoted 2 lines · On Tue, 8 Feb 2022 20:40:03 +0800 Chen-Yu Tsai <[email protected]> wrote:
drivers/clk/mediatek/clk-pll.c | 100 +++++- drivers/clk/mediatek/clk-pll.h | 57 ++++In
clk-pll.cthere is anmtk_clk_register_pllfunction which at some point executes this:
Quoted 7 lines
Quoted 1 line
init.ops =
&mtk_pll_ops;In my opinion there should be a possibility to define a custom
mtk_pll_opsfor a given SoC instead of using a hardcoded one because not all Mediatek SoCs share the same PLL startup/powerdown flow. For example, the existingmtk_pll_prepareimplementation won't work for the entire Mediatek Cortex-A9 SoC family (this includes but not limited to mt6515, mt6517, mt6575, and mt6577).
Ack. My scope is limited to SoCs used in Chromebooks. However Miles and Chun-Jie, who are Cc-ed on the series, should know more.
That said, we can implement support for these varying parameters as we see them, not before.
Quoted 9 lines
Quoted 8 lines
static int
mtk_pll_prepare(struct clk_hw *hw){ struct mtk_clk_pll *pll = to_mtk_clk_pll(hw); u32 r; u32 div_en_mask; r = readl(pll->pwr_addr) | CON0_PWR_ON; writel(r, pll->pwr_addr);
Quoted 7 lines
This code sets a bit to 1 to start a PLL but the SoCs I mentioned above would need to have that bit cleared (set to 0) [1] [2].
Another interesting thing in
mtk_pll_prepareisQuoted 1 line
udelay(20);Is 20 ms a settle time for PLL? If yes then it would also be cool to specify an arbitrary value easily as some PLLs have longer settle time [3] [4].
This is a question for whomever upstreamed the driver.
Quoted 3 lines
Worth noting the SoCs I mentioned aren't in mainline yet, and I think there are more modern mainline-worthy Mediatek SoCs that might also need these changes in the future.
Again, we can implement varying parameters as they appear.
Thanks
ChenYu
Quoted 10 lines
Thanks.
[1] MT6577 HSPA Smartphone Application Processor Datasheet, pages 1212-1227 (
*_CON0registers).
[2] MT6515 GSM/EDGE Smartphone Application Processor Datasheet, pages 1202-1216 (*_CON0registers).
[3] pages 1303-1306 of [1]
[4] MT6589 HSPA+ Smartphone Application Processor Datasheet, page 1344 (MDPLL1 & MDPLL2)
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek