Skip to content

Commit 5da1289

Browse files
committed
Merge branch 'add-cpswxg-sgmii-support-for-j7200-and-j721e'
Siddharth Vadapalli says: ==================== Add CPSWxG SGMII support for J7200 and J721E This series adds support to configure the CPSW Ethernet Switch in SGMII mode, using the am65-cpsw-nuss driver. SGMII mode is supported by the CPSWxG instances on TI's J7200 and J721E SoCs. Thus, SGMII mode is added in the list of extra_modes for the appropriate compatibles corresponding to the aforementioned SoCs. Additionally, the method of setting the supported interface via struct "phylink_config" is simplified by converting the IF/ELSE statements to SWITCH statements. ==================== Link: https://lore.kernel.org/r/20230321111958.2800005-1-s-vadapalli@ti.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 603c334 + 186016d commit 5da1289

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C
7777

7878
#define AM65_CPSW_SGMII_CONTROL_REG 0x010
79+
#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018
7980
#define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0)
8081

8182
#define AM65_CPSW_CTL_VLAN_AWARE BIT(1)
@@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in
14961497
struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave);
14971498
struct am65_cpsw_common *common = port->common;
14981499

1499-
if (common->pdata.extra_modes & BIT(state->interface))
1500+
if (common->pdata.extra_modes & BIT(state->interface)) {
1501+
if (state->interface == PHY_INTERFACE_MODE_SGMII)
1502+
writel(ADVERTISE_SGMII,
1503+
port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG);
1504+
15001505
writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE,
15011506
port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG);
1507+
}
15021508
}
15031509

15041510
static void am65_cpsw_nuss_mac_link_down(struct phylink_config *config, unsigned int mode,
@@ -1539,6 +1545,8 @@ static void am65_cpsw_nuss_mac_link_up(struct phylink_config *config, struct phy
15391545

15401546
if (speed == SPEED_1000)
15411547
mac_control |= CPSW_SL_CTL_GIG;
1548+
if (interface == PHY_INTERFACE_MODE_SGMII)
1549+
mac_control |= CPSW_SL_CTL_EXT_EN;
15421550
if (speed == SPEED_10 && phy_interface_mode_is_rgmii(interface))
15431551
/* Can be used with in band mode only */
15441552
mac_control |= CPSW_SL_CTL_EXT_EN;
@@ -2143,15 +2151,31 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
21432151
port->slave.phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD;
21442152
port->slave.phylink_config.mac_managed_pm = true; /* MAC does PM */
21452153

2146-
if (phy_interface_mode_is_rgmii(port->slave.phy_if)) {
2154+
switch (port->slave.phy_if) {
2155+
case PHY_INTERFACE_MODE_RGMII:
2156+
case PHY_INTERFACE_MODE_RGMII_ID:
2157+
case PHY_INTERFACE_MODE_RGMII_RXID:
2158+
case PHY_INTERFACE_MODE_RGMII_TXID:
21472159
phy_interface_set_rgmii(port->slave.phylink_config.supported_interfaces);
2148-
} else if (port->slave.phy_if == PHY_INTERFACE_MODE_RMII) {
2160+
break;
2161+
2162+
case PHY_INTERFACE_MODE_RMII:
21492163
__set_bit(PHY_INTERFACE_MODE_RMII,
21502164
port->slave.phylink_config.supported_interfaces);
2151-
} else if (common->pdata.extra_modes & BIT(port->slave.phy_if)) {
2152-
__set_bit(PHY_INTERFACE_MODE_QSGMII,
2153-
port->slave.phylink_config.supported_interfaces);
2154-
} else {
2165+
break;
2166+
2167+
case PHY_INTERFACE_MODE_QSGMII:
2168+
case PHY_INTERFACE_MODE_SGMII:
2169+
if (common->pdata.extra_modes & BIT(port->slave.phy_if)) {
2170+
__set_bit(port->slave.phy_if,
2171+
port->slave.phylink_config.supported_interfaces);
2172+
} else {
2173+
dev_err(dev, "selected phy-mode is not supported\n");
2174+
return -EOPNOTSUPP;
2175+
}
2176+
break;
2177+
2178+
default:
21552179
dev_err(dev, "selected phy-mode is not supported\n");
21562180
return -EOPNOTSUPP;
21572181
}
@@ -2753,14 +2777,14 @@ static const struct am65_cpsw_pdata j7200_cpswxg_pdata = {
27532777
.quirks = 0,
27542778
.ale_dev_id = "am64-cpswxg",
27552779
.fdqring_mode = K3_RINGACC_RING_MODE_RING,
2756-
.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII),
2780+
.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_SGMII),
27572781
};
27582782

27592783
static const struct am65_cpsw_pdata j721e_cpswxg_pdata = {
27602784
.quirks = 0,
27612785
.ale_dev_id = "am64-cpswxg",
27622786
.fdqring_mode = K3_RINGACC_RING_MODE_MESSAGE,
2763-
.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII),
2787+
.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_SGMII),
27642788
};
27652789

27662790
static const struct of_device_id am65_cpsw_nuss_of_mtable[] = {

0 commit comments

Comments
 (0)