]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: mediatek: implement MUX_FLAGS and MUX_MIXED_FLAGS macro
authorChristian Marangi <ansuelsmth@gmail.com>
Fri, 28 Jun 2024 17:40:55 +0000 (19:40 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 1 Aug 2024 21:32:18 +0000 (15:32 -0600)
Some simple MUX might require flags to specify the parent source.
Implement MUX_FLAGS as a variant of the MUX macro that takes custom
flags as last arg.
Also implement MUX_MIXED_FLAGS for PARENT_MIXED implementation and
MUX_MIXED with no additional flags.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
drivers/clk/mediatek/clk-mtk.h

index c448ed024aa99b7dd1b7b8606eaa15fa1c0417b0..c1d9901c10bcdd13ba43a8709d56514d2febf05f 100644 (file)
@@ -179,7 +179,20 @@ struct mtk_composite {
 #define MUX_GATE(_id, _parents, _reg, _shift, _width, _gate)           \
        MUX_GATE_FLAGS(_id, _parents, _reg, _shift, _width, _gate, 0)
 
-#define MUX(_id, _parents, _reg, _shift, _width) {                     \
+#define MUX_MIXED_FLAGS(_id, _parents, _reg, _shift, _width, _flags) { \
+               .id = _id,                                              \
+               .mux_reg = _reg,                                        \
+               .mux_shift = _shift,                                    \
+               .mux_mask = BIT(_width) - 1,                            \
+               .gate_shift = -1,                                       \
+               .parent_flags = _parents,                               \
+               .num_parents = ARRAY_SIZE(_parents),                    \
+               .flags = CLK_PARENT_MIXED | (_flags),                   \
+       }
+#define MUX_MIXED(_id, _parents, _reg, _shift, _width)                 \
+       MUX_MIXED_FLAGS(_id, _parents, _reg, _shift, _width, 0)
+
+#define MUX_FLAGS(_id, _parents, _reg, _shift, _width, _flags) {       \
                .id = _id,                                              \
                .mux_reg = _reg,                                        \
                .mux_shift = _shift,                                    \
@@ -187,8 +200,10 @@ struct mtk_composite {
                .gate_shift = -1,                                       \
                .parent = _parents,                                     \
                .num_parents = ARRAY_SIZE(_parents),                    \
-               .flags = 0,                                             \
+               .flags = _flags,                                        \
        }
+#define MUX(_id, _parents, _reg, _shift, _width)                       \
+       MUX_FLAGS(_id, _parents, _reg, _shift, _width, 0)
 
 #define MUX_CLR_SET_UPD_FLAGS(_id, _parents, _mux_ofs, _mux_set_ofs,\
                        _mux_clr_ofs, _shift, _width, _gate,            \