Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: net: stmmac: add port selection programming

In case of SGMII more, for example when a MAC2MAC connection
is needed, the port selection bits (inside the MAC configuration
registers) have to be programmed according to the link selected.
So the patch adds a new DT parameter to pass the port selection
and to programmed related PCS and CORE to use it.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Giuseppe CAVALLARO and committed by
David S. Miller
02e57b9d 3fe5cadb

+53 -2
+3
Documentation/devicetree/bindings/net/stmmac.txt
··· 47 47 supported by this device instance 48 48 - snps,perfect-filter-entries: Number of perfect filter entries supported 49 49 by this device instance 50 + - snps,ps-speed: port selection speed that can be passed to the core when 51 + PCS is supported. For example, this is used in case of SGMII 52 + and MAC2MAC connection. 50 53 - AXI BUS Mode parameters: below the list of all the parameters to program the 51 54 AXI register inside the DMA module: 52 55 - snps,lpi_en: enable Low Power Interface
+1
drivers/net/ethernet/stmicro/stmmac/common.h
··· 531 531 unsigned int rx_csum; 532 532 unsigned int pcs; 533 533 unsigned int pmt; 534 + unsigned int ps; 534 535 }; 535 536 536 537 struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr, int mcbins,
+15
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
··· 46 46 if (mtu > 2000) 47 47 value |= GMAC_CONTROL_JE; 48 48 49 + if (hw->ps) { 50 + value |= GMAC_CONTROL_TE; 51 + 52 + if (hw->ps == SPEED_1000) { 53 + value &= ~GMAC_CONTROL_PS; 54 + } else { 55 + value |= GMAC_CONTROL_PS; 56 + 57 + if (hw->ps == SPEED_10) 58 + value &= ~GMAC_CONTROL_FES; 59 + else 60 + value |= GMAC_CONTROL_FES; 61 + } 62 + } 63 + 49 64 writel(value, ioaddr + GMAC_CONTROL); 50 65 51 66 /* Mask GMAC interrupts */
+15
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
··· 32 32 if (mtu > 2000) 33 33 value |= GMAC_CONFIG_JE; 34 34 35 + if (hw->ps) { 36 + value |= GMAC_CONFIG_TE; 37 + 38 + if (hw->ps == SPEED_1000) { 39 + value &= ~GMAC_CONFIG_PS; 40 + } else { 41 + value |= GMAC_CONFIG_PS; 42 + 43 + if (hw->ps == SPEED_10) 44 + value &= ~GMAC_CONFIG_FES; 45 + else 46 + value |= GMAC_CONFIG_FES; 47 + } 48 + } 49 + 35 50 writel(value, ioaddr + GMAC_CONFIG); 36 51 37 52 /* Mask GMAC interrupts */
+2 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
··· 380 380 spin_lock(&priv->lock); 381 381 382 382 if (priv->hw->mac->pcs_ctrl_ane) 383 - priv->hw->mac->pcs_ctrl_ane(priv->ioaddr, 1, 0, 0); 383 + priv->hw->mac->pcs_ctrl_ane(priv->ioaddr, 1, 384 + priv->hw->ps, 0); 384 385 385 386 spin_unlock(&priv->lock); 386 387
+14 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1666 1666 if (priv->plat->bus_setup) 1667 1667 priv->plat->bus_setup(priv->ioaddr); 1668 1668 1669 + /* PS and related bits will be programmed according to the speed */ 1670 + if (priv->hw->pcs) { 1671 + int speed = priv->plat->mac_port_sel_speed; 1672 + 1673 + if ((speed == SPEED_10) || (speed == SPEED_100) || 1674 + (speed == SPEED_1000)) { 1675 + priv->hw->ps = speed; 1676 + } else { 1677 + dev_warn(priv->device, "invalid port speed\n"); 1678 + priv->hw->ps = 0; 1679 + } 1680 + } 1681 + 1669 1682 /* Initialize the MAC Core */ 1670 1683 priv->hw->mac->core_init(priv->hw, dev->mtu); 1671 1684 ··· 1729 1716 } 1730 1717 1731 1718 if (priv->hw->pcs && priv->hw->mac->pcs_ctrl_ane) 1732 - priv->hw->mac->pcs_ctrl_ane(priv->hw, 1, 0, 0); 1719 + priv->hw->mac->pcs_ctrl_ane(priv->hw, 1, priv->hw->ps, 0); 1733 1720 1734 1721 /* set TX ring length */ 1735 1722 if (priv->hw->dma->set_tx_ring_len)
+2
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 319 319 pr_warn("force_sf_dma_mode is ignored if force_thresh_dma_mode is set."); 320 320 } 321 321 322 + of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed); 323 + 322 324 plat->axi = stmmac_axi_setup(pdev); 323 325 324 326 return plat;
+1
include/linux/stmmac.h
··· 141 141 struct stmmac_axi *axi; 142 142 int has_gmac4; 143 143 bool tso_en; 144 + int mac_port_sel_speed; 144 145 }; 145 146 #endif