net: dsa: b53: SerDes support
v2 cover net: dsa: b53: SerDes support
Hi all,
This patch series adds support for the SerDes found on NorthStar Plus (NSP) which allows us to use the SFP port on the BCM958625HR board (and other similar designs).
Changes in v2:
- migrate to threaded interrupt (Andrew)
- fixed a case where MLO_AN_FIXED's mac_config would still call into the serdes_config callback
- added an additional check on the phylink interface in mac_config
- default to ARCH_BCM_NSP instead of ARCH_BCM_IPROC which is really the NSP Kconfig bit we want
Florian Fainelli (5):
net: dsa: b53: Add ability to enable/disable port interrupts
net: dsa: b53: Make SRAB driver manage port interrupts
net: dsa: b53: Add helper to set link parameters
net: dsa: b53: Add PHYLINK support
net: dsa: b53: Add SerDes support
drivers/net/dsa/b53/Kconfig | 7 + drivers/net/dsa/b53/Makefile | 1 + drivers/net/dsa/b53/b53_common.c | 246 +++++++++++++++++++++++++++---- drivers/net/dsa/b53/b53_priv.h | 36 +++++ drivers/net/dsa/b53/b53_serdes.c | 217 +++++++++++++++++++++++++++ drivers/net/dsa/b53/b53_serdes.h | 121 +++++++++++++++ drivers/net/dsa/b53/b53_srab.c | 210 ++++++++++++++++++++++++++ 7 files changed, 809 insertions(+), 29 deletions(-) create mode 100644 drivers/net/dsa/b53/b53_serdes.c create mode 100644 drivers/net/dsa/b53/b53_serdes.h
Signature · 1 line
2.17.1
PATCH v2 1/5 net: dsa: b53: Add ability to enable/disable port interrupts
Some switches expose individual interrupt line(s) for port specific event(s), allow configuring these interrupts at an appropriate time during port_enable/disable callbacks where all port specific resources are known to be set-up and ready for use.
--- drivers/net/dsa/b53/b53_common.c | 9 +++++++++ drivers/net/dsa/b53/b53_priv.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/net/dsa/b53/b53_common.c +9 -0
@@ -502,8 +502,14 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) {struct b53_device *dev = ds->priv;unsigned int cpu_port = ds->ports[port].cpu_dp->index; +int ret =0 ;u16 pvlan; +if (dev->ops->irq_enable) + ret = dev->ops->irq_enable (dev, port); +if (ret) +return ret; +/* Clear the Rx and Tx disable bits and set to no spanning tree */ b53_write8 (dev,B53_CTRL_PAGE ,B53_PORT_CTRL (port),0 );
@@ -536,6 +542,9 @@ void b53_disable_port(struct dsa_switch *ds, int port, struct phy_device *phy)b53_read8 (dev,B53_CTRL_PAGE ,B53_PORT_CTRL (port), ®); reg |=PORT_CTRL_RX_DISABLE |PORT_CTRL_TX_DISABLE ;b53_write8 (dev,B53_CTRL_PAGE ,B53_PORT_CTRL (port), reg); + +if (dev->ops->irq_disable) + dev->ops->irq_disable (dev, port); }EXPORT_SYMBOL (b53_disable_port);
drivers/net/dsa/b53/b53_priv.h +2 -0
@@ -43,6 +43,8 @@ struct b53_io_ops {int (*write64)(struct b53_device *dev,u8 page,u8 reg,u64 value);int (*phy_read16)(struct b53_device *dev,int addr,int reg,u16 *value);int (*phy_write16)(struct b53_device *dev,int addr,int reg,u16 value); +int (*irq_enable)(struct b53_device *dev,int port); +void (*irq_disable)(struct b53_device *dev,int port); };enum {
Signature · 1 line
2.17.1
PATCH v2 2/5 net: dsa: b53: Make SRAB driver manage port interrupts
In reply to Florian FainelliUpdate the SRAB driver to manage per-port interrupts. Since we cannot sleep during b53_io_ops, schedule a workqueue whenever we get a port specific interrupt. We will later make use of this to call back into PHYLINK when there is e.g: a link state change.
--- drivers/net/dsa/b53/b53_srab.c | 108 +++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+)
drivers/net/dsa/b53/b53_srab.c +108 -0
@@ -22,6 +22,7 @@#include <linux/platform_device.h> #include <linux/platform_data/b53.h> #include <linux/of.h> +#include <linux/workqueue.h> #include "b53_priv.h"
@@ -47,6 +48,7 @@/* command and status register of the SRAB */ #define B53_SRAB_CTRLS 0x40 +#define B53_SRAB_CTRLS_HOST_INTR BIT(1)#define B53_SRAB_CTRLS_RCAREQ BIT(3)#define B53_SRAB_CTRLS_RCAGNT BIT(4)#define B53_SRAB_CTRLS_SW_INIT_DONE BIT(6)
@@ -60,8 +62,17 @@#define B53_SRAB_P7_SLEEP_TIMER BIT(11)#define B53_SRAB_IMP0_SLEEP_TIMER BIT(12) +struct b53_srab_port_priv { +struct work_struct irq_work; +int irq; +bool irq_enabled; +struct b53_device *dev; +unsigned int num; +}; +struct b53_srab_priv {void __iomem *regs; +struct b53_srab_port_priv port_intrs[B53_N_PORTS ]; };static int b53_srab_request_grant (struct b53_device *dev)
@@ -344,6 +355,50 @@ static int b53_srab_write64(struct b53_device *dev, u8 page, u8 reg,return ret; } +static void b53_srab_port_defer (struct work_struct *work) +{ +} + +static irqreturn_t b53_srab_port_isr (int irq,void *dev_id) +{ +struct b53_srab_port_priv *port = dev_id; +struct b53_device *dev = port->dev; +struct b53_srab_priv *priv = dev->priv; + +/* Acknowledge the interrupt */ +writel (BIT (port->num), priv->regs +B53_SRAB_INTR ); + +schedule_work (&port->irq_work); + +return IRQ_HANDLED ; +} + +static int b53_srab_irq_enable (struct b53_device *dev,int port) +{ +struct b53_srab_priv *priv = dev->priv; +struct b53_srab_port_priv *p = &priv->port_intrs[port]; +int ret; + + ret =request_irq (p->irq, b53_srab_port_isr,0 , +dev_name (dev->dev), p); +if (!ret) + p->irq_enabled = true; + +return ret; +} + +static void b53_srab_irq_disable (struct b53_device *dev,int port) +{ +struct b53_srab_priv *priv = dev->priv; +struct b53_srab_port_priv *p = &priv->port_intrs[port]; + +if (p->irq_enabled) { +free_irq (p->irq, p); +cancel_work_sync (&p->irq_work); + p->irq_enabled = false; + } +} +static const struct b53_io_ops b53_srab_ops = { .read8 = b53_srab_read8, .read16 = b53_srab_read16,
@@ -355,6 +410,8 @@ static const struct b53_io_ops b53_srab_ops = { .write32 = b53_srab_write32, .write48 = b53_srab_write48, .write64 = b53_srab_write64, + .irq_enable = b53_srab_irq_enable, + .irq_disable = b53_srab_irq_disable, };static const struct of_device_id b53_srab_of_match[] = {
@@ -379,6 +436,53 @@ static const struct of_device_id b53_srab_of_match[] = { };MODULE_DEVICE_TABLE (of, b53_srab_of_match); +static void b53_srab_intr_set (struct b53_srab_priv *priv,bool set) +{ +u32 reg; + + reg =readl (priv->regs +B53_SRAB_CTRLS ); +if (set) + reg |=B53_SRAB_CTRLS_HOST_INTR ; +else + reg &= ~B53_SRAB_CTRLS_HOST_INTR ; +writel (reg, priv->regs +B53_SRAB_CTRLS ); +} + +static void b53_srab_prepare_irq (struct platform_device *pdev) +{ +struct b53_device *dev =platform_get_drvdata (pdev); +struct b53_srab_priv *priv = dev->priv; +struct b53_srab_port_priv *port; +unsigned int i; +char *name; + +/* Clear all pending interrupts */ +writel (0xffffffff , priv->regs +B53_SRAB_INTR ); + +if (dev->pdata && dev->pdata->chip_id !=BCM58XX_DEVICE_ID ) +return ; + +for (i =0 ; i <B53_N_PORTS ; i++) { + port = &priv->port_intrs[i]; + +/* There is no port 6 */ +if (i ==6 ) +continue ; + + name =kasprintf (GFP_KERNEL ,"link_state_p%d" , i); +if (!name) +return ; + + port->num = i; + port->dev = dev; +INIT_WORK (&port->irq_work, b53_srab_port_defer); + port->irq =platform_get_irq_byname (pdev, name); +kfree (name); + } + +b53_srab_intr_set (priv, true); +} +static int b53_srab_probe (struct platform_device *pdev) {struct b53_platform_data *pdata = pdev->dev.platform_data;
@@ -417,13 +521,17 @@ static int b53_srab_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dev); +b53_srab_prepare_irq (pdev); +return b53_switch_register (dev); }static int b53_srab_remove (struct platform_device *pdev) {struct b53_device *dev =platform_get_drvdata (pdev); +struct b53_srab_priv *priv = dev->priv; +b53_srab_intr_set (priv, false);if (dev)b53_switch_remove (dev);
Signature · 1 line
2.17.1
PATCH v2 3/5 net: dsa: b53: Add helper to set link parameters
In reply to Florian FainelliExtract the logic from b53_adjust_link() responsible for overriding a given port's link, speed, duplex and pause settings and make two helper functions to set the port's configuration and the port's link settings. We will make use of both, as separate functions while adding PHYLINK support next.
--- drivers/net/dsa/b53/b53_common.c | 89 +++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 29 deletions(-)
drivers/net/dsa/b53/b53_common.c +60 -29
@@ -26,6 +26,7 @@#include <linux/module.h> #include <linux/platform_data/b53.h> #include <linux/phy.h> +#include <linux/phylink.h> #include <linux/etherdevice.h> #include <linux/if_bridge.h> #include <net/dsa.h>
@@ -947,33 +948,50 @@ static int b53_setup(struct dsa_switch *ds)return ret; } -static void b53_adjust_link (struct dsa_switch *ds,int port, -struct phy_device *phydev) +static void b53_force_link (struct b53_device *dev,int port,int link) { -struct b53_device *dev = ds->priv; -struct ethtool_eee *p = &dev->ports[port].eee; -u8 rgmii_ctrl =0 , reg =0 , off; - -if (!phy_is_pseudo_fixed_link (phydev)) -return ; +u8 reg, val, off;/* Override the port settings */ if (port == dev->cpu_port) { off =B53_PORT_OVERRIDE_CTRL ; - reg =PORT_OVERRIDE_EN ; + val =PORT_OVERRIDE_EN ; }else { off =B53_GMII_PORT_OVERRIDE_CTRL (port); - reg =GMII_PO_EN ; + val =GMII_PO_EN ; } -/* Set the link UP */ -if (phydev->link) +b53_read8 (dev,B53_CTRL_PAGE , off, ®); + reg |= val; +if (link) reg |=PORT_OVERRIDE_LINK ; +else + reg &= ~PORT_OVERRIDE_LINK ; +b53_write8 (dev,B53_CTRL_PAGE , off, reg); +} + +static void b53_force_port_config (struct b53_device *dev,int port, +int speed,int duplex,int pause) +{ +u8 reg, val, off; + +/* Override the port settings */ +if (port == dev->cpu_port) { + off =B53_PORT_OVERRIDE_CTRL ; + val =PORT_OVERRIDE_EN ; + }else { + off =B53_GMII_PORT_OVERRIDE_CTRL (port); + val =GMII_PO_EN ; + } -if (phydev->duplex ==DUPLEX_FULL ) +b53_read8 (dev,B53_CTRL_PAGE , off, ®); + reg |= val; +if (duplex ==DUPLEX_FULL ) reg |=PORT_OVERRIDE_FULL_DUPLEX ; +else + reg &= ~PORT_OVERRIDE_FULL_DUPLEX ; -switch (phydev->speed) { +switch (speed) {case 2000 : reg |=PORT_OVERRIDE_SPEED_2000M ;/* fallthrough */
@@ -987,21 +1005,41 @@ static void b53_adjust_link(struct dsa_switch *ds, int port, reg |=PORT_OVERRIDE_SPEED_10M ;break ;default : -dev_err (ds->dev,"unknown speed: %d\n" , phydev->speed); +dev_err (dev->dev,"unknown speed: %d\n" , speed);return ; } +if (pause &MLO_PAUSE_RX ) + reg |=PORT_OVERRIDE_RX_FLOW ; +if (pause &MLO_PAUSE_TX ) + reg |=PORT_OVERRIDE_TX_FLOW ; + +b53_write8 (dev,B53_CTRL_PAGE , off, reg); +} + +static void b53_adjust_link (struct dsa_switch *ds,int port, +struct phy_device *phydev) +{ +struct b53_device *dev = ds->priv; +struct ethtool_eee *p = &dev->ports[port].eee; +u8 rgmii_ctrl =0 , reg =0 , off; +int pause; + +if (!phy_is_pseudo_fixed_link (phydev)) +return ; +/* Enable flow control on BCM5301x's CPU port */ if (is5301x (dev) && port == dev->cpu_port) - reg |=PORT_OVERRIDE_RX_FLOW |PORT_OVERRIDE_TX_FLOW ; + pause =MLO_PAUSE_TXRX_MASK ;if (phydev->pause) {if (phydev->asym_pause) - reg |=PORT_OVERRIDE_TX_FLOW ; - reg |=PORT_OVERRIDE_RX_FLOW ; + pause |=MLO_PAUSE_TX ; + pause |=MLO_PAUSE_RX ; } -b53_write8 (dev,B53_CTRL_PAGE , off, reg); +b53_force_port_config (dev, port, phydev->speed, phydev->duplex, pause); +b53_force_link (dev, port, phydev->link);if (is531x5 (dev) &&phy_interface_is_rgmii (phydev)) {if (port ==8 )
@@ -1061,16 +1099,9 @@ static void b53_adjust_link(struct dsa_switch *ds, int port, } }else if (is5301x (dev)) {if (port != dev->cpu_port) { -u8 po_reg =B53_GMII_PORT_OVERRIDE_CTRL (dev->cpu_port); -u8 gmii_po; - -b53_read8 (dev,B53_CTRL_PAGE , po_reg, &gmii_po); - gmii_po |=GMII_PO_LINK | -GMII_PO_RX_FLOW | -GMII_PO_TX_FLOW | -GMII_PO_EN | -GMII_PO_SPEED_2000M ; -b53_write8 (dev,B53_CTRL_PAGE , po_reg, gmii_po); +b53_force_port_config (dev, dev->cpu_port,2000 , +DUPLEX_FULL ,MLO_PAUSE_TXRX_MASK ); +b53_force_link (dev, dev->cpu_port,1 ); } }
Signature · 1 line
2.17.1
PATCH v2 4/5 net: dsa: b53: Add PHYLINK support
In reply to Florian FainelliAdd support for PHYLINK, things are reasonably straight forward since we do not yet support SerDes interfaces, that leaves us with just MLO_AN_PHY and MLO_AN_FIXED to deal with.
--- drivers/net/dsa/b53/b53_common.c | 122 +++++++++++++++++++++++++++++++ drivers/net/dsa/b53/b53_priv.h | 17 +++++ 2 files changed, 139 insertions(+)
drivers/net/dsa/b53/b53_common.c +122 -0
@@ -1109,6 +1109,122 @@ static void b53_adjust_link(struct dsa_switch *ds, int port, p->eee_enabled =b53_eee_init (ds, port, phydev); } +void b53_port_event (struct dsa_switch *ds,int port) +{ +struct b53_device *dev = ds->priv; +bool link; +u16 sts; + +b53_read16 (dev,B53_STAT_PAGE ,B53_LINK_STAT , &sts); + link = !!(sts &BIT (port)); +dsa_port_phylink_mac_change (ds, port, link); +} +EXPORT_SYMBOL (b53_port_event); + +void b53_phylink_validate (struct dsa_switch *ds,int port, +unsigned long *supported, +struct phylink_link_state *state) +{ +struct b53_device *dev = ds->priv; +__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; + +/* Allow all the expected bits */ +phylink_set (mask, Autoneg); +phylink_set_port_modes (mask); +phylink_set (mask, Pause); +phylink_set (mask, Asym_Pause); + +/* With the exclusion of 5325/5365, MII, Reverse MII and 802.3z, we +* support Gigabit, including Half duplex. +*/ +if (state->interface !=PHY_INTERFACE_MODE_MII && + state->interface !=PHY_INTERFACE_MODE_REVMII && + !phy_interface_mode_is_8023z (state->interface) && + !(is5325 (dev) ||is5365 (dev))) { + phylink_set(mask, 1000baseT_Full); + phylink_set(mask, 1000baseT_Half); + } + +if (!phy_interface_mode_is_8023z (state->interface)) { + phylink_set(mask, 10baseT_Half); + phylink_set(mask, 10baseT_Full); + phylink_set(mask, 100baseT_Half); + phylink_set(mask, 100baseT_Full); + } + +bitmap_and (supported, supported, mask, + __ETHTOOL_LINK_MODE_MASK_NBITS); +bitmap_and (state->advertising, state->advertising, mask, + __ETHTOOL_LINK_MODE_MASK_NBITS); + +phylink_helper_basex_speed (state); +} +EXPORT_SYMBOL (b53_phylink_validate); + +int b53_phylink_mac_link_state (struct dsa_switch *ds,int port, +struct phylink_link_state *state) +{ +int ret = -EOPNOTSUPP ; + +return ret; +} +EXPORT_SYMBOL (b53_phylink_mac_link_state); + +void b53_phylink_mac_config (struct dsa_switch *ds,int port, +unsigned int mode, +const struct phylink_link_state *state) +{ +struct b53_device *dev = ds->priv; + +if (mode ==MLO_AN_PHY ) +return ; + +if (mode ==MLO_AN_FIXED ) { +b53_force_port_config (dev, port, state->speed, + state->duplex, state->pause); +return ; + } +} +EXPORT_SYMBOL (b53_phylink_mac_config); + +void b53_phylink_mac_an_restart (struct dsa_switch *ds,int port) +{ +} +EXPORT_SYMBOL (b53_phylink_mac_an_restart); + +void b53_phylink_mac_link_down (struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface) +{ +struct b53_device *dev = ds->priv; + +if (mode ==MLO_AN_PHY ) +return ; + +if (mode ==MLO_AN_FIXED ) { +b53_force_link (dev, port, false); +return ; + } +} +EXPORT_SYMBOL (b53_phylink_mac_link_down); + +void b53_phylink_mac_link_up (struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface, +struct phy_device *phydev) +{ +struct b53_device *dev = ds->priv; + +if (mode ==MLO_AN_PHY ) +return ; + +if (mode ==MLO_AN_FIXED ) { +b53_force_link (dev, port, true); +return ; + } +} +EXPORT_SYMBOL (b53_phylink_mac_link_up); +int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering) {return 0 ;
@@ -1750,6 +1866,12 @@ static const struct dsa_switch_ops b53_switch_ops = { .phy_read = b53_phy_read16, .phy_write = b53_phy_write16, .adjust_link = b53_adjust_link, + .phylink_validate = b53_phylink_validate, + .phylink_mac_link_state = b53_phylink_mac_link_state, + .phylink_mac_config = b53_phylink_mac_config, + .phylink_mac_an_restart = b53_phylink_mac_an_restart, + .phylink_mac_link_down = b53_phylink_mac_link_down, + .phylink_mac_link_up = b53_phylink_mac_link_up, .port_enable = b53_enable_port, .port_disable = b53_disable_port, .get_mac_eee = b53_get_mac_eee,
drivers/net/dsa/b53/b53_priv.h +17 -0
@@ -300,6 +300,23 @@ int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge);void b53_br_leave (struct dsa_switch *ds,int port,struct net_device *bridge);void b53_br_set_stp_state (struct dsa_switch *ds,int port,u8 state);void b53_br_fast_age (struct dsa_switch *ds,int port); +void b53_port_event (struct dsa_switch *ds,int port); +void b53_phylink_validate (struct dsa_switch *ds,int port, +unsigned long *supported, +struct phylink_link_state *state); +int b53_phylink_mac_link_state (struct dsa_switch *ds,int port, +struct phylink_link_state *state); +void b53_phylink_mac_config (struct dsa_switch *ds,int port, +unsigned int mode, +const struct phylink_link_state *state); +void b53_phylink_mac_an_restart (struct dsa_switch *ds,int port); +void b53_phylink_mac_link_down (struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface); +void b53_phylink_mac_link_up (struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface, +struct phy_device *phydev);int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering);int b53_vlan_prepare (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan);
Signature · 1 line
2.17.1
PATCH v2 5/5 net: dsa: b53: Add SerDes support
In reply to Florian FainelliAdd support for the Northstar Plus SerDes which is accessed through a special page of the switch. Since this is something that most people probably will not want to use, make it a configurable option with a default on ARCH_BCM_NSP where it is the most useful currently.
The SerDes supports both SGMII and 1000baseX modes for both lanes, and 2500baseX for one of the lanes, and is internally looking like a seemingly standard MII PHY, except for the few bits that got repurposed.
--- drivers/net/dsa/b53/Kconfig | 7 + drivers/net/dsa/b53/Makefile | 1 + drivers/net/dsa/b53/b53_common.c | 26 ++++ drivers/net/dsa/b53/b53_priv.h | 17 +++ drivers/net/dsa/b53/b53_serdes.c | 217 +++++++++++++++++++++++++++++++ drivers/net/dsa/b53/b53_serdes.h | 121 +++++++++++++++++ drivers/net/dsa/b53/b53_srab.c | 120 +++++++++++++++-- 7 files changed, 500 insertions(+), 9 deletions(-) create mode 100644 drivers/net/dsa/b53/b53_serdes.c create mode 100644 drivers/net/dsa/b53/b53_serdes.h
drivers/net/dsa/b53/Kconfig +7 -0
@@ -35,3 +35,10 @@ config B53_SRAB_DRIVER help Select to enable support for memory-mapped Switch Register Access Bridge Registers (SRAB) like it is found on the BCM53010 + +config B53_SERDES + tristate "B53 SerDes support" + depends on B53 + default ARCH_BCM_NSP + help + Select to enable support for SerDes on e.g: Northstar Plus SoCs.
drivers/net/dsa/b53/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_B53_SPI_DRIVER) += b53_spi.o obj-$(CONFIG_B53_MDIO_DRIVER) += b53_mdio.o obj-$(CONFIG_B53_MMAP_DRIVER) += b53_mmap.o obj-$(CONFIG_B53_SRAB_DRIVER) += b53_srab.o +obj-$(CONFIG_B53_SERDES) += b53_serdes.o
drivers/net/dsa/b53/b53_common.c +26 -0
@@ -765,6 +765,8 @@ static int b53_reset_switch(struct b53_device *priv)memset (priv->vlans,0 ,sizeof (*priv->vlans) * priv->num_vlans);memset (priv->ports,0 ,sizeof (*priv->ports) * priv->num_ports); + priv->serdes_lane =B53_INVALID_LANE ; +return b53_switch_reset (priv); }
@@ -1128,6 +1130,9 @@ void b53_phylink_validate(struct dsa_switch *ds, int port,struct b53_device *dev = ds->priv;__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; +if (dev->ops->serdes_phylink_validate) + dev->ops->serdes_phylink_validate (dev, port, mask, state); +/* Allow all the expected bits */ phylink_set (mask, Autoneg);phylink_set_port_modes (mask);
@@ -1164,8 +1169,13 @@ EXPORT_SYMBOL(b53_phylink_validate);int b53_phylink_mac_link_state (struct dsa_switch *ds,int port,struct phylink_link_state *state) { +struct b53_device *dev = ds->priv;int ret = -EOPNOTSUPP ; +if (phy_interface_mode_is_8023z (state->interface) && + dev->ops->serdes_link_state) + ret = dev->ops->serdes_link_state (dev, port, state); +return ret; }EXPORT_SYMBOL (b53_phylink_mac_link_state);
@@ -1184,11 +1194,19 @@ void b53_phylink_mac_config(struct dsa_switch *ds, int port, state->duplex, state->pause);return ; } + +if (phy_interface_mode_is_8023z (state->interface) && + dev->ops->serdes_config) + dev->ops->serdes_config (dev, port, mode, state); }EXPORT_SYMBOL (b53_phylink_mac_config);void b53_phylink_mac_an_restart (struct dsa_switch *ds,int port) { +struct b53_device *dev = ds->priv; + +if (dev->ops->serdes_an_restart) + dev->ops->serdes_an_restart (dev, port); }EXPORT_SYMBOL (b53_phylink_mac_an_restart);
@@ -1205,6 +1223,10 @@ void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,b53_force_link (dev, port, false);return ; } + +if (phy_interface_mode_is_8023z (interface) && + dev->ops->serdes_link_set) + dev->ops->serdes_link_set (dev, port, mode, interface, false); }EXPORT_SYMBOL (b53_phylink_mac_link_down);
@@ -1222,6 +1244,10 @@ void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,b53_force_link (dev, port, true);return ; } + +if (phy_interface_mode_is_8023z (interface) && + dev->ops->serdes_link_set) + dev->ops->serdes_link_set (dev, port, mode, interface, true); }EXPORT_SYMBOL (b53_phylink_mac_link_up);
drivers/net/dsa/b53/b53_priv.h +17 -0
@@ -29,6 +29,7 @@struct b53_device ;struct net_device ; +struct phylink_link_state ;struct b53_io_ops {int (*read8)(struct b53_device *dev,u8 page,u8 reg,u8 *value);
@@ -45,8 +46,23 @@ struct b53_io_ops {int (*phy_write16)(struct b53_device *dev,int addr,int reg,u16 value);int (*irq_enable)(struct b53_device *dev,int port);void (*irq_disable)(struct b53_device *dev,int port); +u8 (*serdes_map_lane)(struct b53_device *dev,int port); +int (*serdes_link_state)(struct b53_device *dev,int port, +struct phylink_link_state *state); +void (*serdes_config)(struct b53_device *dev,int port, +unsigned int mode, +const struct phylink_link_state *state); +void (*serdes_an_restart)(struct b53_device *dev,int port); +void (*serdes_link_set)(struct b53_device *dev,int port, +unsigned int mode,phy_interface_t interface, +bool link_up); +void (*serdes_phylink_validate)(struct b53_device *dev,int port, +unsigned long *supported, +struct phylink_link_state *state); }; +#define B53_INVALID_LANE 0xff +enum {BCM5325_DEVICE_ID =0x25 ,BCM5365_DEVICE_ID =0x65 ,
@@ -109,6 +125,7 @@ struct b53_device {/* connect specific data */ u8 current_page;struct device *dev; +u8 serdes_lane;/* Master MDIO bus we got probed from */ struct mii_bus *bus;
drivers/net/dsa/b53/b53_serdes.c new file +217 -0
217 lines not on this page · raw message
drivers/net/dsa/b53/b53_serdes.h new file +121 -0
121 lines not on this page · raw message
drivers/net/dsa/b53/b53_srab.c +111 -9
196 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 5 lines · Florian Fainelli
Hi all,
This patch series adds support for the SerDes found on NorthStar Plus (NSP) which allows us to use the SFP port on the BCM958625HR board (and other similar designs).
David, please disregard this version, for some reason I managed to send the incorrect one that does not have the threaded interrupt support.
Quoted 28 lines
Changes in v2:
- migrate to threaded interrupt (Andrew)
- fixed a case where MLO_AN_FIXED'smac_configwould still call into theserdes_configcallback
- added an additional check on the phylink interface inmac_config
- default toARCH_BCM_NSPinstead ofARCH_BCM_IPROCwhich is really the NSPKconfigbit we wantFlorian Fainelli (5):
net: dsa: b53: Add ability to enable/disable port interrupts
net: dsa: b53: Make SRAB driver manage port interrupts
net: dsa: b53: Add helper to set link parameters
net: dsa: b53: Add PHYLINK support
net: dsa: b53: Add SerDes supportdrivers/net/dsa/b53/Kconfig | 7 + drivers/net/dsa/b53/Makefile | 1 + drivers/net/dsa/b53/b53_common.c | 246 +++++++++++++++++++++++++++---- drivers/net/dsa/b53/b53_priv.h | 36 +++++ drivers/net/dsa/b53/b53_serdes.c | 217 +++++++++++++++++++++++++++ drivers/net/dsa/b53/b53_serdes.h | 121 +++++++++++++++ drivers/net/dsa/b53/b53_srab.c | 210 ++++++++++++++++++++++++++ 7 files changed, 809 insertions(+), 29 deletions(-) create mode 100644 drivers/net/dsa/b53/b53_serdes.c create mode 100644 drivers/net/dsa/b53/b53_serdes.h
Signature · 1 line
Florian