From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:20
Hi all,
This is based on net-next (e2a7c34fb285).
I removed the GoP interrupt and PHY optional parts in this v2 to ease
the review process as the MAC/GoP initialization seemed to start less
discussions :)
This series now only aims at making the PPv2 driver less depending on
the firmware/bootloader initialization. Some patches cleanup some parts
as well, and add new interface descriptions in the dt.
The current implementation of the PPv2 driver relies on the
firmware/bootloader initialization to configure some parts, as the Group
of Ports (GoP) and the MACs (GMAC and/or XLG MAC --for 10G--). The
drawback is the kernel must be configured to match exactly what the
bootloader configures which is not convenient and is an issue when using
boards having an Ethernet port and an SFP port wired to the same GoP
port, as no dynamic configuration can be done.
This series adds the GoP and GMAC/XLG MAC initializations so that the
PPV2 does not have to rely on a previous initialization. One part is
still missing from this series, and that would be the 'comphy' which
provides shared serdes PHYs and which must be configured as well for a
full kernel initialization to work. This comphy support will be part of
a following up series. (This series was also tested with this 'comphy'
support, as it's nearly ready).
@Dave: patches 9 and 10 should go through the mvebu tree. Thanks!
Since v1:
- Split the previous series.
- Rebased on net-next and reworked the series accordingly.
- Added support for all RGMII variants.
- Added a patch from Stefan Chulski improving / fixing 10G support.
- Various small fixes.
Antoine Tenart (9):
net: mvpp2: unify register definitions coding style
net: mvpp2: fix the synchronization module bypass macro name
net: mvpp2: move the mii configuration in the ndo_open path
net: mvpp2: initialize the GMAC when using a port
net: mvpp2: initialize the XLG MAC when using a port
net: mvpp2: initialize the GoP
Documentation/bindings: net: marvell-pp2: add the system controller
arm64: dts: marvell: add a reference to the sysctrl syscon in the ppv2
node
arm64: dts: marvell: mcbin: enable more networking ports
Stefan Chulski (1):
net: mvpp2: set maximum packet size for 10G ports
.../devicetree/bindings/net/marvell-pp2.txt | 1 +
arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts | 30 ++
.../boot/dts/marvell/armada-cp110-master.dtsi | 1 +
.../arm64/boot/dts/marvell/armada-cp110-slave.dtsi | 1 +
drivers/net/ethernet/marvell/mvpp2.c | 432 +++++++++++++++++----
5 files changed, 393 insertions(+), 72 deletions(-)
--
2.13.5
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:21
Cosmetic patch to use the same formatting rules on all register
definitions.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 88 ++++++++++++++++++------------------
1 file changed, 44 insertions(+), 44 deletions(-)
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:22
The macro defining the bit to toggle to bypass or not the
synchronization module is wrongly named. Writing 1 will disable bypass.
This patch s/MVPP22_CTRL4_SYNC_BYPASS/MVPP22_CTRL4_SYNC_BYPASS_DIS/.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:23
This moves the mii configuration in the ndo_open path, to allow handling
different mii configurations later and to switch between these
configurations at runtime.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:24
This adds a routine to initialize the GMAC at the port level when using
a port. This wasn't done until this commit, and the mvpp2 driver was
relying on the bootloader/firmware initialization. This doesn't mean
everything is configured in the mvpp2 driver now, but it helps reducing
the gap.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 123 ++++++++++++++++++++++++++++-------
1 file changed, 98 insertions(+), 25 deletions(-)
@@ -4245,6 +4251,92 @@ mvpp2_shared_interrupt_mask_unmask(struct mvpp2_port *port, bool mask)/* Port configuration routines */+staticvoidmvpp2_port_mii_gmac_configure_mode(structmvpp2_port*port)+{+u32val;++if(port->phy_interface==PHY_INTERFACE_MODE_SGMII){+val=readl(port->base+MVPP22_GMAC_CTRL_4_REG);+val|=MVPP22_CTRL4_SYNC_BYPASS_DIS|MVPP22_CTRL4_DP_CLK_SEL|+MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE;+val&=~MVPP22_CTRL4_EXT_PIN_GMII_SEL;+writel(val,port->base+MVPP22_GMAC_CTRL_4_REG);++val=readl(port->base+MVPP2_GMAC_CTRL_2_REG);+val|=MVPP2_GMAC_DISABLE_PADDING;+val&=~MVPP2_GMAC_FLOW_CTRL_MASK;+writel(val,port->base+MVPP2_GMAC_CTRL_2_REG);+}elseif(port->phy_interface==PHY_INTERFACE_MODE_RGMII||+port->phy_interface==PHY_INTERFACE_MODE_RGMII_ID||+port->phy_interface==PHY_INTERFACE_MODE_RGMII_RXID||+port->phy_interface==PHY_INTERFACE_MODE_RGMII_TXID){+val=readl(port->base+MVPP22_GMAC_CTRL_4_REG);+val|=MVPP22_CTRL4_EXT_PIN_GMII_SEL|+MVPP22_CTRL4_SYNC_BYPASS_DIS|+MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE;+val&=~MVPP22_CTRL4_DP_CLK_SEL;+writel(val,port->base+MVPP22_GMAC_CTRL_4_REG);++val=readl(port->base+MVPP2_GMAC_CTRL_2_REG);+val&=~MVPP2_GMAC_DISABLE_PADDING;+writel(val,port->base+MVPP2_GMAC_CTRL_2_REG);+}++/* The port is connected to a copper PHY */+val=readl(port->base+MVPP2_GMAC_CTRL_0_REG);+val&=~MVPP2_GMAC_PORT_TYPE_MASK;+writel(val,port->base+MVPP2_GMAC_CTRL_0_REG);++val=readl(port->base+MVPP2_GMAC_AUTONEG_CONFIG);+val|=MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS|+MVPP2_GMAC_AN_SPEED_EN|MVPP2_GMAC_FLOW_CTRL_AUTONEG|+MVPP2_GMAC_AN_DUPLEX_EN;+if(port->phy_interface==PHY_INTERFACE_MODE_SGMII)+val|=MVPP2_GMAC_IN_BAND_AUTONEG;+writel(val,port->base+MVPP2_GMAC_AUTONEG_CONFIG);+}++staticvoidmvpp2_port_mii_gmac_configure(structmvpp2_port*port)+{+u32val;++/* Force link down */+val=readl(port->base+MVPP2_GMAC_AUTONEG_CONFIG);+val&=~MVPP2_GMAC_FORCE_LINK_PASS;+val|=MVPP2_GMAC_FORCE_LINK_DOWN;+writel(val,port->base+MVPP2_GMAC_AUTONEG_CONFIG);++/* Set the GMAC in a reset state */+val=readl(port->base+MVPP2_GMAC_CTRL_2_REG);+val|=MVPP2_GMAC_PORT_RESET_MASK;+writel(val,port->base+MVPP2_GMAC_CTRL_2_REG);++/* Configure the PCS and in-band AN */+val=readl(port->base+MVPP2_GMAC_CTRL_2_REG);+if(port->phy_interface==PHY_INTERFACE_MODE_SGMII){+val|=MVPP2_GMAC_INBAND_AN_MASK|MVPP2_GMAC_PCS_ENABLE_MASK;+}elseif(port->phy_interface==PHY_INTERFACE_MODE_RGMII||+port->phy_interface==PHY_INTERFACE_MODE_RGMII_ID||+port->phy_interface==PHY_INTERFACE_MODE_RGMII_RXID||+port->phy_interface==PHY_INTERFACE_MODE_RGMII_TXID){+val&=~MVPP2_GMAC_PCS_ENABLE_MASK;+val|=MVPP2_GMAC_PORT_RGMII_MASK;+}+writel(val,port->base+MVPP2_GMAC_CTRL_2_REG);++mvpp2_port_mii_gmac_configure_mode(port);++/* Unset the GMAC reset state */+val=readl(port->base+MVPP2_GMAC_CTRL_2_REG);+val&=~MVPP2_GMAC_PORT_RESET_MASK;+writel(val,port->base+MVPP2_GMAC_CTRL_2_REG);++/* Stop forcing link down */+val=readl(port->base+MVPP2_GMAC_AUTONEG_CONFIG);+val&=~MVPP2_GMAC_FORCE_LINK_DOWN;+writel(val,port->base+MVPP2_GMAC_AUTONEG_CONFIG);+}+staticvoidmvpp22_port_mii_set(structmvpp2_port*port){u32val;
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:25
This adds a routine to initialize the XLG MAC at the port level when
using a port and the XAUI/10GKR interface mode. This wasn't done until
this commit, and the mvpp2 driver was relying on the bootloader/firmware
initialization. This doesn't mean everything is configured in the mvpp2
driver now, but it helps reducing the gap.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:26
From: Stefan Chulski <redacted>
Set maximum packet size for XLG 10G ports. Missing maximum packet size
for XLG configuration will cause kernel panic if oversized packet is
received by port.
Signed-off-by: Stefan Chulski <redacted>
Signed-off-by: Antoine Tenart <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
@@ -4498,6 +4500,18 @@ static inline void mvpp2_gmac_max_rx_size_set(struct mvpp2_port *port)writel(val,port->base+MVPP2_GMAC_CTRL_0_REG);}+/* Change maximum receive size of the port */+staticinlinevoidmvpp2_xlg_max_rx_size_set(structmvpp2_port*port)+{+u32val;++val=readl(port->base+MVPP22_XLG_CTRL1_REG);+val&=~MVPP22_XLG_CTRL1_FRAMESIZELIMIT_MASK;+val|=((port->pkt_size-MVPP2_MH_SIZE)/2)<<+MVPP22_XLG_CTRL1_FRAMESIZELIMIT;+writel(val,port->base+MVPP22_XLG_CTRL1_REG);+}+/* Set defaults to the MVPP2 port */staticvoidmvpp2_defaults_set(structmvpp2_port*port){
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:27
The patch adds GoP (group of ports) initialization functions. The mvpp2
driver was relying on the firmware/bootloader initialization; this patch
moves this setup to the mvpp2 driver.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2.c | 170 +++++++++++++++++++++++++++++++++++
1 file changed, 170 insertions(+)
@@ -731,6 +765,11 @@ struct mvpp2 {*/void__iomem*swth_base[MVPP2_MAX_THREADS];+/* On PPv2.2, some port control registers are located into the system+*controllerspace.Theseregistersareaccessiblethrougharegmap.+*/+structregmap*sysctrl_base;+/* Common clocks */structclk*pp_clk;structclk*gop_clk;
@@ -4259,6 +4298,123 @@ mvpp2_shared_interrupt_mask_unmask(struct mvpp2_port *port, bool mask)/* Port configuration routines */+staticvoidmvpp22_gop_init_rgmii(structmvpp2_port*port)+{+structmvpp2*priv=port->priv;+u32val;++regmap_read(priv->sysctrl_base,GENCONF_PORT_CTRL0,&val);+val|=GENCONF_PORT_CTRL0_BUS_WIDTH_SELECT;+regmap_write(priv->sysctrl_base,GENCONF_PORT_CTRL0,val);++regmap_read(priv->sysctrl_base,GENCONF_CTRL0,&val);+if(port->gop_id==2)+val|=GENCONF_CTRL0_PORT0_RGMII|GENCONF_CTRL0_PORT1_RGMII;+elseif(port->gop_id==3)+val|=GENCONF_CTRL0_PORT1_RGMII_MII;+regmap_write(priv->sysctrl_base,GENCONF_CTRL0,val);+}++staticvoidmvpp22_gop_init_sgmii(structmvpp2_port*port)+{+structmvpp2*priv=port->priv;+u32val;++regmap_read(priv->sysctrl_base,GENCONF_PORT_CTRL0,&val);+val|=GENCONF_PORT_CTRL0_BUS_WIDTH_SELECT|+GENCONF_PORT_CTRL0_RX_DATA_SAMPLE;+regmap_write(priv->sysctrl_base,GENCONF_PORT_CTRL0,val);++if(port->gop_id>1){+regmap_read(priv->sysctrl_base,GENCONF_CTRL0,&val);+if(port->gop_id==2)+val&=~GENCONF_CTRL0_PORT0_RGMII;+elseif(port->gop_id==3)+val&=~GENCONF_CTRL0_PORT1_RGMII_MII;+regmap_write(priv->sysctrl_base,GENCONF_CTRL0,val);+}+}++staticvoidmvpp22_gop_init_10gkr(structmvpp2_port*port)+{+structmvpp2*priv=port->priv;+void__iomem*mpcs=priv->iface_base+MVPP22_MPCS_BASE(port->gop_id);+void__iomem*xpcs=priv->iface_base+MVPP22_XPCS_BASE(port->gop_id);+u32val;++/* XPCS */+val=readl(xpcs+MVPP22_XPCS_CFG0);+val&=~(MVPP22_XPCS_CFG0_PCS_MODE(0x3)|+MVPP22_XPCS_CFG0_ACTIVE_LANE(0x3));+val|=MVPP22_XPCS_CFG0_ACTIVE_LANE(2);+writel(val,xpcs+MVPP22_XPCS_CFG0);++/* MPCS */+val=readl(mpcs+MVPP22_MPCS_CTRL);+val&=~MVPP22_MPCS_CTRL_FWD_ERR_CONN;+writel(val,mpcs+MVPP22_MPCS_CTRL);++val=readl(mpcs+MVPP22_MPCS_CLK_RESET);+val&=~(MVPP22_MPCS_CLK_RESET_DIV_RATIO(0x7)|MAC_CLK_RESET_MAC|+MAC_CLK_RESET_SD_RX|MAC_CLK_RESET_SD_TX);+val|=MVPP22_MPCS_CLK_RESET_DIV_RATIO(1);+writel(val,mpcs+MVPP22_MPCS_CLK_RESET);++val&=~MVPP22_MPCS_CLK_RESET_DIV_SET;+val|=MAC_CLK_RESET_MAC|MAC_CLK_RESET_SD_RX|MAC_CLK_RESET_SD_TX;+writel(val,mpcs+MVPP22_MPCS_CLK_RESET);+}++staticintmvpp22_gop_init(structmvpp2_port*port)+{+structmvpp2*priv=port->priv;+u32val;++if(!priv->sysctrl_base)+return0;++switch(port->phy_interface){+casePHY_INTERFACE_MODE_RGMII:+casePHY_INTERFACE_MODE_RGMII_ID:+casePHY_INTERFACE_MODE_RGMII_RXID:+casePHY_INTERFACE_MODE_RGMII_TXID:+if(port->gop_id==0)+gotoinvalid_conf;+mvpp22_gop_init_rgmii(port);+break;+casePHY_INTERFACE_MODE_SGMII:+mvpp22_gop_init_sgmii(port);+break;+casePHY_INTERFACE_MODE_10GKR:+if(port->gop_id!=0)+gotoinvalid_conf;+mvpp22_gop_init_10gkr(port);+break;+default:+gotounsupported_conf;+}++regmap_read(priv->sysctrl_base,GENCONF_PORT_CTRL1,&val);+val|=GENCONF_PORT_CTRL1_RESET(port->gop_id)|+GENCONF_PORT_CTRL1_EN(port->gop_id);+regmap_write(priv->sysctrl_base,GENCONF_PORT_CTRL1,val);++regmap_read(priv->sysctrl_base,GENCONF_PORT_CTRL0,&val);+val|=GENCONF_PORT_CTRL0_CLK_DIV_PHASE_CLR;+regmap_write(priv->sysctrl_base,GENCONF_PORT_CTRL0,val);++regmap_read(priv->sysctrl_base,GENCONF_SOFT_RESET1,&val);+val|=GENCONF_SOFT_RESET1_GOP;+regmap_write(priv->sysctrl_base,GENCONF_SOFT_RESET1,val);++unsupported_conf:+return0;++invalid_conf:+netdev_err(port->dev,"Invalid port configuration\n");+return-EINVAL;+}+staticvoidmvpp2_port_mii_gmac_configure_mode(structmvpp2_port*port){u32val;
@@ -6105,6 +6261,9 @@ static void mvpp2_start_dev(struct mvpp2_port *port)/* Enable interrupts on all CPUs */mvpp2_interrupts_enable(port);+if(port->priv->hw_version==MVPP22)+mvpp22_gop_init(port);+mvpp2_port_mii_set(port);mvpp2_port_enable(port);phy_start(ndev->phydev);
@@ -7350,6 +7509,17 @@ static int mvpp2_probe(struct platform_device *pdev)priv->iface_base=devm_ioremap_resource(&pdev->dev,res);if(IS_ERR(priv->iface_base))returnPTR_ERR(priv->iface_base);++priv->sysctrl_base=+syscon_regmap_lookup_by_phandle(pdev->dev.of_node,+"marvell,system-controller");+if(IS_ERR(priv->sysctrl_base))+/* The system controller regmap is optional for dt+*compatibilityreasons.Whennotprovided,the+*configurationoftheGoPreliesonthe+*firmware/bootloader.+*/+priv->sysctrl_base=NULL;}for(i=0;i<MVPP2_MAX_THREADS;i++){
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:28
This patch documents the new marvell,system-controller property used by
the Marvell ppv2 network driver.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
Documentation/devicetree/bindings/net/marvell-pp2.txt | 1 +
1 file changed, 1 insertion(+)
@@ -45,6 +45,7 @@ Optional properties (port): be the name associated to the interrupts listed. Valid names are: "tx-cpu0", "tx-cpu1", "tx-cpu2", "tx-cpu3", "rx-shared".+- marvell,system-controller: a phandle to the system controller. Example for marvell,armada-375-pp2:
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:29
The network driver on Marvell SoC (7k/8k) needs to access some registers
in the system controller to configure its ports at runtime. This patch
adds a phandle reference to the syscon system controller node in the
ppv2 node.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 1 +
arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi | 1 +
2 files changed, 2 insertions(+)
From: Antoine Tenart <hidden> Date: 2017-08-22 17:08:30
This patch enables the two GE/SFP ports. They are configured in 10GKR
mode by default. To do this the cpm_xdmio is enabled as well, and two
phy descriptions are added.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts | 30 +++++++++++++++++++++++
1 file changed, 30 insertions(+)
On Tue, Aug 22, 2017 at 07:08:20PM +0200, Antoine Tenart wrote:
Hi all,
This is based on net-next (e2a7c34fb285).
I removed the GoP interrupt and PHY optional parts in this v2 to ease
the review process as the MAC/GoP initialization seemed to start less
discussions :)
Hi Antoine
By that, do you mean setting the SMI PHY address?
Andrew
From: Antoine Tenart <hidden> Date: 2017-08-22 18:38:05
Hi Andrew,
On Tue, Aug 22, 2017 at 08:07:57PM +0200, Andrew Lunn wrote:
On Tue, Aug 22, 2017 at 07:08:20PM +0200, Antoine Tenart wrote:
quoted
This is based on net-next (e2a7c34fb285).
I removed the GoP interrupt and PHY optional parts in this v2 to ease
the review process as the MAC/GoP initialization seemed to start less
discussions :)
By that, do you mean setting the SMI PHY address?
Yes, the one set in the GoP. You asked more precisions but I need get
more info to answer, so I removed it in the meantime.
Antoine
--
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
From: Antoine Tenart <redacted>
Date: Tue, 22 Aug 2017 19:08:20 +0200
This is based on net-next (e2a7c34fb285).
I removed the GoP interrupt and PHY optional parts in this v2 to ease
the review process as the MAC/GoP initialization seemed to start less
discussions :)
This series now only aims at making the PPv2 driver less depending on
the firmware/bootloader initialization. Some patches cleanup some parts
as well, and add new interface descriptions in the dt.
...
@Dave: patches 9 and 10 should go through the mvebu tree. Thanks!
Hi Antoine,
On Tue, Aug 22, 2017 at 07:08:30PM +0200, Antoine Tenart wrote:
quoted hunk
This patch enables the two GE/SFP ports. They are configured in 10GKR
mode by default. To do this the cpm_xdmio is enabled as well, and two
phy descriptions are added.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts | 30 +++++++++++++++++++++++
1 file changed, 30 insertions(+)
From: Antoine Tenart <hidden> Date: 2017-08-23 08:11:12
Hi Baruch,
On Wed, Aug 23, 2017 at 10:28:42AM +0300, Baruch Siach wrote:
On Tue, Aug 22, 2017 at 07:08:30PM +0200, Antoine Tenart wrote:
quoted
This patch enables the two GE/SFP ports. They are configured in 10GKR
mode by default. To do this the cpm_xdmio is enabled as well, and two
phy descriptions are added.
Signed-off-by: Antoine Tenart <redacted>
Tested-by: Marcin Wojtas <redacted>
---
arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts | 30 +++++++++++++++++++++++
1 file changed, 30 insertions(+)