]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Sat, 5 Dec 2020 21:32:07 +0000 (22:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Dec 2020 12:46:45 +0000 (13:46 +0100)
[ Upstream commit 82ca4c922b8992013a238d65cf4e60cc33e12f36 ]

The m250_sel mux clock uses bit 4 in the PRG_ETH0 register. Fix this by
shifting the PRG_ETH0_CLK_M250_SEL_MASK accordingly as the "mask" in
struct clk_mux expects the mask relative to the "shift" field in the
same struct.

While here, get rid of the PRG_ETH0_CLK_M250_SEL_SHIFT macro and use
__ffs() to determine it from the existing PRG_ETH0_CLK_M250_SEL_MASK
macro.

Fixes: 566e8251625304 ("net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20201205213207.519341-1-martin.blumenstingl@googlemail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c

index d71d3c1c85eed7cfdb2c4e79104f7ef305b99995..7521ef5383f16d5ac25aa20e07fc77884a19ef4a 100644 (file)
@@ -30,7 +30,6 @@
 #define PRG_ETH0_RGMII_MODE            BIT(0)
 
 /* mux to choose between fclk_div2 (bit unset) and mpll2 (bit set) */
-#define PRG_ETH0_CLK_M250_SEL_SHIFT    4
 #define PRG_ETH0_CLK_M250_SEL_MASK     GENMASK(4, 4)
 
 #define PRG_ETH0_TXDLY_SHIFT           5
@@ -121,8 +120,9 @@ static int meson8b_init_clk(struct meson8b_dwmac *dwmac)
        init.num_parents = MUX_CLK_NUM_PARENTS;
 
        dwmac->m250_mux.reg = dwmac->regs + PRG_ETH0;
-       dwmac->m250_mux.shift = PRG_ETH0_CLK_M250_SEL_SHIFT;
-       dwmac->m250_mux.mask = PRG_ETH0_CLK_M250_SEL_MASK;
+       dwmac->m250_mux.shift = __ffs(PRG_ETH0_CLK_M250_SEL_MASK);
+       dwmac->m250_mux.mask = PRG_ETH0_CLK_M250_SEL_MASK >>
+                              dwmac->m250_mux.shift;
        dwmac->m250_mux.flags = 0;
        dwmac->m250_mux.table = NULL;
        dwmac->m250_mux.hw.init = &init;