Skip to contentSkip to conversation

Add support for MT8196 clock controllers

PATCH Superseded Laura Nao 6 participants 52 messages Jun 24, 2025 – Jul 22, 2025

Subsystems (6)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Laura Nao

author
#0 lore raw

v2 cover Add support for MT8196 clock controllers

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 v2:
- Fixed incorrect ID numbering in mediatek,mt8196-clock.h
- Improved description for 'mediatek,hardware-voter' in mediatek,mt8196-clock.yaml and mediatek,mt8196-sys-clock.yaml
- Added description for '#reset-cells' in mediatek,mt8196-clock.yaml
- Added missing mediatek,mt8196-vdisp-ao compatible in mediatek,mt8196-clock.yaml
- Fixed license in mediatek,mt8196-resets.h
- Fixed missing of_match_table in clk-mt8196-vdisp_ao.c
- Squashed commit adding UFS and PEXTP reset controller support
- Reordered commits to place reset controller binding before dependent drivers
- Added R-b tags

Link to v1: https://lore.kernel.org/all/[email protected]/

AngeloGioacchino Del Regno (1):
dt-bindings: reset: Add MediaTek MT8196 Reset Controller binding

Laura Nao (28):
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 peripheral 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 adsp 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 |   87 ++
 .../clock/mediatek,mt8196-sys-clock.yaml      |   81 ++
 drivers/clk/mediatek/Kconfig                  |   78 +
 drivers/clk/mediatek/Makefile                 |   14 +
 drivers/clk/mediatek/clk-gate.c               |  106 +-
 drivers/clk/mediatek/clk-gate.h               |    3 +
 drivers/clk/mediatek/clk-mt8196-adsp.c        |  193 +++
 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         |  150 ++
 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    | 1257 +++++++++++++++++
 drivers/clk/mediatek/clk-mt8196-topckgen2.c   |  662 +++++++++
 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    |  769 ++++++++++
 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                |   76 +
 drivers/clk/mediatek/clk-pll.c                |   46 +-
 drivers/clk/mediatek/clk-pll.h                |    9 +
 .../dt-bindings/clock/mediatek,mt8196-clock.h |  867 ++++++++++++
 .../reset/mediatek,mt8196-resets.h            |   26 +
 33 files changed, 6828 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-adsp.c
 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
author
#1 lore raw

PATCH v2 1/29 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
index ce453e1718e5..49ca25dd5418 100644
@@ -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
index 285c8db958b3..c4d06bb11516 100644
@@ -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
author
#2 lore raw

PATCH v2 2/29 clk: mediatek: clk-pll: Add ops for PLLs using set/clr regs and FENC

In reply to 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.

---
 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
index 49ca25dd5418..8f46de77f42d 100644
@@ -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
index c4d06bb11516..7fdc5267a2b5 100644
@@ -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
author
#3 lore raw

PATCH v2 3/29 clk: mediatek: clk-mux: Add ops for mux gates with set/clr/upd and FENC

In reply to 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.

---
 drivers/clk/mediatek/clk-mtk.h |  2 ++
 drivers/clk/mediatek/clk-mux.c | 48 ++++++++++++++++++++++++++++++++++
 drivers/clk/mediatek/clk-mux.h | 34 ++++++++++++++++++++++++
 3 files changed, 84 insertions(+)
drivers/clk/mediatek/clk-mtk.h +2 -0
index c17fe1c2d732..136a4bc6dbe6 100644
@@ -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 +34 -0
index 943ad1d7ce4b..ba390b579e6c 100644
@@ -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,37 @@ 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,		\
+			_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,				\
+		.num_parents = ARRAY_SIZE(_parents),			\
+		.flags = _flags,					\
+		.ops = &mtk_mux_gate_fenc_clr_set_upd_ops,		\
+	}
+
+#define MUX_GATE_FENC_CLR_SET_UPD(_id, _name, _parents,			\
+			_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,	\
+			_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,
Signature · 1 line
2.39.5
author
#4 lore raw

PATCH v2 4/29 clk: mediatek: clk-mtk: Introduce mtk_clk_get_hwv_regmap()

In reply to 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().

---
 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
index ba1d1c495bc2..19cd27941747 100644
@@ -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
index 136a4bc6dbe6..8ed2c9208b1f 100644
@@ -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
author
#5 lore raw

PATCH v2 5/29 clk: mediatek: clk-mux: Add ops for mux gates with HW voter and FENC

In reply to 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.

---
 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
index 8ed2c9208b1f..e2cefd9bc5b8 100644
@@ -20,6 +20,7 @@
 
 #define MHZ (1000 * 1000)
 
+#define MTK_WAIT_HWV_DONE_US	30
 #define MTK_WAIT_FENC_DONE_US	30
 
 struct 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
author
#6 lore raw

PATCH v2 6/29 clk: mediatek: clk-gate: Refactor mtk_clk_register_gate to use mtk_gate struct

In reply to 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 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
index 67d9e741c5e7..0375ccad4be3 100644
@@ -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 *name
 	if (!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
author
#7 lore raw

PATCH v2 7/29 clk: mediatek: clk-gate: Add ops for gates with HW voter

In reply to 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.

---
 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
index 0375ccad4be3..426f3a25763d 100644
@@ -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
index 1a46b4c56fc5..4f05b9855dae 100644
@@ -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
author
#8 lore raw

PATCH v2 8/29 clk: mediatek: clk-mtk: Add MUX_DIV_GATE macro

In reply to 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.

---
 drivers/clk/mediatek/clk-mtk.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/clk/mediatek/clk-mtk.h +19 -0
index e2cefd9bc5b8..3498505b616e 100644
@@ -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
author
#9 lore raw

PATCH v2 9/29 dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

In reply to Laura Nao

Add new binding documentation for system clocks and functional clocks on MediaTek MT8196.

---
 .../bindings/clock/mediatek,mt8196-clock.yaml |  87 ++
 .../clock/mediatek,mt8196-sys-clock.yaml      |  81 ++
 .../dt-bindings/clock/mediatek,mt8196-clock.h | 867 ++++++++++++++++++
 3 files changed, 1035 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
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +87 -0
new file mode 100644
index 000000000000..62f0e215ec4a
@@ -0,0 +1,87 @@
+# 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-adsp
+          - 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:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
+
+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 +81 -0

81 lines not on this page · raw message

include/dt-bindings/clock/mediatek,mt8196-clock.h new file +867 -0

867 lines not on this page · raw message

Signature · 1 line
2.39.5
#10 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines · Laura Nao
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

I already commented on this, so don't send v3 with the same.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Cheers,
Angelo

Quoted 5 lines

I already commented on this, so don't send v3 with the same.

Best regards,
Krzysztof

#12 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Quoted 19 lines · AngeloGioacchino Del Regno

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

So the hardware voter itself (and/or bits inside of its registers) cannot be represented as a clock :\

In the context of clocks, it's used for clocks, (and not touching power domains at all), but in the context of power domains it's used for power domains (and not touching clocks at all).

I'm not sure what qcom does - your reply makes me think that they did it such that the clocks part is in a MMIO and the power domains part is in a different MMIO, without having clock/pd intertwined voting registers...

Still not sure what to do here, then...

Cheers,
Angelo

#14 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Quoted 59 lines · AngeloGioacchino Del Regno

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

Quoted 6 lines

So the hardware voter itself (and/or bits inside of its registers) cannot be represented as a clock :\

In the context of clocks, it's used for clocks, (and not touching power domains at all), but in the context of power domains it's used for power domains (and not touching clocks at all).

I don't understand this. Earlier you mentioned "MUX-GATE and GATE clocks", so these are clocks, right? How these clocks are used in other places as power domains? If they are, this either has to be fixed or apparently this is a power domain and use it as power domain also here.

Really, something called as hardware voter is not that uncommon and it does fit existing bindings.

Quoted 4 lines

I'm not sure what qcom does - your reply makes me think that they did it such that the clocks part is in a MMIO and the power domains part is in a different MMIO, without having clock/pd intertwined voting registers...

No, you just never have direct access to hardware. You place votes and votes go to the firmware. Now depending on person submitting it or writing internal docs, they call it differently, but eventually it is the same. You want to vote for some specific signal to be active or running at some performance level.

Quoted 5 lines

Still not sure what to do here, then...

Cheers,
Angelo

Best regards,
Krzysztof

#15 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Il 25/06/25 13:05, Krzysztof Kozlowski ha scritto:

Quoted 63 lines · AngeloGioacchino Del Regno
Quoted 62 lines

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

So the hardware voter itself (and/or bits inside of its registers) cannot be represented as a clock :\

Quoted 7 lines
Quoted 3 lines

In the context of clocks, it's used for clocks, (and not touching power domains at all), but in the context of power domains it's used for power domains (and not touching clocks at all).

I don't understand this. Earlier you mentioned "MUX-GATE and GATE clocks", so these are clocks, right? How these clocks are used in other places as power domains?

I think you've misread, or I've explained badly enough to make you misread... let me describe some more to try to let you understand this properly.

The hardware voter is a unit that is used to vote for "flipping various switches", in particular, you can vote for, *either*:
- Enabling or disabling a *clock*; or
- Enabling or disabling a *power domain*.

There may be multiple (by hardware, in-silicon) copies of the Hardware Voter; in the specific case of the MediaTek Dimensity 9400 MT6991 and of the MediaTek MT8196 Chromebook SoC, there is only one instance.

The Hardware Voter, there, is located in the SCPSYS macro-block.

The SCPSYS macro-block contains:
- A system controller
- A Hardware Voter IP (new in MT6991/MT8196)
- A power domains controller
- Other hardware that is not relevant for this discussion

The HWV is MMIO-accessible, and there is one (small, for now) set of registers, allowing to vote for turning on/off one (or maybe multiple too, not sure about that as there's no documentation and when I tried with multi-votes it didn't work) clk/pd at a time.

Probably not important but worth mentioning: the HWV can vote for clocks or for power domains in macro-blocks outside of its own (so, outside of the SCPSYS block, for example - it can vote to turn on a clock or a power domain in HFRPSYS as well).

The register set in the HWV is *not* split between clock voters and PDs voters, in the sense that the register set of clock voters is *not contiguous*; trying to be as clear as possible, you have something like (mock register names ahead):
0x0 - CLOCK_VOTER_0 (each bit is a clock)
0x4 - PD_VOTER_0 (each bit is a power domain)
0x8 - SECURE_WORLD_CLOCK_VOTER_1
0xc - PD_VOTER_1
0x10 - SECURE_WORLD_PD_VOTER_0

...etc etc.

Quoted 2 lines
Quoted 1 line

If they are, this either has to be fixed or

apparently this is a power domain and use it as power domain also here.

So no, clocks are not used as power domains, and power domains are not used as clocks; we are talking purely about something that aggregates votes internally and decides to turn on/off "whatever thing it is" (one of the clocks, or one of the power domains) - and to do that, you flip a bit in a register, and then you read another two registers to know the status of the internal state machine....

....and you do that atomically, this can't sleep, the system has to lock up until HWV is done (I think I know what you're thinking, and yes, it's really like this) otherwise you're surely racing.

Quoted 4 lines

Really, something called as hardware voter is not that uncommon and it does fit existing bindings.

Do you mean the interconnect/qcom/bcm-voter.c?

That one seems to aggregate votes in software to place a vote in a hardware voter (the Bus Clock Manager) and I see it as being really convoluted.

For MediaTek's HWV, you don't need to aggregate anything - actually, the HWV itself is taking care of aggregating requests internally...

Also, checking sdx75 and x1e80100 DTs, I see a virtual clock controller described, placing votes through the bcm-voter, and with clocks that looks like being kind of disguised/faked as interconnects?

That's a bit unclear, and even if I'm wrong about those being disguised as icc, and not virtual, purely looking at the usage of the clk_virt and bcm-voters, I seriously don't think that any similar structure with interconnect would fit MediaTek SoCs in any way...

Quoted 11 lines
Quoted 4 lines

I'm not sure what qcom does - your reply makes me think that they did it such that the clocks part is in a MMIO and the power domains part is in a different MMIO, without having clock/pd intertwined voting registers...

No, you just never have direct access to hardware. You place votes and votes go to the firmware. Now depending on person submitting it or writing internal docs, they call it differently, but eventually it is the same. You want to vote for some specific signal to be active or running at some performance level.

Okay then there is one similarity, but it's different; MTK HWV is only arbitering a on/off request; Nothing else.

No RATE votes.
No performance levels.
Literally, that's it.

You have direct access to the hardware, and you can also access the same HW that is arbitered by HWV, effectively overriding whatever HWV is voting for, and you're free to race with HWV if you want, even (why would you want that I don't know, but anyway..!).

Am I still missing anything, or have you got any other doubt, question, consideration, (etc)?

Cheers,
Angelo

#16 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Quoted 75 lines · AngeloGioacchino Del Regno

Il 25/06/25 13:05, Krzysztof Kozlowski ha scritto:

Quoted 63 lines · AngeloGioacchino Del Regno
Quoted 62 lines

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Review

Quoted 13 lines
(quoted diff) +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

So the hardware voter itself (and/or bits inside of its registers) cannot be represented as a clock :\

Quoted 7 lines
Quoted 3 lines

In the context of clocks, it's used for clocks, (and not touching power domains at all), but in the context of power domains it's used for power domains (and not touching clocks at all).

I don't understand this. Earlier you mentioned "MUX-GATE and GATE clocks", so these are clocks, right? How these clocks are used in other places as power domains?

I think you've misread, or I've explained badly enough to make you misread... let me describe some more to try to let you understand this properly.

Quoted 8 lines

The hardware voter is a unit that is used to vote for "flipping various switches", in particular, you can vote for, *either*:
- Enabling or disabling a *clock*; or
- Enabling or disabling a *power domain*.

There may be multiple (by hardware, in-silicon) copies of the Hardware Voter; in the specific case of the MediaTek Dimensity 9400 MT6991 and of the MediaTek MT8196 Chromebook SoC, there is only one instance.

Everything so far very similar to qcom... They do exactly like that.

Quoted 9 lines

The Hardware Voter, there, is located in the SCPSYS macro-block.

The SCPSYS macro-block contains:
- A system controller
- A Hardware Voter IP (new in MT6991/MT8196)
- A power domains controller
- Other hardware that is not relevant for this discussion

Quoted 4 lines

The HWV is MMIO-accessible, and there is one (small, for now) set of registers, allowing to vote for turning on/off one (or maybe multiple too, not sure about that as there's no documentation and when I tried with multi-votes it didn't work) clk/pd at a time.

Sure, the only difference against qcom is interface - qcom uses remoteprocs channels, here you have MMIO. The interface does not matter though.

Quoted 4 lines

Probably not important but worth mentioning: the HWV can vote for clocks or for power domains in macro-blocks outside of its own (so, outside of the SCPSYS block, for example - it can vote to turn on a clock or a power domain in HFRPSYS as well).

Same for qcom.

Quoted 11 lines

The register set in the HWV is *not* split between clock voters and PDs voters, in the sense that the register set of clock voters is *not contiguous*; trying to be as clear as possible, you have something like (mock register names ahead):
0x0 - CLOCK_VOTER_0 (each bit is a clock)
0x4 - PD_VOTER_0 (each bit is a power domain)
0x8 - SECURE_WORLD_CLOCK_VOTER_1
0xc - PD_VOTER_1
0x10 - SECURE_WORLD_PD_VOTER_0

...etc etc.

OK

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

If they are, this either has to be fixed or

apparently this is a power domain and use it as power domain also here.

So no, clocks are not used as power domains, and power domains are not used as clocks; we are talking purely about something that aggregates votes internally

OK

Quoted 3 lines

and decides to turn on/off "whatever thing it is" (one of the clocks, or one of the power domains) - and to do that, you flip a bit in a register, and then you read another two registers to know the status of the internal state machine....

Sure. This is 100% not syscon, though. You must not do it via syscon, because you will be flopping bits of other devices in this driver. What's more, the actual implementation - registers for voting - is irrelevant to this device here. This device here wants:
power domain
or
clock

Hm... don't we have bindings for this? Wait, we have!

Quoted 4 lines

....and you do that atomically, this can't sleep, the system has to lock up until HWV is done (I think I know what you're thinking, and yes, it's really like this) otherwise you're surely racing.

Sure, no problems here.

Quoted 7 lines
Quoted 5 lines

Really, something called as hardware voter is not that uncommon and it does fit existing bindings.

Do you mean the interconnect/qcom/bcm-voter.c?

This and many others - all rpm/rpmh/rsc are for that.

Quoted 3 lines

That one seems to aggregate votes in software to place a vote in a hardware voter (the Bus Clock Manager) and I see it as being really convoluted.

I do not say that drivers are example to follow. Actually, I do not recommend even DT bindings!

Quoted 7 lines

For MediaTek's HWV, you don't need to aggregate anything - actually, the HWV itself is taking care of aggregating requests internally...

Also, checking sdx75 and x1e80100 DTs, I see a virtual clock controller described, placing votes through the bcm-voter, and with clocks that looks like being kind of disguised/faked as interconnects?

Don't remember exactly, but I don't think it matters. What matters is you need to choose appropriate representation for your votes.

Quoted 20 lines

That's a bit unclear, and even if I'm wrong about those being disguised as icc, and not virtual, purely looking at the usage of the clk_virt and bcm-voters, I seriously don't think that any similar structure with interconnect would fit MediaTek SoCs in any way...

Quoted 11 lines
Quoted 4 lines

I'm not sure what qcom does - your reply makes me think that they did it such that the clocks part is in a MMIO and the power domains part is in a different MMIO, without having clock/pd intertwined voting registers...

No, you just never have direct access to hardware. You place votes and votes go to the firmware. Now depending on person submitting it or writing internal docs, they call it differently, but eventually it is the same. You want to vote for some specific signal to be active or running at some performance level.

Quoted 2 lines

Okay then there is one similarity, but it's different; MTK HWV is only arbitering a on/off request; Nothing else.

Does not matter, still the same concept.

In 2026 or 2027 you will do other votes as well...

Quoted 4 lines

No RATE votes.
No performance levels.
Literally, that's it.

Best regards,
Krzysztof

#17 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Il 27/06/25 10:37, Krzysztof Kozlowski ha scritto:

Quoted 203 lines · AngeloGioacchino Del Regno
Quoted 75 lines

Il 25/06/25 13:05, Krzysztof Kozlowski ha scritto:

Quoted 63 lines · AngeloGioacchino Del Regno
Quoted 62 lines

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Review

Quoted 13 lines
(quoted diff) +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

So the hardware voter itself (and/or bits inside of its registers) cannot be represented as a clock :\

Quoted 7 lines
Quoted 3 lines

In the context of clocks, it's used for clocks, (and not touching power domains at all), but in the context of power domains it's used for power domains (and not touching clocks at all).

I don't understand this. Earlier you mentioned "MUX-GATE and GATE clocks", so these are clocks, right? How these clocks are used in other places as power domains?

I think you've misread, or I've explained badly enough to make you misread... let me describe some more to try to let you understand this properly.

Quoted 8 lines

The hardware voter is a unit that is used to vote for "flipping various switches", in particular, you can vote for, *either*:
- Enabling or disabling a *clock*; or
- Enabling or disabling a *power domain*.

There may be multiple (by hardware, in-silicon) copies of the Hardware Voter; in the specific case of the MediaTek Dimensity 9400 MT6991 and of the MediaTek MT8196 Chromebook SoC, there is only one instance.

Everything so far very similar to qcom... They do exactly like that.

Quoted 9 lines

The Hardware Voter, there, is located in the SCPSYS macro-block.

The SCPSYS macro-block contains:
- A system controller
- A Hardware Voter IP (new in MT6991/MT8196)
- A power domains controller
- Other hardware that is not relevant for this discussion

Quoted 4 lines

The HWV is MMIO-accessible, and there is one (small, for now) set of registers, allowing to vote for turning on/off one (or maybe multiple too, not sure about that as there's no documentation and when I tried with multi-votes it didn't work) clk/pd at a time.

Sure, the only difference against qcom is interface - qcom uses remoteprocs channels, here you have MMIO. The interface does not matter though.

Quoted 4 lines

Probably not important but worth mentioning: the HWV can vote for clocks or for power domains in macro-blocks outside of its own (so, outside of the SCPSYS block, for example - it can vote to turn on a clock or a power domain in HFRPSYS as well).

Same for qcom.

Quoted 11 lines

The register set in the HWV is *not* split between clock voters and PDs voters, in the sense that the register set of clock voters is *not contiguous*; trying to be as clear as possible, you have something like (mock register names ahead):
0x0 - CLOCK_VOTER_0 (each bit is a clock)
0x4 - PD_VOTER_0 (each bit is a power domain)
0x8 - SECURE_WORLD_CLOCK_VOTER_1
0xc - PD_VOTER_1
0x10 - SECURE_WORLD_PD_VOTER_0

...etc etc.

OK

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

If they are, this either has to be fixed or

apparently this is a power domain and use it as power domain also here.

So no, clocks are not used as power domains, and power domains are not used as clocks; we are talking purely about something that aggregates votes internally

OK

Quoted 3 lines

and decides to turn on/off "whatever thing it is" (one of the clocks, or one of the power domains) - and to do that, you flip a bit in a register, and then you read another two registers to know the status of the internal state machine....

Sure. This is 100% not syscon, though. You must not do it via syscon, because you will be flopping bits of other devices in this driver. What's more, the actual implementation - registers for voting - is irrelevant to this device here. This device here wants:
power domain
or
clock

Hm... don't we have bindings for this? Wait, we have!

Quoted 4 lines

....and you do that atomically, this can't sleep, the system has to lock up until HWV is done (I think I know what you're thinking, and yes, it's really like this) otherwise you're surely racing.

Sure, no problems here.

Quoted 7 lines
Quoted 5 lines

Really, something called as hardware voter is not that uncommon and it does fit existing bindings.

Do you mean the interconnect/qcom/bcm-voter.c?

This and many others - all rpm/rpmh/rsc are for that.

Quoted 3 lines

That one seems to aggregate votes in software to place a vote in a hardware voter (the Bus Clock Manager) and I see it as being really convoluted.

I do not say that drivers are example to follow. Actually, I do not recommend even DT bindings!

Quoted 7 lines

For MediaTek's HWV, you don't need to aggregate anything - actually, the HWV itself is taking care of aggregating requests internally...

Also, checking sdx75 and x1e80100 DTs, I see a virtual clock controller described, placing votes through the bcm-voter, and with clocks that looks like being kind of disguised/faked as interconnects?

Don't remember exactly, but I don't think it matters. What matters is you need to choose appropriate representation for your votes.

Quoted 20 lines

That's a bit unclear, and even if I'm wrong about those being disguised as icc, and not virtual, purely looking at the usage of the clk_virt and bcm-voters, I seriously don't think that any similar structure with interconnect would fit MediaTek SoCs in any way...

Quoted 11 lines
Quoted 4 lines

I'm not sure what qcom does - your reply makes me think that they did it such that the clocks part is in a MMIO and the power domains part is in a different MMIO, without having clock/pd intertwined voting registers...

No, you just never have direct access to hardware. You place votes and votes go to the firmware. Now depending on person submitting it or writing internal docs, they call it differently, but eventually it is the same. You want to vote for some specific signal to be active or running at some performance level.

Quoted 7 lines
Quoted 2 lines

Okay then there is one similarity, but it's different; MTK HWV is only arbitering a on/off request; Nothing else.

Does not matter, still the same concept.

In 2026 or 2027 you will do other votes as well...

Yeah, okay I think I got your point.

Now that I can understand the sense I think I can come up with some nicer solution.

Thanks for all :-)
Angelo

Quoted 8 lines
Quoted 4 lines

No RATE votes.
No performance levels.
Literally, that's it.

Best regards,
Krzysztof

#18 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

In reply to AngeloGioacchino Del Regno
Quoted 55 lines · AngeloGioacchino Del Regno

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

Quoted 3 lines

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

BTW:

git grep mediatek,hardware-voter
0 results

so I do not accept explanation that you use it in different drivers. Now is the first time this is being upstream, so now is the time when this is shaped.

Best regards,
Krzysztof

#19 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Il 25/06/25 13:06, Krzysztof Kozlowski ha scritto:

Quoted 60 lines · AngeloGioacchino Del Regno
Quoted 55 lines

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml line 64

Quoted 13 lines
Documentation/devicetree/bindings/clock/mediatek,mt8196-clock.yaml new file +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

Quoted 3 lines

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

Quoted 8 lines

BTW:

git grep mediatek,hardware-voter
0 results

so I do not accept explanation that you use it in different drivers. Now is the first time this is being upstream, so now is the time when this is shaped.

I was simply trying to explain how I'm using it in the current design and nothing else; and I am happy to understand what other solution could there be for this and if there's anything cleaner.

You see what I do, and I'm *sure* that you definitely know that my goal is *not* to just tick yet another box, but to make things right, - and with the best possible shape and, especially, community agreement.

Cheers,
Angelo

#20 lore raw

Re: [PATCH v2 09/29] dt-bindings: clock: mediatek: Describe MT8196 peripheral clock controllers

Quoted 70 lines · AngeloGioacchino Del Regno

Il 25/06/25 13:06, Krzysztof Kozlowski ha scritto:

Quoted 60 lines · AngeloGioacchino Del Regno
Quoted 55 lines

Il 25/06/25 10:57, Krzysztof Kozlowski ha scritto:

Quoted 48 lines · AngeloGioacchino Del Regno
Quoted 19 lines

Il 24/06/25 18:02, Krzysztof Kozlowski ha scritto:

Quoted 15 lines · Laura Nao

Review

Quoted 13 lines
(quoted diff) +13 -0
+  '#reset-cells':
+    const: 1
+    description:
+      Reset lines for PEXTP0/1 and UFS blocks.
+
+  mediatek,hardware-voter:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      On the MT8196 SoC, a Hardware Voter (HWV) backed by a fixed-function
+      MCU manages clock and power domain control across the AP and other
+      remote processors. By aggregating their votes, it ensures clocks are
+      safely enabled/disabled and power domains are active before register
+      access.
Quoted 2 lines

Resource voting is not via any phandle, but either interconnects or required opps for power domain.

Quoted 6 lines

Sorry, I'm not sure who is actually misunderstanding what, here... let me try to explain the situation:

This is effectively used as a syscon - as in, the clock controllers need to perform MMIO R/W on both the clock controller itself *and* has to place a vote to the clock controller specific HWV register.

syscon is not the interface to place a vote for clocks. "clocks" property is.

Quoted 9 lines

This is done for MUX-GATE and GATE clocks, other than for power domains.

Note that the HWV system is inside of the power domains controller, and it's split on a per hardware macro-block basis (as per usual MediaTek hardware layout...).

The HWV, therefore, does *not* vote for clock *rates* (so, modeling OPPs would be a software quirk, I think?), does *not* manage bandwidth (and interconnect is for voting BW only?), and is just a "switch to flip".

That's still clocks. Gate is a clock.

Quoted 5 lines

Is this happening because the description has to be improved and creating some misunderstanding, or is it because we are underestimating and/or ignoring something here?

Quoted 5 lines

Other vendors, at least qcom, represent it properly - clocks. Sometimes they mix up and represent it as power domains, but that's because downstream is a mess and because we actually (at upstream) don't really know what is inside there - is it a clock or power domain.

Quoted 3 lines

....but the hardware voter cannot be represented as a clock, because you use it for clocks *or* power domains (but at the same time, and of course in different drivers, and in different *intertwined* registers).

Quoted 8 lines

BTW:

git grep mediatek,hardware-voter
0 results

so I do not accept explanation that you use it in different drivers. Now is the first time this is being upstream, so now is the time when this is shaped.

Quoted 7 lines

I was simply trying to explain how I'm using it in the current design and nothing else; and I am happy to understand what other solution could there be for this and if there's anything cleaner.

You see what I do, and I'm *sure* that you definitely know that my goal is *not* to just tick yet another box, but to make things right, - and with the best possible shape and, especially, community agreement.

Ack, I understand. Your case here is really not different from all others. Interface is different, hardware is different, but the concept - you place votes via some intermediary - is completely the same which qcom is doing since years and maybe other vendors as well.

And I expect more and more of this in case of Mediatek, so in the future you will be plcing votes not only for on/off but also for values. Everyone goes there, mobile, automotive... maybe IoT lags behind because performance there is not that important, but all others need top performance with top energy saving which they cannot do in Linux and they move it to firmware (SCMI, hw voter, dedicated blocks, whatever).

You need to start designing this proper with that future in mind and syscon is a strong no-go. Whether this is clocks, power domains or interconnects - dunno yet, maybe both.

Best regards,
Krzysztof

author
#21 lore raw

PATCH v2 10/29 dt-bindings: reset: Add MediaTek MT8196 Reset Controller binding

In reply to Laura Nao

From: AngeloGioacchino Del Regno <[email protected]>

Add a binding for the PEXTP0/1 and UFS reset controllers found in the MediaTek MT8196 Chromebook SoC.

---
 .../reset/mediatek,mt8196-resets.h            | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8196-resets.h
include/dt-bindings/reset/mediatek,mt8196-resets.h new file +26 -0
new file mode 100644
index 000000000000..46ced0850d91
@@ -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
#22 lore raw

Re: [PATCH v2 10/29] dt-bindings: reset: Add MediaTek MT8196 Reset Controller binding

Quoted 11 lines · Laura Nao

From: AngeloGioacchino Del Regno <[email protected]>

Add a binding for the PEXTP0/1 and UFS reset controllers found in the MediaTek MT8196 Chromebook SoC.

---
 .../reset/mediatek,mt8196-resets.h            | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8196-resets.h

No improvements.

<form letter>
This is a friendly reminder during the review process.

It seems my or other reviewer's previous comments were not fully addressed. Maybe the feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.

Thank you.
</form letter>

Best regards,
Krzysztof

#23 lore raw

Re: [PATCH v2 10/29] dt-bindings: reset: Add MediaTek MT8196 Reset Controller binding

Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Laura Nao

From: AngeloGioacchino Del Regno <[email protected]>

Add a binding for the PEXTP0/1 and UFS reset controllers found in the MediaTek MT8196 Chromebook SoC.

Quoted 8 lines
Quoted 6 lines
---
 .../reset/mediatek,mt8196-resets.h            | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8196-resets.h

No improvements.

I see the license got fixed, so half improvements. My other comment stays.

Respond to the comments instead.

Best regards,
Krzysztof

author
#24 lore raw

Re: [PATCH v2 10/29] dt-bindings: reset: Add MediaTek MT8196 Reset Controller binding

In reply to Krzysztof Kozlowski

Hi Krzysztof,

Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Laura Nao

From: AngeloGioacchino Del Regno <[email protected]>

Add a binding for the PEXTP0/1 and UFS reset controllers found in the MediaTek MT8196 Chromebook SoC.

Quoted 9 lines
Quoted 6 lines
---
 .../reset/mediatek,mt8196-resets.h            | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8196-resets.h

No improvements.

Apologies - I misinterpreted your comment. I assumed you were referring to adding the commit message details to the binding doc (which is why I added a description for reset-cells), but I realize now you likely meant the header file should be included in the same commit which adds the clock binding documentation. Is that correct?

I’ll fix that in the next revision.

Thanks,

Laura

author
#25 lore raw

PATCH v2 11/29 clk: mediatek: Add MT8196 apmixedsys clock support

In reply to Laura Nao

Add 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
index ff8a87112969..c55a7c8bdcc5 100644
@@ -1060,6 +1060,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
index 73004e318702..b1773d2bcb3d 100644
@@ -160,6 +160,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
author
#26 lore raw

PATCH v2 12/29 clk: mediatek: Add MT8196 topckgen clock support

In reply to Laura Nao

Add 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 | 1257 ++++++++++++++++++++
 2 files changed, 1258 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen.c
drivers/clk/mediatek/Makefile +1 -1
index b1773d2bcb3d..bc0e86e20074 100644
@@ -160,7 +160,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 +1257 -0

