Commit 89caaa2d authored by Niklas Cassel's avatar Niklas Cassel Committed by David S. Miller

net: stmmac: add support for independent DMA pbl for tx/rx

GMAC and newer supports independent programmable burst lengths for
DMA tx/rx. Add new optional devicetree properties representing this.

To be backwards compatible, snps,pbl will still be valid, but
snps,txpbl/snps,rxpbl will override the value in snps,pbl if set.

If the IP is synthesized to use the AXI interface, there is a register
and a matching DT property inside the optional stmmac-axi-config DT node
for controlling burst lengths, named snps,blen.
However, using this register, it is not possible to control tx and rx
independently. Also, this register is not available if the IP was
synthesized with, e.g., the AHB interface.
Signed-off-by: default avatarNiklas Cassel <niklas.cassel@axis.com>
Acked-by: default avatarAlexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 825658a2
...@@ -34,7 +34,11 @@ Optional properties: ...@@ -34,7 +34,11 @@ Optional properties:
platforms. platforms.
- tx-fifo-depth: See ethernet.txt file in the same directory - tx-fifo-depth: See ethernet.txt file in the same directory
- rx-fifo-depth: See ethernet.txt file in the same directory - rx-fifo-depth: See ethernet.txt file in the same directory
- snps,pbl Programmable Burst Length - snps,pbl Programmable Burst Length (tx and rx)
- snps,txpbl Tx Programmable Burst Length. Only for GMAC and newer.
If set, DMA tx will use this value rather than snps,pbl.
- snps,rxpbl Rx Programmable Burst Length. Only for GMAC and newer.
If set, DMA rx will use this value rather than snps,pbl.
- snps,aal Address-Aligned Beats - snps,aal Address-Aligned Beats
- snps,fixed-burst Program the DMA to use the fixed burst mode - snps,fixed-burst Program the DMA to use the fixed burst mode
- snps,mixed-burst Program the DMA to use the mixed burst mode - snps,mixed-burst Program the DMA to use the mixed burst mode
......
...@@ -153,7 +153,8 @@ Where: ...@@ -153,7 +153,8 @@ Where:
o pbl: the Programmable Burst Length is maximum number of beats to o pbl: the Programmable Burst Length is maximum number of beats to
be transferred in one DMA transaction. be transferred in one DMA transaction.
GMAC also enables the 4xPBL by default. GMAC also enables the 4xPBL by default.
o fixed_burst/mixed_burst/burst_len o txpbl/rxpbl: GMAC and newer supports independent DMA pbl for tx/rx.
o fixed_burst/mixed_burst/aal
o clk_csr: fixed CSR Clock range selection. o clk_csr: fixed CSR Clock range selection.
o has_gmac: uses the GMAC core. o has_gmac: uses the GMAC core.
o enh_desc: if sets the MAC will use the enhanced descriptor structure. o enh_desc: if sets the MAC will use the enhanced descriptor structure.
...@@ -205,16 +206,22 @@ tuned according to the HW capabilities. ...@@ -205,16 +206,22 @@ tuned according to the HW capabilities.
struct stmmac_dma_cfg { struct stmmac_dma_cfg {
int pbl; int pbl;
int txpbl;
int rxpbl;
int fixed_burst; int fixed_burst;
int burst_len_supported; int mixed_burst;
bool aal;
}; };
Where: Where:
o pbl: Programmable Burst Length o pbl: Programmable Burst Length (tx and rx)
o txpbl: Transmit Programmable Burst Length. Only for GMAC and newer.
If set, DMA tx will use this value rather than pbl.
o rxpbl: Receive Programmable Burst Length. Only for GMAC and newer.
If set, DMA rx will use this value rather than pbl.
o fixed_burst: program the DMA to use the fixed burst mode o fixed_burst: program the DMA to use the fixed burst mode
o burst_len: this is the value we put in the register o mixed_burst: program the DMA to use the mixed burst mode
supported values are provided as macros in o aal: Address-Aligned Beats
linux/stmmac.h header file.
--- ---
......
...@@ -89,20 +89,20 @@ static void dwmac1000_dma_init(void __iomem *ioaddr, ...@@ -89,20 +89,20 @@ static void dwmac1000_dma_init(void __iomem *ioaddr,
u32 dma_tx, u32 dma_rx, int atds) u32 dma_tx, u32 dma_rx, int atds)
{ {
u32 value = readl(ioaddr + DMA_BUS_MODE); u32 value = readl(ioaddr + DMA_BUS_MODE);
int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;
int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;
/* /*
* Set the DMA PBL (Programmable Burst Length) mode. * Set the DMA PBL (Programmable Burst Length) mode.
* *
* Note: before stmmac core 3.50 this mode bit was 4xPBL, and * Note: before stmmac core 3.50 this mode bit was 4xPBL, and
* post 3.5 mode bit acts as 8*PBL. * post 3.5 mode bit acts as 8*PBL.
*
* This configuration doesn't take care about the Separate PBL
* so only the bits: 13-8 are programmed with the PBL passed from the
* platform.
*/ */
value |= DMA_BUS_MODE_MAXPBL; value |= DMA_BUS_MODE_MAXPBL;
value &= ~DMA_BUS_MODE_PBL_MASK; value |= DMA_BUS_MODE_USP;
value |= (dma_cfg->pbl << DMA_BUS_MODE_PBL_SHIFT); value &= ~(DMA_BUS_MODE_PBL_MASK | DMA_BUS_MODE_RPBL_MASK);
value |= (txpbl << DMA_BUS_MODE_PBL_SHIFT);
value |= (rxpbl << DMA_BUS_MODE_RPBL_SHIFT);
/* Set the Fixed burst mode */ /* Set the Fixed burst mode */
if (dma_cfg->fixed_burst) if (dma_cfg->fixed_burst)
......
...@@ -71,11 +71,14 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi) ...@@ -71,11 +71,14 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
writel(value, ioaddr + DMA_SYS_BUS_MODE); writel(value, ioaddr + DMA_SYS_BUS_MODE);
} }
static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl, static void dwmac4_dma_init_channel(void __iomem *ioaddr,
struct stmmac_dma_cfg *dma_cfg,
u32 dma_tx_phy, u32 dma_rx_phy, u32 dma_tx_phy, u32 dma_rx_phy,
u32 channel) u32 channel)
{ {
u32 value; u32 value;
int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;
int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;
/* set PBL for each channels. Currently we affect same configuration /* set PBL for each channels. Currently we affect same configuration
* on each channel * on each channel
...@@ -85,11 +88,11 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl, ...@@ -85,11 +88,11 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl,
writel(value, ioaddr + DMA_CHAN_CONTROL(channel)); writel(value, ioaddr + DMA_CHAN_CONTROL(channel));
value = readl(ioaddr + DMA_CHAN_TX_CONTROL(channel)); value = readl(ioaddr + DMA_CHAN_TX_CONTROL(channel));
value = value | (pbl << DMA_BUS_MODE_PBL_SHIFT); value = value | (txpbl << DMA_BUS_MODE_PBL_SHIFT);
writel(value, ioaddr + DMA_CHAN_TX_CONTROL(channel)); writel(value, ioaddr + DMA_CHAN_TX_CONTROL(channel));
value = readl(ioaddr + DMA_CHAN_RX_CONTROL(channel)); value = readl(ioaddr + DMA_CHAN_RX_CONTROL(channel));
value = value | (pbl << DMA_BUS_MODE_RPBL_SHIFT); value = value | (rxpbl << DMA_BUS_MODE_RPBL_SHIFT);
writel(value, ioaddr + DMA_CHAN_RX_CONTROL(channel)); writel(value, ioaddr + DMA_CHAN_RX_CONTROL(channel));
/* Mask interrupts by writing to CSR7 */ /* Mask interrupts by writing to CSR7 */
...@@ -120,8 +123,7 @@ static void dwmac4_dma_init(void __iomem *ioaddr, ...@@ -120,8 +123,7 @@ static void dwmac4_dma_init(void __iomem *ioaddr,
writel(value, ioaddr + DMA_SYS_BUS_MODE); writel(value, ioaddr + DMA_SYS_BUS_MODE);
for (i = 0; i < DMA_CHANNEL_NB_MAX; i++) for (i = 0; i < DMA_CHANNEL_NB_MAX; i++)
dwmac4_dma_init_channel(ioaddr, dma_cfg->pbl, dwmac4_dma_init_channel(ioaddr, dma_cfg, dma_tx, dma_rx, i);
dma_tx, dma_rx, i);
} }
static void _dwmac4_dump_dma_regs(void __iomem *ioaddr, u32 channel) static void _dwmac4_dump_dma_regs(void __iomem *ioaddr, u32 channel)
......
...@@ -315,6 +315,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) ...@@ -315,6 +315,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl); of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
if (!dma_cfg->pbl) if (!dma_cfg->pbl)
dma_cfg->pbl = DEFAULT_DMA_PBL; dma_cfg->pbl = DEFAULT_DMA_PBL;
of_property_read_u32(np, "snps,txpbl", &dma_cfg->txpbl);
of_property_read_u32(np, "snps,rxpbl", &dma_cfg->rxpbl);
dma_cfg->aal = of_property_read_bool(np, "snps,aal"); dma_cfg->aal = of_property_read_bool(np, "snps,aal");
dma_cfg->fixed_burst = of_property_read_bool(np, "snps,fixed-burst"); dma_cfg->fixed_burst = of_property_read_bool(np, "snps,fixed-burst");
......
...@@ -88,6 +88,8 @@ struct stmmac_mdio_bus_data { ...@@ -88,6 +88,8 @@ struct stmmac_mdio_bus_data {
struct stmmac_dma_cfg { struct stmmac_dma_cfg {
int pbl; int pbl;
int txpbl;
int rxpbl;
int fixed_burst; int fixed_burst;
int mixed_burst; int mixed_burst;
bool aal; bool aal;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment