Add support for MT8196 clock controllers
Subsystems (6)
v4 cover Add support for MT8196 clock controllers
This patch series introduces support for the clock controllers on the MediaTek MT8196 platform, following up on an earlier submission[1].
MT8196 uses a hardware voting mechanism to control some of the clock muxes and gates, along with a fence register responsible for tracking PLL and mux gate readiness. The series introduces support for these voting and fence mechanisms, and includes drivers for all clock controllers on the platform.
[1] https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Expanded the commit message for the clock controller bindings to include the addition of the hardware voter handle
- Extended the description of the mediatek,hardware-voter phandle to explain the limitations of the HWV implementation on MT8196 and justify the use of a custom handle instead of relying on generic APIs
Link to v3: https://lore.kernel.org/all/[email protected]
Laura Nao (27):
clk: mediatek: clk-pll: Add set/clr regs for shared PLL enable control
clk: mediatek: clk-pll: Add ops for PLLs using set/clr regs and FENC
clk: mediatek: clk-mux: Add ops for mux gates with set/clr/upd and
FENC
clk: mediatek: clk-mtk: Introduce mtk_clk_get_hwv_regmap()
clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC
clk: mediatek: clk-gate: Refactor mtk_clk_register_gate to use
mtk_gate struct
clk: mediatek: clk-gate: Add ops for gates with HW voter
clk: mediatek: clk-mtk: Add MUX_DIV_GATE macro
dt-bindings: clock: mediatek: Describe MT8196 clock controllers
clk: mediatek: Add MT8196 apmixedsys clock support
clk: mediatek: Add MT8196 topckgen clock support
clk: mediatek: Add MT8196 topckgen2 clock support
clk: mediatek: Add MT8196 vlpckgen clock support
clk: mediatek: Add MT8196 peripheral clock support
clk: mediatek: Add MT8196 ufssys clock support
clk: mediatek: Add MT8196 pextpsys clock support
clk: mediatek: Add MT8196 I2C clock support
clk: mediatek: Add MT8196 mcu clock support
clk: mediatek: Add MT8196 mdpsys clock support
clk: mediatek: Add MT8196 mfg clock support
clk: mediatek: Add MT8196 disp0 clock support
clk: mediatek: Add MT8196 disp1 clock support
clk: mediatek: Add MT8196 disp-ao clock support
clk: mediatek: Add MT8196 ovl0 clock support
clk: mediatek: Add MT8196 ovl1 clock support
clk: mediatek: Add MT8196 vdecsys clock support
clk: mediatek: Add MT8196 vencsys clock support
.../bindings/clock/mediatek,mt8196-clock.yaml | 112 ++ .../clock/mediatek,mt8196-sys-clock.yaml | 107 ++ drivers/clk/mediatek/Kconfig | 71 ++ drivers/clk/mediatek/Makefile | 13 + drivers/clk/mediatek/clk-gate.c | 106 +- drivers/clk/mediatek/clk-gate.h | 3 + drivers/clk/mediatek/clk-mt8196-apmixedsys.c | 203 ++++ drivers/clk/mediatek/clk-mt8196-disp0.c | 169 +++ drivers/clk/mediatek/clk-mt8196-disp1.c | 170 +++ .../clk/mediatek/clk-mt8196-imp_iic_wrap.c | 117 +++ drivers/clk/mediatek/clk-mt8196-mcu.c | 166 +++ drivers/clk/mediatek/clk-mt8196-mdpsys.c | 187 ++++ drivers/clk/mediatek/clk-mt8196-mfg.c | 149 +++ drivers/clk/mediatek/clk-mt8196-ovl0.c | 154 +++ drivers/clk/mediatek/clk-mt8196-ovl1.c | 153 +++ drivers/clk/mediatek/clk-mt8196-peri_ao.c | 144 +++ drivers/clk/mediatek/clk-mt8196-pextp.c | 131 +++ drivers/clk/mediatek/clk-mt8196-topckgen.c | 984 ++++++++++++++++++ drivers/clk/mediatek/clk-mt8196-topckgen2.c | 567 ++++++++++ drivers/clk/mediatek/clk-mt8196-ufs_ao.c | 109 ++ drivers/clk/mediatek/clk-mt8196-vdec.c | 253 +++++ drivers/clk/mediatek/clk-mt8196-vdisp_ao.c | 79 ++ drivers/clk/mediatek/clk-mt8196-venc.c | 235 +++++ drivers/clk/mediatek/clk-mt8196-vlpckgen.c | 726 +++++++++++++ drivers/clk/mediatek/clk-mtk.c | 16 + drivers/clk/mediatek/clk-mtk.h | 23 + drivers/clk/mediatek/clk-mux.c | 119 ++- drivers/clk/mediatek/clk-mux.h | 87 ++ drivers/clk/mediatek/clk-pll.c | 46 +- drivers/clk/mediatek/clk-pll.h | 9 + .../dt-bindings/clock/mediatek,mt8196-clock.h | 802 ++++++++++++++ .../reset/mediatek,mt8196-resets.h | 26 + 32 files changed, 6212 insertions(+), 24 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8196-sys-clock.yaml create mode 100644 drivers/clk/mediatek/clk-mt8196-apmixedsys.c create mode 100644 drivers/clk/mediatek/clk-mt8196-disp0.c create mode 100644 drivers/clk/mediatek/clk-mt8196-disp1.c create mode 100644 drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c create mode 100644 drivers/clk/mediatek/clk-mt8196-mcu.c create mode 100644 drivers/clk/mediatek/clk-mt8196-mdpsys.c create mode 100644 drivers/clk/mediatek/clk-mt8196-mfg.c create mode 100644 drivers/clk/mediatek/clk-mt8196-ovl0.c create mode 100644 drivers/clk/mediatek/clk-mt8196-ovl1.c create mode 100644 drivers/clk/mediatek/clk-mt8196-peri_ao.c create mode 100644 drivers/clk/mediatek/clk-mt8196-pextp.c create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen.c create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen2.c create mode 100644 drivers/clk/mediatek/clk-mt8196-ufs_ao.c create mode 100644 drivers/clk/mediatek/clk-mt8196-vdec.c create mode 100644 drivers/clk/mediatek/clk-mt8196-vdisp_ao.c create mode 100644 drivers/clk/mediatek/clk-mt8196-venc.c create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.c create mode 100644 include/dt-bindings/clock/mediatek,mt8196-clock.h create mode 100644 include/dt-bindings/reset/mediatek,mt8196-resets.h
Signature · 1 line
2.39.5
PATCH v4 1/27 clk: mediatek: clk-pll: Add set/clr regs for shared PLL enable control
On MT8196, there are set/clr registers to control a shared PLL enable register. These are intended to prevent different masters from manipulating the PLLs independently. Add the corresponding en_set_reg and en_clr_reg fields to the mtk_pll_data structure.
--- drivers/clk/mediatek/clk-pll.c | 4 ++++ drivers/clk/mediatek/clk-pll.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/clk/mediatek/clk-pll.c +4 -0
@@ -308,6 +308,10 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, pll->en_addr = base + data->en_reg; else pll->en_addr = pll->base_addr + REG_CON0; +if (data->en_set_reg) + pll->en_set_addr = base + data->en_set_reg; +if (data->en_clr_reg) + pll->en_clr_addr = base + data->en_clr_reg; pll->hw.init = &init; pll->data = data;
drivers/clk/mediatek/clk-pll.h +4 -0
@@ -47,6 +47,8 @@ struct mtk_pll_data {const struct mtk_pll_div_table *div_table;const char *parent_name;u32 en_reg; +u32 en_set_reg; +u32 en_clr_reg;u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ u8 pcw_chg_bit; };
@@ -68,6 +70,8 @@ struct mtk_clk_pll {void __iomem *pcw_addr;void __iomem *pcw_chg_addr;void __iomem *en_addr; +void __iomem *en_set_addr; +void __iomem *en_clr_addr;const struct mtk_pll_data *data; };
Signature · 1 line
2.39.5
Re: [PATCH v4 01/27] clk: mediatek: clk-pll: Add set/clr regs for shared PLL enable control
Quoted 9 lines · Laura Nao
On MT8196, there are set/clr registers to control a shared PLL enable register. These are intended to prevent different masters from manipulating the PLLs independently. Add the corresponding
en_set_reganden_clr_regfields to themtk_pll_datastructure.Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>
PATCH v4 2/27 clk: mediatek: clk-pll: Add ops for PLLs using set/clr regs and FENC
In reply to Laura NaoMT8196 uses a combination of set/clr registers to control the PLL enable state, along with a FENC bit to check the preparation status. Add new set of PLL clock operations with support for set/clr enable and FENC status logic.
--- drivers/clk/mediatek/clk-pll.c | 42 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-pll.h | 5 ++++ 2 files changed, 46 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-pll.c +41 -1
@@ -37,6 +37,13 @@ int mtk_pll_is_prepared(struct clk_hw *hw)return (readl (pll->en_addr) &BIT (pll->data->pll_en_bit)) !=0 ; } +static int mtk_pll_fenc_is_prepared (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +return readl (pll->fenc_addr) & pll->fenc_mask; +} +static unsigned long __mtk_pll_recalc_rate (struct mtk_clk_pll *pll,u32 fin,u32 pcw,int postdiv) {
@@ -274,6 +281,25 @@ void mtk_pll_unprepare(struct clk_hw *hw)writel (r, pll->pwr_addr); } +static int mtk_pll_prepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_set_addr); + +/* Wait 20us after enable for the PLL to stabilize */ +udelay (20 ); + +return 0 ; +} + +static void mtk_pll_unprepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_clr_addr); +} +const struct clk_ops mtk_pll_ops = { .is_prepared = mtk_pll_is_prepared, .prepare = mtk_pll_prepare,
@@ -283,6 +309,16 @@ const struct clk_ops mtk_pll_ops = { .set_rate = mtk_pll_set_rate, }; +const struct clk_ops mtk_pll_fenc_clr_set_ops = { + .is_prepared = mtk_pll_fenc_is_prepared, + .prepare = mtk_pll_prepare_setclr, + .unprepare = mtk_pll_unprepare_setclr, + .recalc_rate = mtk_pll_recalc_rate, + .round_rate = mtk_pll_round_rate, + .set_rate = mtk_pll_set_rate, +}; +EXPORT_SYMBOL_GPL (mtk_pll_fenc_clr_set_ops); + struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, const struct mtk_pll_data *data, void __iomem *base,
@@ -315,6 +351,9 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, pll->hw.init = &init; pll->data = data; + pll->fenc_addr = base + data->fenc_sta_ofs; + pll->fenc_mask =BIT (data->fenc_sta_bit); + init.name = data->name; init.flags = (data->flags &PLL_AO ) ?CLK_IS_CRITICAL :0 ; init.ops = pll_ops;
@@ -337,12 +376,13 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data, {struct mtk_clk_pll *pll;struct clk_hw *hw; +const struct clk_ops *pll_ops = data->ops ? data->ops : &mtk_pll_ops; pll =kzalloc (sizeof (*pll),GFP_KERNEL );if (!pll)return ERR_PTR (-ENOMEM ); - hw =mtk_clk_register_pll_ops (pll, data, base, &mtk_pll_ops); + hw =mtk_clk_register_pll_ops (pll, data, base, pll_ops);if (IS_ERR (hw))kfree (pll);
drivers/clk/mediatek/clk-pll.h +5 -0
@@ -29,6 +29,7 @@ struct mtk_pll_data {u32 reg;u32 pwr_reg;u32 en_mask; +u32 fenc_sta_ofs;u32 pd_reg;u32 tuner_reg;u32 tuner_en_reg;
@@ -51,6 +52,7 @@ struct mtk_pll_data {u32 en_clr_reg;u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ u8 pcw_chg_bit; +u8 fenc_sta_bit; };/*
@@ -72,6 +74,8 @@ struct mtk_clk_pll {void __iomem *en_addr;void __iomem *en_set_addr;void __iomem *en_clr_addr; +void __iomem *fenc_addr; +u32 fenc_mask;const struct mtk_pll_data *data; };
@@ -82,6 +86,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, struct clk_hw_onecell_data *clk_data);extern const struct clk_ops mtk_pll_ops; +extern const struct clk_ops mtk_pll_fenc_clr_set_ops;static inline struct mtk_clk_pll *to_mtk_clk_pll (struct clk_hw *hw) {
Signature · 1 line
2.39.5
Re: [PATCH v4 02/27] clk: mediatek: clk-pll: Add ops for PLLs using set/clr regs and FENC
Quoted 19 lines · Laura Nao
MT8196 uses a combination of set/clr registers to control the PLL enable state, along with a FENC bit to check the preparation status. Add new set of PLL clock operations with support for set/clr enable and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-pll.c | 42 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-pll.h | 5 ++++ 2 files changed, 46 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-pll.c +0
-0
drivers/clk/mediatek/clk-pll.c int mtk_pll_is_prepared(struct clk_hw *hw) · line 44
Quoted 8 lines
drivers/clk/mediatek/clk-pll.c +5
-0@@ -37,6 +37,13 @@ int mtk_pll_is_prepared(struct clk_hw *hw)return (readl (pll->en_addr) &BIT (pll->data->pll_en_bit)) !=0 ; } +static int mtk_pll_fenc_is_prepared (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +return readl (pll->fenc_addr) & pll->fenc_mask;
Nits:
I'd do a double-negate (!!) just to indicate that we only care about true or false.
Also, why do we need to store fenc_mask instead of just shifting the bit here? Same goes for the register address. |pll| has the base address. Why do we need to pre-calculate it?
The code is OK; it just seems a bit wasteful on memory.
Either way, this is
Quoted 113 lines
drivers/clk/mediatek/clk-pll.c +36
-1+} +static unsigned long __mtk_pll_recalc_rate (struct mtk_clk_pll *pll,u32 fin,u32 pcw,int postdiv) {@@ -274,6 +281,25 @@ void mtk_pll_unprepare(struct clk_hw *hw)writel (r, pll->pwr_addr); } +static int mtk_pll_prepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_set_addr); + +/* Wait 20us after enable for the PLL to stabilize */ +udelay (20 ); + +return 0 ; +} + +static void mtk_pll_unprepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_clr_addr); +} +const struct clk_ops mtk_pll_ops = { .is_prepared = mtk_pll_is_prepared, .prepare = mtk_pll_prepare,@@ -283,6 +309,16 @@ const struct clk_ops mtk_pll_ops = { .set_rate = mtk_pll_set_rate, }; +const struct clk_ops mtk_pll_fenc_clr_set_ops = { + .is_prepared = mtk_pll_fenc_is_prepared, + .prepare = mtk_pll_prepare_setclr, + .unprepare = mtk_pll_unprepare_setclr, + .recalc_rate = mtk_pll_recalc_rate, + .round_rate = mtk_pll_round_rate, + .set_rate = mtk_pll_set_rate, +}; +EXPORT_SYMBOL_GPL (mtk_pll_fenc_clr_set_ops); + struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, const struct mtk_pll_data *data, void __iomem *base,@@ -315,6 +351,9 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, pll->hw.init = &init; pll->data = data; + pll->fenc_addr = base + data->fenc_sta_ofs; + pll->fenc_mask =BIT (data->fenc_sta_bit); + init.name = data->name; init.flags = (data->flags &PLL_AO ) ?CLK_IS_CRITICAL :0 ; init.ops = pll_ops;@@ -337,12 +376,13 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data, {struct mtk_clk_pll *pll;struct clk_hw *hw; +const struct clk_ops *pll_ops = data->ops ? data->ops : &mtk_pll_ops; pll =kzalloc (sizeof (*pll),GFP_KERNEL );if (!pll)return ERR_PTR (-ENOMEM ); - hw =mtk_clk_register_pll_ops (pll, data, base, &mtk_pll_ops); + hw =mtk_clk_register_pll_ops (pll, data, base, pll_ops);if (IS_ERR (hw))kfree (pll);drivers/clk/mediatek/clk-pll.h +5
-1@@ -29,6 +29,7 @@ struct mtk_pll_data {u32 reg;u32 pwr_reg;u32 en_mask; +u32 fenc_sta_ofs;u32 pd_reg;u32 tuner_reg;u32 tuner_en_reg;@@ -51,6 +52,7 @@ struct mtk_pll_data {u32 en_clr_reg;u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ u8 pcw_chg_bit; +u8 fenc_sta_bit; };/* @@ -72,6 +74,8 @@ struct mtk_clk_pll {void __iomem *en_addr;void __iomem *en_set_addr;void __iomem *en_clr_addr; +void __iomem *fenc_addr; +u32 fenc_mask;const struct mtk_pll_data *data; };@@ -82,6 +86,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, struct clk_hw_onecell_data *clk_data);extern const struct clk_ops mtk_pll_ops; +extern const struct clk_ops mtk_pll_fenc_clr_set_ops;static inline struct mtk_clk_pll *to_mtk_clk_pll (struct clk_hw *hw) { --2.39.5
Re: [PATCH v4 02/27] clk: mediatek: clk-pll: Add ops for PLLs using set/clr regs and FENC
Hi Chen-Yu,
Quoted 31 lines · Chen-Yu Tsai
Quoted 19 lines · Laura Nao
MT8196 uses a combination of set/clr registers to control the PLL enable state, along with a FENC bit to check the preparation status. Add new set of PLL clock operations with support for set/clr enable and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-pll.c | 42 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-pll.h | 5 ++++ 2 files changed, 46 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-pll.c +0
-0drivers/clk/mediatek/clk-pll.c int mtk_pll_is_prepared(struct clk_hw *hw) · line 44
Quoted 8 lines
drivers/clk/mediatek/clk-pll.c +5
-0@@ -37,6 +37,13 @@ int mtk_pll_is_prepared(struct clk_hw *hw)return (readl (pll->en_addr) &BIT (pll->data->pll_en_bit)) !=0 ; } +static int mtk_pll_fenc_is_prepared (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +return readl (pll->fenc_addr) & pll->fenc_mask;Nits:
Quoted 9 lines
I'd do a double-negate (!!) just to indicate that we only care about true or false.
Also, why do we need to store
fenc_maskinstead of just shifting the bit here? Same goes for the register address. |pll| has the base address. Why do we need to pre-calculate it?The code is OK; it just seems a bit wasteful on memory.
Thanks for the heads up - since these are only used here for now, I agree they’re not really adding value. I’ll drop fenc_mask and fenc_addr in the next revision.
Best,
Laura
Quoted 117 lines
Either way, this is
Reviewed-by Chen-Yu Tsai <[email protected]>Quoted 113 lines
drivers/clk/mediatek/clk-pll.c +36
-1+} +static unsigned long __mtk_pll_recalc_rate (struct mtk_clk_pll *pll,u32 fin,u32 pcw,int postdiv) {@@ -274,6 +281,25 @@ void mtk_pll_unprepare(struct clk_hw *hw)writel (r, pll->pwr_addr); } +static int mtk_pll_prepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_set_addr); + +/* Wait 20us after enable for the PLL to stabilize */ +udelay (20 ); + +return 0 ; +} + +static void mtk_pll_unprepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_clr_addr); +} +const struct clk_ops mtk_pll_ops = { .is_prepared = mtk_pll_is_prepared, .prepare = mtk_pll_prepare,@@ -283,6 +309,16 @@ const struct clk_ops mtk_pll_ops = { .set_rate = mtk_pll_set_rate, }; +const struct clk_ops mtk_pll_fenc_clr_set_ops = { + .is_prepared = mtk_pll_fenc_is_prepared, + .prepare = mtk_pll_prepare_setclr, + .unprepare = mtk_pll_unprepare_setclr, + .recalc_rate = mtk_pll_recalc_rate, + .round_rate = mtk_pll_round_rate, + .set_rate = mtk_pll_set_rate, +}; +EXPORT_SYMBOL_GPL (mtk_pll_fenc_clr_set_ops); + struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, const struct mtk_pll_data *data, void __iomem *base,@@ -315,6 +351,9 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, pll->hw.init = &init; pll->data = data; + pll->fenc_addr = base + data->fenc_sta_ofs; + pll->fenc_mask =BIT (data->fenc_sta_bit); + init.name = data->name; init.flags = (data->flags &PLL_AO ) ?CLK_IS_CRITICAL :0 ; init.ops = pll_ops;@@ -337,12 +376,13 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data, {struct mtk_clk_pll *pll;struct clk_hw *hw; +const struct clk_ops *pll_ops = data->ops ? data->ops : &mtk_pll_ops; pll =kzalloc (sizeof (*pll),GFP_KERNEL );if (!pll)return ERR_PTR (-ENOMEM ); - hw =mtk_clk_register_pll_ops (pll, data, base, &mtk_pll_ops); + hw =mtk_clk_register_pll_ops (pll, data, base, pll_ops);if (IS_ERR (hw))kfree (pll);drivers/clk/mediatek/clk-pll.h +5
-1@@ -29,6 +29,7 @@ struct mtk_pll_data {u32 reg;u32 pwr_reg;u32 en_mask; +u32 fenc_sta_ofs;u32 pd_reg;u32 tuner_reg;u32 tuner_en_reg;@@ -51,6 +52,7 @@ struct mtk_pll_data {u32 en_clr_reg;u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ u8 pcw_chg_bit; +u8 fenc_sta_bit; };/* @@ -72,6 +74,8 @@ struct mtk_clk_pll {void __iomem *en_addr;void __iomem *en_set_addr;void __iomem *en_clr_addr; +void __iomem *fenc_addr; +u32 fenc_mask;const struct mtk_pll_data *data; };@@ -82,6 +86,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, struct clk_hw_onecell_data *clk_data);extern const struct clk_ops mtk_pll_ops; +extern const struct clk_ops mtk_pll_fenc_clr_set_ops;static inline struct mtk_clk_pll *to_mtk_clk_pll (struct clk_hw *hw) { --2.39.5
Re: [PATCH v4 02/27] clk: mediatek: clk-pll: Add ops for PLLs using set/clr regs and FENC
Quoted 41 lines · Laura Nao
Hi Chen-Yu,
Quoted 38 lines · Chen-Yu Tsai
Quoted 19 lines · Laura Nao
MT8196 uses a combination of set/clr registers to control the PLL enable state, along with a FENC bit to check the preparation status. Add new set of PLL clock operations with support for set/clr enable and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-pll.c | 42 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-pll.h | 5 ++++ 2 files changed, 46 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-pll.c +0
-0drivers/clk/mediatek/clk-pll.c int mtk_pll_is_prepared(struct clk_hw *hw) · line 44
Quoted 8 lines
drivers/clk/mediatek/clk-pll.c +5
-0@@ -37,6 +37,13 @@ int mtk_pll_is_prepared(struct clk_hw *hw)return (readl (pll->en_addr) &BIT (pll->data->pll_en_bit)) !=0 ; } +static int mtk_pll_fenc_is_prepared (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +return readl (pll->fenc_addr) & pll->fenc_mask;Nits:
I'd do a double-negate (!!) just to indicate that we only care about true or false.
Also, why do we need to store
fenc_maskinstead of just shifting the bit here? Same goes for the register address. |pll| has the base address. Why do we need to pre-calculate it?
Quoted 7 lines
Quoted 2 lines
The code is OK; it just seems a bit wasteful on memory.
Thanks for the heads up - since these are only used here for now, I agree they’re not really adding value. I’ll drop
fenc_maskandfenc_addrin the next revision.
On second thought, since pll->base_addr is initialized as base + data->reg (i.e. at CON0 offset), and the FENC status register sits before that in the register map, it can’t be derived directly from pll->base_addr.
So we need to keep fenc_addr, but I’ll drop fenc_mask and shift the bit inline instead.
Laura
Quoted 122 lines
Best,
Laura
Quoted 117 lines
Either way, this is
Reviewed-by Chen-Yu Tsai <[email protected]>Quoted 113 lines
drivers/clk/mediatek/clk-pll.c +36
-1+} +static unsigned long __mtk_pll_recalc_rate (struct mtk_clk_pll *pll,u32 fin,u32 pcw,int postdiv) {@@ -274,6 +281,25 @@ void mtk_pll_unprepare(struct clk_hw *hw)writel (r, pll->pwr_addr); } +static int mtk_pll_prepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_set_addr); + +/* Wait 20us after enable for the PLL to stabilize */ +udelay (20 ); + +return 0 ; +} + +static void mtk_pll_unprepare_setclr (struct clk_hw *hw) +{ +struct mtk_clk_pll *pll =to_mtk_clk_pll (hw); + +writel (BIT (pll->data->pll_en_bit), pll->en_clr_addr); +} +const struct clk_ops mtk_pll_ops = { .is_prepared = mtk_pll_is_prepared, .prepare = mtk_pll_prepare,@@ -283,6 +309,16 @@ const struct clk_ops mtk_pll_ops = { .set_rate = mtk_pll_set_rate, }; +const struct clk_ops mtk_pll_fenc_clr_set_ops = { + .is_prepared = mtk_pll_fenc_is_prepared, + .prepare = mtk_pll_prepare_setclr, + .unprepare = mtk_pll_unprepare_setclr, + .recalc_rate = mtk_pll_recalc_rate, + .round_rate = mtk_pll_round_rate, + .set_rate = mtk_pll_set_rate, +}; +EXPORT_SYMBOL_GPL (mtk_pll_fenc_clr_set_ops); + struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, const struct mtk_pll_data *data, void __iomem *base,@@ -315,6 +351,9 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll, pll->hw.init = &init; pll->data = data; + pll->fenc_addr = base + data->fenc_sta_ofs; + pll->fenc_mask =BIT (data->fenc_sta_bit); + init.name = data->name; init.flags = (data->flags &PLL_AO ) ?CLK_IS_CRITICAL :0 ; init.ops = pll_ops;@@ -337,12 +376,13 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data, {struct mtk_clk_pll *pll;struct clk_hw *hw; +const struct clk_ops *pll_ops = data->ops ? data->ops : &mtk_pll_ops; pll =kzalloc (sizeof (*pll),GFP_KERNEL );if (!pll)return ERR_PTR (-ENOMEM ); - hw =mtk_clk_register_pll_ops (pll, data, base, &mtk_pll_ops); + hw =mtk_clk_register_pll_ops (pll, data, base, pll_ops);if (IS_ERR (hw))kfree (pll);drivers/clk/mediatek/clk-pll.h +5
-1@@ -29,6 +29,7 @@ struct mtk_pll_data {u32 reg;u32 pwr_reg;u32 en_mask; +u32 fenc_sta_ofs;u32 pd_reg;u32 tuner_reg;u32 tuner_en_reg;@@ -51,6 +52,7 @@ struct mtk_pll_data {u32 en_clr_reg;u8 pll_en_bit;/* Assume 0, indicates BIT(0) by default */ u8 pcw_chg_bit; +u8 fenc_sta_bit; };/* @@ -72,6 +74,8 @@ struct mtk_clk_pll {void __iomem *en_addr;void __iomem *en_set_addr;void __iomem *en_clr_addr; +void __iomem *fenc_addr; +u32 fenc_mask;const struct mtk_pll_data *data; };@@ -82,6 +86,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, struct clk_hw_onecell_data *clk_data);extern const struct clk_ops mtk_pll_ops; +extern const struct clk_ops mtk_pll_fenc_clr_set_ops;static inline struct mtk_clk_pll *to_mtk_clk_pll (struct clk_hw *hw) { --2.39.5
PATCH v4 3/27 clk: mediatek: clk-mux: Add ops for mux gates with set/clr/upd and FENC
In reply to Laura NaoMT8196 uses set/clr/upd registers for mux gate enable/disable control, along with a FENC bit to check the status. Add new set of mux gate clock operations with support for set/clr/upd and FENC status logic.
--- drivers/clk/mediatek/clk-mtk.h | 2 ++ drivers/clk/mediatek/clk-mux.c | 48 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mux.h | 45 +++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)
drivers/clk/mediatek/clk-mtk.h +2 -0
@@ -20,6 +20,8 @@#define MHZ (1000 * 1000) +#define MTK_WAIT_FENC_DONE_US 30 +struct platform_device ;/*
drivers/clk/mediatek/clk-mux.c +48 -0
72 lines not on this page · raw message
drivers/clk/mediatek/clk-mux.h +45 -0
68 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 03/27] clk: mediatek: clk-mux: Add ops for mux gates with set/clr/upd and FENC
Quoted 19 lines · Laura Nao
MT8196 uses set/clr/upd registers for mux gate enable/disable control, along with a FENC bit to check the status. Add new set of mux gate clock operations with support for set/clr/upd and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-mtk.h | 2 ++ drivers/clk/mediatek/clk-mux.c | 48 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mux.h | 45 +++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)drivers/clk/mediatek/clk-mtk.h +0
-0
drivers/clk/mediatek/clk-mtk.h line 24
Quoted 5 lines
drivers/clk/mediatek/clk-mtk.h +2
-0@@ -20,6 +20,8 @@#define MHZ (1000 * 1000) +#define MTK_WAIT_FENC_DONE_US 30 +
Nit: I think it would be nicer if you define this locally in the mux type clk code, just to keep the two completely separate.
Quoted 51 lines
drivers/clk/mediatek/clk-mtk.h +0
-0struct platform_device ;/* drivers/clk/mediatek/clk-mux.c +28
-0@@ -15,6 +15,7 @@#include <linux/spinlock.h> #include <linux/slab.h> +#include "clk-mtk.h" #include "clk-mux.h" struct mtk_clk_mux {@@ -30,6 +31,33 @@ static inline struct mtk_clk_mux *to_mtk_clk_mux(struct clk_hw *hw) return container_of(hw, struct mtk_clk_mux, hw); } +static int mtk_clk_mux_fenc_enable_setclr (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +unsigned long flags; +u32 val; +int ret; + +if (mux->lock) +spin_lock_irqsave (mux->lock, flags); +else +__acquire (mux->lock); + +regmap_write (mux->regmap, mux->data->clr_ofs, +BIT (mux->data->gate_shift)); + + ret =regmap_read_poll_timeout_atomic (mux->regmap, mux->data->fenc_sta_mon_ofs, + val, val &BIT (mux->data->fenc_shift),1 , +MTK_WAIT_FENC_DONE_US ); + +if (mux->lock) +spin_unlock_irqrestore (mux->lock, flags); +else +__release (mux->lock); + +return ret; +} +static int mtk_clk_mux_enable_setclr (struct clk_hw *hw) {struct mtk_clk_mux *mux =to_mtk_clk_mux (hw);@@ -70,6 +98,16 @@ static void mtk_clk_mux_disable_setclr(struct clk_hw *hw) BIT(mux->data->gate_shift));
drivers/clk/mediatek/clk-mux.c static void mtk_clk_mux_disable_setclr(struct clk_hw *hw) · line 108
Quoted 10 lines
drivers/clk/mediatek/clk-mux.c +8
-0} +static int mtk_clk_mux_fenc_is_enabled (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +u32 val; + +regmap_read (mux->regmap, mux->data->fenc_sta_mon_ofs, &val); + +return val &BIT (mux->data->fenc_shift);
Nit: Do a double negate.
Quoted 76 lines
drivers/clk/mediatek/clk-mux.c +12
-0+} +static int mtk_clk_mux_is_enabled (struct clk_hw *hw) {struct mtk_clk_mux *mux =to_mtk_clk_mux (hw);@@ -168,6 +206,16 @@ const struct clk_ops mtk_mux_gate_clr_set_upd_ops = { };EXPORT_SYMBOL_GPL (mtk_mux_gate_clr_set_upd_ops); +const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops = { + .enable = mtk_clk_mux_fenc_enable_setclr, + .disable = mtk_clk_mux_disable_setclr, + .is_enabled = mtk_clk_mux_fenc_is_enabled, + .get_parent = mtk_clk_mux_get_parent, + .set_parent = mtk_clk_mux_set_parent_setclr_lock, + .determine_rate = mtk_clk_mux_determine_rate, +}; +EXPORT_SYMBOL_GPL (mtk_mux_gate_fenc_clr_set_upd_ops); + static struct clk_hw *mtk_clk_register_mux(struct device *dev, const struct mtk_mux *mux, struct regmap *regmap,drivers/clk/mediatek/clk-mux.h +27
-0@@ -28,11 +28,13 @@ struct mtk_mux {u32 set_ofs;u32 clr_ofs;u32 upd_ofs; +u32 fenc_sta_mon_ofs;u8 mux_shift;u8 mux_width;u8 gate_shift;s8 upd_shift; +u8 fenc_shift;const struct clk_ops *ops;signed char num_parents;@@ -77,6 +79,7 @@ struct mtk_mux {extern const struct clk_ops mtk_mux_clr_set_upd_ops;extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops; +extern const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops; #define MUX_GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ _mux_set_ofs, _mux_clr_ofs, _shift, _width, \@@ -118,6 +121,48 @@ extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops; 0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \ mtk_mux_clr_set_upd_ops) +#define MUX_GATE_FENC_CLR_SET_UPD_FLAGS (_id, _name, _parents, _paridx, \ + _num_parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, _flags) { \ + .id = _id, \ + .name = _name, \ + .mux_ofs = _mux_ofs, \ + .set_ofs = _mux_set_ofs, \ + .clr_ofs = _mux_clr_ofs, \ + .upd_ofs = _upd_ofs, \ + .fenc_sta_mon_ofs = _fenc_sta_mon_ofs, \ + .mux_shift = _shift, \ + .mux_width = _width, \ + .gate_shift = _gate, \ + .upd_shift = _upd, \ + .fenc_shift = _fenc, \ + .parent_names = _parents, \ + .parent_index = _paridx, \ + .num_parents = _num_parents, \ + .flags = _flags, \ + .ops = &mtk_mux_gate_fenc_clr_set_upd_ops, \ + } + +#define MUX_GATE_FENC_CLR_SET_UPD(_id, _name, _parents, \
drivers/clk/mediatek/clk-mux.h extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops; · line 157
Quoted 10 lines
drivers/clk/mediatek/clk-mux.h +10
-0+ _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc) \ +MUX_GATE_FENC_CLR_SET_UPD_FLAGS (_id, _name, _parents, \ +NULL ,ARRAY_SIZE (_parents), _mux_ofs, \ + _mux_set_ofs, _mux_clr_ofs, _shift, \ + _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, 0) + +#define MUX_GATE_FENC_CLR_SET_UPD_INDEXED(_id, _name, _parents, _paridx, \
^^^^^^
This looks like a tab when it should have been a space?
ChenYu
Quoted 14 lines
drivers/clk/mediatek/clk-mux.h +8
-1+ _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc) \ + MUX_GATE_FENC_CLR_SET_UPD_FLAGS(_id, _name, _parents, _paridx, \ + ARRAY_SIZE(_paridx), _mux_ofs, _mux_set_ofs, \ + _mux_clr_ofs, _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, 0) + int mtk_clk_register_muxes(struct device *dev, const struct mtk_mux *muxes, int num, struct device_node *node, --2.39.5
Re: [PATCH v4 03/27] clk: mediatek: clk-mux: Add ops for mux gates with set/clr/upd and FENC
Quoted 21 lines · Chen-Yu Tsai
Quoted 20 lines · Laura Nao
MT8196 uses set/clr/upd registers for mux gate enable/disable control, along with a FENC bit to check the status. Add new set of mux gate clock operations with support for set/clr/upd and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-mtk.h | 2 ++ drivers/clk/mediatek/clk-mux.c | 48 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mux.h | 45 +++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)drivers/clk/mediatek/clk-mtk.h +0
-0@@ -20,6 +20,8 @@
Quoted 8 lines
drivers/clk/mediatek/clk-mtk.h line 24
Quoted 4 lines
drivers/clk/mediatek/clk-mtk.h +2
-0#define MHZ (1000 * 1000) +#define MTK_WAIT_FENC_DONE_US 30 +Nit: I think it would be nicer if you define this locally in the mux type clk code, just to keep the two completely separate.
Ack, will move this to clk-mux.c.
Quoted 53 lines
Quoted 53 lines
drivers/clk/mediatek/clk-mtk.h +0
-0struct platform_device ;/* drivers/clk/mediatek/clk-mux.c +28
-0@@ -15,6 +15,7 @@#include <linux/spinlock.h> #include <linux/slab.h> +#include "clk-mtk.h" #include "clk-mux.h" struct mtk_clk_mux {@@ -30,6 +31,33 @@ static inline struct mtk_clk_mux *to_mtk_clk_mux(struct clk_hw *hw) return container_of(hw, struct mtk_clk_mux, hw); } +static int mtk_clk_mux_fenc_enable_setclr (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +unsigned long flags; +u32 val; +int ret; + +if (mux->lock) +spin_lock_irqsave (mux->lock, flags); +else +__acquire (mux->lock); + +regmap_write (mux->regmap, mux->data->clr_ofs, +BIT (mux->data->gate_shift)); + + ret =regmap_read_poll_timeout_atomic (mux->regmap, mux->data->fenc_sta_mon_ofs, + val, val &BIT (mux->data->fenc_shift),1 , +MTK_WAIT_FENC_DONE_US ); + +if (mux->lock) +spin_unlock_irqrestore (mux->lock, flags); +else +__release (mux->lock); + +return ret; +} +static int mtk_clk_mux_enable_setclr (struct clk_hw *hw) {struct mtk_clk_mux *mux =to_mtk_clk_mux (hw);@@ -70,6 +98,16 @@ static void mtk_clk_mux_disable_setclr(struct clk_hw *hw) BIT(mux->data->gate_shift)); }
Quoted 11 lines
drivers/clk/mediatek/clk-mux.c static void mtk_clk_mux_disable_setclr(struct clk_hw *hw) · line 108
Quoted 8 lines
drivers/clk/mediatek/clk-mux.c +8
-0+static int mtk_clk_mux_fenc_is_enabled (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +u32 val; + +regmap_read (mux->regmap, mux->data->fenc_sta_mon_ofs, &val); + +return val &BIT (mux->data->fenc_shift);Nit: Do a double negate.
Ack.
Quoted 88 lines
Quoted 76 lines
drivers/clk/mediatek/clk-mux.c +12
-0+} +static int mtk_clk_mux_is_enabled (struct clk_hw *hw) {struct mtk_clk_mux *mux =to_mtk_clk_mux (hw);@@ -168,6 +206,16 @@ const struct clk_ops mtk_mux_gate_clr_set_upd_ops = { };EXPORT_SYMBOL_GPL (mtk_mux_gate_clr_set_upd_ops); +const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops = { + .enable = mtk_clk_mux_fenc_enable_setclr, + .disable = mtk_clk_mux_disable_setclr, + .is_enabled = mtk_clk_mux_fenc_is_enabled, + .get_parent = mtk_clk_mux_get_parent, + .set_parent = mtk_clk_mux_set_parent_setclr_lock, + .determine_rate = mtk_clk_mux_determine_rate, +}; +EXPORT_SYMBOL_GPL (mtk_mux_gate_fenc_clr_set_upd_ops); + static struct clk_hw *mtk_clk_register_mux(struct device *dev, const struct mtk_mux *mux, struct regmap *regmap,drivers/clk/mediatek/clk-mux.h +27
-0@@ -28,11 +28,13 @@ struct mtk_mux {u32 set_ofs;u32 clr_ofs;u32 upd_ofs; +u32 fenc_sta_mon_ofs;u8 mux_shift;u8 mux_width;u8 gate_shift;s8 upd_shift; +u8 fenc_shift;const struct clk_ops *ops;signed char num_parents;@@ -77,6 +79,7 @@ struct mtk_mux {extern const struct clk_ops mtk_mux_clr_set_upd_ops;extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops; +extern const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops; #define MUX_GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ _mux_set_ofs, _mux_clr_ofs, _shift, _width, \@@ -118,6 +121,48 @@ extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops; 0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \ mtk_mux_clr_set_upd_ops) +#define MUX_GATE_FENC_CLR_SET_UPD_FLAGS (_id, _name, _parents, _paridx, \ + _num_parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, _flags) { \ + .id = _id, \ + .name = _name, \ + .mux_ofs = _mux_ofs, \ + .set_ofs = _mux_set_ofs, \ + .clr_ofs = _mux_clr_ofs, \ + .upd_ofs = _upd_ofs, \ + .fenc_sta_mon_ofs = _fenc_sta_mon_ofs, \ + .mux_shift = _shift, \ + .mux_width = _width, \ + .gate_shift = _gate, \ + .upd_shift = _upd, \ + .fenc_shift = _fenc, \ + .parent_names = _parents, \ + .parent_index = _paridx, \ + .num_parents = _num_parents, \ + .flags = _flags, \ + .ops = &mtk_mux_gate_fenc_clr_set_upd_ops, \ + } + +#define MUX_GATE_FENC_CLR_SET_UPD(_id, _name, _parents, \drivers/clk/mediatek/clk-mux.h extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops; · line 157
Quoted 10 lines
drivers/clk/mediatek/clk-mux.h +10
-0+ _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc) \ +MUX_GATE_FENC_CLR_SET_UPD_FLAGS (_id, _name, _parents, \ +NULL ,ARRAY_SIZE (_parents), _mux_ofs, \ + _mux_set_ofs, _mux_clr_ofs, _shift, \ + _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, 0) + +#define MUX_GATE_FENC_CLR_SET_UPD_INDEXED(_id, _name, _parents, _paridx, \^^^^^^
Quoted 2 lines
This looks like a tab when it should have been a space?
Definitely - thanks for the heads up, I'll fix it.
Best,
Laura
Quoted 16 lines
ChenYu
Quoted 14 lines
drivers/clk/mediatek/clk-mux.h +8
-1+ _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc) \ + MUX_GATE_FENC_CLR_SET_UPD_FLAGS(_id, _name, _parents, _paridx, \ + ARRAY_SIZE(_paridx), _mux_ofs, _mux_set_ofs, \ + _mux_clr_ofs, _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, 0) + int mtk_clk_register_muxes(struct device *dev, const struct mtk_mux *muxes, int num, struct device_node *node, --2.39.5
PATCH v4 4/27 clk: mediatek: clk-mtk: Introduce mtk_clk_get_hwv_regmap()
In reply to Laura NaoOn MT8196, some clock controllers use a separate regmap for hardware voting via set/clear/status registers. Add mtk_clk_get_hwv_regmap() to retrieve this optional regmap, avoiding duplicated lookup code in mtk_clk_register_muxes() and mtk_clk_register_gate().
--- drivers/clk/mediatek/clk-mtk.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 1 + 2 files changed, 17 insertions(+)
drivers/clk/mediatek/clk-mtk.c +16 -0
@@ -685,4 +685,20 @@ void mtk_clk_simple_remove(struct platform_device *pdev) }EXPORT_SYMBOL_GPL (mtk_clk_simple_remove); +struct regmap *mtk_clk_get_hwv_regmap (struct device_node *node) +{ +struct device_node *hwv_node; +struct regmap *regmap_hwv; + + hwv_node =of_parse_phandle (node,"mediatek,hardware-voter" ,0 ); +if (!hwv_node) +return NULL ; + + regmap_hwv =device_node_to_regmap (hwv_node); +of_node_put (hwv_node); + +return regmap_hwv; +} +EXPORT_SYMBOL_GPL (mtk_clk_get_hwv_regmap); +MODULE_LICENSE ("GPL" );
drivers/clk/mediatek/clk-mtk.h +1 -0
@@ -247,5 +247,6 @@ int mtk_clk_pdev_probe(struct platform_device *pdev);void mtk_clk_pdev_remove (struct platform_device *pdev);int mtk_clk_simple_probe (struct platform_device *pdev);void mtk_clk_simple_remove (struct platform_device *pdev); +struct regmap *mtk_clk_get_hwv_regmap (struct device_node *node);#endif /* __DRV_CLK_MTK_H */
Signature · 1 line
2.39.5
Re: [PATCH v4 04/27] clk: mediatek: clk-mtk: Introduce mtk_clk_get_hwv_regmap()
Quoted 9 lines · Laura Nao
On MT8196, some clock controllers use a separate regmap for hardware voting via set/clear/status registers. Add mtk_clk_get_hwv_regmap() to retrieve this optional regmap, avoiding duplicated lookup code in
mtk_clk_register_muxes()and mtk_clk_register_gate().Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>
PATCH v4 5/27 clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC
In reply to Laura NaoMT8196 use a HW voter for mux gate enable/disable control, along with a FENC status bit to check the status. Voting is performed using set/clr/upd registers, with a status bit used to verify the vote state. Add new set of mux gate clock operations with support for voting via set/clr/upd regs and FENC status logic.
--- drivers/clk/mediatek/clk-mtk.h | 1 + drivers/clk/mediatek/clk-mux.c | 71 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-mux.h | 42 ++++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mtk.h +1 -0
@@ -20,6 +20,7 @@#define MHZ (1000 * 1000) +#define MTK_WAIT_HWV_DONE_US 30#define MTK_WAIT_FENC_DONE_US 30struct platform_device ;
drivers/clk/mediatek/clk-mux.c +70 -1
130 lines not on this page · raw message
drivers/clk/mediatek/clk-mux.h +42 -0
60 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 05/27] clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC
Quoted 149 lines · Laura Nao
MT8196 use a HW voter for mux gate enable/disable control, along with a FENC status bit to check the status. Voting is performed using set/clr/upd registers, with a status bit used to verify the vote state. Add new set of mux gate clock operations with support for voting via set/clr/upd regs and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-mtk.h | 1 + drivers/clk/mediatek/clk-mux.c | 71 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-mux.h | 42 ++++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-mtk.h +1
-0@@ -20,6 +20,7 @@#define MHZ (1000 * 1000) +#define MTK_WAIT_HWV_DONE_US 30#define MTK_WAIT_FENC_DONE_US 30struct platform_device ;drivers/clk/mediatek/clk-mux.c +62
-0@@ -8,6 +8,7 @@#include <linux/clk-provider.h> #include <linux/compiler_types.h> #include <linux/container_of.h> +#include <linux/dev_printk.h> #include <linux/err.h> #include <linux/mfd/syscon.h> #include <linux/module.h> @@ -21,6 +22,7 @@struct mtk_clk_mux {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;const struct mtk_mux *data;spinlock_t *lock;bool reparent;@@ -118,6 +120,41 @@ static int mtk_clk_mux_is_enabled(struct clk_hw *hw)return (val &BIT (mux->data->gate_shift)) ==0 ; } +static int mtk_clk_mux_hwv_fenc_enable (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +u32 val; +int ret; + +regmap_write (mux->regmap_hwv, mux->data->hwv_set_ofs, +BIT (mux->data->gate_shift)); + + ret =regmap_read_poll_timeout_atomic (mux->regmap_hwv, mux->data->hwv_sta_ofs, + val, val &BIT (mux->data->gate_shift),0 , +MTK_WAIT_HWV_DONE_US ); +if (ret) +return ret; + + ret =regmap_read_poll_timeout_atomic (mux->regmap, mux->data->fenc_sta_mon_ofs, + val, val &BIT (mux->data->fenc_shift),1 , +MTK_WAIT_FENC_DONE_US ); + +return ret; +} + +static void mtk_clk_mux_hwv_disable (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +u32 val; + +regmap_write (mux->regmap_hwv, mux->data->hwv_clr_ofs, +BIT (mux->data->gate_shift)); + +regmap_read_poll_timeout_atomic (mux->regmap_hwv, mux->data->hwv_sta_ofs, + val, (val &BIT (mux->data->gate_shift)), +0 ,MTK_WAIT_HWV_DONE_US ); +} +static u8 mtk_clk_mux_get_parent (struct clk_hw *hw) {struct mtk_clk_mux *mux =to_mtk_clk_mux (hw);@@ -189,6 +226,14 @@ static int mtk_clk_mux_determine_rate(struct clk_hw *hw,return clk_mux_determine_rate_flags (hw, req, mux->data->flags); } +static bool mtk_clk_mux_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_mux_gate_hwv_fenc_clr_set_upd_ops) +return true; + +return false; +} +const struct clk_ops mtk_mux_clr_set_upd_ops = { .get_parent = mtk_clk_mux_get_parent, .set_parent = mtk_clk_mux_set_parent_setclr_lock,@@ -216,9 +261,20 @@ const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops = { };EXPORT_SYMBOL_GPL (mtk_mux_gate_fenc_clr_set_upd_ops); +const struct clk_ops mtk_mux_gate_hwv_fenc_clr_set_upd_ops = { + .enable = mtk_clk_mux_hwv_fenc_enable, + .disable = mtk_clk_mux_hwv_disable, + .is_enabled = mtk_clk_mux_fenc_is_enabled, + .get_parent = mtk_clk_mux_get_parent, + .set_parent = mtk_clk_mux_set_parent_setclr_lock, + .determine_rate = mtk_clk_mux_determine_rate, +}; +EXPORT_SYMBOL_GPL (mtk_mux_gate_hwv_fenc_clr_set_upd_ops); +static struct clk_hw *mtk_clk_register_mux (struct device *dev,const struct mtk_mux *mux,struct regmap *regmap, +struct regmap *regmap_hwv,spinlock_t *lock) {struct mtk_clk_mux *clk_mux;@@ -234,8 +290,13 @@ static struct clk_hw *mtk_clk_register_mux(struct device *dev, init.parent_names = mux->parent_names; init.num_parents = mux->num_parents; init.ops = mux->ops; +if (mtk_clk_mux_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO ); + } clk_mux->regmap = regmap; + clk_mux->regmap_hwv = regmap_hwv; clk_mux->data = mux; clk_mux->lock = lock; clk_mux->hw.init = &init;@@ -268,6 +329,7 @@ int mtk_clk_register_muxes(struct device *dev, struct clk_hw_onecell_data *clk_data) {struct regmap *regmap; +struct regmap *regmap_hwv;struct clk_hw *hw;int i;
drivers/clk/mediatek/clk-mux.c int mtk_clk_register_muxes(struct device *dev, · line 346
Quoted 8 lines
drivers/clk/mediatek/clk-mux.c +5
-0@@ -277,6 +339,13 @@ int mtk_clk_register_muxes(struct device *dev,return PTR_ERR (regmap); } + regmap_hwv =mtk_clk_get_hwv_regmap (node); +if (IS_ERR (regmap_hwv)) { +pr_err ("Cannot find hardware voter regmap for %pOF: %pe\n" , + node, regmap_hwv); +return PTR_ERR (regmap_hwv);
Is there a reason why we aren't using dev_err() or even dev_err_probe() here?
The rest looks OK.
ChenYu
Quoted 84 lines
drivers/clk/mediatek/clk-mux.c +3
-1+ } +for (i =0 ; i < num; i++) {const struct mtk_mux *mux = &muxes[i];@@ -286,7 +355,7 @@ int mtk_clk_register_muxes(struct device *dev,continue ; } - hw =mtk_clk_register_mux (dev, mux, regmap, lock); + hw =mtk_clk_register_mux (dev, mux, regmap, regmap_hwv, lock);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", mux->name,drivers/clk/mediatek/clk-mux.h +42
-1@@ -28,6 +28,10 @@ struct mtk_mux {u32 set_ofs;u32 clr_ofs;u32 upd_ofs; + +u32 hwv_set_ofs; +u32 hwv_clr_ofs; +u32 hwv_sta_ofs;u32 fenc_sta_mon_ofs;u8 mux_shift;@@ -80,6 +84,7 @@ struct mtk_mux {extern const struct clk_ops mtk_mux_clr_set_upd_ops;extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops;extern const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops; +extern const struct clk_ops mtk_mux_gate_hwv_fenc_clr_set_upd_ops; #define MUX_GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ _mux_set_ofs, _mux_clr_ofs, _shift, _width, \@@ -121,6 +126,43 @@ extern const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops; 0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \ mtk_mux_clr_set_upd_ops) +#define MUX_GATE_HWV_FENC_CLR_SET_UPD_FLAGS (_id, _name, _parents, \ + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _hwv_sta_ofs, _hwv_set_ofs, _hwv_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, _flags) { \ + .id = _id, \ + .name = _name, \ + .mux_ofs = _mux_ofs, \ + .set_ofs = _mux_set_ofs, \ + .clr_ofs = _mux_clr_ofs, \ + .hwv_sta_ofs = _hwv_sta_ofs, \ + .hwv_set_ofs = _hwv_set_ofs, \ + .hwv_clr_ofs = _hwv_clr_ofs, \ + .upd_ofs = _upd_ofs, \ + .fenc_sta_mon_ofs = _fenc_sta_mon_ofs, \ + .mux_shift = _shift, \ + .mux_width = _width, \ + .gate_shift = _gate, \ + .upd_shift = _upd, \ + .fenc_shift = _fenc, \ + .parent_names = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .flags = _flags, \ + .ops = &mtk_mux_gate_hwv_fenc_clr_set_upd_ops, \ + } + +#define MUX_GATE_HWV_FENC_CLR_SET_UPD (_id, _name, _parents, \ + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _hwv_sta_ofs, _hwv_set_ofs, _hwv_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc) \ + MUX_GATE_HWV_FENC_CLR_SET_UPD_FLAGS(_id, _name, _parents, \ + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _hwv_sta_ofs, _hwv_set_ofs, _hwv_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, 0) + #define MUX_GATE_FENC_CLR_SET_UPD_FLAGS(_id, _name, _parents, _paridx, \ _num_parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ _shift, _width, _gate, _upd_ofs, _upd, \ --2.39.5
Re: [PATCH v4 05/27] clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC
Quoted 153 lines · Chen-Yu Tsai
Quoted 152 lines · Laura Nao
MT8196 use a HW voter for mux gate enable/disable control, along with a FENC status bit to check the status. Voting is performed using set/clr/upd registers, with a status bit used to verify the vote state. Add new set of mux gate clock operations with support for voting via set/clr/upd regs and FENC status logic.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-mtk.h | 1 + drivers/clk/mediatek/clk-mux.c | 71 +++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-mux.h | 42 ++++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-mtk.h +1
-0@@ -20,6 +20,7 @@#define MHZ (1000 * 1000) +#define MTK_WAIT_HWV_DONE_US 30#define MTK_WAIT_FENC_DONE_US 30struct platform_device ;drivers/clk/mediatek/clk-mux.c +62
-0@@ -8,6 +8,7 @@#include <linux/clk-provider.h> #include <linux/compiler_types.h> #include <linux/container_of.h> +#include <linux/dev_printk.h> #include <linux/err.h> #include <linux/mfd/syscon.h> #include <linux/module.h> @@ -21,6 +22,7 @@struct mtk_clk_mux {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;const struct mtk_mux *data;spinlock_t *lock;bool reparent;@@ -118,6 +120,41 @@ static int mtk_clk_mux_is_enabled(struct clk_hw *hw)return (val &BIT (mux->data->gate_shift)) ==0 ; } +static int mtk_clk_mux_hwv_fenc_enable (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +u32 val; +int ret; + +regmap_write (mux->regmap_hwv, mux->data->hwv_set_ofs, +BIT (mux->data->gate_shift)); + + ret =regmap_read_poll_timeout_atomic (mux->regmap_hwv, mux->data->hwv_sta_ofs, + val, val &BIT (mux->data->gate_shift),0 , +MTK_WAIT_HWV_DONE_US ); +if (ret) +return ret; + + ret =regmap_read_poll_timeout_atomic (mux->regmap, mux->data->fenc_sta_mon_ofs, + val, val &BIT (mux->data->fenc_shift),1 , +MTK_WAIT_FENC_DONE_US ); + +return ret; +} + +static void mtk_clk_mux_hwv_disable (struct clk_hw *hw) +{ +struct mtk_clk_mux *mux =to_mtk_clk_mux (hw); +u32 val; + +regmap_write (mux->regmap_hwv, mux->data->hwv_clr_ofs, +BIT (mux->data->gate_shift)); + +regmap_read_poll_timeout_atomic (mux->regmap_hwv, mux->data->hwv_sta_ofs, + val, (val &BIT (mux->data->gate_shift)), +0 ,MTK_WAIT_HWV_DONE_US ); +} +static u8 mtk_clk_mux_get_parent (struct clk_hw *hw) {struct mtk_clk_mux *mux =to_mtk_clk_mux (hw);@@ -189,6 +226,14 @@ static int mtk_clk_mux_determine_rate(struct clk_hw *hw,return clk_mux_determine_rate_flags (hw, req, mux->data->flags); } +static bool mtk_clk_mux_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_mux_gate_hwv_fenc_clr_set_upd_ops) +return true; + +return false; +} +const struct clk_ops mtk_mux_clr_set_upd_ops = { .get_parent = mtk_clk_mux_get_parent, .set_parent = mtk_clk_mux_set_parent_setclr_lock,@@ -216,9 +261,20 @@ const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops = { };EXPORT_SYMBOL_GPL (mtk_mux_gate_fenc_clr_set_upd_ops); +const struct clk_ops mtk_mux_gate_hwv_fenc_clr_set_upd_ops = { + .enable = mtk_clk_mux_hwv_fenc_enable, + .disable = mtk_clk_mux_hwv_disable, + .is_enabled = mtk_clk_mux_fenc_is_enabled, + .get_parent = mtk_clk_mux_get_parent, + .set_parent = mtk_clk_mux_set_parent_setclr_lock, + .determine_rate = mtk_clk_mux_determine_rate, +}; +EXPORT_SYMBOL_GPL (mtk_mux_gate_hwv_fenc_clr_set_upd_ops); +static struct clk_hw *mtk_clk_register_mux (struct device *dev,const struct mtk_mux *mux,struct regmap *regmap, +struct regmap *regmap_hwv,spinlock_t *lock) {struct mtk_clk_mux *clk_mux;@@ -234,8 +290,13 @@ static struct clk_hw *mtk_clk_register_mux(struct device *dev, init.parent_names = mux->parent_names; init.num_parents = mux->num_parents; init.ops = mux->ops; +if (mtk_clk_mux_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO ); + } clk_mux->regmap = regmap; + clk_mux->regmap_hwv = regmap_hwv; clk_mux->data = mux; clk_mux->lock = lock; clk_mux->hw.init = &init;@@ -268,6 +329,7 @@ int mtk_clk_register_muxes(struct device *dev, struct clk_hw_onecell_data *clk_data) {struct regmap *regmap; +struct regmap *regmap_hwv;struct clk_hw *hw;int i;@@ -277,6 +339,13 @@ int mtk_clk_register_muxes(struct device *dev,return PTR_ERR (regmap); }
Quoted 9 lines
drivers/clk/mediatek/clk-mux.c int mtk_clk_register_muxes(struct device *dev, · line 346
Quoted 5 lines
drivers/clk/mediatek/clk-mux.c +5
-0+ regmap_hwv =mtk_clk_get_hwv_regmap (node); +if (IS_ERR (regmap_hwv)) { +pr_err ("Cannot find hardware voter regmap for %pOF: %pe\n" , + node, regmap_hwv); +return PTR_ERR (regmap_hwv);Is there a reason why we aren't using
dev_err()or evendev_err_probe()here?
Not really, just got swayed by the surrounding pr_* calls. I’ll fix it here and in the other mtk_clk_get_hwv_regmap call. We can clean up the remaining pr_* calls in a separate patch.
Thanks,
Laura
Quoted 88 lines
The rest looks OK.
ChenYu
Quoted 84 lines
drivers/clk/mediatek/clk-mux.c +3
-1+ } +for (i =0 ; i < num; i++) {const struct mtk_mux *mux = &muxes[i];@@ -286,7 +355,7 @@ int mtk_clk_register_muxes(struct device *dev,continue ; } - hw =mtk_clk_register_mux (dev, mux, regmap, lock); + hw =mtk_clk_register_mux (dev, mux, regmap, regmap_hwv, lock);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", mux->name,drivers/clk/mediatek/clk-mux.h +42
-1@@ -28,6 +28,10 @@ struct mtk_mux {u32 set_ofs;u32 clr_ofs;u32 upd_ofs; + +u32 hwv_set_ofs; +u32 hwv_clr_ofs; +u32 hwv_sta_ofs;u32 fenc_sta_mon_ofs;u8 mux_shift;@@ -80,6 +84,7 @@ struct mtk_mux {extern const struct clk_ops mtk_mux_clr_set_upd_ops;extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops;extern const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops; +extern const struct clk_ops mtk_mux_gate_hwv_fenc_clr_set_upd_ops; #define MUX_GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ _mux_set_ofs, _mux_clr_ofs, _shift, _width, \@@ -121,6 +126,43 @@ extern const struct clk_ops mtk_mux_gate_fenc_clr_set_upd_ops; 0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \ mtk_mux_clr_set_upd_ops) +#define MUX_GATE_HWV_FENC_CLR_SET_UPD_FLAGS (_id, _name, _parents, \ + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _hwv_sta_ofs, _hwv_set_ofs, _hwv_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, _flags) { \ + .id = _id, \ + .name = _name, \ + .mux_ofs = _mux_ofs, \ + .set_ofs = _mux_set_ofs, \ + .clr_ofs = _mux_clr_ofs, \ + .hwv_sta_ofs = _hwv_sta_ofs, \ + .hwv_set_ofs = _hwv_set_ofs, \ + .hwv_clr_ofs = _hwv_clr_ofs, \ + .upd_ofs = _upd_ofs, \ + .fenc_sta_mon_ofs = _fenc_sta_mon_ofs, \ + .mux_shift = _shift, \ + .mux_width = _width, \ + .gate_shift = _gate, \ + .upd_shift = _upd, \ + .fenc_shift = _fenc, \ + .parent_names = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .flags = _flags, \ + .ops = &mtk_mux_gate_hwv_fenc_clr_set_upd_ops, \ + } + +#define MUX_GATE_HWV_FENC_CLR_SET_UPD (_id, _name, _parents, \ + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _hwv_sta_ofs, _hwv_set_ofs, _hwv_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc) \ + MUX_GATE_HWV_FENC_CLR_SET_UPD_FLAGS(_id, _name, _parents, \ + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ + _hwv_sta_ofs, _hwv_set_ofs, _hwv_clr_ofs, \ + _shift, _width, _gate, _upd_ofs, _upd, \ + _fenc_sta_mon_ofs, _fenc, 0) + #define MUX_GATE_FENC_CLR_SET_UPD_FLAGS(_id, _name, _parents, _paridx, \ _num_parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ _shift, _width, _gate, _upd_ofs, _upd, \ --2.39.5
PATCH v4 6/27 clk: mediatek: clk-gate: Refactor mtk_clk_register_gate to use mtk_gate struct
In reply to Laura NaoMT8196 uses a HW voter for gate enable/disable control, with set/clr/sta registers located in a separate regmap. Refactor mtk_clk_register_gate() to take a struct mtk_gate instead of individual parameters, avoiding the need to add three extra arguments to support HW voter register offsets.
--- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-)
drivers/clk/mediatek/clk-gate.c +13 -22
@@ -152,12 +152,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv); -static struct clk_hw *mtk_clk_register_gate (struct device *dev,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) +static struct clk_hw *mtk_clk_register_gate (struct device *dev, +const struct mtk_gate *gate, +struct regmap *regmap) {struct mtk_clk_gate *cg;int ret;
@@ -167,17 +164,17 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, const char *nameif (!cg)return ERR_PTR (-ENOMEM ); - init.name = name; - init.flags = flags |CLK_SET_RATE_PARENT ; - init.parent_names = parent_name ? &parent_name :NULL ; - init.num_parents = parent_name ?1 :0 ; - init.ops = ops; + init.name = gate->name; + init.flags = gate->flags |CLK_SET_RATE_PARENT ; + init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; + init.num_parents = gate->parent_name ?1 :0 ; + init.ops = gate->ops; cg->regmap = regmap; - cg->set_ofs = set_ofs; - cg->clr_ofs = clr_ofs; - cg->sta_ofs = sta_ofs; - cg->bit = bit; + cg->set_ofs = gate->regs->set_ofs; + cg->clr_ofs = gate->regs->clr_ofs; + cg->sta_ofs = gate->regs->sta_ofs; + cg->bit = gate->shift; cg->hw.init = &init;
@@ -228,13 +225,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,continue ; } - hw =mtk_clk_register_gate (dev, gate->name, gate->parent_name, - regmap, - gate->regs->set_ofs, - gate->regs->clr_ofs, - gate->regs->sta_ofs, - gate->shift, gate->ops, - gate->flags); + hw =mtk_clk_register_gate (dev, gate, regmap);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", gate->name,
Signature · 1 line
2.39.5
Re: [PATCH v4 06/27] clk: mediatek: clk-gate: Refactor mtk_clk_register_gate to use mtk_gate struct
Quoted 48 lines · Laura Nao
MT8196 uses a HW voter for gate enable/disable control, with set/clr/sta registers located in a separate regmap. Refactor
mtk_clk_register_gate()to take a structmtk_gateinstead of individual parameters, avoiding the need to add three extra arguments to support HW voter register offsets.Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-)drivers/clk/mediatek/clk-gate.c +8
-11@@ -152,12 +152,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv); -static struct clk_hw *mtk_clk_register_gate (struct device *dev,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) +static struct clk_hw *mtk_clk_register_gate (struct device *dev, +const struct mtk_gate *gate, +struct regmap *regmap) {struct mtk_clk_gate *cg;int ret;@@ -167,17 +164,17 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, const char *nameif (!cg)return ERR_PTR (-ENOMEM ); - init.name = name; - init.flags = flags |CLK_SET_RATE_PARENT ; - init.parent_names = parent_name ? &parent_name :NULL ; - init.num_parents = parent_name ?1 :0 ; - init.ops = ops; + init.name = gate->name; + init.flags = gate->flags |CLK_SET_RATE_PARENT ; + init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; + init.num_parents = gate->parent_name ?1 :0 ; + init.ops = gate->ops;
drivers/clk/mediatek/clk-gate.c static struct clk_hw *mtk_clk_register_gate(struct device *dev, const char *name · line 177
Quoted 10 lines
drivers/clk/mediatek/clk-gate.c +4
-4cg->regmap = regmap; - cg->set_ofs = set_ofs; - cg->clr_ofs = clr_ofs; - cg->sta_ofs = sta_ofs; - cg->bit = bit; + cg->set_ofs = gate->regs->set_ofs; + cg->clr_ofs = gate->regs->clr_ofs; + cg->sta_ofs = gate->regs->sta_ofs; + cg->bit = gate->shift;
I'd rather see |struct mtk_clk_gate| (the runtime data) gain a pointer to the static data |struct mtk_gate| instead of doing all the copying. This is just needless duplication.
ChenYu
Quoted 20 lines
drivers/clk/mediatek/clk-gate.c +1
-8cg->hw.init = &init;@@ -228,13 +225,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,continue ; } - hw =mtk_clk_register_gate (dev, gate->name, gate->parent_name, - regmap, - gate->regs->set_ofs, - gate->regs->clr_ofs, - gate->regs->sta_ofs, - gate->shift, gate->ops, - gate->flags); + hw =mtk_clk_register_gate (dev, gate, regmap);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", gate->name, --2.39.5
Re: [PATCH v4 06/27] clk: mediatek: clk-gate: Refactor mtk_clk_register_gate to use mtk_gate struct
Quoted 50 lines · Chen-Yu Tsai
Quoted 49 lines · Laura Nao
MT8196 uses a HW voter for gate enable/disable control, with set/clr/sta registers located in a separate regmap. Refactor
mtk_clk_register_gate()to take a structmtk_gateinstead of individual parameters, avoiding the need to add three extra arguments to support HW voter register offsets.Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-)drivers/clk/mediatek/clk-gate.c +8
-11@@ -152,12 +152,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv); -static struct clk_hw *mtk_clk_register_gate (struct device *dev,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) +static struct clk_hw *mtk_clk_register_gate (struct device *dev, +const struct mtk_gate *gate, +struct regmap *regmap) {struct mtk_clk_gate *cg;int ret;@@ -167,17 +164,17 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, const char *nameif (!cg)return ERR_PTR (-ENOMEM ); - init.name = name; - init.flags = flags |CLK_SET_RATE_PARENT ; - init.parent_names = parent_name ? &parent_name :NULL ; - init.num_parents = parent_name ?1 :0 ; - init.ops = ops; + init.name = gate->name; + init.flags = gate->flags |CLK_SET_RATE_PARENT ; + init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; + init.num_parents = gate->parent_name ?1 :0 ; + init.ops = gate->ops;
Quoted 14 lines
drivers/clk/mediatek/clk-gate.c static struct clk_hw *mtk_clk_register_gate(struct device *dev, const char *name · line 177
Quoted 9 lines
drivers/clk/mediatek/clk-gate.c +4
-4cg->regmap = regmap; - cg->set_ofs = set_ofs; - cg->clr_ofs = clr_ofs; - cg->sta_ofs = sta_ofs; - cg->bit = bit; + cg->set_ofs = gate->regs->set_ofs; + cg->clr_ofs = gate->regs->clr_ofs; + cg->sta_ofs = gate->regs->sta_ofs; + cg->bit = gate->shift;I'd rather see |struct mtk_clk_gate| (the runtime data) gain a pointer to the static data |struct mtk_gate| instead of doing all the copying. This is just needless duplication.
Ack - I'll refactor this in the next revision.
Thanks,
Laura
Quoted 22 lines
ChenYu
Quoted 20 lines
drivers/clk/mediatek/clk-gate.c +1
-8cg->hw.init = &init;@@ -228,13 +225,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,continue ; } - hw =mtk_clk_register_gate (dev, gate->name, gate->parent_name, - regmap, - gate->regs->set_ofs, - gate->regs->clr_ofs, - gate->regs->sta_ofs, - gate->shift, gate->ops, - gate->flags); + hw =mtk_clk_register_gate (dev, gate, regmap);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", gate->name, --2.39.5
PATCH v4 7/27 clk: mediatek: clk-gate: Add ops for gates with HW voter
In reply to Laura NaoMT8196 use a HW voter for gate enable/disable control. Voting is performed using set/clr regs, with a status bit used to verify the vote state. Add new set of gate clock operations with support for voting via set/clr regs.
--- drivers/clk/mediatek/clk-gate.c | 77 +++++++++++++++++++++++++++++++-- drivers/clk/mediatek/clk-gate.h | 3 ++ 2 files changed, 77 insertions(+), 3 deletions(-)
drivers/clk/mediatek/clk-gate.c +74 -3
@@ -5,6 +5,7 @@*/ #include <linux/clk-provider.h> +#include <linux/dev_printk.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/printk.h>
@@ -12,14 +13,19 @@#include <linux/slab.h> #include <linux/types.h> +#include "clk-mtk.h" #include "clk-gate.h" struct mtk_clk_gate {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;int set_ofs;int clr_ofs;int sta_ofs; +unsigned int hwv_set_ofs; +unsigned int hwv_clr_ofs; +unsigned int hwv_sta_ofs;u8 bit; };
@@ -100,6 +106,28 @@ static void mtk_cg_disable_inv(struct clk_hw *hw)mtk_cg_clr_bit (hw); } +static int mtk_cg_hwv_set_en (struct clk_hw *hw,bool enable) +{ +struct mtk_clk_gate *cg =to_mtk_clk_gate (hw); +u32 val; + +regmap_write (cg->regmap_hwv, enable ? cg->hwv_set_ofs : cg->hwv_clr_ofs,BIT (cg->bit)); + +return regmap_read_poll_timeout_atomic (cg->regmap_hwv, cg->hwv_sta_ofs, val, + val &BIT (cg->bit), +0 ,MTK_WAIT_HWV_DONE_US ); +} + +static int mtk_cg_hwv_enable (struct clk_hw *hw) +{ +return mtk_cg_hwv_set_en (hw, true); +} + +static void mtk_cg_hwv_disable (struct clk_hw *hw) +{ +mtk_cg_hwv_set_en (hw, false); +} +static int mtk_cg_enable_no_setclr (struct clk_hw *hw) {mtk_cg_clr_bit_no_setclr (hw);
@@ -124,6 +152,15 @@ static void mtk_cg_disable_inv_no_setclr(struct clk_hw *hw)mtk_cg_clr_bit_no_setclr (hw); } +static bool mtk_cg_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_clk_gate_hwv_ops_setclr || + ops == &mtk_clk_gate_hwv_ops_setclr_inv) +return true; + +return false; +} +const struct clk_ops mtk_clk_gate_ops_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable,
@@ -138,6 +175,20 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_hwv_ops_setclr = { + .is_enabled = mtk_cg_bit_is_cleared, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr); + +const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv = { + .is_enabled = mtk_cg_bit_is_set, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_ops_no_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable_no_setclr,
@@ -153,8 +204,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = {EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv);static struct clk_hw *mtk_clk_register_gate (struct device *dev, -const struct mtk_gate *gate, -struct regmap *regmap) +const struct mtk_gate *gate, +struct regmap *regmap, +struct regmap *regmap_hwv) {struct mtk_clk_gate *cg;int ret;
@@ -169,11 +221,22 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; init.num_parents = gate->parent_name ?1 :0 ; init.ops = gate->ops; +if (mtk_cg_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO ); + } cg->regmap = regmap; + cg->regmap_hwv = regmap_hwv; cg->set_ofs = gate->regs->set_ofs; cg->clr_ofs = gate->regs->clr_ofs; cg->sta_ofs = gate->regs->sta_ofs; +if (gate->hwv_regs) { + cg->hwv_set_ofs = gate->hwv_regs->set_ofs; + cg->hwv_clr_ofs = gate->hwv_regs->clr_ofs; + cg->hwv_sta_ofs = gate->hwv_regs->sta_ofs; + } + cg->bit = gate->shift; cg->hw.init = &init;
@@ -206,6 +269,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,int i;struct clk_hw *hw;struct regmap *regmap; +struct regmap *regmap_hwv;if (!clk_data)return -ENOMEM ;
@@ -216,6 +280,13 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,return PTR_ERR (regmap); } + regmap_hwv =mtk_clk_get_hwv_regmap (node); +if (IS_ERR (regmap_hwv)) { +pr_err ("Cannot find hardware voter regmap for %pOF: %pe\n" , + node, regmap_hwv); +return PTR_ERR (regmap_hwv); + } +for (i =0 ; i < num; i++) {const struct mtk_gate *gate = &clks[i];
@@ -225,7 +296,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,continue ; } - hw =mtk_clk_register_gate (dev, gate, regmap); + hw =mtk_clk_register_gate (dev, gate, regmap, regmap_hwv);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", gate->name,
drivers/clk/mediatek/clk-gate.h +3 -0
@@ -19,6 +19,8 @@ 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; +extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr; +extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv;struct mtk_gate_regs {u32 sta_ofs;
@@ -31,6 +33,7 @@ struct mtk_gate {const char *name;const char *parent_name;const struct mtk_gate_regs *regs; +const struct mtk_gate_regs *hwv_regs;int shift;const struct clk_ops *ops;unsigned long flags;
Signature · 1 line
2.39.5
Re: [PATCH v4 07/27] clk: mediatek: clk-gate: Add ops for gates with HW voter
Quoted 125 lines · Laura Nao
MT8196 use a HW voter for gate enable/disable control. Voting is performed using set/clr regs, with a status bit used to verify the vote state. Add new set of gate clock operations with support for voting via set/clr regs.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-gate.c | 77 +++++++++++++++++++++++++++++++-- drivers/clk/mediatek/clk-gate.h | 3 ++ 2 files changed, 77 insertions(+), 3 deletions(-)drivers/clk/mediatek/clk-gate.c +54
-2@@ -5,6 +5,7 @@*/ #include <linux/clk-provider.h> +#include <linux/dev_printk.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/printk.h> @@ -12,14 +13,19 @@#include <linux/slab.h> #include <linux/types.h> +#include "clk-mtk.h" #include "clk-gate.h" struct mtk_clk_gate {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;int set_ofs;int clr_ofs;int sta_ofs; +unsigned int hwv_set_ofs; +unsigned int hwv_clr_ofs; +unsigned int hwv_sta_ofs;u8 bit; };@@ -100,6 +106,28 @@ static void mtk_cg_disable_inv(struct clk_hw *hw)mtk_cg_clr_bit (hw); } +static int mtk_cg_hwv_set_en (struct clk_hw *hw,bool enable) +{ +struct mtk_clk_gate *cg =to_mtk_clk_gate (hw); +u32 val; + +regmap_write (cg->regmap_hwv, enable ? cg->hwv_set_ofs : cg->hwv_clr_ofs,BIT (cg->bit)); + +return regmap_read_poll_timeout_atomic (cg->regmap_hwv, cg->hwv_sta_ofs, val, + val &BIT (cg->bit), +0 ,MTK_WAIT_HWV_DONE_US ); +} + +static int mtk_cg_hwv_enable (struct clk_hw *hw) +{ +return mtk_cg_hwv_set_en (hw, true); +} + +static void mtk_cg_hwv_disable (struct clk_hw *hw) +{ +mtk_cg_hwv_set_en (hw, false); +} +static int mtk_cg_enable_no_setclr (struct clk_hw *hw) {mtk_cg_clr_bit_no_setclr (hw);@@ -124,6 +152,15 @@ static void mtk_cg_disable_inv_no_setclr(struct clk_hw *hw)mtk_cg_clr_bit_no_setclr (hw); } +static bool mtk_cg_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_clk_gate_hwv_ops_setclr || + ops == &mtk_clk_gate_hwv_ops_setclr_inv) +return true; + +return false; +} +const struct clk_ops mtk_clk_gate_ops_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable,@@ -138,6 +175,20 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_hwv_ops_setclr = { + .is_enabled = mtk_cg_bit_is_cleared, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr); + +const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv = { + .is_enabled = mtk_cg_bit_is_set, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_ops_no_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable_no_setclr,@@ -153,8 +204,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = {EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv);static struct clk_hw *mtk_clk_register_gate (struct device *dev, -const struct mtk_gate *gate, -struct regmap *regmap) +const struct mtk_gate *gate, +struct regmap *regmap, +struct regmap *regmap_hwv) {struct mtk_clk_gate *cg;int ret;
drivers/clk/mediatek/clk-gate.c static struct clk_hw *mtk_clk_register_gate(struct device *dev, · line 226
Quoted 6 lines
drivers/clk/mediatek/clk-gate.c +3
-0@@ -169,11 +221,22 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; init.num_parents = gate->parent_name ?1 :0 ; init.ops = gate->ops; +if (mtk_cg_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO );
return dev_err_probe()?
I believe the same applies to the previous patch.
Quoted 25 lines
drivers/clk/mediatek/clk-gate.c +9
-0+ } cg->regmap = regmap; + cg->regmap_hwv = regmap_hwv; cg->set_ofs = gate->regs->set_ofs; cg->clr_ofs = gate->regs->clr_ofs; cg->sta_ofs = gate->regs->sta_ofs; +if (gate->hwv_regs) { + cg->hwv_set_ofs = gate->hwv_regs->set_ofs; + cg->hwv_clr_ofs = gate->hwv_regs->clr_ofs; + cg->hwv_sta_ofs = gate->hwv_regs->sta_ofs; + } + cg->bit = gate->shift; cg->hw.init = &init;@@ -206,6 +269,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,int i;struct clk_hw *hw;struct regmap *regmap; +struct regmap *regmap_hwv;if (!clk_data)return -ENOMEM ;
drivers/clk/mediatek/clk-gate.c int mtk_clk_register_gates(struct device *dev, struct device_node *node, · line 287
Quoted 8 lines
drivers/clk/mediatek/clk-gate.c +5
-0@@ -216,6 +280,13 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,return PTR_ERR (regmap); } + regmap_hwv =mtk_clk_get_hwv_regmap (node); +if (IS_ERR (regmap_hwv)) { +pr_err ("Cannot find hardware voter regmap for %pOF: %pe\n" , + node, regmap_hwv); +return PTR_ERR (regmap_hwv);
return dev_err_probe();
ChenYu
Quoted 38 lines
drivers/clk/mediatek/clk-gate.c +3
-1+ } +for (i =0 ; i < num; i++) {const struct mtk_gate *gate = &clks[i];@@ -225,7 +296,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,continue ; } - hw =mtk_clk_register_gate (dev, gate, regmap); + hw =mtk_clk_register_gate (dev, gate, regmap, regmap_hwv);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", gate->name,drivers/clk/mediatek/clk-gate.h +3
-1@@ -19,6 +19,8 @@ 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; +extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr; +extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv;struct mtk_gate_regs {u32 sta_ofs;@@ -31,6 +33,7 @@ struct mtk_gate {const char *name;const char *parent_name;const struct mtk_gate_regs *regs; +const struct mtk_gate_regs *hwv_regs;int shift;const struct clk_ops *ops;unsigned long flags; --2.39.5
Re: [PATCH v4 07/27] clk: mediatek: clk-gate: Add ops for gates with HW voter
Quoted 135 lines · Chen-Yu Tsai
Quoted 125 lines · Laura Nao
MT8196 use a HW voter for gate enable/disable control. Voting is performed using set/clr regs, with a status bit used to verify the vote state. Add new set of gate clock operations with support for voting via set/clr regs.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-gate.c | 77 +++++++++++++++++++++++++++++++-- drivers/clk/mediatek/clk-gate.h | 3 ++ 2 files changed, 77 insertions(+), 3 deletions(-)drivers/clk/mediatek/clk-gate.c +54
-2@@ -5,6 +5,7 @@*/ #include <linux/clk-provider.h> +#include <linux/dev_printk.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/printk.h> @@ -12,14 +13,19 @@#include <linux/slab.h> #include <linux/types.h> +#include "clk-mtk.h" #include "clk-gate.h" struct mtk_clk_gate {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;int set_ofs;int clr_ofs;int sta_ofs; +unsigned int hwv_set_ofs; +unsigned int hwv_clr_ofs; +unsigned int hwv_sta_ofs;u8 bit; };@@ -100,6 +106,28 @@ static void mtk_cg_disable_inv(struct clk_hw *hw)mtk_cg_clr_bit (hw); } +static int mtk_cg_hwv_set_en (struct clk_hw *hw,bool enable) +{ +struct mtk_clk_gate *cg =to_mtk_clk_gate (hw); +u32 val; + +regmap_write (cg->regmap_hwv, enable ? cg->hwv_set_ofs : cg->hwv_clr_ofs,BIT (cg->bit)); + +return regmap_read_poll_timeout_atomic (cg->regmap_hwv, cg->hwv_sta_ofs, val, + val &BIT (cg->bit), +0 ,MTK_WAIT_HWV_DONE_US ); +} + +static int mtk_cg_hwv_enable (struct clk_hw *hw) +{ +return mtk_cg_hwv_set_en (hw, true); +} + +static void mtk_cg_hwv_disable (struct clk_hw *hw) +{ +mtk_cg_hwv_set_en (hw, false); +} +static int mtk_cg_enable_no_setclr (struct clk_hw *hw) {mtk_cg_clr_bit_no_setclr (hw);@@ -124,6 +152,15 @@ static void mtk_cg_disable_inv_no_setclr(struct clk_hw *hw)mtk_cg_clr_bit_no_setclr (hw); } +static bool mtk_cg_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_clk_gate_hwv_ops_setclr || + ops == &mtk_clk_gate_hwv_ops_setclr_inv) +return true; + +return false; +} +const struct clk_ops mtk_clk_gate_ops_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable,@@ -138,6 +175,20 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_hwv_ops_setclr = { + .is_enabled = mtk_cg_bit_is_cleared, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr); + +const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv = { + .is_enabled = mtk_cg_bit_is_set, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_ops_no_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable_no_setclr,@@ -153,8 +204,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = {EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv);static struct clk_hw *mtk_clk_register_gate (struct device *dev, -const struct mtk_gate *gate, -struct regmap *regmap) +const struct mtk_gate *gate, +struct regmap *regmap, +struct regmap *regmap_hwv) {struct mtk_clk_gate *cg;int ret;drivers/clk/mediatek/clk-gate.c static struct clk_hw *mtk_clk_register_gate(struct device *dev, · line 226
Quoted 6 lines
drivers/clk/mediatek/clk-gate.c +3
-0@@ -169,11 +221,22 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; init.num_parents = gate->parent_name ?1 :0 ; init.ops = gate->ops; +if (mtk_cg_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO );return
dev_err_probe()?
Quoted 2 lines
I believe the same applies to the previous patch.
mtk_clk_register_gate and mtk_clk_register_mux actually both return a struct clk_hw *.
Quoted 28 lines
Quoted 28 lines
drivers/clk/mediatek/clk-gate.c +9
-0+ } cg->regmap = regmap; + cg->regmap_hwv = regmap_hwv; cg->set_ofs = gate->regs->set_ofs; cg->clr_ofs = gate->regs->clr_ofs; cg->sta_ofs = gate->regs->sta_ofs; +if (gate->hwv_regs) { + cg->hwv_set_ofs = gate->hwv_regs->set_ofs; + cg->hwv_clr_ofs = gate->hwv_regs->clr_ofs; + cg->hwv_sta_ofs = gate->hwv_regs->sta_ofs; + } + cg->bit = gate->shift; cg->hw.init = &init;@@ -206,6 +269,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,int i;struct clk_hw *hw;struct regmap *regmap; +struct regmap *regmap_hwv;if (!clk_data)return -ENOMEM ;@@ -216,6 +280,13 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,return PTR_ERR (regmap); }
Quoted 8 lines
drivers/clk/mediatek/clk-gate.c int mtk_clk_register_gates(struct device *dev, struct device_node *node, · line 287
Quoted 5 lines
drivers/clk/mediatek/clk-gate.c +5
-0+ regmap_hwv =mtk_clk_get_hwv_regmap (node); +if (IS_ERR (regmap_hwv)) { +pr_err ("Cannot find hardware voter regmap for %pOF: %pe\n" , + node, regmap_hwv); +return PTR_ERR (regmap_hwv);return
dev_err_probe();
Will do.
Thanks,
Laura
Quoted 40 lines
ChenYu
Quoted 38 lines
drivers/clk/mediatek/clk-gate.c +3
-1+ } +for (i =0 ; i < num; i++) {const struct mtk_gate *gate = &clks[i];@@ -225,7 +296,7 @@ int mtk_clk_register_gates(struct device *dev, struct device_node *node,continue ; } - hw =mtk_clk_register_gate (dev, gate, regmap); + hw =mtk_clk_register_gate (dev, gate, regmap, regmap_hwv);if (IS_ERR (hw)) { pr_err("Failed to register clk %s: %pe\n", gate->name,drivers/clk/mediatek/clk-gate.h +3
-1@@ -19,6 +19,8 @@ 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; +extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr; +extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv;struct mtk_gate_regs {u32 sta_ofs;@@ -31,6 +33,7 @@ struct mtk_gate {const char *name;const char *parent_name;const struct mtk_gate_regs *regs; +const struct mtk_gate_regs *hwv_regs;int shift;const struct clk_ops *ops;unsigned long flags; --2.39.5
Re: [PATCH v4 07/27] clk: mediatek: clk-gate: Add ops for gates with HW voter
Quoted 137 lines · Laura Nao
Quoted 135 lines · Chen-Yu Tsai
Quoted 125 lines · Laura Nao
MT8196 use a HW voter for gate enable/disable control. Voting is performed using set/clr regs, with a status bit used to verify the vote state. Add new set of gate clock operations with support for voting via set/clr regs.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-gate.c | 77 +++++++++++++++++++++++++++++++-- drivers/clk/mediatek/clk-gate.h | 3 ++ 2 files changed, 77 insertions(+), 3 deletions(-)drivers/clk/mediatek/clk-gate.c +54
-2@@ -5,6 +5,7 @@*/ #include <linux/clk-provider.h> +#include <linux/dev_printk.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/printk.h> @@ -12,14 +13,19 @@#include <linux/slab.h> #include <linux/types.h> +#include "clk-mtk.h" #include "clk-gate.h" struct mtk_clk_gate {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;int set_ofs;int clr_ofs;int sta_ofs; +unsigned int hwv_set_ofs; +unsigned int hwv_clr_ofs; +unsigned int hwv_sta_ofs;u8 bit; };@@ -100,6 +106,28 @@ static void mtk_cg_disable_inv(struct clk_hw *hw)mtk_cg_clr_bit (hw); } +static int mtk_cg_hwv_set_en (struct clk_hw *hw,bool enable) +{ +struct mtk_clk_gate *cg =to_mtk_clk_gate (hw); +u32 val; + +regmap_write (cg->regmap_hwv, enable ? cg->hwv_set_ofs : cg->hwv_clr_ofs,BIT (cg->bit)); + +return regmap_read_poll_timeout_atomic (cg->regmap_hwv, cg->hwv_sta_ofs, val, + val &BIT (cg->bit), +0 ,MTK_WAIT_HWV_DONE_US ); +} + +static int mtk_cg_hwv_enable (struct clk_hw *hw) +{ +return mtk_cg_hwv_set_en (hw, true); +} + +static void mtk_cg_hwv_disable (struct clk_hw *hw) +{ +mtk_cg_hwv_set_en (hw, false); +} +static int mtk_cg_enable_no_setclr (struct clk_hw *hw) {mtk_cg_clr_bit_no_setclr (hw);@@ -124,6 +152,15 @@ static void mtk_cg_disable_inv_no_setclr(struct clk_hw *hw)mtk_cg_clr_bit_no_setclr (hw); } +static bool mtk_cg_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_clk_gate_hwv_ops_setclr || + ops == &mtk_clk_gate_hwv_ops_setclr_inv) +return true; + +return false; +} +const struct clk_ops mtk_clk_gate_ops_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable,@@ -138,6 +175,20 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_hwv_ops_setclr = { + .is_enabled = mtk_cg_bit_is_cleared, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr); + +const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv = { + .is_enabled = mtk_cg_bit_is_set, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_ops_no_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable_no_setclr,@@ -153,8 +204,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = {EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv);static struct clk_hw *mtk_clk_register_gate (struct device *dev, -const struct mtk_gate *gate, -struct regmap *regmap) +const struct mtk_gate *gate, +struct regmap *regmap, +struct regmap *regmap_hwv) {struct mtk_clk_gate *cg;int ret;drivers/clk/mediatek/clk-gate.c static struct clk_hw *mtk_clk_register_gate(struct device *dev, · line 226
Quoted 6 lines
drivers/clk/mediatek/clk-gate.c +3
-0@@ -169,11 +221,22 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; init.num_parents = gate->parent_name ?1 :0 ; init.ops = gate->ops; +if (mtk_cg_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO );return
dev_err_probe()?
Quoted 5 lines
Quoted 2 lines
I believe the same applies to the previous patch.
mtk_clk_register_gateandmtk_clk_register_muxactually both return a structclk_hw*.
Oops, you're right. If that case I believe dev_err_ptr_probe() could be used?
ChenYu
Re: [PATCH v4 07/27] clk: mediatek: clk-gate: Add ops for gates with HW voter
Quoted 138 lines · Chen-Yu Tsai
Quoted 137 lines · Laura Nao
Quoted 135 lines · Chen-Yu Tsai
Quoted 125 lines · Laura Nao
MT8196 use a HW voter for gate enable/disable control. Voting is performed using set/clr regs, with a status bit used to verify the vote state. Add new set of gate clock operations with support for voting via set/clr regs.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/clk-gate.c | 77 +++++++++++++++++++++++++++++++-- drivers/clk/mediatek/clk-gate.h | 3 ++ 2 files changed, 77 insertions(+), 3 deletions(-)drivers/clk/mediatek/clk-gate.c +54
-2@@ -5,6 +5,7 @@*/ #include <linux/clk-provider.h> +#include <linux/dev_printk.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/printk.h> @@ -12,14 +13,19 @@#include <linux/slab.h> #include <linux/types.h> +#include "clk-mtk.h" #include "clk-gate.h" struct mtk_clk_gate {struct clk_hw hw;struct regmap *regmap; +struct regmap *regmap_hwv;int set_ofs;int clr_ofs;int sta_ofs; +unsigned int hwv_set_ofs; +unsigned int hwv_clr_ofs; +unsigned int hwv_sta_ofs;u8 bit; };@@ -100,6 +106,28 @@ static void mtk_cg_disable_inv(struct clk_hw *hw)mtk_cg_clr_bit (hw); } +static int mtk_cg_hwv_set_en (struct clk_hw *hw,bool enable) +{ +struct mtk_clk_gate *cg =to_mtk_clk_gate (hw); +u32 val; + +regmap_write (cg->regmap_hwv, enable ? cg->hwv_set_ofs : cg->hwv_clr_ofs,BIT (cg->bit)); + +return regmap_read_poll_timeout_atomic (cg->regmap_hwv, cg->hwv_sta_ofs, val, + val &BIT (cg->bit), +0 ,MTK_WAIT_HWV_DONE_US ); +} + +static int mtk_cg_hwv_enable (struct clk_hw *hw) +{ +return mtk_cg_hwv_set_en (hw, true); +} + +static void mtk_cg_hwv_disable (struct clk_hw *hw) +{ +mtk_cg_hwv_set_en (hw, false); +} +static int mtk_cg_enable_no_setclr (struct clk_hw *hw) {mtk_cg_clr_bit_no_setclr (hw);@@ -124,6 +152,15 @@ static void mtk_cg_disable_inv_no_setclr(struct clk_hw *hw)mtk_cg_clr_bit_no_setclr (hw); } +static bool mtk_cg_uses_hwv (const struct clk_ops *ops) +{ +if (ops == &mtk_clk_gate_hwv_ops_setclr || + ops == &mtk_clk_gate_hwv_ops_setclr_inv) +return true; + +return false; +} +const struct clk_ops mtk_clk_gate_ops_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable,@@ -138,6 +175,20 @@ const struct clk_ops mtk_clk_gate_ops_setclr_inv = { };EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_hwv_ops_setclr = { + .is_enabled = mtk_cg_bit_is_cleared, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr); + +const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv = { + .is_enabled = mtk_cg_bit_is_set, + .enable = mtk_cg_hwv_enable, + .disable = mtk_cg_hwv_disable, +}; +EXPORT_SYMBOL_GPL (mtk_clk_gate_hwv_ops_setclr_inv); +const struct clk_ops mtk_clk_gate_ops_no_setclr = { .is_enabled = mtk_cg_bit_is_cleared, .enable = mtk_cg_enable_no_setclr,@@ -153,8 +204,9 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = {EXPORT_SYMBOL_GPL (mtk_clk_gate_ops_no_setclr_inv);static struct clk_hw *mtk_clk_register_gate (struct device *dev, -const struct mtk_gate *gate, -struct regmap *regmap) +const struct mtk_gate *gate, +struct regmap *regmap, +struct regmap *regmap_hwv) {struct mtk_clk_gate *cg;int ret;drivers/clk/mediatek/clk-gate.c static struct clk_hw *mtk_clk_register_gate(struct device *dev, · line 226
Quoted 6 lines
drivers/clk/mediatek/clk-gate.c +3
-0@@ -169,11 +221,22 @@ static struct clk_hw *mtk_clk_register_gate(struct device *dev, init.parent_names = gate->parent_name ? &gate->parent_name :NULL ; init.num_parents = gate->parent_name ?1 :0 ; init.ops = gate->ops; +if (mtk_cg_uses_hwv (init.ops) && !regmap_hwv) { +dev_err (dev,"regmap not found for hardware voter clocks\n" ); +return ERR_PTR (-ENXIO );return
dev_err_probe()?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I believe the same applies to the previous patch.
mtk_clk_register_gateandmtk_clk_register_muxactually both return a structclk_hw*.Oops, you're right. If that case I believe
dev_err_ptr_probe()could be used?
Indeed, thanks for the pointer. I'll fix it in the next revision.
Laura
PATCH v4 8/27 clk: mediatek: clk-mtk: Add MUX_DIV_GATE macro
In reply to Laura NaoOn MT8196, some clocks use one register for parent selection and gating, and a separate register for frequency division. Since composite clocks can combine a mux, divider, and gate in a single entity, add a macro to simplify registration of such clocks by combining parent selection, frequency scaling, and enable control into one definition.
--- drivers/clk/mediatek/clk-mtk.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/clk/mediatek/clk-mtk.h +19 -0
@@ -176,6 +176,25 @@ struct mtk_composite { .flags = 0, \ } +#define MUX_DIV_GATE (_id, _name, _parents, \ + _mux_reg, _mux_shift, _mux_width, \ + _div_reg, _div_shift, _div_width, \ + _gate_reg, _gate_shift) { \ + .id = _id, \ + .name = _name, \ + .parent_names = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .mux_reg = _mux_reg, \ + .mux_shift = _mux_shift, \ + .mux_width = _mux_width, \ + .divider_reg = _div_reg, \ + .divider_shift = _div_shift, \ + .divider_width = _div_width, \ + .gate_reg = _gate_reg, \ + .gate_shift = _gate_shift, \ + .flags = CLK_SET_RATE_PARENT, \ + } + int mtk_clk_register_composites(struct device *dev, const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock,
Signature · 1 line
2.39.5
Re: [PATCH v4 08/27] clk: mediatek: clk-mtk: Add MUX_DIV_GATE macro
Quoted 10 lines · Laura Nao
On MT8196, some clocks use one register for parent selection and gating, and a separate register for frequency division. Since composite clocks can combine a mux, divider, and gate in a single entity, add a macro to simplify registration of such clocks by combining parent selection, frequency scaling, and enable control into one definition.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>
PATCH v4 9/27 dt-bindings: clock: mediatek: Describe MT8196 clock controllers
In reply to Laura NaoIntroduce binding documentation for system clocks, functional clocks, and PEXTP0/1 and UFS reset controllers on MediaTek MT8196.
This binding also includes a handle to the hardware voter, a fixed-function MCU designed to aggregate votes from the application processor and other remote processors to manage clocks and power domains.
The HWV on MT8196/MT6991 is incomplete and requires software to manually enable power supplies, parent clocks, and FENC, as well as write to both the HWV MMIO and the controller registers.
Because of these constraints, the HWV cannot be modeled using generic clock, power domain, or interconnect APIs. Instead, a custom phandle is exceptionally used to provide direct, syscon-like register access to drivers.
--- .../bindings/clock/mediatek,mt8196-clock.yaml | 112 +++ .../clock/mediatek,mt8196-sys-clock.yaml | 107 +++ .../dt-bindings/clock/mediatek,mt8196-clock.h | 802 ++++++++++++++++++ .../reset/mediatek,mt8196-resets.h | 26 + 4 files changed, 1047 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8196-sys-clock.yaml create mode 100644 include/dt-bindings/clock/mediatek,mt8196-clock.h create mode 100644 include/dt-bindings/reset/mediatek,mt8196-resets.h
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +112 -0
@@ -0,0 +1,112 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/mediatek,mt8196-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Functional Clock Controller for MT8196 + +maintainers: + - Guangjie Song <[email protected]> + - Laura Nao <[email protected]> + +description: | + The clock architecture in MediaTek SoCs is structured like below: + PLLs --> + dividers --> + muxes + --> + clock gate + + The device nodes provide clock gate control in different IP blocks. + +properties: + compatible: + items: + - enum: + - mediatek,mt8196-imp-iic-wrap-c + - mediatek,mt8196-imp-iic-wrap-e + - mediatek,mt8196-imp-iic-wrap-n + - mediatek,mt8196-imp-iic-wrap-w + - mediatek,mt8196-mdpsys0 + - mediatek,mt8196-mdpsys1 + - mediatek,mt8196-pericfg-ao + - mediatek,mt8196-pextp0cfg-ao + - mediatek,mt8196-pextp1cfg-ao + - mediatek,mt8196-ufscfg-ao + - mediatek,mt8196-vencsys + - mediatek,mt8196-vencsys-c1 + - mediatek,mt8196-vencsys-c2 + - mediatek,mt8196-vdecsys + - mediatek,mt8196-vdecsys-soc + - mediatek,mt8196-vdisp-ao + - const: syscon + + reg: + maxItems: 1 + + '#clock-cells': + const: 1 + + '#reset-cells': + const: 1 + description: + Reset lines for PEXTP0/1 and UFS blocks. + + mediatek,hardware-voter: + $ref: /schemas/types.yaml#/definitions/phandle + description: | + Phandle to the "Hardware Voter" (HWV), as named in the vendor + documentation for MT8196/MT6991. + + The HWV is a SoC-internal fixed-function MCU used to collect votes from + both the Application Processor and other remote processors within the SoC. + It is intended to transparently enable or disable hardware resources (such + as power domains or clocks) based on internal vote aggregation handled by + the MCU's internal state machine. + + However, in practice, this design is incomplete. While the HWV performs + some internal vote aggregation,software is still required to + - Manually enable power supplies externally, if present and if required + - Manually enable parent clocks via direct MMIO writes to clock controllers + - Enable the FENC after the clock has been ungated via direct MMIO + writes to clock controllers + + As such, the HWV behaves more like a hardware-managed clock reference + counter than a true voter. Furthermore, it is not a separate + controller. It merely serves as an alternative interface to the same + underlying clock or power controller. Actual control still requires + direct access to the controller's own MMIO register space, in + addition to writing to the HWV's MMIO region. + + For this reason, a custom phandle is used here - drivers need to directly + access the HWV MMIO region in a syscon-like fashion, due to how the + hardware is wired. This differs from true hardware voting systems, which + typically do not require custom phandles and rely instead on generic APIs + (clocks, power domains, interconnects). + + The name "hardware-voter" is retained to match vendor documentation, but + this should not be reused or misunderstood as a proper voting mechanism. + +required: + - compatible + - reg + - '#clock-cells' + +additionalProperties: false + +examples: + - | + pericfg_ao: clock-controller@16640000 { + compatible = "mediatek,mt8196-pericfg-ao", "syscon"; + reg = <0x16640000 0x1000>; + mediatek,hardware-voter = <&scp_hwv>; + #clock-cells = <1>; + }; + - | + pextp0cfg_ao: clock-controller@169b0000 { + compatible = "mediatek,mt8196-pextp0cfg-ao", "syscon"; + reg = <0x169b0000 0x1000>; + #clock-cells = <1>; + #reset-cells = <1>; + };
Documentation/devicetree/bindings/clock/mediatek,mt8196-sys-clock.yaml new file +107 -0
107 lines not on this page · raw message
include/dt-bindings/clock/mediatek,mt8196-clock.h new file +802 -0
802 lines not on this page · raw message
include/dt-bindings/reset/mediatek,mt8196-resets.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (c) 2025 Collabora Ltd. +* Author: AngeloGioacchino Del Regno <[email protected]> +*/ + +#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT8196 +#define _DT_BINDINGS_RESET_CONTROLLER_MT8196 + +/* PEXTP0 resets */ +#define MT8196_PEXTP0_RST0_PCIE0_MAC 0 +#define MT8196_PEXTP0_RST0_PCIE0_PHY 1 + +/* PEXTP1 resets */ +#define MT8196_PEXTP1_RST0_PCIE1_MAC 0 +#define MT8196_PEXTP1_RST0_PCIE1_PHY 1 +#define MT8196_PEXTP1_RST0_PCIE2_MAC 2 +#define MT8196_PEXTP1_RST0_PCIE2_PHY 3 + +/* UFS resets */ +#define MT8196_UFSAO_RST0_UFS_MPHY 0 +#define MT8196_UFSAO_RST1_UFS_UNIPRO 1 +#define MT8196_UFSAO_RST1_UFS_CRYPTO 2 +#define MT8196_UFSAO_RST1_UFSHCI 3 + +#endif /* _DT_BINDINGS_RESET_CONTROLLER_MT8196 */
Signature · 1 line
2.39.5
Re: [PATCH v4 09/27] dt-bindings: clock: mediatek: Describe MT8196 clock controllers
Quoted 16 lines · Laura Nao
Introduce binding documentation for system clocks, functional clocks, and PEXTP0/1 and UFS reset controllers on MediaTek MT8196.
This binding also includes a handle to the hardware voter, a fixed-function MCU designed to aggregate votes from the application processor and other remote processors to manage clocks and power domains.
The HWV on MT8196/MT6991 is incomplete and requires software to manually enable power supplies, parent clocks, and FENC, as well as write to both the HWV MMIO and the controller registers.
Because of these constraints, the HWV cannot be modeled using generic clock, power domain, or interconnect APIs. Instead, a custom phandle is exceptionally used to provide direct, syscon-like register access to drivers.
Quoted 5 lines
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Co-developed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>---
Best regards,
Krzysztof
PATCH v4 10/27 clk: mediatek: Add MT8196 apmixedsys clock support
In reply to Laura NaoAdd support for the MT8196 apmixedsys clock controller, which provides PLLs generated from SoC 26m.
--- drivers/clk/mediatek/Kconfig | 8 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-apmixedsys.c | 203 +++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-apmixedsys.c
drivers/clk/mediatek/Kconfig +8 -0
@@ -1002,6 +1002,14 @@ config COMMON_CLK_MT8195_VENCSYS help This driver supports MediaTek MT8195 vencsys clocks. +config COMMON_CLK_MT8196 + tristate "Clock driver for MediaTek MT8196" + depends on ARM64 || COMPILE_TEST + select COMMON_CLK_MEDIATEK + default ARCH_MEDIATEK + help + This driver supports MediaTek MT8196 basic clocks. + config COMMON_CLK_MT8365 tristate "Clock driver for MediaTek MT8365" depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -150,6 +150,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_VDOSYS) += clk-mt8195-vdo0.o clk-mt8195-vdo1.o obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o +obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-apmixedsys.c new file +203 -0
203 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 11/27 clk: mediatek: Add MT8196 topckgen clock support
In reply to Laura NaoAdd support for the MT8196 topckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8196-topckgen.c | 984 +++++++++++++++++++++ 2 files changed, 985 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen.c
drivers/clk/mediatek/Makefile +1 -1
@@ -150,7 +150,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_VDOSYS) += clk-mt8195-vdo0.o clk-mt8195-vdo1.o obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o -obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o +obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +984 -0
984 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 12/27 clk: mediatek: Add MT8196 topckgen2 clock support
In reply to Laura NaoAdd support for the MT8196 topckgen2 clock controller, which provides muxes and dividers for clock selection in other IP blocks.
--- drivers/clk/mediatek/Makefile | 3 +- drivers/clk/mediatek/clk-mt8196-topckgen2.c | 567 ++++++++++++++++++++ 2 files changed, 569 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen2.c
drivers/clk/mediatek/Makefile +2 -1
@@ -150,7 +150,8 @@ obj-$(CONFIG_COMMON_CLK_MT8195_VDOSYS) += clk-mt8195-vdo0.o clk-mt8195-vdo1.o obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o -obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o +obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ + clk-mt8196-topckgen2.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-topckgen2.c new file +567 -0
567 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 13/27 clk: mediatek: Add MT8196 vlpckgen clock support
In reply to Laura NaoAdd support for the MT8196 vlpckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8196-vlpckgen.c | 726 +++++++++++++++++++++ 2 files changed, 727 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.c
drivers/clk/mediatek/Makefile +1 -1
@@ -151,7 +151,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ - clk-mt8196-topckgen2.o + clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +726 -0
726 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 13/27] clk: mediatek: Add MT8196 vlpckgen clock support
Quoted 196 lines · Laura Nao
Add support for the MT8196 vlpckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8196-vlpckgen.c | 726 +++++++++++++++++++++ 2 files changed, 727 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.cdrivers/clk/mediatek/Makefile +1
-1@@ -151,7 +151,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ - clk-mt8196-topckgen2.o + clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.odrivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +165
-0@@ -0,0 +1,726 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 MediaTek Inc. +* Guangjie Song <[email protected]> +* Copyright (c) 2025 Collabora Ltd. +* Laura Nao <[email protected]> +*/ +#include <dt-bindings/clock/mediatek,mt8196-clock.h> +#include <linux/clk.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#include "clk-mtk.h" +#include "clk-mux.h" +#include "clk-pll.h" + +/* MUX SEL REG */ +#define VLP_CLK_CFG_UPDATE 0x0004 +#define VLP_CLK_CFG_UPDATE1 0x0008 +#define VLP_CLK_CFG_0 0x0010 +#define VLP_CLK_CFG_0_SET 0x0014 +#define VLP_CLK_CFG_0_CLR 0x0018 +#define VLP_CLK_CFG_1 0x0020 +#define VLP_CLK_CFG_1_SET 0x0024 +#define VLP_CLK_CFG_1_CLR 0x0028 +#define VLP_CLK_CFG_2 0x0030 +#define VLP_CLK_CFG_2_SET 0x0034 +#define VLP_CLK_CFG_2_CLR 0x0038 +#define VLP_CLK_CFG_3 0x0040 +#define VLP_CLK_CFG_3_SET 0x0044 +#define VLP_CLK_CFG_3_CLR 0x0048 +#define VLP_CLK_CFG_4 0x0050 +#define VLP_CLK_CFG_4_SET 0x0054 +#define VLP_CLK_CFG_4_CLR 0x0058 +#define VLP_CLK_CFG_5 0x0060 +#define VLP_CLK_CFG_5_SET 0x0064 +#define VLP_CLK_CFG_5_CLR 0x0068 +#define VLP_CLK_CFG_6 0x0070 +#define VLP_CLK_CFG_6_SET 0x0074 +#define VLP_CLK_CFG_6_CLR 0x0078 +#define VLP_CLK_CFG_7 0x0080 +#define VLP_CLK_CFG_7_SET 0x0084 +#define VLP_CLK_CFG_7_CLR 0x0088 +#define VLP_CLK_CFG_8 0x0090 +#define VLP_CLK_CFG_8_SET 0x0094 +#define VLP_CLK_CFG_8_CLR 0x0098 +#define VLP_CLK_CFG_9 0x00a0 +#define VLP_CLK_CFG_9_SET 0x00a4 +#define VLP_CLK_CFG_9_CLR 0x00a8 +#define VLP_CLK_CFG_10 0x00b0 +#define VLP_CLK_CFG_10_SET 0x00b4 +#define VLP_CLK_CFG_10_CLR 0x00b8 +#define VLP_OCIC_FENC_STATUS_MON_0 0x039c +#define VLP_OCIC_FENC_STATUS_MON_1 0x03a0 + +/* MUX SHIFT */ +#define TOP_MUX_SCP_SHIFT 0 +#define TOP_MUX_SCP_SPI_SHIFT 1 +#define TOP_MUX_SCP_IIC_SHIFT 2 +#define TOP_MUX_SCP_IIC_HS_SHIFT 3 +#define TOP_MUX_PWRAP_ULPOSC_SHIFT 4 +#define TOP_MUX_SPMI_M_TIA_32K_SHIFT 5 +#define TOP_MUX_APXGPT_26M_B_SHIFT 6 +#define TOP_MUX_DPSW_SHIFT 7 +#define TOP_MUX_DPSW_CENTRAL_SHIFT 8 +#define TOP_MUX_SPMI_M_MST_SHIFT 9 +#define TOP_MUX_DVFSRC_SHIFT 10 +#define TOP_MUX_PWM_VLP_SHIFT 11 +#define TOP_MUX_AXI_VLP_SHIFT 12 +#define TOP_MUX_SYSTIMER_26M_SHIFT 13 +#define TOP_MUX_SSPM_SHIFT 14 +#define TOP_MUX_SRCK_SHIFT 15 +#define TOP_MUX_CAMTG0_SHIFT 16 +#define TOP_MUX_CAMTG1_SHIFT 17 +#define TOP_MUX_CAMTG2_SHIFT 18 +#define TOP_MUX_CAMTG3_SHIFT 19 +#define TOP_MUX_CAMTG4_SHIFT 20 +#define TOP_MUX_CAMTG5_SHIFT 21 +#define TOP_MUX_CAMTG6_SHIFT 22 +#define TOP_MUX_CAMTG7_SHIFT 23 +#define TOP_MUX_SSPM_26M_SHIFT 25 +#define TOP_MUX_ULPOSC_SSPM_SHIFT 26 +#define TOP_MUX_VLP_PBUS_26M_SHIFT 27 +#define TOP_MUX_DEBUG_ERR_FLAG_VLP_26M_SHIFT 28 +#define TOP_MUX_DPMSRDMA_SHIFT 29 +#define TOP_MUX_VLP_PBUS_156M_SHIFT 30 +#define TOP_MUX_SPM_SHIFT 0 +#define TOP_MUX_MMINFRA_VLP_SHIFT 1 +#define TOP_MUX_USB_TOP_SHIFT 2 +#define TOP_MUX_SSUSB_XHCI_SHIFT 3 +#define TOP_MUX_NOC_VLP_SHIFT 4 +#define TOP_MUX_AUDIO_H_SHIFT 5 +#define TOP_MUX_AUD_ENGEN1_SHIFT 6 +#define TOP_MUX_AUD_ENGEN2_SHIFT 7 +#define TOP_MUX_AUD_INTBUS_SHIFT 8 +#define TOP_MUX_SPU_VLP_26M_SHIFT 9 +#define TOP_MUX_SPU0_VLP_SHIFT 10 +#define TOP_MUX_SPU1_VLP_SHIFT 11 + +/* CKSTA REG */ +#define VLP_CKSTA_REG0 0x0250 +#define VLP_CKSTA_REG1 0x0254 + +/* HW Voter REG */ +#define HWV_CG_9_SET 0x0048 +#define HWV_CG_9_CLR 0x004c +#define HWV_CG_9_DONE 0x2c24 +#define HWV_CG_10_SET 0x0050 +#define HWV_CG_10_CLR 0x0054 +#define HWV_CG_10_DONE 0x2c28 + +/* PLL REG */ +#define VLP_AP_PLL_CON3 0x264 +#define VLP_APLL1_TUNER_CON0 0x2a4 +#define VLP_APLL2_TUNER_CON0 0x2a8 +#define VLP_APLL1_CON0 0x274 +#define VLP_APLL1_CON1 0x278 +#define VLP_APLL1_CON2 0x27c +#define VLP_APLL1_CON3 0x280 +#define VLP_APLL2_CON0 0x28c +#define VLP_APLL2_CON1 0x290 +#define VLP_APLL2_CON2 0x294 +#define VLP_APLL2_CON3 0x298 + +/* vlp apll1 tuner default value*/ +#define VLP_APLL1_TUNER_CON0_VALUE 0x6f28bd4d +/* vlp apll2 tuner default value + 1*/ +#define VLP_APLL2_TUNER_CON0_VALUE 0x78fd5265 + +#define VLP_PLLEN_ALL 0x080 +#define VLP_PLLEN_ALL_SET 0x084 +#define VLP_PLLEN_ALL_CLR 0x088 + +#define MT8196_PLL_FMAX (3800UL * MHZ) +#define MT8196_PLL_FMIN (1500UL * MHZ) +#define MT8196_INTEGER_BITS 8 + +#define PLL_FENC (_id, _name, _reg, _fenc_sta_ofs, _fenc_sta_bit,\ + _flags, _pd_reg, _pd_shift, \ + _pcw_reg, _pcw_shift, _pcwbits, \ + _pll_en_bit) { \ + .id = _id, \ + .name = _name, \ + .reg = _reg, \ + .fenc_sta_ofs = _fenc_sta_ofs, \ + .fenc_sta_bit = _fenc_sta_bit, \ + .flags = _flags, \ + .fmax = MT8196_PLL_FMAX, \ + .fmin = MT8196_PLL_FMIN, \ + .pd_reg = _pd_reg, \ + .pd_shift = _pd_shift, \ + .pcw_reg = _pcw_reg, \ + .pcw_shift = _pcw_shift, \ + .pcwbits = _pcwbits, \ + .pcwibits = MT8196_INTEGER_BITS, \ + .en_reg = VLP_PLLEN_ALL, \ + .en_set_reg = VLP_PLLEN_ALL_SET, \ + .en_clr_reg = VLP_PLLEN_ALL_CLR, \ + .pll_en_bit = _pll_en_bit, \ + .ops = &mtk_pll_fenc_clr_set_ops, \ +}
drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 175
Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10
-0+ +static DEFINE_SPINLOCK (mt8196_clk_vlp_lock); + +static const struct mtk_fixed_factor top_divs[] = { +FACTOR (CLK_VLP_APLL1_D4 ,"apll1_d4" ,"vlp_apll1" ,1 ,4 ), +FACTOR (CLK_VLP_APLL1_D8 ,"apll1_d8" ,"vlp_apll1" ,1 ,8 ), +FACTOR (CLK_VLP_APLL2_D4 ,"apll2_d4" ,"vlp_apll2" ,1 ,4 ), +FACTOR (CLK_VLP_APLL2_D8 ,"apll2_d8" ,"vlp_apll2" ,1 ,8 ), +}; +
I just realized I forgot to add the definition for vlp_clk26m back into the driver after adding it as a parent for the audio clocks.
In the original submission, it appears to be a copy of clk26m within the VLP domain:
FACTOR(CLK_VLP_CK_CLKSQ, "vlp_clksq_ck", "clk26m", 1, 1),
I'll add it back to the top_divs list in the next revision. Might as well rename top_divs to vlp_divs for consistency, I’ll handle that too.
Best,
Laura
Quoted 551 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +551
-0+static const char *const vlp_scp_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d6" , +"mainpll_d4" , +"mainpll_d3" , +"vlp_apll1" +}; + +static const char *const vlp_scp_spi_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d7_d2" , +"mainpll_d5_d2" +}; + +static const char *const vlp_scp_iic_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d5_d4" , +"mainpll_d7_d2" +}; + +static const char *const vlp_scp_iic_hs_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d5_d4" , +"mainpll_d7_d2" , +"mainpll_d7" +}; + +static const char *const vlp_pwrap_ulposc_parents[] = { +"clk26m" , +"osc_d20" , +"osc_d14" , +"osc_d10" +}; + +static const char *const vlp_spmi_32k_parents[] = { +"clk26m" , +"clk32k" , +"osc_d20" , +"osc_d14" , +"osc_d10" +}; + +static const char *const vlp_apxgpt_26m_b_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_dpsw_parents[] = { +"clk26m" , +"osc_d10" , +"osc_d7" , +"mainpll_d7_d4" +}; + +static const char *const vlp_dpsw_central_parents[] = { +"clk26m" , +"osc_d10" , +"osc_d7" , +"mainpll_d7_d4" +}; + +static const char *const vlp_spmi_m_parents[] = { +"clk26m" , +"osc_d20" , +"osc_d14" , +"osc_d10" +}; + +static const char *const vlp_dvfsrc_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_pwm_vlp_parents[] = { +"clk26m" , +"clk32k" , +"osc_d20" , +"osc_d8" , +"mainpll_d4_d8" +}; + +static const char *const vlp_axi_vlp_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d7_d4" , +"osc_d4" , +"mainpll_d7_d2" +}; + +static const char *const vlp_systimer_26m_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_sspm_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d5_d2" , +"osc_d2" , +"mainpll_d6" +}; + +static const char *const vlp_srck_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_camtg0_1_parents[] = { +"clk26m" , +"univpll_192m_d32" , +"univpll_192m_d16" , +"clk13m" , +"osc_d40" , +"osc_d32" , +"univpll_192m_d10" , +"univpll_192m_d8" , +"univpll_d6_d16" , +"ulposc3" , +"osc_d20" , +"ck2_tvdpll1_d16" , +"univpll_d6_d8" +}; + +static const char *const vlp_camtg2_7_parents[] = { +"clk26m" , +"univpll_192m_d32" , +"univpll_192m_d16" , +"clk13m" , +"osc_d40" , +"osc_d32" , +"univpll_192m_d10" , +"univpll_192m_d8" , +"univpll_d6_d16" , +"osc_d20" , +"ck2_tvdpll1_d16" , +"univpll_d6_d8" +}; + +static const char *const vlp_sspm_26m_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_ulposc_sspm_parents[] = { +"clk26m" , +"osc_d2" , +"mainpll_d4_d2" +}; + +static const char *const vlp_vlp_pbus_26m_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_debug_err_flag_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_dpmsrdma_parents[] = { +"clk26m" , +"mainpll_d7_d2" +}; + +static const char *const vlp_vlp_pbus_156m_parents[] = { +"clk26m" , +"osc_d2" , +"mainpll_d7_d2" , +"mainpll_d7" +}; + +static const char *const vlp_spm_parents[] = { +"clk26m" , +"mainpll_d7_d4" +}; + +static const char *const vlp_mminfra_parents[] = { +"clk26m" , +"osc_d4" , +"mainpll_d3" +}; + +static const char *const vlp_usb_parents[] = { +"clk26m" , +"mainpll_d9" +}; + +static const char *const vlp_noc_vlp_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d9" +}; + +static const char *const vlp_audio_h_parents[] = { +"clk26m" , +"vlp_clk26m" , +"vlp_apll1" , +"vlp_apll2" +}; + +static const char *const vlp_aud_engen1_parents[] = { +"clk26m" , +"vlp_clk26m" , +"apll1_d8" , +"apll1_d4" +}; + +static const char *const vlp_aud_engen2_parents[] = { +"clk26m" , +"vlp_clk26m" , +"apll2_d8" , +"apll2_d4" +}; + +static const char *const vlp_aud_intbus_parents[] = { +"clk26m" , +"vlp_clk26m" , +"mainpll_d7_d4" , +"mainpll_d4_d4" +}; + +static const u8 vlp_aud_parent_index[] = {1 ,2 ,3 }; + +static const char *const vlp_spvlp_26m_parents[] = { +"clk26m" , +"osc_d20" +}; + +static const char *const vlp_spu0_vlp_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d4_d4" , +"mainpll_d4_d2" , +"mainpll_d7" , +"mainpll_d6" , +"mainpll_d5" +}; + +static const char *const vlp_spu1_vlp_parents[] = { +"clk26m" , +"osc_d20" , +"mainpll_d4_d4" , +"mainpll_d4_d2" , +"mainpll_d7" , +"mainpll_d6" , +"mainpll_d5" +}; + +static const struct mtk_mux vlp_muxes[] = { +/* VLP_CLK_CFG_0 */ +MUX_GATE_FENC_CLR_SET_UPD (CLK_VLP_SCP ,"vlp_scp" , vlp_scp_parents, +VLP_CLK_CFG_0 ,VLP_CLK_CFG_0_SET ,VLP_CLK_CFG_0_CLR , +0 ,3 ,7 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_SCP_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,31 ), +MUX_CLR_SET_UPD (CLK_VLP_SCP_SPI ,"vlp_scp_spi" , + vlp_scp_spi_parents,VLP_CLK_CFG_0 ,VLP_CLK_CFG_0_SET , +VLP_CLK_CFG_0_CLR ,8 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SCP_SPI_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SCP_IIC ,"vlp_scp_iic" , + vlp_scp_iic_parents,VLP_CLK_CFG_0 ,VLP_CLK_CFG_0_SET , +VLP_CLK_CFG_0_CLR ,16 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SCP_IIC_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SCP_IIC_HS ,"vlp_scp_iic_hs" , + vlp_scp_iic_hs_parents,VLP_CLK_CFG_0 ,VLP_CLK_CFG_0_SET , +VLP_CLK_CFG_0_CLR ,24 ,3 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SCP_IIC_HS_SHIFT ), +/* VLP_CLK_CFG_1 */ +MUX_CLR_SET_UPD (CLK_VLP_PWRAP_ULPOSC ,"vlp_pwrap_ulposc" , + vlp_pwrap_ulposc_parents,VLP_CLK_CFG_1 ,VLP_CLK_CFG_1_SET , +VLP_CLK_CFG_1_CLR ,0 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_PWRAP_ULPOSC_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SPMI_M_TIA_32K ,"vlp_spmi_32k" , + vlp_spmi_32k_parents,VLP_CLK_CFG_1 ,VLP_CLK_CFG_1_SET , +VLP_CLK_CFG_1_CLR ,8 ,3 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SPMI_M_TIA_32K_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_APXGPT_26M_B ,"vlp_apxgpt_26m_b" , + vlp_apxgpt_26m_b_parents,VLP_CLK_CFG_1 ,VLP_CLK_CFG_1_SET , +VLP_CLK_CFG_1_CLR ,16 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_APXGPT_26M_B_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_DPSW ,"vlp_dpsw" , + vlp_dpsw_parents,VLP_CLK_CFG_1 ,VLP_CLK_CFG_1_SET , +VLP_CLK_CFG_1_CLR ,24 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_DPSW_SHIFT ), +/* VLP_CLK_CFG_2 */ +MUX_CLR_SET_UPD (CLK_VLP_DPSW_CENTRAL ,"vlp_dpsw_central" , + vlp_dpsw_central_parents,VLP_CLK_CFG_2 ,VLP_CLK_CFG_2_SET , +VLP_CLK_CFG_2_CLR ,0 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_DPSW_CENTRAL_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SPMI_M_MST ,"vlp_spmi_m" , + vlp_spmi_m_parents,VLP_CLK_CFG_2 ,VLP_CLK_CFG_2_SET , +VLP_CLK_CFG_2_CLR ,8 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SPMI_M_MST_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_DVFSRC ,"vlp_dvfsrc" , + vlp_dvfsrc_parents,VLP_CLK_CFG_2 ,VLP_CLK_CFG_2_SET , +VLP_CLK_CFG_2_CLR ,16 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_DVFSRC_SHIFT ), +MUX_GATE_FENC_CLR_SET_UPD (CLK_VLP_PWM_VLP ,"vlp_pwm_vlp" , vlp_pwm_vlp_parents, +VLP_CLK_CFG_2 ,VLP_CLK_CFG_2_SET ,VLP_CLK_CFG_2_CLR , +24 ,3 ,31 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_PWM_VLP_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,20 ), +/* VLP_CLK_CFG_3 */ +MUX_CLR_SET_UPD (CLK_VLP_AXI_VLP ,"vlp_axi_vlp" , + vlp_axi_vlp_parents,VLP_CLK_CFG_3 ,VLP_CLK_CFG_3_SET , +VLP_CLK_CFG_3_CLR ,0 ,3 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_AXI_VLP_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SYSTIMER_26M ,"vlp_systimer_26m" , + vlp_systimer_26m_parents,VLP_CLK_CFG_3 ,VLP_CLK_CFG_3_SET , +VLP_CLK_CFG_3_CLR ,8 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SYSTIMER_26M_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SSPM ,"vlp_sspm" , + vlp_sspm_parents,VLP_CLK_CFG_3 ,VLP_CLK_CFG_3_SET , +VLP_CLK_CFG_3_CLR ,16 ,3 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SSPM_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SRCK ,"vlp_srck" , + vlp_srck_parents,VLP_CLK_CFG_3 ,VLP_CLK_CFG_3_SET , +VLP_CLK_CFG_3_CLR ,24 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SRCK_SHIFT ), +/* VLP_CLK_CFG_4 */ +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG0 ,"vlp_camtg0" , vlp_camtg0_1_parents, +VLP_CLK_CFG_4 ,VLP_CLK_CFG_4_SET ,VLP_CLK_CFG_4_CLR , +HWV_CG_9_DONE ,HWV_CG_9_SET ,HWV_CG_9_CLR , +0 ,4 ,7 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG0_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,15 ), +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG1 ,"vlp_camtg1" , vlp_camtg0_1_parents, +VLP_CLK_CFG_4 ,VLP_CLK_CFG_4_SET ,VLP_CLK_CFG_4_CLR , +HWV_CG_9_DONE ,HWV_CG_9_SET ,HWV_CG_9_CLR , +8 ,4 ,15 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG1_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,14 ), +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG2 ,"vlp_camtg2" , vlp_camtg2_7_parents, +VLP_CLK_CFG_4 ,VLP_CLK_CFG_4_SET ,VLP_CLK_CFG_4_CLR , +HWV_CG_9_DONE ,HWV_CG_9_SET ,HWV_CG_9_CLR , +16 ,4 ,23 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG2_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,13 ), +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG3 ,"vlp_camtg3" , vlp_camtg2_7_parents, +VLP_CLK_CFG_4 ,VLP_CLK_CFG_4_SET ,VLP_CLK_CFG_4_CLR , +HWV_CG_9_DONE ,HWV_CG_9_SET ,HWV_CG_9_CLR , +24 ,4 ,31 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG3_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,12 ), +/* VLP_CLK_CFG_5 */ +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG4 ,"vlp_camtg4" , vlp_camtg2_7_parents, +VLP_CLK_CFG_5 ,VLP_CLK_CFG_5_SET ,VLP_CLK_CFG_5_CLR , +HWV_CG_10_DONE ,HWV_CG_10_SET ,HWV_CG_10_CLR , +0 ,4 ,7 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG4_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,11 ), +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG5 ,"vlp_camtg5" , vlp_camtg2_7_parents, +VLP_CLK_CFG_5 ,VLP_CLK_CFG_5_SET ,VLP_CLK_CFG_5_CLR , +HWV_CG_10_DONE ,HWV_CG_10_SET ,HWV_CG_10_CLR , +8 ,4 ,15 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG5_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,10 ), +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG6 ,"vlp_camtg6" , vlp_camtg2_7_parents, +VLP_CLK_CFG_5 ,VLP_CLK_CFG_5_SET ,VLP_CLK_CFG_5_CLR , +HWV_CG_10_DONE ,HWV_CG_10_SET ,HWV_CG_10_CLR , +16 ,4 ,23 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG6_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,9 ), +MUX_GATE_HWV_FENC_CLR_SET_UPD (CLK_VLP_CAMTG7 ,"vlp_camtg7" , vlp_camtg2_7_parents, +VLP_CLK_CFG_5 ,VLP_CLK_CFG_5_SET ,VLP_CLK_CFG_5_CLR , +HWV_CG_10_DONE ,HWV_CG_10_SET ,HWV_CG_10_CLR , +24 ,4 ,31 ,VLP_CLK_CFG_UPDATE ,TOP_MUX_CAMTG7_SHIFT , +VLP_OCIC_FENC_STATUS_MON_0 ,8 ), +/* VLP_CLK_CFG_6 */ +MUX_CLR_SET_UPD (CLK_VLP_SSPM_26M ,"vlp_sspm_26m" , + vlp_sspm_26m_parents,VLP_CLK_CFG_6 ,VLP_CLK_CFG_6_SET , +VLP_CLK_CFG_6_CLR ,8 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_SSPM_26M_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_ULPOSC_SSPM ,"vlp_ulposc_sspm" , + vlp_ulposc_sspm_parents,VLP_CLK_CFG_6 ,VLP_CLK_CFG_6_SET , +VLP_CLK_CFG_6_CLR ,16 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_ULPOSC_SSPM_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_VLP_PBUS_26M ,"vlp_vlp_pbus_26m" , + vlp_vlp_pbus_26m_parents,VLP_CLK_CFG_6 ,VLP_CLK_CFG_6_SET , +VLP_CLK_CFG_6_CLR ,24 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_VLP_PBUS_26M_SHIFT ), +/* VLP_CLK_CFG_7 */ +MUX_CLR_SET_UPD (CLK_VLP_DEBUG_ERR_FLAG ,"vlp_debug_err_flag" , + vlp_debug_err_flag_parents,VLP_CLK_CFG_7 ,VLP_CLK_CFG_7_SET , +VLP_CLK_CFG_7_CLR ,0 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_DEBUG_ERR_FLAG_VLP_26M_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_DPMSRDMA ,"vlp_dpmsrdma" , + vlp_dpmsrdma_parents,VLP_CLK_CFG_7 ,VLP_CLK_CFG_7_SET , +VLP_CLK_CFG_7_CLR ,8 ,1 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_DPMSRDMA_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_VLP_PBUS_156M ,"vlp_vlp_pbus_156m" , + vlp_vlp_pbus_156m_parents,VLP_CLK_CFG_7 ,VLP_CLK_CFG_7_SET , +VLP_CLK_CFG_7_CLR ,16 ,2 , +VLP_CLK_CFG_UPDATE ,TOP_MUX_VLP_PBUS_156M_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SPM ,"vlp_spm" , + vlp_spm_parents,VLP_CLK_CFG_7 ,VLP_CLK_CFG_7_SET , +VLP_CLK_CFG_7_CLR ,24 ,1 , +VLP_CLK_CFG_UPDATE1 ,TOP_MUX_SPM_SHIFT ), +/* VLP_CLK_CFG_8 */ +MUX_GATE_FENC_CLR_SET_UPD (CLK_VLP_MMINFRA ,"vlp_mminfra" , vlp_mminfra_parents, +VLP_CLK_CFG_8 ,VLP_CLK_CFG_8_SET ,VLP_CLK_CFG_8_CLR , +0 ,2 ,7 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_MMINFRA_VLP_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,31 ), +MUX_GATE_FENC_CLR_SET_UPD (CLK_VLP_USB_TOP ,"vlp_usb" , vlp_usb_parents, +VLP_CLK_CFG_8 ,VLP_CLK_CFG_8_SET ,VLP_CLK_CFG_8_CLR , +8 ,1 ,15 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_USB_TOP_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,30 ), +MUX_GATE_FENC_CLR_SET_UPD (CLK_VLP_USB_XHCI ,"vlp_usb_xhci" , vlp_usb_parents, +VLP_CLK_CFG_8 ,VLP_CLK_CFG_8_SET ,VLP_CLK_CFG_8_CLR , +16 ,1 ,23 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_SSUSB_XHCI_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,29 ), +MUX_CLR_SET_UPD (CLK_VLP_NOC_VLP ,"vlp_noc_vlp" , + vlp_noc_vlp_parents,VLP_CLK_CFG_8 ,VLP_CLK_CFG_8_SET , +VLP_CLK_CFG_8_CLR ,24 ,2 , +VLP_CLK_CFG_UPDATE1 ,TOP_MUX_NOC_VLP_SHIFT ), +/* VLP_CLK_CFG_9 */ +MUX_GATE_FENC_CLR_SET_UPD_INDEXED (CLK_VLP_AUDIO_H ,"vlp_audio_h" , + vlp_audio_h_parents, vlp_aud_parent_index, +VLP_CLK_CFG_9 ,VLP_CLK_CFG_9_SET ,VLP_CLK_CFG_9_CLR , +0 ,2 ,7 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_AUDIO_H_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,27 ), +MUX_GATE_FENC_CLR_SET_UPD_INDEXED (CLK_VLP_AUD_ENGEN1 ,"vlp_aud_engen1" , + vlp_aud_engen1_parents, vlp_aud_parent_index, +VLP_CLK_CFG_9 ,VLP_CLK_CFG_9_SET ,VLP_CLK_CFG_9_CLR , +8 ,2 ,15 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_AUD_ENGEN1_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,26 ), +MUX_GATE_FENC_CLR_SET_UPD_INDEXED (CLK_VLP_AUD_ENGEN2 ,"vlp_aud_engen2" , + vlp_aud_engen2_parents, vlp_aud_parent_index, +VLP_CLK_CFG_9 ,VLP_CLK_CFG_9_SET ,VLP_CLK_CFG_9_CLR , +16 ,2 ,23 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_AUD_ENGEN2_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,25 ), +MUX_GATE_FENC_CLR_SET_UPD_INDEXED (CLK_VLP_AUD_INTBUS ,"vlp_aud_intbus" , + vlp_aud_intbus_parents, vlp_aud_parent_index, +VLP_CLK_CFG_9 ,VLP_CLK_CFG_9_SET ,VLP_CLK_CFG_9_CLR , +24 ,2 ,31 ,VLP_CLK_CFG_UPDATE1 ,TOP_MUX_AUD_INTBUS_SHIFT , +VLP_OCIC_FENC_STATUS_MON_1 ,24 ), +/* VLP_CLK_CFG_10 */ +MUX_CLR_SET_UPD (CLK_VLP_SPVLP_26M ,"vlp_spvlp_26m" , + vlp_spvlp_26m_parents,VLP_CLK_CFG_10 ,VLP_CLK_CFG_10_SET , +VLP_CLK_CFG_10_CLR ,0 ,1 , +VLP_CLK_CFG_UPDATE1 ,TOP_MUX_SPU_VLP_26M_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SPU0_VLP ,"vlp_spu0_vlp" , + vlp_spu0_vlp_parents,VLP_CLK_CFG_10 ,VLP_CLK_CFG_10_SET , +VLP_CLK_CFG_10_CLR ,8 ,3 , +VLP_CLK_CFG_UPDATE1 ,TOP_MUX_SPU0_VLP_SHIFT ), +MUX_CLR_SET_UPD (CLK_VLP_SPU1_VLP ,"vlp_spu1_vlp" , + vlp_spu1_vlp_parents,VLP_CLK_CFG_10 ,VLP_CLK_CFG_10_SET , +VLP_CLK_CFG_10_CLR ,16 ,3 , +VLP_CLK_CFG_UPDATE1 ,TOP_MUX_SPU1_VLP_SHIFT ), +}; + +static const struct mtk_pll_data vlp_plls[] = { +PLL_FENC (CLK_VLP_APLL1 ,"vlp_apll1" ,VLP_APLL1_CON0 ,0x0358 ,1 ,0 , +VLP_APLL1_CON1 ,24 ,VLP_APLL1_CON2 ,0 ,32 ,0 ), +PLL_FENC (CLK_VLP_APLL2 ,"vlp_apll2" ,VLP_APLL2_CON0 ,0x0358 ,0 ,0 , +VLP_APLL2_CON1 ,24 ,VLP_APLL2_CON2 ,0 ,32 ,1 ), +}; + +static const struct regmap_config vlpckgen_regmap_config = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + .max_register =0x1000 , + .fast_io = true, +}; + +static int clk_mt8196_vlp_probe (struct platform_device *pdev) +{ +static void __iomem *base; +struct clk_hw_onecell_data *clk_data; +int r; +struct device_node *node = pdev->dev.of_node; +struct device *dev = &pdev->dev; +struct regmap *regmap; + + clk_data =mtk_alloc_clk_data (ARRAY_SIZE (vlp_muxes) + +ARRAY_SIZE (vlp_plls)); +if (!clk_data) +return -ENOMEM ; + + base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (base)) +return PTR_ERR (base); + + regmap =devm_regmap_init_mmio (dev, base, &vlpckgen_regmap_config); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + + r =mtk_clk_register_factors (top_divs,ARRAY_SIZE (top_divs), clk_data); +if (r) + goto free_clk_data; + + r =mtk_clk_register_muxes (&pdev->dev, vlp_muxes,ARRAY_SIZE (vlp_muxes), + node, &mt8196_clk_vlp_lock, clk_data); +if (r) + goto unregister_factors; + + r =mtk_clk_register_plls (node, vlp_plls,ARRAY_SIZE (vlp_plls), + clk_data); +if (r) + goto unregister_muxes; + + r =of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); +if (r) + goto unregister_plls; + +platform_set_drvdata (pdev, clk_data); + +/* Initialize APLL tuner registers */ +regmap_write (regmap,VLP_APLL1_TUNER_CON0 ,VLP_APLL1_TUNER_CON0_VALUE ); +regmap_write (regmap,VLP_APLL2_TUNER_CON0 ,VLP_APLL2_TUNER_CON0_VALUE ); + +return r; + +unregister_plls: +mtk_clk_unregister_plls (vlp_plls,ARRAY_SIZE (vlp_plls), clk_data); +unregister_muxes: +mtk_clk_unregister_muxes (vlp_muxes,ARRAY_SIZE (vlp_muxes), clk_data); +unregister_factors: +mtk_clk_unregister_factors (top_divs,ARRAY_SIZE (top_divs), clk_data); +free_clk_data: +mtk_free_clk_data (clk_data); + +return r; +} + +static void clk_mt8196_vlp_remove (struct platform_device *pdev) +{ +struct clk_hw_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 (vlp_plls,ARRAY_SIZE (vlp_plls), clk_data); +mtk_clk_unregister_muxes (vlp_muxes,ARRAY_SIZE (vlp_muxes), clk_data); +mtk_clk_unregister_factors (top_divs,ARRAY_SIZE (top_divs), clk_data); +mtk_free_clk_data (clk_data); +} + +static const struct of_device_id of_match_clk_mt8196_vlp_ck[] = { + { .compatible ="mediatek,mt8196-vlpckgen" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, of_match_clk_mt8196_vlp_ck); + +static struct platform_driver clk_mt8196_vlp_drv = { + .probe = clk_mt8196_vlp_probe, + .remove = clk_mt8196_vlp_remove, + .driver = { + .name ="clk-mt8196-vlpck" , + .of_match_table = of_match_clk_mt8196_vlp_ck, + }, +}; + +MODULE_DESCRIPTION ("MediaTek MT8196 VLP clock generator driver" ); +module_platform_driver (clk_mt8196_vlp_drv); +MODULE_LICENSE ("GPL" );
PATCH v4 14/27 clk: mediatek: Add MT8196 peripheral clock support
In reply to Laura NaoAdd support for the MT8196 peripheral clock controller, which provides clock gate control for dma/flashif/msdc/pwm/spi/uart.
--- drivers/clk/mediatek/Makefile | 3 +- drivers/clk/mediatek/clk-mt8196-peri_ao.c | 144 ++++++++++++++++++++++ 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-peri_ao.c
drivers/clk/mediatek/Makefile +2 -1
@@ -151,7 +151,8 @@ obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ - clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o + clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ + clk-mt8196-peri_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-peri_ao.c new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 15/27 clk: mediatek: Add MT8196 ufssys clock support
In reply to Laura NaoAdd support for the MT8196 ufssys clock controller, which provides clock gate control for UFS.
--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-ufs_ao.c | 109 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-ufs_ao.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_UFSSYS + tristate "Clock driver for MediaTek MT8196 ufssys" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 ufssys clocks. + config COMMON_CLK_MT8365 tristate "Clock driver for MediaTek MT8365" depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 15/27] clk: mediatek: Add MT8196 ufssys clock support
Quoted 51 lines · Laura Nao
Add support for the MT8196 ufssys clock controller, which provides clock gate control for UFS.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Co-developed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-ufs_ao.c | 109 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-ufs_ao.cdrivers/clk/mediatek/Kconfig +7
-0@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_UFSSYS + tristate "Clock driver for MediaTek MT8196 ufssys" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 ufssys clocks. + config COMMON_CLK_MT8365 tristate "Clock driver for MediaTek MT8365" depends on ARCH_MEDIATEK || COMPILE_TESTdrivers/clk/mediatek/Makefile +1
-0@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.odrivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +0
-0
drivers/clk/mediatek/clk-mt8196-ufs_ao.c line 9
Quoted 9 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +9
-0@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 MediaTek Inc. +* Guangjie Song <[email protected]> +* Copyright (c) 2025 Collabora Ltd. +* Laura Nao <[email protected]> +*/ +#include <dt-bindings/clock/mediatek,mt8196-clock.h> +#include <dt-bindings/reset/mediatek,mt8196-resets.h>
Nit: add empty line here for separation.
Quoted 20 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +20
-0+#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#include "clk-gate.h" +#include "clk-mtk.h" + +#define MT8196_UFSAO_RST0_SET_OFFSET 0x48 +#define MT8196_UFSAO_RST1_SET_OFFSET 0x148 + +static const struct mtk_gate_regs ufsao0_cg_regs = { + .set_ofs =0x108 , + .clr_ofs =0x10c , + .sta_ofs =0x104 , +}; + +static const struct mtk_gate_regs ufsao1_cg_regs = { + .set_ofs =0x8 , + .clr_ofs =0xc ,
drivers/clk/mediatek/clk-mt8196-ufs_ao.c line 39
Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +10
-0+ .sta_ofs = 0x4, +}; + +#define GATE_UFSAO0 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &ufsao0_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \
This probably doesn't work correctly, since not every clock defined below has the "ufs" clock as its parent. If the requirement is that the "ufs" clock be enabled for accessing this register, it is going to fail (badly).
ChenYu
Quoted 73 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +70
-1+ .ops = &mtk_clk_gate_ops_setclr, \ + } + +#define GATE_UFSAO1 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &ufsao1_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \ + .ops = &mtk_clk_gate_ops_setclr, \ + } + +static const struct mtk_gate ufsao_clks[] = { +/* UFSAO0 */ +GATE_UFSAO0 (CLK_UFSAO_UFSHCI_UFS ,"ufsao_ufshci_ufs" ,"ufs" ,0 ), +GATE_UFSAO0 (CLK_UFSAO_UFSHCI_AES ,"ufsao_ufshci_aes" ,"aes_ufsfde" ,1 ), +/* UFSAO1 */ +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_TX_SYM ,"ufsao_unipro_tx_sym" ,"clk26m" ,0 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_RX_SYM0 ,"ufsao_unipro_rx_sym0" ,"clk26m" ,1 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_RX_SYM1 ,"ufsao_unipro_rx_sym1" ,"clk26m" ,2 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_SYS ,"ufsao_unipro_sys" ,"ufs" ,3 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_SAP ,"ufsao_unipro_sap" ,"clk26m" ,4 ), +GATE_UFSAO1 (CLK_UFSAO_PHY_SAP ,"ufsao_phy_sap" ,"clk26m" ,8 ), +}; + +static u16 ufsao_rst_ofs[] = { +MT8196_UFSAO_RST0_SET_OFFSET , +MT8196_UFSAO_RST1_SET_OFFSET +}; + +static u16 ufsao_rst_idx_map[] = { + [MT8196_UFSAO_RST0_UFS_MPHY ] =8 , + [MT8196_UFSAO_RST1_UFS_UNIPRO ] =1 *RST_NR_PER_BANK +0 , + [MT8196_UFSAO_RST1_UFS_CRYPTO ] =1 *RST_NR_PER_BANK +1 , + [MT8196_UFSAO_RST1_UFSHCI ] =1 *RST_NR_PER_BANK +2 , +}; + +static const struct mtk_clk_rst_desc ufsao_rst_desc = { + .version =MTK_RST_SET_CLR , + .rst_bank_ofs = ufsao_rst_ofs, + .rst_bank_nr =ARRAY_SIZE (ufsao_rst_ofs), + .rst_idx_map = ufsao_rst_idx_map, + .rst_idx_map_nr =ARRAY_SIZE (ufsao_rst_idx_map), +}; + +static const struct mtk_clk_desc ufsao_mcd = { + .clks = ufsao_clks, + .num_clks =ARRAY_SIZE (ufsao_clks), + .rst_desc = &ufsao_rst_desc, +}; + +static const struct of_device_id of_match_clk_mt8196_ufs_ao[] = { + { .compatible ="mediatek,mt8196-ufscfg-ao" , .data = &ufsao_mcd }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, of_match_clk_mt8196_ufs_ao); + +static struct platform_driver clk_mt8196_ufs_ao_drv = { + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, + .driver = { + .name ="clk-mt8196-ufs-ao" , + .of_match_table = of_match_clk_mt8196_ufs_ao, + }, +}; + +module_platform_driver (clk_mt8196_ufs_ao_drv); +MODULE_DESCRIPTION ("MediaTek MT8196 ufs_ao clocks driver" ); +MODULE_LICENSE ("GPL" ); --2.39.5
Re: [PATCH v4 15/27] clk: mediatek: Add MT8196 ufssys clock support
Quoted 55 lines · Chen-Yu Tsai
Quoted 54 lines · Laura Nao
Add support for the MT8196 ufssys clock controller, which provides clock gate control for UFS.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Co-developed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-ufs_ao.c | 109 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-ufs_ao.cdrivers/clk/mediatek/Kconfig +7
-0@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_UFSSYS + tristate "Clock driver for MediaTek MT8196 ufssys" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 ufssys clocks. + config COMMON_CLK_MT8365 tristate "Clock driver for MediaTek MT8365" depends on ARCH_MEDIATEK || COMPILE_TESTdrivers/clk/mediatek/Makefile +1
-0@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.odrivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +3
-0@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 MediaTek Inc.
Quoted 9 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c line 9
Quoted 6 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +6
-0+* Guangjie Song <[email protected]> +* Copyright (c) 2025 Collabora Ltd. +* Laura Nao <[email protected]> +*/ +#include <dt-bindings/clock/mediatek,mt8196-clock.h> +#include <dt-bindings/reset/mediatek,mt8196-resets.h> Nit: add empty line here for separation.
Ack.
Quoted 27 lines
Quoted 27 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +27
-0+#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#include "clk-gate.h" +#include "clk-mtk.h" + +#define MT8196_UFSAO_RST0_SET_OFFSET 0x48 +#define MT8196_UFSAO_RST1_SET_OFFSET 0x148 + +static const struct mtk_gate_regs ufsao0_cg_regs = { + .set_ofs =0x108 , + .clr_ofs =0x10c , + .sta_ofs =0x104 , +}; + +static const struct mtk_gate_regs ufsao1_cg_regs = { + .set_ofs =0x8 , + .clr_ofs =0xc , + .sta_ofs =0x4 , +}; + +#define GATE_UFSAO0 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \
Quoted 9 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c line 39
Quoted 3 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +3
-0+ .regs = &ufsao0_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \This probably doesn't work correctly, since not every clock defined below has the "ufs" clock as its parent. If the requirement is that the "ufs" clock be enabled for accessing this register, it is going to fail (badly).
Thanks for pointing this out - I missed this because, as you noted, other drivers using this flag defined gates with the same parent and worked correctly (i.e., I2C). I don’t have a way to justify keeping this flag at the moment, and I can’t test whether the ufs clock is required for register access at this stage of upstream support (same goes for the other drivers with this issue).
I’m thinking of removing it here and in the other affected drivers, and revisit the issue once we have actual users for these clocks upstream.
Best,
Laura
Quoted 75 lines
ChenYu
Quoted 73 lines
drivers/clk/mediatek/clk-mt8196-ufs_ao.c new file +70
-1+ .ops = &mtk_clk_gate_ops_setclr, \ + } + +#define GATE_UFSAO1 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &ufsao1_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \ + .ops = &mtk_clk_gate_ops_setclr, \ + } + +static const struct mtk_gate ufsao_clks[] = { +/* UFSAO0 */ +GATE_UFSAO0 (CLK_UFSAO_UFSHCI_UFS ,"ufsao_ufshci_ufs" ,"ufs" ,0 ), +GATE_UFSAO0 (CLK_UFSAO_UFSHCI_AES ,"ufsao_ufshci_aes" ,"aes_ufsfde" ,1 ), +/* UFSAO1 */ +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_TX_SYM ,"ufsao_unipro_tx_sym" ,"clk26m" ,0 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_RX_SYM0 ,"ufsao_unipro_rx_sym0" ,"clk26m" ,1 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_RX_SYM1 ,"ufsao_unipro_rx_sym1" ,"clk26m" ,2 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_SYS ,"ufsao_unipro_sys" ,"ufs" ,3 ), +GATE_UFSAO1 (CLK_UFSAO_UNIPRO_SAP ,"ufsao_unipro_sap" ,"clk26m" ,4 ), +GATE_UFSAO1 (CLK_UFSAO_PHY_SAP ,"ufsao_phy_sap" ,"clk26m" ,8 ), +}; + +static u16 ufsao_rst_ofs[] = { +MT8196_UFSAO_RST0_SET_OFFSET , +MT8196_UFSAO_RST1_SET_OFFSET +}; + +static u16 ufsao_rst_idx_map[] = { + [MT8196_UFSAO_RST0_UFS_MPHY ] =8 , + [MT8196_UFSAO_RST1_UFS_UNIPRO ] =1 *RST_NR_PER_BANK +0 , + [MT8196_UFSAO_RST1_UFS_CRYPTO ] =1 *RST_NR_PER_BANK +1 , + [MT8196_UFSAO_RST1_UFSHCI ] =1 *RST_NR_PER_BANK +2 , +}; + +static const struct mtk_clk_rst_desc ufsao_rst_desc = { + .version =MTK_RST_SET_CLR , + .rst_bank_ofs = ufsao_rst_ofs, + .rst_bank_nr =ARRAY_SIZE (ufsao_rst_ofs), + .rst_idx_map = ufsao_rst_idx_map, + .rst_idx_map_nr =ARRAY_SIZE (ufsao_rst_idx_map), +}; + +static const struct mtk_clk_desc ufsao_mcd = { + .clks = ufsao_clks, + .num_clks =ARRAY_SIZE (ufsao_clks), + .rst_desc = &ufsao_rst_desc, +}; + +static const struct of_device_id of_match_clk_mt8196_ufs_ao[] = { + { .compatible ="mediatek,mt8196-ufscfg-ao" , .data = &ufsao_mcd }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, of_match_clk_mt8196_ufs_ao); + +static struct platform_driver clk_mt8196_ufs_ao_drv = { + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, + .driver = { + .name ="clk-mt8196-ufs-ao" , + .of_match_table = of_match_clk_mt8196_ufs_ao, + }, +}; + +module_platform_driver (clk_mt8196_ufs_ao_drv); +MODULE_DESCRIPTION ("MediaTek MT8196 ufs_ao clocks driver" ); +MODULE_LICENSE ("GPL" ); --2.39.5
PATCH v4 16/27 clk: mediatek: Add MT8196 pextpsys clock support
In reply to Laura NaoAdd support for the MT8196 pextpsys clock controller, which provides clock gate control for PCIe.
--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-pextp.c | 131 ++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-pextp.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_PEXTPSYS + tristate "Clock driver for MediaTek MT8196 pextpsys" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 pextpsys clocks. + config COMMON_CLK_MT8196_UFSSYS tristate "Clock driver for MediaTek MT8196 ufssys" depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o
drivers/clk/mediatek/clk-mt8196-pextp.c new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 16/27] clk: mediatek: Add MT8196 pextpsys clock support
Quoted 51 lines · Laura Nao
Add support for the MT8196 pextpsys clock controller, which provides clock gate control for PCIe.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Co-developed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-pextp.c | 131 ++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-pextp.cdrivers/clk/mediatek/Kconfig +7
-0@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_PEXTPSYS + tristate "Clock driver for MediaTek MT8196 pextpsys" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 pextpsys clocks. + config COMMON_CLK_MT8196_UFSSYS tristate "Clock driver for MediaTek MT8196 ufssys" depends on COMMON_CLK_MT8196drivers/clk/mediatek/Makefile +1
-0@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.odrivers/clk/mediatek/clk-mt8196-pextp.c new file +0
-0
drivers/clk/mediatek/clk-mt8196-pextp.c line 9
Quoted 9 lines
drivers/clk/mediatek/clk-mt8196-pextp.c new file +9
-0@@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 MediaTek Inc. +* Guangjie Song <[email protected]> +* Copyright (c) 2025 Collabora Ltd. +* Laura Nao <[email protected]> +*/ +#include <dt-bindings/clock/mediatek,mt8196-clock.h> +#include <dt-bindings/reset/mediatek,mt8196-resets.h>
Nit: empty line here for separation.
Quoted 14 lines
drivers/clk/mediatek/clk-mt8196-pextp.c new file +14
-0+#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#include "clk-gate.h" +#include "clk-mtk.h" +#include "reset.h" + +#define MT8196_PEXTP_RST0_SET_OFFSET 0x8 + +static const struct mtk_gate_regs pext_cg_regs = { + .set_ofs =0x18 , + .clr_ofs =0x1c ,
drivers/clk/mediatek/clk-mt8196-pextp.c line 33
Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-pextp.c new file +10
-0+ .sta_ofs = 0x14, +}; + +#define GATE_PEXT (_id, _name, _parent, _shift) {\ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &pext_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \
Same issue as the previous patch. If one of the parents shown below needs to be enabled for register access, this is going to fail badly. If it's not needed, then this flag makes no sense here.
ChenYu
Quoted 101 lines
drivers/clk/mediatek/clk-mt8196-pextp.c new file +98
-1+ .ops = &mtk_clk_gate_ops_setclr,\ + } + +static const struct mtk_gate pext_clks[] = { +GATE_PEXT (CLK_PEXT_PEXTP_MAC_P0_TL ,"pext_pm0_tl" ,"tl" ,0 ), +GATE_PEXT (CLK_PEXT_PEXTP_MAC_P0_REF ,"pext_pm0_ref" ,"clk26m" ,1 ), +GATE_PEXT (CLK_PEXT_PEXTP_PHY_P0_MCU_BUS ,"pext_pp0_mcu_bus" ,"clk26m" ,6 ), +GATE_PEXT (CLK_PEXT_PEXTP_PHY_P0_PEXTP_REF ,"pext_pp0_pextp_ref" ,"clk26m" ,7 ), +GATE_PEXT (CLK_PEXT_PEXTP_MAC_P0_AXI_250 ,"pext_pm0_axi_250" ,"ufs_pexpt0_mem_sub" ,12 ), +GATE_PEXT (CLK_PEXT_PEXTP_MAC_P0_AHB_APB ,"pext_pm0_ahb_apb" ,"ufs_pextp0_axi" ,13 ), +GATE_PEXT (CLK_PEXT_PEXTP_MAC_P0_PL_P ,"pext_pm0_pl_p" ,"clk26m" ,14 ), +GATE_PEXT (CLK_PEXT_PEXTP_VLP_AO_P0_LP ,"pext_pextp_vlp_ao_p0_lp" ,"clk26m" ,19 ), +}; + +static u16 pext_rst_ofs[] = {MT8196_PEXTP_RST0_SET_OFFSET }; + +static u16 pext_rst_idx_map[] = { + [MT8196_PEXTP0_RST0_PCIE0_MAC ] =0 , + [MT8196_PEXTP0_RST0_PCIE0_PHY ] =1 , +}; + +static const struct mtk_clk_rst_desc pext_rst_desc = { + .version =MTK_RST_SET_CLR , + .rst_bank_ofs = pext_rst_ofs, + .rst_bank_nr =ARRAY_SIZE (pext_rst_ofs), + .rst_idx_map = pext_rst_idx_map, + .rst_idx_map_nr =ARRAY_SIZE (pext_rst_idx_map), +}; + +static const struct mtk_clk_desc pext_mcd = { + .clks = pext_clks, + .num_clks =ARRAY_SIZE (pext_clks), + .rst_desc = &pext_rst_desc, +}; + +static const struct mtk_gate pext1_clks[] = { +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P1_TL ,"pext1_pm1_tl" ,"tl_p1" ,0 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P1_REF ,"pext1_pm1_ref" ,"clk26m" ,1 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P2_TL ,"pext1_pm2_tl" ,"tl_p2" ,2 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P2_REF ,"pext1_pm2_ref" ,"clk26m" ,3 ), +GATE_PEXT (CLK_PEXT1_PEXTP_PHY_P1_MCU_BUS ,"pext1_pp1_mcu_bus" ,"clk26m" ,8 ), +GATE_PEXT (CLK_PEXT1_PEXTP_PHY_P1_PEXTP_REF ,"pext1_pp1_pextp_ref" ,"clk26m" ,9 ), +GATE_PEXT (CLK_PEXT1_PEXTP_PHY_P2_MCU_BUS ,"pext1_pp2_mcu_bus" ,"clk26m" ,10 ), +GATE_PEXT (CLK_PEXT1_PEXTP_PHY_P2_PEXTP_REF ,"pext1_pp2_pextp_ref" ,"clk26m" ,11 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P1_AXI_250 ,"pext1_pm1_axi_250" , +"pextp1_usb_axi" ,16 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P1_AHB_APB ,"pext1_pm1_ahb_apb" , +"pextp1_usb_mem_sub" ,17 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P1_PL_P ,"pext1_pm1_pl_p" ,"clk26m" ,18 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P2_AXI_250 ,"pext1_pm2_axi_250" , +"pextp1_usb_axi" ,19 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P2_AHB_APB ,"pext1_pm2_ahb_apb" , +"pextp1_usb_mem_sub" ,20 ), +GATE_PEXT (CLK_PEXT1_PEXTP_MAC_P2_PL_P ,"pext1_pm2_pl_p" ,"clk26m" ,21 ), +GATE_PEXT (CLK_PEXT1_PEXTP_VLP_AO_P1_LP ,"pext1_pextp_vlp_ao_p1_lp" ,"clk26m" ,26 ), +GATE_PEXT (CLK_PEXT1_PEXTP_VLP_AO_P2_LP ,"pext1_pextp_vlp_ao_p2_lp" ,"clk26m" ,27 ), +}; + +static u16 pext1_rst_idx_map[] = { + [MT8196_PEXTP1_RST0_PCIE1_MAC ] =0 , + [MT8196_PEXTP1_RST0_PCIE1_PHY ] =1 , + [MT8196_PEXTP1_RST0_PCIE2_MAC ] =8 , + [MT8196_PEXTP1_RST0_PCIE2_PHY ] =9 , +}; + +static const struct mtk_clk_rst_desc pext1_rst_desc = { + .version =MTK_RST_SET_CLR , + .rst_bank_ofs = pext_rst_ofs, + .rst_bank_nr =ARRAY_SIZE (pext_rst_ofs), + .rst_idx_map = pext1_rst_idx_map, + .rst_idx_map_nr =ARRAY_SIZE (pext1_rst_idx_map), +}; + +static const struct mtk_clk_desc pext1_mcd = { + .clks = pext1_clks, + .num_clks =ARRAY_SIZE (pext1_clks), + .rst_desc = &pext1_rst_desc, +}; + +static const struct of_device_id of_match_clk_mt8196_pextp[] = { + { .compatible ="mediatek,mt8196-pextp0cfg-ao" , .data = &pext_mcd }, + { .compatible ="mediatek,mt8196-pextp1cfg-ao" , .data = &pext1_mcd }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, of_match_clk_mt8196_pextp); + +static struct platform_driver clk_mt8196_pextp_drv = { + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, + .driver = { + .name ="clk-mt8196-pextp" , + .of_match_table = of_match_clk_mt8196_pextp, + }, +}; + +module_platform_driver (clk_mt8196_pextp_drv); +MODULE_DESCRIPTION ("MediaTek MT8196 PCIe transmit phy clocks driver" ); +MODULE_LICENSE ("GPL" ); --2.39.5
PATCH v4 17/27 clk: mediatek: Add MT8196 I2C clock support
In reply to Laura NaoAdd support for the MT8196 I2C clock controller, which provides clock gate control for I2C.
--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + .../clk/mediatek/clk-mt8196-imp_iic_wrap.c | 117 ++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_IMP_IIC_WRAP + tristate "Clock driver for MediaTek MT8196 imp_iic_wrap" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 i2c clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 17/27] clk: mediatek: Add MT8196 I2C clock support
Quoted 50 lines · Laura Nao
Add support for the MT8196 I2C clock controller, which provides clock gate control for I2C.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + .../clk/mediatek/clk-mt8196-imp_iic_wrap.c | 117 ++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.cdrivers/clk/mediatek/Kconfig +7
-0@@ -1010,6 +1010,13 @@ config COMMON_CLK_MT8196 help This driver supports MediaTek MT8196 basic clocks. +config COMMON_CLK_MT8196_IMP_IIC_WRAP + tristate "Clock driver for MediaTek MT8196 imp_iic_wrap" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 i2c clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196drivers/clk/mediatek/Makefile +1
-0@@ -153,6 +153,7 @@ obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.odrivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c new file +0
-0
drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c line 8
Quoted 8 lines
drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c new file +8
-0@@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 MediaTek Inc. +* Guangjie Song <[email protected]> +* Copyright (c) 2025 Collabora Ltd. +* Laura Nao <[email protected]> +*/ +#include <dt-bindings/clock/mediatek,mt8196-clock.h>
Nit: add line for separation.
Quoted 11 lines
drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c new file +11
-0+#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#include "clk-gate.h" +#include "clk-mtk.h" + +static const struct mtk_gate_regs imp_cg_regs = { + .set_ofs =0xe08 , + .clr_ofs =0xe04 ,
drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c line 29
Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-imp_iic_wrap.c new file +10
-0+ .sta_ofs = 0xe00, +}; + +#define GATE_IMP (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &imp_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \
So here it likely works because the parent for all the gates are the same, which is the clock feeding this block.
PATCH v4 18/27 clk: mediatek: Add MT8196 mcu clock support
In reply to Laura NaoAdd support for the MT8196 mcu clock controller, which provides PLL control for MCU.
--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-mcu.c | 166 ++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-mcu.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1017,6 +1017,13 @@ config COMMON_CLK_MT8196_IMP_IIC_WRAP help This driver supports MediaTek MT8196 i2c clocks. +config COMMON_CLK_MT8196_MCUSYS + tristate "Clock driver for MediaTek MT8196 mcusys" + depends on COMMON_CLK_MT8196 + default COMMON_CLK_MT8196 + help + This driver supports MediaTek MT8196 mcusys clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
@@ -154,6 +154,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ clk-mt8196-peri_ao.o obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o +obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-mcu.c new file +166 -0
166 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 19/27 clk: mediatek: Add MT8196 mdpsys clock support
In reply to Laura NaoAdd support for the MT8196 mdpsys clock controller, which provides clock gate control for MDP.
--- drivers/clk/mediatek/Kconfig | 7 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-mdpsys.c | 187 +++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-mdpsys.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1024,6 +1024,13 @@ config COMMON_CLK_MT8196_MCUSYS help This driver supports MediaTek MT8196 mcusys clocks. +config COMMON_CLK_MT8196_MDPSYS + tristate "Clock driver for MediaTek MT8196 mdpsys" + depends on COMMON_CLK_MT8196 + default m + help + This driver supports MediaTek MT8196 mdpsys clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
@@ -155,6 +155,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o clk-mt8196-peri_ao.o obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o +obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-mdpsys.c new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v4 19/27] clk: mediatek: Add MT8196 mdpsys clock support
Quoted 19 lines · Laura Nao
Add support for the MT8196 mdpsys clock controller, which provides clock gate control for MDP.
Reviewed-by Nícolas F. R. A. Prado <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Laura Nao <[email protected]>--- drivers/clk/mediatek/Kconfig | 7 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-mdpsys.c | 187 +++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-mdpsys.cdrivers/clk/mediatek/Kconfig +0
-0
drivers/clk/mediatek/Kconfig config COMMON_CLK_MT8196_MCUSYS · line 1030
Quoted 7 lines
drivers/clk/mediatek/Kconfig +4
-0@@ -1024,6 +1024,13 @@ config COMMON_CLK_MT8196_MCUSYS help This driver supports MediaTek MT8196 mcusys clocks. +config COMMON_CLK_MT8196_MDPSYS + tristate "Clock driver for MediaTek MT8196 mdpsys" + depends on COMMON_CLK_MT8196 + default m
Please use "default COMMON_CLK_MT8196" for consistency with other patches and other platforms.
Quoted 119 lines
drivers/clk/mediatek/Kconfig +3
-0+ help + This driver supports MediaTek MT8196 mdpsys clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196drivers/clk/mediatek/Makefile +1
-0@@ -155,6 +155,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o clk-mt8196-peri_ao.o obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o +obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.odrivers/clk/mediatek/clk-mt8196-mdpsys.c new file +95
-0@@ -0,0 +1,187 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 MediaTek Inc. +* Guangjie Song <[email protected]> +* Copyright (c) 2025 Collabora Ltd. +* Laura Nao <[email protected]> +*/ + +#include "clk-gate.h" +#include "clk-mtk.h" + +#include <dt-bindings/clock/mediatek,mt8196-clock.h> +#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +static const struct mtk_gate_regs mdp0_cg_regs = { + .set_ofs =0x104 , + .clr_ofs =0x108 , + .sta_ofs =0x100 , +}; + +static const struct mtk_gate_regs mdp1_cg_regs = { + .set_ofs =0x114 , + .clr_ofs =0x118 , + .sta_ofs =0x110 , +}; + +static const struct mtk_gate_regs mdp2_cg_regs = { + .set_ofs =0x124 , + .clr_ofs =0x128 , + .sta_ofs =0x120 , +}; + +#define GATE_MDP0 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &mdp0_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \ + .ops = &mtk_clk_gate_ops_setclr, \ + } + +#define GATE_MDP1 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &mdp1_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \ + .ops = &mtk_clk_gate_ops_setclr, \ + } + +#define GATE_MDP2 (_id, _name, _parent, _shift) { \ + .id = _id, \ + .name = _name, \ + .parent_name = _parent, \ + .regs = &mdp2_cg_regs, \ + .shift = _shift, \ + .flags = CLK_OPS_PARENT_ENABLE, \ + .ops = &mtk_clk_gate_ops_setclr, \ + } + +static const struct mtk_gate mdp1_clks[] = { +/* MDP1-0 */ +GATE_MDP0 (CLK_MDP1_MDP_MUTEX0 ,"mdp1_mdp_mutex0" ,"mdp" ,0 ), +GATE_MDP0 (CLK_MDP1_SMI0 ,"mdp1_smi0" ,"mdp" ,1 ), +GATE_MDP0 (CLK_MDP1_APB_BUS ,"mdp1_apb_bus" ,"mdp" ,2 ), +GATE_MDP0 (CLK_MDP1_MDP_RDMA0 ,"mdp1_mdp_rdma0" ,"mdp" ,3 ), +GATE_MDP0 (CLK_MDP1_MDP_RDMA1 ,"mdp1_mdp_rdma1" ,"mdp" ,4 ), +GATE_MDP0 (CLK_MDP1_MDP_RDMA2 ,"mdp1_mdp_rdma2" ,"mdp" ,5 ), +GATE_MDP0 (CLK_MDP1_MDP_BIRSZ0 ,"mdp1_mdp_birsz0" ,"mdp" ,6 ), +GATE_MDP0 (CLK_MDP1_MDP_HDR0 ,"mdp1_mdp_hdr0" ,"mdp" ,7 ), +GATE_MDP0 (CLK_MDP1_MDP_AAL0 ,"mdp1_mdp_aal0" ,"mdp" ,8 ), +GATE_MDP0 (CLK_MDP1_MDP_RSZ0 ,"mdp1_mdp_rsz0" ,"mdp" ,9 ), +GATE_MDP0 (CLK_MDP1_MDP_RSZ2 ,"mdp1_mdp_rsz2" ,"mdp" ,10 ), +GATE_MDP0 (CLK_MDP1_MDP_TDSHP0 ,"mdp1_mdp_tdshp0" ,"mdp" ,11 ), +GATE_MDP0 (CLK_MDP1_MDP_COLOR0 ,"mdp1_mdp_color0" ,"mdp" ,12 ), +GATE_MDP0 (CLK_MDP1_MDP_WROT0 ,"mdp1_mdp_wrot0" ,"mdp" ,13 ), +GATE_MDP0 (CLK_MDP1_MDP_WROT1 ,"mdp1_mdp_wrot1" ,"mdp" ,14 ), +GATE_MDP0 (CLK_MDP1_MDP_WROT2 ,"mdp1_mdp_wrot2" ,"mdp" ,15 ), +GATE_MDP0 (CLK_MDP1_MDP_FAKE_ENG0 ,"mdp1_mdp_fake_eng0" ,"mdp" ,16 ), +GATE_MDP0 (CLK_MDP1_APB_DB ,"mdp1_apb_db" ,"mdp" ,17 ), +GATE_MDP0 (CLK_MDP1_MDP_DLI_ASYNC0 ,"mdp1_mdp_dli_async0" ,"mdp" ,18 ), +GATE_MDP0 (CLK_MDP1_MDP_DLI_ASYNC1 ,"mdp1_mdp_dli_async1" ,"mdp" ,19 ), +GATE_MDP0 (CLK_MDP1_MDP_DLO_ASYNC0 ,"mdp1_mdp_dlo_async0" ,"mdp" ,20 ), +GATE_MDP0 (CLK_MDP1_MDP_DLO_ASYNC1 ,"mdp1_mdp_dlo_async1" ,"mdp" ,21 ), +GATE_MDP0 (CLK_MDP1_MDP_DLI_ASYNC2 ,"mdp1_mdp_dli_async2" ,"mdp" ,22 ), +GATE_MDP0 (CLK_MDP1_MDP_DLO_ASYNC2 ,"mdp1_mdp_dlo_async2" ,"mdp" ,23 ), +GATE_MDP0 (CLK_MDP1_MDP_DLO_ASYNC3 ,"mdp1_mdp_dlo_async3" ,"mdp" ,24 ), +GATE_MDP0 (CLK_MDP1_IMG_DL_ASYNC0 ,"mdp1_img_dl_async0" ,"mdp" ,25 ), +GATE_MDP0 (CLK_MDP1_MDP_RROT0 ,"mdp1_mdp_rrot0" ,"mdp" ,26 ), +GATE_MDP0 (CLK_MDP1_MDP_MERGE0 ,"mdp1_mdp_merge0" ,"mdp" ,27 ),
drivers/clk/mediatek/clk-mt8196-mdpsys.c line 105
Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-mdpsys.c new file +10
-0+GATE_MDP0 (CLK_MDP1_MDP_C3D0 ,"mdp1_mdp_c3d0" ,"mdp" ,28 ), +GATE_MDP0 (CLK_MDP1_MDP_FG0 ,"mdp1_mdp_fg0" ,"mdp" ,29 ), +GATE_MDP0 (CLK_MDP1_MDP_CLA2 ,"mdp1_mdp_cla2" ,"mdp" ,30 ), +GATE_MDP0 (CLK_MDP1_MDP_DLO_ASYNC4 ,"mdp1_mdp_dlo_async4" ,"mdp" ,31 ), +/* MDP1-1 */ +GATE_MDP1 (CLK_MDP1_VPP_RSZ0 ,"mdp1_vpp_rsz0" ,"mdp" ,0 ), +GATE_MDP1 (CLK_MDP1_VPP_RSZ1 ,"mdp1_vpp_rsz1" ,"mdp" ,1 ), +GATE_MDP1 (CLK_MDP1_MDP_DLO_ASYNC5 ,"mdp1_mdp_dlo_async5" ,"mdp" ,2 ), +GATE_MDP1 (CLK_MDP1_IMG0 ,"mdp1_img0" ,"mdp" ,3 ), + GATE_MDP1(CLK_MDP1_F26M, "mdp1_f26m", "clk26m", 27),
Assuming CLK_OPS_PARENT_ENABLE is intended, this gate will fail to be toggled if the "mdp" clock is not already enabled.
Quoted 42 lines
drivers/clk/mediatek/clk-mt8196-mdpsys.c new file +42
-0+/* MDP1-2 */ +GATE_MDP2 (CLK_MDP1_IMG_DL_RELAY0 ,"mdp1_img_dl_relay0" ,"mdp" ,0 ), + GATE_MDP2(CLK_MDP1_IMG_DL_RELAY1, "mdp1_img_dl_relay1", "mdp", 8), +}; + +static const struct mtk_clk_desc mdp1_mcd = { + .clks = mdp1_clks, + .num_clks =ARRAY_SIZE (mdp1_clks), + .need_runtime_pm = true, +}; + + +static const struct mtk_gate mdp_clks[] = { +/* MDP0 */ +GATE_MDP0 (CLK_MDP_MDP_MUTEX0 ,"mdp_mdp_mutex0" ,"mdp" ,0 ), +GATE_MDP0 (CLK_MDP_SMI0 ,"mdp_smi0" ,"mdp" ,1 ), +GATE_MDP0 (CLK_MDP_APB_BUS ,"mdp_apb_bus" ,"mdp" ,2 ), +GATE_MDP0 (CLK_MDP_MDP_RDMA0 ,"mdp_mdp_rdma0" ,"mdp" ,3 ), +GATE_MDP0 (CLK_MDP_MDP_RDMA1 ,"mdp_mdp_rdma1" ,"mdp" ,4 ), +GATE_MDP0 (CLK_MDP_MDP_RDMA2 ,"mdp_mdp_rdma2" ,"mdp" ,5 ), +GATE_MDP0 (CLK_MDP_MDP_BIRSZ0 ,"mdp_mdp_birsz0" ,"mdp" ,6 ), +GATE_MDP0 (CLK_MDP_MDP_HDR0 ,"mdp_mdp_hdr0" ,"mdp" ,7 ), +GATE_MDP0 (CLK_MDP_MDP_AAL0 ,"mdp_mdp_aal0" ,"mdp" ,8 ), +GATE_MDP0 (CLK_MDP_MDP_RSZ0 ,"mdp_mdp_rsz0" ,"mdp" ,9 ), +GATE_MDP0 (CLK_MDP_MDP_RSZ2 ,"mdp_mdp_rsz2" ,"mdp" ,10 ), +GATE_MDP0 (CLK_MDP_MDP_TDSHP0 ,"mdp_mdp_tdshp0" ,"mdp" ,11 ), +GATE_MDP0 (CLK_MDP_MDP_COLOR0 ,"mdp_mdp_color0" ,"mdp" ,12 ), +GATE_MDP0 (CLK_MDP_MDP_WROT0 ,"mdp_mdp_wrot0" ,"mdp" ,13 ), +GATE_MDP0 (CLK_MDP_MDP_WROT1 ,"mdp_mdp_wrot1" ,"mdp" ,14 ), +GATE_MDP0 (CLK_MDP_MDP_WROT2 ,"mdp_mdp_wrot2" ,"mdp" ,15 ), +GATE_MDP0 (CLK_MDP_MDP_FAKE_ENG0 ,"mdp_mdp_fake_eng0" ,"mdp" ,16 ), +GATE_MDP0 (CLK_MDP_APB_DB ,"mdp_apb_db" ,"mdp" ,17 ), +GATE_MDP0 (CLK_MDP_MDP_DLI_ASYNC0 ,"mdp_mdp_dli_async0" ,"mdp" ,18 ), +GATE_MDP0 (CLK_MDP_MDP_DLI_ASYNC1 ,"mdp_mdp_dli_async1" ,"mdp" ,19 ), +GATE_MDP0 (CLK_MDP_MDP_DLO_ASYNC0 ,"mdp_mdp_dlo_async0" ,"mdp" ,20 ), +GATE_MDP0 (CLK_MDP_MDP_DLO_ASYNC1 ,"mdp_mdp_dlo_async1" ,"mdp" ,21 ), +GATE_MDP0 (CLK_MDP_MDP_DLI_ASYNC2 ,"mdp_mdp_dli_async2" ,"mdp" ,22 ), +GATE_MDP0 (CLK_MDP_MDP_DLO_ASYNC2 ,"mdp_mdp_dlo_async2" ,"mdp" ,23 ), +GATE_MDP0 (CLK_MDP_MDP_DLO_ASYNC3 ,"mdp_mdp_dlo_async3" ,"mdp" ,24 ), +GATE_MDP0 (CLK_MDP_IMG_DL_ASYNC0 ,"mdp_img_dl_async0" ,"mdp" ,25 ), +GATE_MDP0 (CLK_MDP_MDP_RROT0 ,"mdp_mdp_rrot0" ,"mdp" ,26 ), + GATE_MDP0(CLK_MDP_MDP_MERGE0, "mdp_mdp_merge0", "mdp", 27),
drivers/clk/mediatek/clk-mt8196-mdpsys.c line 157
Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-mdpsys.c new file +10
-0+GATE_MDP0 (CLK_MDP_MDP_C3D0 ,"mdp_mdp_c3d0" ,"mdp" ,28 ), +GATE_MDP0 (CLK_MDP_MDP_FG0 ,"mdp_mdp_fg0" ,"mdp" ,29 ), +GATE_MDP0 (CLK_MDP_MDP_CLA2 ,"mdp_mdp_cla2" ,"mdp" ,30 ), +GATE_MDP0 (CLK_MDP_MDP_DLO_ASYNC4 ,"mdp_mdp_dlo_async4" ,"mdp" ,31 ), +/* MDP1 */ +GATE_MDP1 (CLK_MDP_VPP_RSZ0 ,"mdp_vpp_rsz0" ,"mdp" ,0 ), +GATE_MDP1 (CLK_MDP_VPP_RSZ1 ,"mdp_vpp_rsz1" ,"mdp" ,1 ), +GATE_MDP1 (CLK_MDP_MDP_DLO_ASYNC5 ,"mdp_mdp_dlo_async5" ,"mdp" ,2 ), +GATE_MDP1 (CLK_MDP_IMG0 ,"mdp_img0" ,"mdp" ,3 ), + GATE_MDP1(CLK_MDP_F26M, "mdp_f26m", "clk26m", 27),
Same for this one.
ChenYu
Quoted 33 lines
drivers/clk/mediatek/clk-mt8196-mdpsys.c new file +30
-1+/* MDP2 */ +GATE_MDP2 (CLK_MDP_IMG_DL_RELAY0 ,"mdp_img_dl_relay0" ,"mdp" ,0 ), + GATE_MDP2(CLK_MDP_IMG_DL_RELAY1, "mdp_img_dl_relay1", "mdp", 8), +}; + +static const struct mtk_clk_desc mdp_mcd = { + .clks = mdp_clks, + .num_clks =ARRAY_SIZE (mdp_clks), + .need_runtime_pm = true, +}; + +static const struct of_device_id of_match_clk_mt8196_mdpsys[] = { + { .compatible ="mediatek,mt8196-mdpsys1" , .data = &mdp1_mcd }, + { .compatible ="mediatek,mt8196-mdpsys0" , .data = &mdp_mcd }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, of_match_clk_mt8196_mdpsys); + +static struct platform_driver clk_mt8196_mdpsys_drv = { + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove, + .driver = { + .name ="clk-mt8196-mdpsys" , + .of_match_table = of_match_clk_mt8196_mdpsys, + }, +}; +module_platform_driver (clk_mt8196_mdpsys_drv); + +MODULE_DESCRIPTION ("MediaTek MT8196 Multimedia Data Path clocks driver" ); +MODULE_LICENSE ("GPL" ); --2.39.5
PATCH v4 20/27 clk: mediatek: Add MT8196 mfg clock support
In reply to Laura NaoAdd support for the MT8196 mfg clock controller, which provides PLL control for the GPU.
--- drivers/clk/mediatek/Kconfig | 7 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-mfg.c | 149 ++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-mfg.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1031,6 +1031,13 @@ config COMMON_CLK_MT8196_MDPSYS help This driver supports MediaTek MT8196 mdpsys clocks. +config COMMON_CLK_MT8196_MFGCFG + tristate "Clock driver for MediaTek MT8196 mfgcfg" + depends on COMMON_CLK_MT8196 + default m + help + This driver supports MediaTek MT8196 mfgcfg clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
@@ -156,6 +156,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o +obj-$(CONFIG_COMMON_CLK_MT8196_MFGCFG) += clk-mt8196-mfg.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-mfg.c new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 21/27 clk: mediatek: Add MT8196 disp0 clock support
In reply to Laura NaoAdd support for the MT8196 disp0 clock controller, which provides clock gate control for the display system. It is integrated with the mtk-mmsys driver, which registers the disp0 clock driver via platform_device_register_data().
--- drivers/clk/mediatek/Kconfig | 7 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-disp0.c | 169 ++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-disp0.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1038,6 +1038,13 @@ config COMMON_CLK_MT8196_MFGCFG help This driver supports MediaTek MT8196 mfgcfg clocks. +config COMMON_CLK_MT8196_MMSYS + tristate "Clock driver for MediaTek MT8196 mmsys" + depends on COMMON_CLK_MT8196 + default m + help + This driver supports MediaTek MT8196 mmsys clocks. + config COMMON_CLK_MT8196_PEXTPSYS tristate "Clock driver for MediaTek MT8196 pextpsys" depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
@@ -157,6 +157,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_MFGCFG) += clk-mt8196-mfg.o +obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-disp0.c new file +169 -0
169 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 22/27 clk: mediatek: Add MT8196 disp1 clock support
In reply to Laura NaoAdd support for the MT8196 disp1 clock controller, which provides clock gate control for the display system. It is integrated with the mtk-mmsys driver, which registers the disp1 clock driver via platform_device_register_data().
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8196-disp1.c | 170 ++++++++++++++++++++++++ 2 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-disp1.c
drivers/clk/mediatek/Makefile +1 -1
@@ -157,7 +157,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_MFGCFG) += clk-mt8196-mfg.o -obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o +obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-disp1.c new file +170 -0
170 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 23/27 clk: mediatek: Add MT8196 disp-ao clock support
In reply to Laura NaoAdd support for the MT8196 disp-ao clock controller, which provides clock gate control for the display system. It is integrated with the mtk-mmsys driver, which registers the disp-ao clock driver via platform_device_register_data().
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8196-vdisp_ao.c | 79 ++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-vdisp_ao.c
drivers/clk/mediatek/Makefile +1 -1
@@ -157,7 +157,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_MFGCFG) += clk-mt8196-mfg.o -obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o +obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o clk-mt8196-vdisp_ao.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-vdisp_ao.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 24/27 clk: mediatek: Add MT8196 ovl0 clock support
In reply to Laura NaoAdd support for the MT8196 ovl0 clock controller, which provides clock gate control for the display system. It is integrated with the mtk-mmsys driver, which registers the ovl0 clock driver via platform_device_register_data().
--- drivers/clk/mediatek/Makefile | 3 +- drivers/clk/mediatek/clk-mt8196-ovl0.c | 154 +++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-ovl0.c
drivers/clk/mediatek/Makefile +2 -1
@@ -157,7 +157,8 @@ obj-$(CONFIG_COMMON_CLK_MT8196_IMP_IIC_WRAP) += clk-mt8196-imp_iic_wrap.o obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_MFGCFG) += clk-mt8196-mfg.o -obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o clk-mt8196-vdisp_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o clk-mt8196-vdisp_ao.o \ + clk-mt8196-ovl0.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-ovl0.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 25/27 clk: mediatek: Add MT8196 ovl1 clock support
In reply to Laura NaoAdd support for the MT8196 ovl1 clock controller, which provides clock gate control for the display system. It is integrated with the mtk-mmsys driver, which registers the ovl1 clock driver via platform_device_register_data().
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8196-ovl1.c | 153 +++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/mediatek/clk-mt8196-ovl1.c
drivers/clk/mediatek/Makefile +1 -1
@@ -158,7 +158,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_MCUSYS) += clk-mt8196-mcu.o obj-$(CONFIG_COMMON_CLK_MT8196_MDPSYS) += clk-mt8196-mdpsys.o obj-$(CONFIG_COMMON_CLK_MT8196_MFGCFG) += clk-mt8196-mfg.o obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o clk-mt8196-vdisp_ao.o \ - clk-mt8196-ovl0.o + clk-mt8196-ovl0.o clk-mt8196-ovl1.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o
drivers/clk/mediatek/clk-mt8196-ovl1.c new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 26/27 clk: mediatek: Add MT8196 vdecsys clock support
In reply to Laura NaoAdd support for the MT8196 vdecsys clock controller, which provides clock gate control for the video decoder.
--- drivers/clk/mediatek/Kconfig | 7 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-vdec.c | 253 +++++++++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-vdec.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1059,6 +1059,13 @@ config COMMON_CLK_MT8196_UFSSYS help This driver supports MediaTek MT8196 ufssys clocks. +config COMMON_CLK_MT8196_VDECSYS + tristate "Clock driver for MediaTek MT8196 vdecsys" + depends on COMMON_CLK_MT8196 + default m + help + This driver supports MediaTek MT8196 vdecsys clocks. + config COMMON_CLK_MT8365 tristate "Clock driver for MediaTek MT8365" depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -161,6 +161,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o c clk-mt8196-ovl0.o clk-mt8196-ovl1.o obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o +obj-$(CONFIG_COMMON_CLK_MT8196_VDECSYS) += clk-mt8196-vdec.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-vdec.c new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 27/27 clk: mediatek: Add MT8196 vencsys clock support
In reply to Laura NaoAdd support for the MT8196 vencsys clock controller, which provides clock gate control for the video encoder.
--- drivers/clk/mediatek/Kconfig | 7 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8196-venc.c | 235 +++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8196-venc.c
drivers/clk/mediatek/Kconfig +7 -0
@@ -1066,6 +1066,13 @@ config COMMON_CLK_MT8196_VDECSYS help This driver supports MediaTek MT8196 vdecsys clocks. +config COMMON_CLK_MT8196_VENCSYS + tristate "Clock driver for MediaTek MT8196 vencsys" + depends on COMMON_CLK_MT8196 + default m + help + This driver supports MediaTek MT8196 vencsys clocks. + config COMMON_CLK_MT8365 tristate "Clock driver for MediaTek MT8365" depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -162,6 +162,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_MMSYS) += clk-mt8196-disp0.o clk-mt8196-disp1.o c obj-$(CONFIG_COMMON_CLK_MT8196_PEXTPSYS) += clk-mt8196-pextp.o obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o obj-$(CONFIG_COMMON_CLK_MT8196_VDECSYS) += clk-mt8196-vdec.o +obj-$(CONFIG_COMMON_CLK_MT8196_VENCSYS) += clk-mt8196-venc.o obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
drivers/clk/mediatek/clk-mt8196-venc.c new file +235 -0
235 lines not on this page · raw message
Signature · 1 line
2.39.5