Netdev Archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G
@ 2023-04-04  6:14 Siddharth Vadapalli
  2023-04-04  6:14 ` [PATCH net-next v3 1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config() Siddharth Vadapalli
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2023-04-04  6:14 UTC (permalink / raw
  To: davem, edumazet, kuba, linux, pabeni, rogerq
  Cc: netdev, linux-kernel, linux-arm-kernel, srk, s-vadapalli

Hello,

This series adds a new compatible to am65-cpsw driver for the CPSW9G
instance of the CPSW Ethernet Switch on TI's J784S4 SoC which has 8
external ports and 1 internal host port.

The CPSW9G instance supports QSGMII and USXGMII modes for which driver
support is added.

Additionally, the interface mode specific configurations are moved to the
am65_cpsw_nuss_mac_config() callback. Also, a TODO comment is added for
verifying whether in-band mode is necessary for 10 Mbps RGMII mode.

NOTE:
I have verified that the mac_config() operations are preserved across
link up and link down events for SGMII and USXGMII mode with the new
implementation in this series, as suggested by:
Russell King <linux@armlinux.org.uk>

For patches 1 and 3 of this series, I believe that the following tag:
Suggested-by: Russell King <linux@armlinux.org.uk>
should be added. However, I did not add it since I did not yet get
the permission to do so. I will be happy if the tags are added, since
the new implementation is almost entirely based on Russell's suggestion,
with minor changes made by me.

Changes from v2:
1. In am65_cpsw_nuss_mac_config(), set the CPSW_SL_CTL_EXT_EN bit in the
   MAC control register if the mode is SGMII. Else, clear that bit.
2. In am65_cpsw_nuss_mac_link_down(), instead of resetting the entire MAC
   control register, only clear those bits that can possibly be set in the
   am65_cpsw_nuss_mac_link_up() function. Resetting the entire MAC control
   register will result in loss of the configuration performed by the
   am65_cpsw_nuss_mac_config() function.
3. In am65_cpsw_nuss_mac_link_down(), since the MAC control register
   will not be reset, the CPSW_SL_CTL_CMD_IDLE bit which was previously
   cleared as a part of the reset, needs to be cleared in the
   am65_cpsw_nuss_mac_link_up() function. This is the correct approach,
   since the MAC should remain IDLE until the link is detected.
4. In am65_cpsw_nuss_mac_config(), set the CPSW_SL_CTL_XGIG and the
   CPSW_SL_CTL_XGMII_EN bits in the MAC control register if the mode is
   USXGMII. Else, clear those bits.

Changes from v1:
1. Add a patch to move interface mode specific configuration from the
   mac_link_up() callback to the mac_config() callback of the am65-cpsw
   driver. Also, add a TODO comment for 10 Mbps RGMII in-band mode.
2. Add MAC_5000FD to the list of mac_capabilities member unconditionally,
   since the CPSW MAC supports it.
3. Add USXGMII mode specific configuration in the mac_config() callback
   along with the SGMII mode specific configuration, instead of the
   mac_link_up() callback which was incorrectly done in the v1 series.

v2:
https://lore.kernel.org/r/20230403110106.983994-1-s-vadapalli@ti.com/
v1:
https://lore.kernel.org/r/20230331065110.604516-1-s-vadapalli@ti.com/

Regards,
Siddharth.

Siddharth Vadapalli (3):
  net: ethernet: ti: am65-cpsw: Move mode specific config to
    mac_config()
  net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G
  net: ethernet: ti: am65-cpsw: Enable USXGMII mode for J784S4 CPSW9G

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 42 +++++++++++++++++++++---
 1 file changed, 37 insertions(+), 5 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next v3 1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config()
  2023-04-04  6:14 [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G Siddharth Vadapalli
@ 2023-04-04  6:14 ` Siddharth Vadapalli
  2023-04-04  6:14 ` [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G Siddharth Vadapalli
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2023-04-04  6:14 UTC (permalink / raw
  To: davem, edumazet, kuba, linux, pabeni, rogerq
  Cc: netdev, linux-kernel, linux-arm-kernel, srk, s-vadapalli

Move the interface mode specific configuration to the mac_config()
callback am65_cpsw_nuss_mac_config().

Also, do not reset the MAC Control register on mac_link_down(). Only
clear those bits that can possibly be set in mac_link_up().

Let the MAC remain in IDLE state after mac_link_down(). Bring it out of
the IDLE state on mac_link_up().

Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index d17757ecbf42..99d18eb6bbe9 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1506,9 +1506,13 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in
 	struct am65_cpsw_common *common = port->common;
 
 	if (common->pdata.extra_modes & BIT(state->interface)) {
-		if (state->interface == PHY_INTERFACE_MODE_SGMII)
+		if (state->interface == PHY_INTERFACE_MODE_SGMII) {
 			writel(ADVERTISE_SGMII,
 			       port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG);
+			cpsw_sl_ctl_set(port->slave.mac_sl, CPSW_SL_CTL_EXT_EN);
+		} else {
+			cpsw_sl_ctl_clr(port->slave.mac_sl, CPSW_SL_CTL_EXT_EN);
+		}
 
 		writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE,
 		       port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG);
@@ -1523,6 +1527,7 @@ static void am65_cpsw_nuss_mac_link_down(struct phylink_config *config, unsigned
 	struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave);
 	struct am65_cpsw_common *common = port->common;
 	struct net_device *ndev = port->ndev;
+	u32 mac_control;
 	int tmo;
 
 	/* disable forwarding */
@@ -1534,7 +1539,14 @@ static void am65_cpsw_nuss_mac_link_down(struct phylink_config *config, unsigned
 	dev_dbg(common->dev, "down msc_sl %08x tmo %d\n",
 		cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_MACSTATUS), tmo);
 
-	cpsw_sl_ctl_reset(port->slave.mac_sl);
+	/* All the bits that am65_cpsw_nuss_mac_link_up() can possibly set */
+	mac_control = CPSW_SL_CTL_GMII_EN | CPSW_SL_CTL_GIG | CPSW_SL_CTL_IFCTL_A |
+		      CPSW_SL_CTL_FULLDUPLEX | CPSW_SL_CTL_RX_FLOW_EN | CPSW_SL_CTL_TX_FLOW_EN;
+	/* If interface mode is RGMII, CPSW_SL_CTL_EXT_EN might have been set for 10 Mbps */
+	if (phy_interface_mode_is_rgmii(interface))
+		mac_control |= CPSW_SL_CTL_EXT_EN;
+	/* Only clear those bits that can be set by am65_cpsw_nuss_mac_link_up() */
+	cpsw_sl_ctl_clr(port->slave.mac_sl, mac_control);
 
 	am65_cpsw_qos_link_down(ndev);
 	netif_tx_stop_all_queues(ndev);
@@ -1551,10 +1563,12 @@ static void am65_cpsw_nuss_mac_link_up(struct phylink_config *config, struct phy
 	u32 mac_control = CPSW_SL_CTL_GMII_EN;
 	struct net_device *ndev = port->ndev;
 
+	/* Bring the port out of idle state */
+	cpsw_sl_ctl_clr(port->slave.mac_sl, CPSW_SL_CTL_CMD_IDLE);
+
 	if (speed == SPEED_1000)
 		mac_control |= CPSW_SL_CTL_GIG;
-	if (interface == PHY_INTERFACE_MODE_SGMII)
-		mac_control |= CPSW_SL_CTL_EXT_EN;
+	/* TODO: Verify whether in-band is necessary for 10 Mbps RGMII */
 	if (speed == SPEED_10 && phy_interface_mode_is_rgmii(interface))
 		/* Can be used with in band mode only */
 		mac_control |= CPSW_SL_CTL_EXT_EN;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G
  2023-04-04  6:14 [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G Siddharth Vadapalli
  2023-04-04  6:14 ` [PATCH net-next v3 1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config() Siddharth Vadapalli
@ 2023-04-04  6:14 ` Siddharth Vadapalli
  2023-04-04 11:38   ` Roger Quadros
  2023-04-04  6:14 ` [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpsw: Enable USXGMII mode " Siddharth Vadapalli
  2023-04-08  2:50 ` [PATCH net-next v3 0/3] Add support " patchwork-bot+netdevbpf
  3 siblings, 1 reply; 6+ messages in thread
From: Siddharth Vadapalli @ 2023-04-04  6:14 UTC (permalink / raw
  To: davem, edumazet, kuba, linux, pabeni, rogerq
  Cc: netdev, linux-kernel, linux-arm-kernel, srk, s-vadapalli

TI's J784S4 SoC supports QSGMII mode with the CPSW9G instance of the
CPSW Ethernet Switch. Add a new compatible for J784S4 SoC and enable
QSGMII support for it by adding QSGMII mode to the extra_modes member of
the "j784s4_cpswxg_pdata" SoC data.

Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 99d18eb6bbe9..f1e83d49de75 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2810,12 +2810,20 @@ static const struct am65_cpsw_pdata j721e_cpswxg_pdata = {
 	.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_SGMII),
 };
 
+static const struct am65_cpsw_pdata j784s4_cpswxg_pdata = {
+	.quirks = 0,
+	.ale_dev_id = "am64-cpswxg",
+	.fdqring_mode = K3_RINGACC_RING_MODE_MESSAGE,
+	.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII),
+};
+
 static const struct of_device_id am65_cpsw_nuss_of_mtable[] = {
 	{ .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0},
 	{ .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_pdata},
 	{ .compatible = "ti,am642-cpsw-nuss", .data = &am64x_cpswxg_pdata},
 	{ .compatible = "ti,j7200-cpswxg-nuss", .data = &j7200_cpswxg_pdata},
 	{ .compatible = "ti,j721e-cpswxg-nuss", .data = &j721e_cpswxg_pdata},
+	{ .compatible = "ti,j784s4-cpswxg-nuss", .data = &j784s4_cpswxg_pdata},
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, am65_cpsw_nuss_of_mtable);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpsw: Enable USXGMII mode for J784S4 CPSW9G
  2023-04-04  6:14 [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G Siddharth Vadapalli
  2023-04-04  6:14 ` [PATCH net-next v3 1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config() Siddharth Vadapalli
  2023-04-04  6:14 ` [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G Siddharth Vadapalli
@ 2023-04-04  6:14 ` Siddharth Vadapalli
  2023-04-08  2:50 ` [PATCH net-next v3 0/3] Add support " patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2023-04-04  6:14 UTC (permalink / raw
  To: davem, edumazet, kuba, linux, pabeni, rogerq
  Cc: netdev, linux-kernel, linux-arm-kernel, srk, s-vadapalli

TI's J784S4 SoC supports USXGMII mode. Add USXGMII mode to the
extra_modes member of the J784S4 SoC data.

Configure MAC control register for supporting USXGMII mode and add
MAC_5000FD in the "mac_capabilities" member of struct "phylink_config".

Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index f1e83d49de75..cf7bef5e3e22 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1514,6 +1514,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in
 			cpsw_sl_ctl_clr(port->slave.mac_sl, CPSW_SL_CTL_EXT_EN);
 		}
 
+		if (state->interface == PHY_INTERFACE_MODE_USXGMII) {
+			cpsw_sl_ctl_set(port->slave.mac_sl,
+					CPSW_SL_CTL_XGIG | CPSW_SL_CTL_XGMII_EN);
+		} else {
+			cpsw_sl_ctl_clr(port->slave.mac_sl,
+					CPSW_SL_CTL_XGIG | CPSW_SL_CTL_XGMII_EN);
+		}
+
 		writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE,
 		       port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG);
 	}