1,257 lines not on this page · raw message

Signature · 1 line
2.39.5
#27 lore raw

Re: [PATCH v2 12/29] clk: mediatek: Add MT8196 topckgen clock support

Hi,

There's a lot of duplication in the driver.

Quoted 31 lines · Laura Nao

Add 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 | 1257 ++++++++++++++++++++
 2 files changed, 1258 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen.c
drivers/clk/mediatek/Makefile +1 -1
index b1773d2bcb3d..bc0e86e20074 100644
@@ -160,7 +160,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 +0 -0
new file mode 100644
index 000000000000..fc0c1227dd8d
@@ -0,0 +1,1257 @@

[...]

drivers/clk/mediatek/clk-mt8196-topckgen.c line 293

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+static const char * const p_axi_parents[] = {
+       "clk26m",
+       "mainpll_d7_d8",
+       "mainpll_d5_d8",
+       "osc_d8",
+       "mainpll_d7_d4",
+       "mainpll_d5_d4",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2"
+};

The next two lists are the same as the one above. Please merge them together.

Quoted 39 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +39 -0
+static const char * const ufs_pextp0_axi_parents[] = {
+       "clk26m",
+       "mainpll_d7_d8",
+       "mainpll_d5_d8",
+       "osc_d8",
+       "mainpll_d7_d4",
+       "mainpll_d5_d4",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2"
+};
+
+static const char * const pextp1_usb_axi_parents[] = {
+       "clk26m",
+       "mainpll_d7_d8",
+       "mainpll_d5_d8",
+       "osc_d8",
+       "mainpll_d7_d4",
+       "mainpll_d5_d4",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2"
+};
+
+static const char * const p_fmem_sub_parents[] = {
+       "clk26m",
+       "mainpll_d5_d8",
+       "mainpll_d5_d4",
+       "osc_d4",
+       "univpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4"
+};
+
+static const char * const ufs_pexpt0_mem_sub_parents[] = {
+       "clk26m",
+       "mainpll_d5_d8",

drivers/clk/mediatek/clk-mt8196-topckgen.c line 343

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+       "mainpll_d5_d4",
+       "osc_d4",
+       "univpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4"
+};

The next one is the same as the previous one. Please merge together.

Quoted 27 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +27 -0
+static const char * const pextp1_usb_mem_sub_parents[] = {
+       "clk26m",
+       "mainpll_d5_d8",
+       "mainpll_d5_d4",
+       "osc_d4",
+       "univpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4"
+};
+
+static const char * const p_noc_parents[] = {
+       "clk26m",
+       "mainpll_d5_d8",
+       "mainpll_d5_d4",
+       "osc_d4",
+       "univpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4",
+       "mainpll_d3"

drivers/clk/mediatek/clk-mt8196-topckgen.c line 381

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+};
+
+static const char * const emi_n_parents[] = {
+       "clk26m",
+       "osc_d4",
+       "mainpll_d5_d8",
+       "mainpll_d5_d4",
+       "mainpll_d4_d4",
+       "emipll1_ck"
+};

The next one is the same as the previous one.

Quoted 8 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +8 -0
+static const char * const emi_s_parents[] = {
+       "clk26m",
+       "osc_d4",
+       "mainpll_d5_d8",
+       "mainpll_d5_d4",
+       "mainpll_d4_d4",
+       "emipll1_ck"
+};

[...]

drivers/clk/mediatek/clk-mt8196-topckgen.c line 478

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+static const char * const spi0_b_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d5_d4",
+       "mainpll_d4_d4",
+       "univpll_d4_d4",
+       "mainpll_d6_d2",
+       "univpll_192m",
+       "univpll_d6_d2"
+};

All the SPI clocks have the same set of parents. Please just have one list.

[...]

drivers/clk/mediatek/clk-mt8196-topckgen.c line 563

Quoted 7 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +7 -0
+static const char * const msdc30_1_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "mainpll_d6_d2",
+       "univpll_d6_d2",
+       "msdcpll_d2"
+};

Please merge the two msdc30 parent lists.

Quoted 12 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +12 -0
+static const char * const msdc30_2_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "mainpll_d6_d2",
+       "univpll_d6_d2",
+       "msdcpll_d2"
+};
+
+static const char * const disp_pwm_parents[] = {
+       "clk26m",
+       "osc_d32",
+       "osc_d8",

drivers/clk/mediatek/clk-mt8196-topckgen.c line 586

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+       "univpll_d6_d4",
+       "univpll_d5_d4",
+       "osc_d4",
+       "mainpll_d4_d4"
+};
+
+static const char * const usb_1p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4"
+};

The next one is the same as the previous one. Please merge together.

Quoted 7 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +7 -0
+static const char * const usb_xhci_1p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4"
+};
+
+static const char * const usb_fmcnt_p1_parents[] = {
+       "clk26m",

drivers/clk/mediatek/clk-mt8196-topckgen.c line 604

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+       "univpll_192m_d4"
+};
+
+static const char * const i2c_p_parents[] = {
+       "clk26m",
+       "mainpll_d4_d8",
+       "univpll_d5_d4",
+       "mainpll_d4_d4",
+       "univpll_d5_d2"
+};

All the I2C clocks have the same set of parents. Please just have one list.

[...]

drivers/clk/mediatek/clk-mt8196-topckgen.c line 709

Quoted 6 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +6 -0
+static const char * const tl_parents[] = {
+       "clk26m",
+       "mainpll_d7_d4",
+       "mainpll_d4_d4",
+       "mainpll_d5_d2"
+};

The lists for the tl clocks are the same. Please merge.

[...]

drivers/clk/mediatek/clk-mt8196-topckgen.c line 762

Quoted 8 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +8 -0
+static const char * const ssr_pka_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d6",
+       "mainpll_d5"
+};

This one and the next could be merged.

Quoted 21 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +21 -0
+static const char * const ssr_dma_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d6",
+       "mainpll_d5"
+};
+
+static const char * const ssr_kdf_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d4_d2",
+       "mainpll_d7"
+};
+
+static const char * const ssr_rng_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2"

drivers/clk/mediatek/clk-mt8196-topckgen.c line 794

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+};
+
+static const char * const spu0_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d6",
+       "mainpll_d5"
+};

This one and the next could be merged.

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+static const char * const spu1_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d6",
+       "mainpll_d5"
+};
+
+static const char * const dxcc_parents[] = {

drivers/clk/mediatek/clk-mt8196-topckgen.c line 815

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +10 -0
+       "clk26m",
+       "mainpll_d4_d8",
+       "mainpll_d4_d4",
+       "mainpll_d4_d2"
+};
+
+static const char * const apll_i2sin0_m_parents[] = {
+       "aud_1",
+       "aud_2"
+};

All the audio interface clocks have the same set of parents. Please have just one list.

[...]

Thanks
ChenYu

#28 lore raw

Re: [PATCH v2 12/29] clk: mediatek: Add MT8196 topckgen clock support

In reply to Laura Nao

Another thing,

Quoted 30 lines · Laura Nao

Add 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 | 1257 ++++++++++++++++++++
 2 files changed, 1258 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen.c
drivers/clk/mediatek/Makefile +1 -1
index b1773d2bcb3d..bc0e86e20074 100644
@@ -160,7 +160,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 +0 -0
new file mode 100644
index 000000000000..fc0c1227dd8d

[...]

drivers/clk/mediatek/clk-mt8196-topckgen.c line 235

Quoted 4 lines
drivers/clk/mediatek/clk-mt8196-topckgen.c new file +4 -0
+       FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "vlp_apll1", 1, 4),
+       FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "vlp_apll1", 1, 8),
+       FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "vlp_apll2", 1, 4),
+       FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "vlp_apll2", 1, 8),

These aren't used anywhere in this driver, but they are referenced directly in the vlpckgen driver. Maybe these should be moved over to that driver instead? Otherwise we end up with some weird circular link between the two clock controllers which doesn't seem correct to me.

[...]

author
#29 lore raw

PATCH v2 13/29 clk: mediatek: Add MT8196 topckgen2 clock support

In reply to Laura Nao

Add 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 | 662 ++++++++++++++++++++
 2 files changed, 664 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-topckgen2.c
