Le mer. 23 sept. 2026 à 22:33, David Lechner <[email protected]> a écrit : > > On 9/17/26 7:51 AM, Julien Stephan wrote: > > Subsystem clock blocks only provide gates, and every one of them > > declares the very same struct mtk_clk_tree boilerplate. clk-mt8189.c > > already hides it behind a local GATE_CLK_TREE() macro. > > > > Move that macro to clk-mtk.h as MTK_GATE_CLK_TREE() so that the other > > MediaTek clock drivers can use it too. The tree name and the array of > > external clock rates are now passed explicitly, as their names differ > > from one driver to another. > > I thought I had cleaned all of these up so this is no longer true. However
Hi David, Agreed for external clock rates but the tree name can't be derived from the gate array name everywhere. For example, mt8365 has mt8365_infracfg_tree for ifr_clks. I forgot to rephrase it in v2, maybe you can do it when applying if nothing else comes up. Thank you Julien > I still would keep the argument explicit just for the sake of better grep > results now that the macro definition will be in a different file. > > > > > No functional change. > > > > Signed-off-by: Julien Stephan <[email protected]> > > --- > > drivers/clk/mediatek/clk-mt8189.c | 23 +++++++---------------- > > drivers/clk/mediatek/clk-mtk.h | 22 ++++++++++++++++++++++ > > 2 files changed, 29 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/clk/mediatek/clk-mt8189.c > > b/drivers/clk/mediatek/clk-mt8189.c > > index 3724dffcc3a..8df09f4a129 100644 > > --- a/drivers/clk/mediatek/clk-mt8189.c > > +++ b/drivers/clk/mediatek/clk-mt8189.c > > @@ -1994,22 +1994,13 @@ static const struct udevice_id mt8189_vlpckgen[] = { > > { } > > }; > > > > -#define GATE_CLK_TREE(_name) \ > > -static const struct mtk_clk_tree _name##_tree = { \ > > - .ext_clk_rates = ext_clock_rates, \ > > - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), \ > > - .gates = _name, \ > > - .num_gates = ARRAY_SIZE(_name), \ > > - .gates_offs = _name[0].id, \ > > -} > > - > > -GATE_CLK_TREE(perao_clks); > > -GATE_CLK_TREE(imp_clks); > > -GATE_CLK_TREE(mm_clks); > > -GATE_CLK_TREE(mminfra_config_clks); > > -GATE_CLK_TREE(ufs_config_ao_clks); > > -GATE_CLK_TREE(ufs_config_pdn_clks); > > -GATE_CLK_TREE(vlpcfg_ao_clks); > > +MTK_GATE_CLK_TREE(perao_clks_tree, perao_clks, ext_clock_rates); > > +MTK_GATE_CLK_TREE(imp_clks_tree, imp_clks, ext_clock_rates); > > +MTK_GATE_CLK_TREE(mm_clks_tree, mm_clks, ext_clock_rates); > > +MTK_GATE_CLK_TREE(mminfra_config_clks_tree, mminfra_config_clks, > > ext_clock_rates); > > +MTK_GATE_CLK_TREE(ufs_config_ao_clks_tree, ufs_config_ao_clks, > > ext_clock_rates); > > +MTK_GATE_CLK_TREE(ufs_config_pdn_clks_tree, ufs_config_pdn_clks, > > ext_clock_rates); > > +MTK_GATE_CLK_TREE(vlpcfg_ao_clks_tree, vlpcfg_ao_clks, ext_clock_rates); > > > > static const struct udevice_id of_match_mt8189_clk_gate[] = { > > { .compatible = "mediatek,mt8189-peri-ao", .data = > > (ulong)&perao_clks_tree }, > > diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h > > index 9244542a2a5..e3a7ff75734 100644 > > --- a/drivers/clk/mediatek/clk-mtk.h > > +++ b/drivers/clk/mediatek/clk-mtk.h > > @@ -8,6 +8,7 @@ > > #define __DRV_CLK_MTK_H > > > > #include <linux/bitops.h> > > +#include <linux/kernel.h> > > > > #define MHZ (1000 * 1000) > > > > @@ -274,6 +275,27 @@ struct mtk_clk_tree { > > enum mtk_clk_tree_type type; > > }; > > > > +/** > > + * MTK_GATE_CLK_TREE() - declare a clock tree made of gates only > > + * @_tree: name of the struct mtk_clk_tree to declare > > + * @_gates: struct mtk_gate array backing the tree > > + * @_ext_rates: array holding the rates of the external clocks > > + * > > + * Most subsystem clock blocks only provide gates, whose IDs are > > + * contiguous and start at the ID of the first entry of @_gates. > > + * > > + * @_tree is declared static, so this must be used from the file > > + * defining @_gates. > > + */ > > +#define MTK_GATE_CLK_TREE(_tree, _gates, _ext_rates) \ > > I would be tempted to put _ext_rates first so that they line up nicely when > the macro is used. It will make the lines look less noisy. > > > + static const struct mtk_clk_tree _tree = { \ > > + .ext_clk_rates = _ext_rates, \ > > + .num_ext_clks = ARRAY_SIZE(_ext_rates), \ > > + .gates = _gates, \ > > + .num_gates = ARRAY_SIZE(_gates), \ > > + .gates_offs = _gates[0].id, \ > > + } > > + > > struct mtk_clk_priv { > > void __iomem *base; > > const struct mtk_clk_tree *tree; > > >