@@ -2171,7 +2179,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
 	/* Configuring Phylink */
 	port->slave.phylink_config.dev = &port->ndev->dev;
 	port->slave.phylink_config.type = PHYLINK_NETDEV;
-	port->slave.phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD;
+	port->slave.phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
+						      MAC_1000FD | MAC_5000FD;
 	port->slave.phylink_config.mac_managed_pm = true; /* MAC does PM */
 
 	switch (port->slave.phy_if) {
@@ -2189,6 +2198,7 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
 
 	case PHY_INTERFACE_MODE_QSGMII:
 	case PHY_INTERFACE_MODE_SGMII:
+	case PHY_INTERFACE_MODE_USXGMII:
 		if (common->pdata.extra_modes & BIT(port->slave.phy_if)) {
 			__set_bit(port->slave.phy_if,
 				  port->slave.phylink_config.supported_interfaces);
@@ -2814,7 +2824,7 @@ static const struct am65_cpsw_pdata j784s4_cpswxg_pdata = {
 	.quirks = 0,
 	.ale_dev_id = "am64-cpswxg",
 	.fdqring_mode = K3_RINGACC_RING_MODE_MESSAGE,
-	.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII),
+	.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_USXGMII),
 };
 
 static const struct of_device_id am65_cpsw_nuss_of_mtable[] = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G
  2023-04-04  6:14 ` [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G Siddharth Vadapalli
@ 2023-04-04 11:38   ` Roger Quadros
  0 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2023-04-04 11:38 UTC (permalink / raw
  To: Siddharth Vadapalli, davem, edumazet, kuba, linux, pabeni
  Cc: netdev, linux-kernel, linux-arm-kernel, srk



On 04/04/2023 09:14, Siddharth Vadapalli wrote:
> TI's J784S4 SoC supports QSGMII mode with the CPSW9G instance of the
> CPSW Ethernet Switch. Add a new compatible for J784S4 SoC and enable
> QSGMII support for it by adding QSGMII mode to the extra_modes member of
> the "j784s4_cpswxg_pdata" SoC data.
> 
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G
  2023-04-04  6:14 [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G Siddharth Vadapalli
                   ` (2 preceding siblings ...)
  2023-04-04  6:14 ` [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpsw: Enable USXGMII mode " Siddharth Vadapalli
@ 2023-04-08  2:50 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-08  2:50 UTC (permalink / raw
  To: Siddharth Vadapalli
  Cc: davem, edumazet, kuba, linux, pabeni, rogerq, netdev,
	linux-kernel, linux-arm-kernel, srk

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 4 Apr 2023 11:44:56 +0530 you wrote:
> Hello,
> 
> This series adds a new compatible to am65-cpsw driver for the CPSW9G
> instance of the CPSW Ethernet Switch on TI's J784S4 SoC which has 8
> external ports and 1 internal host port.
> 
> The CPSW9G instance supports QSGMII and USXGMII modes for which driver
> support is added.
> 
> [...]

Here is the summary with links:
  - [net-next,v3,1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config()
    https://git.kernel.org/netdev/net-next/c/ce639b767139
  - [net-next,v3,2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G
    https://git.kernel.org/netdev/net-next/c/4e003d61e795
  - [net-next,v3,3/3] net: ethernet: ti: am65-cpsw: Enable USXGMII mode for J784S4 CPSW9G
    https://git.kernel.org/netdev/net-next/c/8e672b560e0b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-08  2:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04  6:14 [PATCH net-next v3 0/3] Add support for J784S4 CPSW9G Siddharth Vadapalli
2023-04-04  6:14 ` [PATCH net-next v3 1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config() Siddharth Vadapalli
2023-04-04  6:14 ` [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpsw: Enable QSGMII for J784S4 CPSW9G Siddharth Vadapalli
2023-04-04 11:38   ` Roger Quadros
2023-04-04  6:14 ` [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpsw: Enable USXGMII mode " Siddharth Vadapalli
2023-04-08  2:50 ` [PATCH net-next v3 0/3] Add support " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).