]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: move stmmac_axi_blen_to_mask() to stmmac_main.c
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 19 Nov 2025 10:23:30 +0000 (10:23 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 21 Nov 2025 01:57:40 +0000 (17:57 -0800)
Move the call to stmmac_axi_blen_to_mask() out of the individual
MAC version drivers into the main code in stmmac_init_dma_engine(),
passing the resulting value through a new member, axi_blen_regval,
in the struct stmmac_axi structure.

There is now no need for stmmac_axi_blen_to_dma_mask() to use
u32p_replace_bits(), so use FIELD_PREP() instead.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vLfLW-0000000FMb1-0zKV@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
include/linux/stmmac.h

index b6476a1bfeab01a921932562e08a50966add7a75..6d9b8fac3c6d0fd76733ab4a1a8cce2420fa40b4 100644 (file)
@@ -41,8 +41,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
         * set). Note that the UNDEF bit is readonly, and is the inverse of
         * Bus Mode bit 16.
         */
-       stmmac_axi_blen_to_mask(&value, axi->axi_blen,
-                               ARRAY_SIZE(axi->axi_blen));
+       value = (value & ~DMA_AXI_BLEN_MASK) | axi->axi_blen_regval;
 
        writel(value, ioaddr + DMA_AXI_BUS_MODE);
 }
index 90d03c7b29f4c730ace1a89a0698227e3ee248af..7b513324cfb08174cf6ec4eafb92357cdfb787e2 100644 (file)
@@ -40,8 +40,7 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
         * set). Note that the UNDEF bit is readonly, and is the inverse of
         * Bus Mode bit 16.
         */
-       stmmac_axi_blen_to_mask(&value, axi->axi_blen,
-                               ARRAY_SIZE(axi->axi_blen));
+       value = (value & ~DMA_AXI_BLEN_MASK) | axi->axi_blen_regval;
 
        writel(value, ioaddr + DMA_SYS_BUS_MODE);
 }
index 8a2cb6ca9588eec9531b456e36eb6f480f5efd9e..cc1bdc0975d5b6c8c1a778ff6992901ab40c1645 100644 (file)
@@ -106,8 +106,7 @@ static void dwxgmac2_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
         * set). Note that the UNDEF bit is readonly, and is the inverse of
         * Bus Mode bit 16.
         */
-       stmmac_axi_blen_to_mask(&value, axi->axi_blen,
-                               ARRAY_SIZE(axi->axi_blen));
+       value = (value & ~DMA_AXI_BLEN_MASK) | axi->axi_blen_regval;
 
        writel(value, ioaddr + XGMAC_DMA_SYSBUS_MODE);
        writel(XGMAC_TDPS, ioaddr + XGMAC_TX_EDMA_CTRL);
index 0b1e571f70f0e48289c011e69625c6e34bcb3ed4..aac82ddfb8c0312862cfd7a71889884153d62fc8 100644 (file)
@@ -223,7 +223,7 @@ void stmmac_axi_blen_to_mask(u32 *regval, const u32 *blen, size_t len)
                val |= burst >> 2;
        }
 
-       u32p_replace_bits(regval, val, DMA_AXI_BLEN_MASK);
+       *regval = FIELD_PREP(DMA_AXI_BLEN_MASK, val);
 }
 
 /**
@@ -3212,8 +3212,12 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
        /* DMA Configuration */
        stmmac_dma_init(priv, priv->ioaddr, priv->plat->dma_cfg);
 
-       if (priv->plat->axi)
+       if (priv->plat->axi) {
+               /* Encode the AXI burst length to a register value */
+               stmmac_axi_blen_to_mask(&priv->plat->axi->axi_blen_regval,
+                                       priv->plat->axi->axi_blen, AXI_BLEN);
                stmmac_axi(priv, priv->ioaddr, priv->plat->axi);
+       }
 
        /* DMA CSR Channel configuration */
        for (chan = 0; chan < dma_csr_ch; chan++) {
index 673b068fdadf4e2420574dcb44d280985121b56a..d1a41fe0825f95dd89a99a44a2b96c3f3f02d378 100644 (file)
@@ -113,6 +113,7 @@ struct stmmac_axi {
        u32 axi_wr_osr_lmt;
        u32 axi_rd_osr_lmt;
        bool axi_kbbe;
+       u32 axi_blen_regval;
        u32 axi_blen[AXI_BLEN];
        bool axi_fb;
        bool axi_mb;