[PATCH 2/3] clk: mediatek: clk-mtk: Add composite mux tables

Alexandre Mergnat amergnat at baylibre.com
Tue Nov 17 11:16:03 PST 2026


Composite muxes register a generic clk_mux, which writes parent index N
as register value N unless it is given a table. struct mtk_composite
cannot pass such a table, so a composite mux cannot describe a selector
whose parent values are not contiguous, such as the MT8196 PWM source
selectors.

Let struct mtk_composite carry a table for the generic clk_mux, and add
MUX_FLAGS_INDEXED() to declare a mux with a table.

Signed-off-by: Alexandre Mergnat <amergnat at baylibre.com>
---
 drivers/clk/mediatek/clk-mtk.c |  1 +
 drivers/clk/mediatek/clk-mtk.h | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 3dfdd3a422f8..b426f7a36e68 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -239,6 +239,7 @@ static struct clk_hw *mtk_clk_register_composite(struct device *dev,
 		mux->shift = mc->mux_shift;
 		mux->lock = lock;
 		mux->flags = mc->mux_flags;
+		mux->table = mc->mux_table;
 		mux_hw = &mux->hw;
 		mux_ops = &clk_mux_ops;
 
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 5417b9264e6d..c7822a8d015c 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -93,6 +93,7 @@ struct mtk_composite {
 	const char *name;
 	const char * const *parent_names;
 	const char *parent;
+	const u32 *mux_table;
 	unsigned flags;
 
 	uint32_t mux_reg;
@@ -161,6 +162,21 @@ struct mtk_composite {
 		.flags = _flags,				\
 	}
 
+#define MUX_FLAGS_INDEXED(_id, _name, _parents, _table, _reg, _shift,	\
+			  _width, _flags) {				\
+		.id = _id,						\
+		.name = _name,						\
+		.mux_reg = _reg,					\
+		.mux_shift = _shift,					\
+		.mux_width = _width,					\
+		.mux_table = _table,					\
+		.gate_shift = -1,					\
+		.divider_shift = -1,					\
+		.parent_names = _parents,				\
+		.num_parents = ARRAY_SIZE(_parents),			\
+		.flags = _flags,					\
+	}
+
 #define DIV_GATE(_id, _name, _parent, _gate_reg, _gate_shift, _div_reg,	\
 					_div_width, _div_shift) {	\
 		.id = _id,						\

-- 
2.43.0




More information about the Linux-mediatek mailing list