drivers/clk/mediatek/Makefile +2 -1
index bc0e86e20074..0688d7bf4979 100644
@@ -160,7 +160,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 +662 -0

662 lines not on this page · raw message

Signature · 1 line
2.39.5
author
#30 lore raw

PATCH v2 14/29 clk: mediatek: Add MT8196 vlpckgen clock support

In reply to Laura Nao

Add 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 | 769 +++++++++++++++++++++
 2 files changed, 770 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.c
drivers/clk/mediatek/Makefile +1 -1
index 0688d7bf4979..24683dd51783 100644
@@ -161,7 +161,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 +769 -0

769 lines not on this page · raw message

Signature · 1 line
2.39.5
#31 lore raw

Re: [PATCH v2 14/29] clk: mediatek: Add MT8196 vlpckgen clock support

Hi,

Quoted 31 lines · Laura Nao

Add 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 | 769 +++++++++++++++++++++
 2 files changed, 770 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.c
drivers/clk/mediatek/Makefile +1 -1
index 0688d7bf4979..24683dd51783 100644
@@ -161,7 +161,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 +0 -0
new file mode 100644
index 000000000000..23a673dd4c5c
@@ -0,0 +1,769 @@

[...]

Quoted 5 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +5 -0
+static const char * const vlp_camtg0_parents[] = {
+       "clk26m",
+       "univpll_192m_d32",
+       "univpll_192m_d16",
+       "clk13m",

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 288

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       "osc_d40",
+       "osc_d32",
+       "univpll_192m_d10",
+       "univpll_192m_d8",
+       "univpll_d6_d16",
+       "ulposc3",
+       "osc_d20",
+       "ck2_tvdpll1_d16",
+       "univpll_d6_d8"
+};

It seems all the vlp_camtg* parents are the same. Please merge them and just have one list.

Quoted 38 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +38 -0
+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"
+};
+

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 443

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+static const char * const vlp_mminfra_parents[] = {
+       "clk26m",
+       "osc_d4",
+       "mainpll_d3"
+};
+
+static const char * const vlp_usb_parents[] = {
+       "clk26m",
+       "mainpll_d9"
+};

The previous and the next one are the same.

Quoted 12 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +12 -0
+static const char * const vlp_usb_xhci_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[] = {

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 466

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       "clk26m",
+       "vlp_apll1",
+       "vlp_apll2"
+};
+
+static const char * const vlp_aud_engen1_parents[] = {
+       "clk26m",
+       "apll1_d8",
+       "apll1_d4"
+};

The previous and the next one are the same.

Quoted 13 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +13 -0
+static const char * const vlp_aud_engen2_parents[] = {
+       "clk26m",
+       "apll2_d8",
+       "apll2_d4"
+};
+
+static const char * const vlp_aud_intbus_parents[] = {
+       "clk26m",
+       "mainpll_d7_d4",
+       "mainpll_d4_d4"
+};
+
+static const char * const vlp_spvlp_26m

[...]

Quoted 25 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +25 -0
+static int clk_mt8196_vlp_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+       struct device_node *node = pdev->dev.of_node;
+
+       clk_data = mtk_alloc_clk_data(ARRAY_SIZE(vlp_muxes) +
+                                     ARRAY_SIZE(vlp_plls));
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_muxes(&pdev->dev, vlp_muxes, ARRAY_SIZE(vlp_muxes),
+                                  node, &mt8196_clk_vlp_lock, clk_data);
+       if (r)
+               goto free_clk_data;
+
+       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;
+

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 736

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       platform_set_drvdata(pdev, clk_data);
+
+       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);
+free_clk_data:
+       mtk_free_clk_data(clk_data);

The AFE driver sets some tuner parameters in the VLPCKGEN block at probe time. Maybe we could do that here instead?

/* vlp_cksys_clk: 0x1c016000 */
#define VLP_APLL1_TUNER_CON0 0x02a4
#define VLP_APLL2_TUNER_CON0 0x02a8

/* 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

       regmap_write(afe_priv->vlp_ck, VLP_APLL1_TUNER_CON0,
VLP_APLL1_TUNER_CON0_VALUE);
       regmap_write(afe_priv->vlp_ck, VLP_APLL2_TUNER_CON0,

VLP_APLL2_TUNER_CON0_VALUE);

ChenYu

Quoted 36 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +33 -1
+
+       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_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");
--

2.39.5

#32 lore raw

Re: [PATCH v2 14/29] clk: mediatek: Add MT8196 vlpckgen clock support

Quoted 134 lines · Chen-Yu Tsai

Hi,

Quoted 31 lines · Laura Nao

Add 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 | 769 +++++++++++++++++++++
 2 files changed, 770 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.c
drivers/clk/mediatek/Makefile +1 -1
index 0688d7bf4979..24683dd51783 100644
@@ -161,7 +161,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 +0 -0
new file mode 100644
index 000000000000..23a673dd4c5c
@@ -0,0 +1,769 @@

[...]

Quoted 5 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +5 -0
+static const char * const vlp_camtg0_parents[] = {
+       "clk26m",
+       "univpll_192m_d32",
+       "univpll_192m_d16",
+       "clk13m",

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 288

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       "osc_d40",
+       "osc_d32",
+       "univpll_192m_d10",
+       "univpll_192m_d8",
+       "univpll_d6_d16",
+       "ulposc3",
+       "osc_d20",
+       "ck2_tvdpll1_d16",
+       "univpll_d6_d8"
+};

It seems all the vlp_camtg* parents are the same. Please merge them and just have one list.

Quoted 38 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +38 -0
+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"
+};
+

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 443

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+static const char * const vlp_mminfra_parents[] = {
+       "clk26m",
+       "osc_d4",
+       "mainpll_d3"
+};
+
+static const char * const vlp_usb_parents[] = {
+       "clk26m",
+       "mainpll_d9"
+};

The previous and the next one are the same.

Quoted 12 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +12 -0
+static const char * const vlp_usb_xhci_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[] = {

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 466

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       "clk26m",
+       "vlp_apll1",
+       "vlp_apll2"
+};
+
+static const char * const vlp_aud_engen1_parents[] = {
+       "clk26m",
+       "apll1_d8",
+       "apll1_d4"
+};

The previous and the next one are the same.

Quoted 11 lines

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 478

Quoted 11 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +11 -0
+static const char * const vlp_aud_engen2_parents[] = {
+       "clk26m",
+       "apll2_d8",
+       "apll2_d4"
+};
+
+static const char * const vlp_aud_intbus_parents[] = {
+       "clk26m",
+       "mainpll_d7_d4",
+       "mainpll_d4_d4"
+};

Also, all these audio related clocks (audio_h, aud_engen1, aud_engen2 aud_intbus) have a "vlp_clk26m" clock as their parent. It should be:

- clk26m (clk26m from the top ckgen domain)
- vlp_clk26m (clk26m from the VLP domain)
- (from PLLs)
- (from PLLs)

Moreover, an offline discussion with the audio owner suggests that of the two 26 MHz clock parents, we really just want the one from the VLP domain, as that one is usable even under suspend. This could be done by providing an index table.

ChenYu

Quoted 96 lines
Quoted 2 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +2 -0
+
+static const char * const vlp_spvlp_26m

[...]

Quoted 25 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +25 -0
+static int clk_mt8196_vlp_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+       struct device_node *node = pdev->dev.of_node;
+
+       clk_data = mtk_alloc_clk_data(ARRAY_SIZE(vlp_muxes) +
+                                     ARRAY_SIZE(vlp_plls));
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_muxes(&pdev->dev, vlp_muxes, ARRAY_SIZE(vlp_muxes),
+                                  node, &mt8196_clk_vlp_lock, clk_data);
+       if (r)
+               goto free_clk_data;
+
+       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;
+

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 736

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       platform_set_drvdata(pdev, clk_data);
+
+       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);
+free_clk_data:
+       mtk_free_clk_data(clk_data);

The AFE driver sets some tuner parameters in the VLPCKGEN block at probe time. Maybe we could do that here instead?

/* vlp_cksys_clk: 0x1c016000 */
#define VLP_APLL1_TUNER_CON0 0x02a4
#define VLP_APLL2_TUNER_CON0 0x02a8

/* 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

       regmap_write(afe_priv->vlp_ck, VLP_APLL1_TUNER_CON0,
VLP_APLL1_TUNER_CON0_VALUE);
       regmap_write(afe_priv->vlp_ck, VLP_APLL2_TUNER_CON0,

VLP_APLL2_TUNER_CON0_VALUE);

ChenYu

Quoted 36 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +33 -1
+
+       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_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");
--

2.39.5

author
#33 lore raw

Re: [PATCH v2 14/29] clk: mediatek: Add MT8196 vlpckgen clock support

Quoted 155 lines · Chen-Yu Tsai
Quoted 134 lines · Chen-Yu Tsai

Hi,

Quoted 31 lines · Laura Nao

Add 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 | 769 +++++++++++++++++++++
 2 files changed, 770 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-vlpckgen.c
drivers/clk/mediatek/Makefile +1 -1
index 0688d7bf4979..24683dd51783 100644
@@ -161,7 +161,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 +0 -0
new file mode 100644
index 000000000000..23a673dd4c5c
@@ -0,0 +1,769 @@

[...]

Quoted 5 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +5 -0
+static const char * const vlp_camtg0_parents[] = {
+       "clk26m",
+       "univpll_192m_d32",
+       "univpll_192m_d16",
+       "clk13m",

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 288

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       "osc_d40",
+       "osc_d32",
+       "univpll_192m_d10",
+       "univpll_192m_d8",
+       "univpll_d6_d16",
+       "ulposc3",
+       "osc_d20",
+       "ck2_tvdpll1_d16",
+       "univpll_d6_d8"
+};

It seems all the vlp_camtg* parents are the same. Please merge them and just have one list.

Quoted 38 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +38 -0
+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"
+};
+

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 443

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+static const char * const vlp_mminfra_parents[] = {
+       "clk26m",
+       "osc_d4",
+       "mainpll_d3"
+};
+
+static const char * const vlp_usb_parents[] = {
+       "clk26m",
+       "mainpll_d9"
+};

The previous and the next one are the same.

Quoted 12 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +12 -0
+static const char * const vlp_usb_xhci_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[] = {

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 466

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       "clk26m",
+       "vlp_apll1",
+       "vlp_apll2"
+};
+
+static const char * const vlp_aud_engen1_parents[] = {
+       "clk26m",
+       "apll1_d8",
+       "apll1_d4"
+};

The previous and the next one are the same.

Quoted 11 lines

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 478

Quoted 11 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +11 -0
+static const char * const vlp_aud_engen2_parents[] = {
+       "clk26m",
+       "apll2_d8",
+       "apll2_d4"
+};
+
+static const char * const vlp_aud_intbus_parents[] = {
+       "clk26m",
+       "mainpll_d7_d4",
+       "mainpll_d4_d4"
+};

Also, all these audio related clocks (audio_h, aud_engen1, aud_engen2 aud_intbus) have a "vlp_clk26m" clock as their parent. It should be:

- clk26m (clk26m from the top ckgen domain)
- vlp_clk26m (clk26m from the VLP domain)
- (from PLLs)
- (from PLLs)

Quoted 5 lines

Moreover, an offline discussion with the audio owner suggests that of the two 26 MHz clock parents, we really just want the one from the VLP domain, as that one is usable even under suspend. This could be done by providing an index table.

Hi ChenYu,

Thanks for the feedback - I’ll make these changes along with the previous suggestions and submit a v3.

Best,

Laura

Quoted 98 lines

ChenYu

Quoted 96 lines
Quoted 2 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +2 -0
+
+static const char * const vlp_spvlp_26m

[...]

Quoted 25 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +25 -0
+static int clk_mt8196_vlp_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+       struct device_node *node = pdev->dev.of_node;
+
+       clk_data = mtk_alloc_clk_data(ARRAY_SIZE(vlp_muxes) +
+                                     ARRAY_SIZE(vlp_plls));
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_muxes(&pdev->dev, vlp_muxes, ARRAY_SIZE(vlp_muxes),
+                                  node, &mt8196_clk_vlp_lock, clk_data);
+       if (r)
+               goto free_clk_data;
+
+       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;
+

drivers/clk/mediatek/clk-mt8196-vlpckgen.c line 736

Quoted 10 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +10 -0
+       platform_set_drvdata(pdev, clk_data);
+
+       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);
+free_clk_data:
+       mtk_free_clk_data(clk_data);

The AFE driver sets some tuner parameters in the VLPCKGEN block at probe time. Maybe we could do that here instead?

/* vlp_cksys_clk: 0x1c016000 */
#define VLP_APLL1_TUNER_CON0 0x02a4
#define VLP_APLL2_TUNER_CON0 0x02a8

/* 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

       regmap_write(afe_priv->vlp_ck, VLP_APLL1_TUNER_CON0,
VLP_APLL1_TUNER_CON0_VALUE);
       regmap_write(afe_priv->vlp_ck, VLP_APLL2_TUNER_CON0,

VLP_APLL2_TUNER_CON0_VALUE);

ChenYu

Quoted 36 lines
drivers/clk/mediatek/clk-mt8196-vlpckgen.c new file +33 -1
+
+       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_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");
--

2.39.5

author
#34 lore raw

PATCH v2 15/29 clk: mediatek: Add MT8196 peripheral clock support

In reply to Laura Nao

Add 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
index 24683dd51783..fc941b5baf04 100644
@@ -161,7 +161,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
author
#35 lore raw

PATCH v2 16/29 clk: mediatek: Add MT8196 ufssys clock support

In reply to Laura Nao

Add 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
index c55a7c8bdcc5..848624792a23 100644
@@ -1068,6 +1068,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
index fc941b5baf04..ee6a1bb5ce38 100644
@@ -163,6 +163,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
author
#36 lore raw

PATCH v2 17/29 clk: mediatek: Add MT8196 pextpsys clock support

In reply to Laura Nao

Add 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
index 848624792a23..cd12e7ff3e12 100644
@@ -1068,6 +1068,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
index ee6a1bb5ce38..21e768f67283 100644
@@ -163,6 +163,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
author
#37 lore raw

PATCH v2 18/29 clk: mediatek: Add MT8196 adsp clock support

In reply to Laura Nao

Add support for the MT8196 adsp clock controller, which provides clock gate control for Audio DSP.

---
 drivers/clk/mediatek/Kconfig           |   7 +
 drivers/clk/mediatek/Makefile          |   1 +
 drivers/clk/mediatek/clk-mt8196-adsp.c | 193 +++++++++++++++++++++++++
 3 files changed, 201 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-adsp.c
drivers/clk/mediatek/Kconfig +7 -0
index cd12e7ff3e12..d4c97f64b42a 100644
@@ -1068,6 +1068,13 @@ config COMMON_CLK_MT8196
 	help
 	  This driver supports MediaTek MT8196 basic clocks.
 
+config COMMON_CLK_MT8196_ADSP
+	tristate "Clock driver for MediaTek MT8196 adsp"
+	depends on COMMON_CLK_MT8196
+	default m
+	help
+	  This driver supports MediaTek MT8196 adsp clocks
+
 config COMMON_CLK_MT8196_PEXTPSYS
 	tristate "Clock driver for MediaTek MT8196 pextpsys"
 	depends on COMMON_CLK_MT8196
drivers/clk/mediatek/Makefile +1 -0
index 21e768f67283..6a34ee2f7855 100644
@@ -163,6 +163,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_ADSP) += clk-mt8196-adsp.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-adsp.c new file +193 -0

193 lines not on this page · raw message

Signature · 1 line
2.39.5
#38 lore raw

Re: [PATCH v2 18/29] clk: mediatek: Add MT8196 adsp clock support

Hi,

Quoted 18 lines · Laura Nao

Add support for the MT8196 adsp clock controller, which provides clock gate control for Audio DSP.

---
 drivers/clk/mediatek/Kconfig           |   7 +
 drivers/clk/mediatek/Makefile          |   1 +
 drivers/clk/mediatek/clk-mt8196-adsp.c | 193 +++++++++++++++++++++++++
 3 files changed, 201 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-adsp.c
drivers/clk/mediatek/Kconfig +0 -0
index cd12e7ff3e12..d4c97f64b42a 100644

drivers/clk/mediatek/Kconfig config COMMON_CLK_MT8196 · line 1077

Quoted 10 lines
drivers/clk/mediatek/Kconfig +7 -0
@@ -1068,6 +1068,13 @@ config COMMON_CLK_MT8196
        help
          This driver supports MediaTek MT8196 basic clocks.
 
+config COMMON_CLK_MT8196_ADSP
+       tristate "Clock driver for MediaTek MT8196 adsp"
+       depends on COMMON_CLK_MT8196
+       default m
+       help
+         This driver supports MediaTek MT8196 adsp clocks
+

This is part of the AFE block, and really should not be a separate device node nor driver. The AFE driver should internalize all these controls and ideally model some of them as ASoC widgets so that DAPM can handle sequencing altogether.

So please drop this patch, and also drop the entry from the binding.

I've mentioned this to MediaTek's audio and clock owners, though I assume this request was somehow lost in the process.

ChenYu

author
#39 lore raw

PATCH v2 19/29 clk: mediatek: Add MT8196 I2C clock support

In reply to Laura Nao

Add 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
index d4c97f64b42a..6c556bec4531 100644
@@ -1075,6 +1075,13 @@ config COMMON_CLK_MT8196_ADSP
 	help
 	  This driver supports MediaTek MT8196 adsp 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
index 6a34ee2f7855..120cf20acdc1 100644
@@ -164,6 +164,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_ADSP) += clk-mt8196-adsp.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
author
#40 lore raw

PATCH v2 20/29 clk: mediatek: Add MT8196 mcu clock support

In reply to Laura Nao

Add 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
index 6c556bec4531..ed1073c5b432 100644
@@ -1082,6 +1082,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
index 120cf20acdc1..7b284ccc1b48 100644
@@ -165,6 +165,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o
 				   clk-mt8196-peri_ao.o
 obj-$(CONFIG_COMMON_CLK_MT8196_ADSP) += clk-mt8196-adsp.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
author
#41 lore raw

PATCH v2 21/29 clk: mediatek: Add MT8196 mdpsys clock support

In reply to Laura Nao

Add 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
index ed1073c5b432..c193295d4136 100644
@@ -1089,6 +1089,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
index 7b284ccc1b48..b9a54d65e27c 100644
@@ -166,6 +166,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o
 obj-$(CONFIG_COMMON_CLK_MT8196_ADSP) += clk-mt8196-adsp.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
author
#42 lore raw

PATCH v2 22/29 clk: mediatek: Add MT8196 mfg clock support

In reply to Laura Nao

Add 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 | 150 ++++++++++++++++++++++++++
 3 files changed, 158 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8196-mfg.c
drivers/clk/mediatek/Kconfig +7 -0
index c193295d4136..9735f37f1e09 100644
@@ -1096,6 +1096,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
index b9a54d65e27c..31436c8e2a80 100644
@@ -167,6 +167,7 @@ obj-$(CONFIG_COMMON_CLK_MT8196_ADSP) += clk-mt8196-adsp.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 +150 -0

150 lines not on this page · raw message

Signature · 1 line
2.39.5
#43 lore raw

Re: [PATCH v2 22/29] clk: mediatek: Add MT8196 mfg clock support

kernel test robot noticed the following build warnings:

Hi Laura,

kernel test robot noticed the following build warnings:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v6.16-rc3 next-20250627] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Laura-Nao/clk-mediatek-clk-pll-Add-set-clr-regs-for-shared-PLL-enable-control/20250624-225217
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
patch link:    https://lore.kernel.org/r/20250624143220.244549-23-laura.nao%40collabora.com
patch subject: [PATCH v2 22/29] clk: mediatek: Add MT8196 mfg clock support
config: arm64-randconfig-r053-20250629 (https://download.01.org/0day-ci/archive/20250630/[email protected]/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project e04c938cc08a90ae60440ce22d072ebc69d67ee8)
rustc: rustc 1.78.0 (9b00956e5 2024-04-29)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

cocci warnings: (new ones prefixed by >>)

>> drivers/clk/mediatek/clk-mt8196-mfg.c:143:3-8: No need to set .owner here. The core will do it.

vim +143 drivers/clk/mediatek/clk-mt8196-mfg.c

137
138 static struct platform_driver clk_mt8196_mfg_drv = {
139 .probe = clk_mt8196_mfg_probe,
140 .remove = clk_mt8196_mfg_remove,
141 .driver = {
142 .name = "clk-mt8196-mfg",

 > 143			.owner = THIS_MODULE,

144 .of_match_table = of_match_clk_mt8196_mfg,
145 },
146 };
147 module_platform_driver(clk_mt8196_mfg_drv);
148

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author
#44 lore raw

PATCH v2 23/29 clk: mediatek: Add MT8196 disp0 clock support

In reply to Laura Nao

Add 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
index 9735f37f1e09..6bcefb782b9c 100644
@@ -1103,6 +1103,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
index 31436c8e2a80..eacaec3d61ce 100644
@@ -168,6 +168,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
author
#45 lore raw

PATCH v2 24/29 clk: mediatek: Add MT8196 disp1 clock support

In reply to Laura Nao

Add 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
index eacaec3d61ce..18ada357e6ae 100644
@@ -168,7 +168,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
author
#46 lore raw

PATCH v2 25/29 clk: mediatek: Add MT8196 disp-ao clock support

In reply to Laura Nao

Add 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
index 18ada357e6ae..112607da29ab 100644
@@ -168,7 +168,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
author
#47 lore raw

PATCH v2 26/29 clk: mediatek: Add MT8196 ovl0 clock support

In reply to Laura Nao

Add 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
index 112607da29ab..14a3caac04e4 100644
@@ -168,7 +168,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
author
#48 lore raw

PATCH v2 27/29 clk: mediatek: Add MT8196 ovl1 clock support

In reply to Laura Nao

Add 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
index 14a3caac04e4..e3fa5cc2163a 100644
@@ -169,7 +169,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
author
#49 lore raw

PATCH v2 28/29 clk: mediatek: Add MT8196 vdecsys clock support

In reply to Laura Nao

Add 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
index 6bcefb782b9c..fc20942a547e 100644
@@ -1124,6 +1124,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
index e3fa5cc2163a..5d3b68649a53 100644
@@ -172,6 +172,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
author
#50 lore raw

PATCH v2 29/29 clk: mediatek: Add MT8196 vencsys clock support

In reply to Laura Nao

Add 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
index fc20942a547e..84b91e7bc8f6 100644
@@ -1131,6 +1131,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
index 5d3b68649a53..069cca024cd1 100644
@@ -173,6 +173,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
Reviewed-by on the v2 series
#51 lore raw
In reply to Laura Nao
Quoted 64 lines · Laura Nao

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 v2:
- Fixed incorrect ID numbering in mediatek,mt8196-clock.h
- Improved description for 'mediatek,hardware-voter' in mediatek,mt8196-clock.yaml and mediatek,mt8196-sys-clock.yaml
- Added description for '#reset-cells' in mediatek,mt8196-clock.yaml
- Added missing mediatek,mt8196-vdisp-ao compatible in mediatek,mt8196-clock.yaml
- Fixed license in mediatek,mt8196-resets.h
- Fixed missing of_match_table in clk-mt8196-vdisp_ao.c
- Squashed commit adding UFS and PEXTP reset controller support
- Reordered commits to place reset controller binding before dependent drivers
- Added R-b tags

Link to v1:
https://lore.kernel.org/all/[email protected]/

AngeloGioacchino Del Regno (1):
  dt-bindings: reset: Add MediaTek MT8196 Reset Controller binding

Laura Nao (28):
  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 peripheral 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 adsp clock support
  clk: mediatek: Add MT8196 I2C clock support
  clk: mediatek: Add MT8196 mcu clock support
  clk: mediatek: Add MT8196 mdpsys clock support

Quoted 8 lines

  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

For the whole series:

(as I internally reviewed it before submission)

Signature · 3 lines
Thanks,

Nícolas