* [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch
@ 2025-02-07 2:43 Tristram.Ha
2025-02-07 2:43 ` [PATCH RFC net-next v2 1/3] net: pcs: xpcs: Activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477 Tristram.Ha
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Tristram.Ha @ 2025-02-07 2:43 UTC (permalink / raw)
To: Russell King, Woojung Huh, Andrew Lunn, Vladimir Oltean,
Heiner Kallweit, Maxime Chevallier
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
UNGLinuxDriver, netdev, linux-kernel, Tristram Ha
From: Tristram Ha <tristram.ha@microchip.com>
The KSZ9477 switch DSA driver uses XPCS driver to operate its SGMII
port. After the previous XPCS driver updates are added the XPCS patch
can be used to activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477.
The KSZ9477 driver will generate a special value for PMA device ids to
activate the new code.
This will require the previous 4 patches from Russell King about
"net: xpcs: cleanups and partial support for KSZ9477."
Tristram Ha (3):
net: pcs: xpcs: Activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477
net: dsa: microchip: Add SGMII port support to KSZ9477 switch
net: dsa: microchip: Add SGMII port support to KSZ9477 switch
drivers/net/dsa/microchip/Kconfig | 1 +
drivers/net/dsa/microchip/ksz9477.c | 98 +++++++++++++++++++++++++-
drivers/net/dsa/microchip/ksz9477.h | 4 +-
drivers/net/dsa/microchip/ksz_common.c | 36 ++++++++--
drivers/net/dsa/microchip/ksz_common.h | 22 +++++-
drivers/net/pcs/pcs-xpcs.c | 2 +
include/linux/pcs/pcs-xpcs.h | 1 +
7 files changed, 157 insertions(+), 7 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH RFC net-next v2 1/3] net: pcs: xpcs: Activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477 2025-02-07 2:43 [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch Tristram.Ha @ 2025-02-07 2:43 ` Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch Tristram.Ha ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Tristram.Ha @ 2025-02-07 2:43 UTC (permalink / raw) To: Russell King, Woojung Huh, Andrew Lunn, Vladimir Oltean, Heiner Kallweit, Maxime Chevallier Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel, Tristram Ha From: Tristram Ha <tristram.ha@microchip.com> Microchip KSZ9477 SGMII uses old XPCS IP and requires special code to operate correctly. A special value from PMA device ids will be used to activate DW_XPCS_SGMII_MODE_MAC_MANUL. Signed-off-by: Tristram Ha <tristram.ha@microchip.com> --- drivers/net/pcs/pcs-xpcs.c | 2 ++ include/linux/pcs/pcs-xpcs.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index d522e4a5a138..5aad67ff4a4f 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1482,6 +1482,8 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev) xpcs->sgmii_10_100_8bit = DW_XPCS_SGMII_10_100_8BIT; xpcs->sgmii_mode = DW_XPCS_SGMII_MODE_PHY_HW; } else { + if (xpcs->info.pma == MICROCHIP_KSZ9477_PMA_ID) + xpcs->sgmii_mode = DW_XPCS_SGMII_MODE_MAC_MANUAL; xpcs->need_reset = true; } diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 733f4ddd2ef1..637d5356a961 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -39,6 +39,7 @@ enum dw_xpcs_pma_id { DW_XPCS_PMA_GEN5_10G_ID, DW_XPCS_PMA_GEN5_12G_ID, WX_TXGBE_XPCS_PMA_10G_ID = 0x0018fc80, + MICROCHIP_KSZ9477_PMA_ID = 0x00229477, }; struct dw_xpcs_info { -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch 2025-02-07 2:43 [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 1/3] net: pcs: xpcs: Activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477 Tristram.Ha @ 2025-02-07 2:43 ` Tristram.Ha 2025-02-07 16:52 ` Vladimir Oltean 2025-02-07 2:43 ` [PATCH RFC net-next v2 3/3] " Tristram.Ha 2025-02-07 9:32 ` [PATCH RFC net-next v2 0/3] " Russell King (Oracle) 3 siblings, 1 reply; 7+ messages in thread From: Tristram.Ha @ 2025-02-07 2:43 UTC (permalink / raw) To: Russell King, Woojung Huh, Andrew Lunn, Vladimir Oltean, Heiner Kallweit, Maxime Chevallier Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel, Tristram Ha From: Tristram Ha <tristram.ha@microchip.com> The KSZ9477 DSA driver uses XPCS driver to operate its SGMII port. Signed-off-by: Tristram Ha <tristram.ha@microchip.com> --- v2 - update Kconfig to pass compilation test drivers/net/dsa/microchip/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/dsa/microchip/Kconfig b/drivers/net/dsa/microchip/Kconfig index 12a86585a77f..c71d3fd5dfeb 100644 --- a/drivers/net/dsa/microchip/Kconfig +++ b/drivers/net/dsa/microchip/Kconfig @@ -6,6 +6,7 @@ menuconfig NET_DSA_MICROCHIP_KSZ_COMMON select NET_DSA_TAG_NONE select NET_IEEE8021Q_HELPERS select DCB + select PCS_XPCS help This driver adds support for Microchip KSZ8, KSZ9 and LAN937X series switch chips, being KSZ8863/8873, -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch 2025-02-07 2:43 ` [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch Tristram.Ha @ 2025-02-07 16:52 ` Vladimir Oltean 2025-02-07 19:03 ` Tristram.Ha 0 siblings, 1 reply; 7+ messages in thread From: Vladimir Oltean @ 2025-02-07 16:52 UTC (permalink / raw) To: Tristram.Ha Cc: Russell King, Woojung Huh, Andrew Lunn, Heiner Kallweit, Maxime Chevallier, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel On Thu, Feb 06, 2025 at 06:43:15PM -0800, Tristram.Ha@microchip.com wrote: > From: Tristram Ha <tristram.ha@microchip.com> > > The KSZ9477 DSA driver uses XPCS driver to operate its SGMII port. > > Signed-off-by: Tristram Ha <tristram.ha@microchip.com> > --- > v2 > - update Kconfig to pass compilation test > > drivers/net/dsa/microchip/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/dsa/microchip/Kconfig b/drivers/net/dsa/microchip/Kconfig > index 12a86585a77f..c71d3fd5dfeb 100644 > --- a/drivers/net/dsa/microchip/Kconfig > +++ b/drivers/net/dsa/microchip/Kconfig > @@ -6,6 +6,7 @@ menuconfig NET_DSA_MICROCHIP_KSZ_COMMON > select NET_DSA_TAG_NONE > select NET_IEEE8021Q_HELPERS > select DCB > + select PCS_XPCS > help > This driver adds support for Microchip KSZ8, KSZ9 and > LAN937X series switch chips, being KSZ8863/8873, > -- > 2.34.1 > I'm not sure if you split this change intentionally or by mistake, but either way, you need to squash this patch into 3/3. ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch 2025-02-07 16:52 ` Vladimir Oltean @ 2025-02-07 19:03 ` Tristram.Ha 0 siblings, 0 replies; 7+ messages in thread From: Tristram.Ha @ 2025-02-07 19:03 UTC (permalink / raw) To: olteanv Cc: linux, Woojung.Huh, andrew, hkallweit1, maxime.chevallier, davem, edumazet, kuba, pabeni, UNGLinuxDriver, netdev, linux-kernel > -----Original Message----- > From: Vladimir Oltean <olteanv@gmail.com> > Sent: Friday, February 7, 2025 8:52 AM > To: Tristram Ha - C24268 <Tristram.Ha@microchip.com> > Cc: Russell King <linux@armlinux.org.uk>; Woojung Huh - C21699 > <Woojung.Huh@microchip.com>; Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit > <hkallweit1@gmail.com>; Maxime Chevallier <maxime.chevallier@bootlin.com>; > David S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; > Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; > UNGLinuxDriver <UNGLinuxDriver@microchip.com>; netdev@vger.kernel.org; linux- > kernel@vger.kernel.org > Subject: Re: [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support > to KSZ9477 switch > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content > is safe > > On Thu, Feb 06, 2025 at 06:43:15PM -0800, Tristram.Ha@microchip.com wrote: > > From: Tristram Ha <tristram.ha@microchip.com> > > > > The KSZ9477 DSA driver uses XPCS driver to operate its SGMII port. > > > > Signed-off-by: Tristram Ha <tristram.ha@microchip.com> > > --- > > v2 > > - update Kconfig to pass compilation test > > > > drivers/net/dsa/microchip/Kconfig | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/net/dsa/microchip/Kconfig b/drivers/net/dsa/microchip/Kconfig > > index 12a86585a77f..c71d3fd5dfeb 100644 > > --- a/drivers/net/dsa/microchip/Kconfig > > +++ b/drivers/net/dsa/microchip/Kconfig > > @@ -6,6 +6,7 @@ menuconfig NET_DSA_MICROCHIP_KSZ_COMMON > > select NET_DSA_TAG_NONE > > select NET_IEEE8021Q_HELPERS > > select DCB > > + select PCS_XPCS > > help > > This driver adds support for Microchip KSZ8, KSZ9 and > > LAN937X series switch chips, being KSZ8863/8873, > > -- > > 2.34.1 > > > > I'm not sure if you split this change intentionally or by mistake, but > either way, you need to squash this patch into 3/3. Will update that. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH RFC net-next v2 3/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch 2025-02-07 2:43 [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 1/3] net: pcs: xpcs: Activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477 Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch Tristram.Ha @ 2025-02-07 2:43 ` Tristram.Ha 2025-02-07 9:32 ` [PATCH RFC net-next v2 0/3] " Russell King (Oracle) 3 siblings, 0 replies; 7+ messages in thread From: Tristram.Ha @ 2025-02-07 2:43 UTC (permalink / raw) To: Russell King, Woojung Huh, Andrew Lunn, Vladimir Oltean, Heiner Kallweit, Maxime Chevallier Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel, Tristram Ha From: Tristram Ha <tristram.ha@microchip.com> The KSZ9477 switch DSA driver uses the XPCS driver to operate its SGMII port. It generates a value when device ids from MDIO_MMD_PMAPMD are checked to activate DW_XPCS_SGMII_MODE_MAC_MANUAL mode so that some special code are used to operate the SGMII port correctly. Signed-off-by: Tristram Ha <tristram.ha@microchip.com> --- v2 - remove sgmii_mutex - remove parentheses in returned value in sgmii check functions - remove sgmii reset function as this is done in XPCS driver - access only 1 16-bit value in SGMII MMD access functions - use phy_interface_or to set capabilities drivers/net/dsa/microchip/ksz9477.c | 98 +++++++++++++++++++++++++- drivers/net/dsa/microchip/ksz9477.h | 4 +- drivers/net/dsa/microchip/ksz_common.c | 36 ++++++++-- drivers/net/dsa/microchip/ksz_common.h | 22 +++++- 4 files changed, 153 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 29fe79ea74cd..861a166c3b4d 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -2,7 +2,7 @@ /* * Microchip KSZ9477 switch driver main logic * - * Copyright (C) 2017-2024 Microchip Technology Inc. + * Copyright (C) 2017-2025 Microchip Technology Inc. */ #include <linux/kernel.h> @@ -161,6 +161,94 @@ static int ksz9477_wait_alu_sta_ready(struct ksz_device *dev) 10, 1000); } +static void port_sgmii_s(struct ksz_device *dev, uint port, u16 devid, u16 reg) +{ + u32 data; + + data = (devid & MII_MMD_CTRL_DEVAD_MASK) << 16; + data |= reg; + ksz_pwrite32(dev, port, REG_PORT_SGMII_ADDR__4, data); +} + +static void port_sgmii_r(struct ksz_device *dev, uint port, u16 devid, u16 reg, + u16 *buf) +{ + port_sgmii_s(dev, port, devid, reg); + ksz_pread16(dev, port, REG_PORT_SGMII_DATA__4 + 2, buf); + + /* Simulate a value to activate DW_XPCS_SGMII_MODE_MAC_MANUAL in the + * XPCS driver. + */ + if (devid == MDIO_MMD_PMAPMD) { + if (reg == MDIO_DEVID1) + *buf = 0x9477; + else if (reg == MDIO_DEVID2) + *buf = 0x22 << 10; + } +} + +static void port_sgmii_w(struct ksz_device *dev, uint port, u16 devid, u16 reg, + u16 buf) +{ + port_sgmii_s(dev, port, devid, reg); + ksz_pwrite32(dev, port, REG_PORT_SGMII_DATA__4, buf); +} + +static int ksz9477_pcs_read(struct mii_bus *bus, int phy, int mmd, int reg) +{ + struct ksz_device *dev = bus->priv; + int port = ksz_get_sgmii_port(dev); + u16 val; + + port_sgmii_r(dev, port, mmd, reg, &val); + return val; +} + +static int ksz9477_pcs_write(struct mii_bus *bus, int phy, int mmd, int reg, + u16 val) +{ + struct ksz_device *dev = bus->priv; + int port = ksz_get_sgmii_port(dev); + + port_sgmii_w(dev, port, mmd, reg, val); + return 0; +} + +int ksz9477_pcs_create(struct ksz_device *dev) +{ + /* This chip has a SGMII port. */ + if (ksz_has_sgmii_port(dev)) { + int port = ksz_get_sgmii_port(dev); + struct ksz_port *p = &dev->ports[port]; + struct phylink_pcs *pcs; + struct mii_bus *bus; + int ret; + + bus = devm_mdiobus_alloc(dev->dev); + if (!bus) + return -ENOMEM; + + bus->name = "ksz_pcs_mdio_bus"; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-pcs", + dev_name(dev->dev)); + bus->read_c45 = &ksz9477_pcs_read; + bus->write_c45 = &ksz9477_pcs_write; + bus->parent = dev->dev; + bus->phy_mask = ~0; + bus->priv = dev; + + ret = devm_mdiobus_register(dev->dev, bus); + if (ret) + return ret; + + pcs = xpcs_create_pcs_mdiodev(bus, 0); + if (IS_ERR(pcs)) + return PTR_ERR(pcs); + p->pcs = pcs; + } + return 0; +} + int ksz9477_reset_switch(struct ksz_device *dev) { u8 data8; @@ -978,6 +1066,14 @@ void ksz9477_get_caps(struct ksz_device *dev, int port, if (dev->info->gbit_capable[port]) config->mac_capabilities |= MAC_1000FD; + + if (ksz_is_sgmii_port(dev, port)) { + struct ksz_port *p = &dev->ports[port]; + + phy_interface_or(config->supported_interfaces, + config->supported_interfaces, + p->pcs->supported_interfaces); + } } int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs) diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h index d2166b0d881e..0d1a6dfda23e 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -2,7 +2,7 @@ /* * Microchip KSZ9477 series Header file * - * Copyright (C) 2017-2022 Microchip Technology Inc. + * Copyright (C) 2017-2025 Microchip Technology Inc. */ #ifndef __KSZ9477_H @@ -97,4 +97,6 @@ void ksz9477_acl_match_process_l2(struct ksz_device *dev, int port, u16 ethtype, u8 *src_mac, u8 *dst_mac, unsigned long cookie, u32 prio); +int ksz9477_pcs_create(struct ksz_device *dev); + #endif diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 89f0796894af..bf2ce48a264e 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2,7 +2,7 @@ /* * Microchip switch driver main logic * - * Copyright (C) 2017-2024 Microchip Technology Inc. + * Copyright (C) 2017-2025 Microchip Technology Inc. */ #include <linux/delay.h> @@ -354,10 +354,26 @@ static void ksz9477_phylink_mac_link_up(struct phylink_config *config, int speed, int duplex, bool tx_pause, bool rx_pause); +static struct phylink_pcs * +ksz_phylink_mac_select_pcs(struct phylink_config *config, + phy_interface_t interface) +{ + struct dsa_port *dp = dsa_phylink_to_port(config); + struct ksz_device *dev = dp->ds->priv; + struct ksz_port *p = &dev->ports[dp->index]; + + if (ksz_is_sgmii_port(dev, dp->index) && + (interface == PHY_INTERFACE_MODE_SGMII || + interface == PHY_INTERFACE_MODE_1000BASEX)) + return p->pcs; + return NULL; +} + static const struct phylink_mac_ops ksz9477_phylink_mac_ops = { .mac_config = ksz_phylink_mac_config, .mac_link_down = ksz_phylink_mac_link_down, .mac_link_up = ksz9477_phylink_mac_link_up, + .mac_select_pcs = ksz_phylink_mac_select_pcs, }; static const struct ksz_dev_ops ksz9477_dev_ops = { @@ -395,6 +411,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .reset = ksz9477_reset_switch, .init = ksz9477_switch_init, .exit = ksz9477_switch_exit, + .pcs_create = ksz9477_pcs_create, }; static const struct phylink_mac_ops lan937x_phylink_mac_ops = { @@ -1035,8 +1052,7 @@ static const struct regmap_range ksz9477_valid_regs[] = { regmap_reg_range(0x701b, 0x701b), regmap_reg_range(0x701f, 0x7020), regmap_reg_range(0x7030, 0x7030), - regmap_reg_range(0x7200, 0x7203), - regmap_reg_range(0x7206, 0x7207), + regmap_reg_range(0x7200, 0x7207), regmap_reg_range(0x7300, 0x7301), regmap_reg_range(0x7400, 0x7401), regmap_reg_range(0x7403, 0x7403), @@ -1552,6 +1568,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { true, false, false}, .gbit_capable = {true, true, true, true, true, true, true}, .ptp_capable = true, + .sgmii_port = 7, .wr_table = &ksz9477_register_set, .rd_table = &ksz9477_register_set, }, @@ -1944,6 +1961,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .internal_phy = {true, true, true, true, true, false, false}, .gbit_capable = {true, true, true, true, true, true, true}, + .sgmii_port = 7, .wr_table = &ksz9477_register_set, .rd_table = &ksz9477_register_set, }, @@ -2067,7 +2085,7 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port) spin_unlock(&mib->stats64_lock); - if (dev->info->phy_errata_9477) { + if (dev->info->phy_errata_9477 && !ksz_is_sgmii_port(dev, port)) { ret = ksz9477_errata_monitor(dev, port, raw->tx_late_col); if (ret) dev_err(dev->dev, "Failed to monitor transmission halt\n"); @@ -2775,6 +2793,12 @@ static int ksz_setup(struct dsa_switch *ds) if (ret) return ret; + if (ksz_has_sgmii_port(dev) && dev->dev_ops->pcs_create) { + ret = dev->dev_ops->pcs_create(dev); + if (ret) + return ret; + } + /* set broadcast storm protection 10% rate */ regmap_update_bits(ksz_regmap_16(dev), regs[S_BROADCAST_CTRL], BROADCAST_STORM_RATE, @@ -3613,6 +3637,10 @@ static void ksz_phylink_mac_config(struct phylink_config *config, if (dev->info->internal_phy[port]) return; + /* No need to configure XMII control register when using SGMII. */ + if (ksz_is_sgmii_port(dev, port)) + return; + if (phylink_autoneg_inband(mode)) { dev_err(dev->dev, "In-band AN not supported!\n"); return; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index af17a9c030d4..963dd3b3909b 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Microchip switch driver common header * - * Copyright (C) 2017-2024 Microchip Technology Inc. + * Copyright (C) 2017-2025 Microchip Technology Inc. */ #ifndef __KSZ_COMMON_H @@ -10,6 +10,7 @@ #include <linux/etherdevice.h> #include <linux/kernel.h> #include <linux/mutex.h> +#include <linux/pcs/pcs-xpcs.h> #include <linux/phy.h> #include <linux/regmap.h> #include <net/dsa.h> @@ -93,6 +94,7 @@ struct ksz_chip_data { bool internal_phy[KSZ_MAX_NUM_PORTS]; bool gbit_capable[KSZ_MAX_NUM_PORTS]; bool ptp_capable; + u8 sgmii_port; const struct regmap_access_table *wr_table; const struct regmap_access_table *rd_table; }; @@ -141,6 +143,7 @@ struct ksz_port { void *acl_priv; struct ksz_irq pirq; u8 num; + struct phylink_pcs *pcs; #if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP) struct hwtstamp_config tstamp_config; bool hwts_tx_en; @@ -440,6 +443,8 @@ struct ksz_dev_ops { int (*reset)(struct ksz_device *dev); int (*init)(struct ksz_device *dev); void (*exit)(struct ksz_device *dev); + + int (*pcs_create)(struct ksz_device *dev); }; struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); @@ -731,6 +736,21 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port) dev->chip_id == LAN9372_CHIP_ID) && port == KSZ_PORT_4; } +static inline int ksz_get_sgmii_port(struct ksz_device *dev) +{ + return dev->info->sgmii_port - 1; +} + +static inline bool ksz_has_sgmii_port(struct ksz_device *dev) +{ + return dev->info->sgmii_port > 0; +} + +static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port) +{ + return dev->info->sgmii_port == port + 1; +} + /* STP State Defines */ #define PORT_TX_ENABLE BIT(2) #define PORT_RX_ENABLE BIT(1) -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch 2025-02-07 2:43 [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch Tristram.Ha ` (2 preceding siblings ...) 2025-02-07 2:43 ` [PATCH RFC net-next v2 3/3] " Tristram.Ha @ 2025-02-07 9:32 ` Russell King (Oracle) 3 siblings, 0 replies; 7+ messages in thread From: Russell King (Oracle) @ 2025-02-07 9:32 UTC (permalink / raw) To: Tristram.Ha Cc: Woojung Huh, Andrew Lunn, Vladimir Oltean, Heiner Kallweit, Maxime Chevallier, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel On Thu, Feb 06, 2025 at 06:43:13PM -0800, Tristram.Ha@microchip.com wrote: > The KSZ9477 switch DSA driver uses XPCS driver to operate its SGMII > port. After the previous XPCS driver updates are added the XPCS patch > can be used to activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477. > > The KSZ9477 driver will generate a special value for PMA device ids to > activate the new code. > > This will require the previous 4 patches from Russell King about > "net: xpcs: cleanups and partial support for KSZ9477." Great, thanks for using that work. It would be helpful if you could reply to my posting with reviewed/tested-by as appropriate please. Thanks again. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-02-07 19:03 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-02-07 2:43 [PATCH RFC net-next v2 0/3] Add SGMII port support to KSZ9477 switch Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 1/3] net: pcs: xpcs: Activate DW_XPCS_SGMII_MODE_MAC_MANUAL for KSZ9477 Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 2/3] net: dsa: microchip: Add SGMII port support to KSZ9477 switch Tristram.Ha 2025-02-07 16:52 ` Vladimir Oltean 2025-02-07 19:03 ` Tristram.Ha 2025-02-07 2:43 ` [PATCH RFC net-next v2 3/3] " Tristram.Ha 2025-02-07 9:32 ` [PATCH RFC net-next v2 0/3] " Russell King (Oracle)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox