1. 06 Jan, 2020 9 commits
    • Vladimir Oltean's avatar
      net: dsa: felix: Add PCS operations for PHYLINK · bdeced75
      Vladimir Oltean authored
      Layerscape SoCs traditionally expose the SerDes configuration/status for
      Ethernet protocols (PCS for SGMII/USXGMII/10GBase-R etc etc) in a register
      format that is compatible with clause 22 or clause 45 (depending on
      SerDes protocol). Each MAC has its own internal MDIO bus on which there
      is one or more of these PCS's, responding to commands at a configurable
      PHY address. The per-port internal MDIO bus (which is just for PCSs) is
      totally separate and has nothing to do with the dedicated external MDIO
      controller (which is just for PHYs), but the register map for the MDIO
      controller is the same.
      
      The VSC9959 (Felix) switch instantiated in the LS1028A is integrated
      in hardware with the ENETC PCS of its DSA master, and reuses its MDIO
      controller driver, so Felix has been made to depend on it in Kconfig.
      
       +------------------------------------------------------------------------+
       |                   +--------+ GMII (typically disabled via RCW)         |
       | ENETC PCI         |  ENETC |--------------------------+                |
       | Root Complex      | port 3 |-----------------------+  |                |
       | Integrated        +--------+                       |  |                |
       | Endpoint                                           |  |                |
       |                   +--------+ 2.5G GMII             |  |                |
       |                   |  ENETC |--------------+        |  |                |
       |                   | port 2 |-----------+  |        |  |                |
       |                   +--------+           |  |        |  |                |
       |                                     +--------+  +--------+             |
       |                                     |  Felix |  |  Felix |             |
       |                                     | port 4 |  | port 5 |             |
       |                                     +--------+  +--------+             |
       |                                                                        |
       | +--------+  +--------+  +--------+  +--------+  +--------+  +--------+ |
       | |  ENETC |  |  ENETC |  |  Felix |  |  Felix |  |  Felix |  |  Felix | |
       | | port 0 |  | port 1 |  | port 0 |  | port 1 |  | port 2 |  | port 3 | |
       +------------------------------------------------------------------------+
       |    ||||  SerDes |          ||||        ||||        ||||        ||||    |
       | +--------+block |       +--------------------------------------------+ |
       | |  ENETC |      |       |       ENETC port 2 internal MDIO bus       | |
       | | port 0 |      |       |  PCS         PCS          PCS        PCS   | |
       | |   PCS  |      |       |   0           1            2          3    | |
       +-----------------|------------------------------------------------------+
              v          v           v           v            v          v
           SGMII/      RGMII    QSGMII/QSXGMII/4xSGMII/4x1000Base-X/4x2500Base-X
          USXGMII/   (bypasses
        1000Base-X/   SerDes)
        2500Base-X
      
      In the LS1028A SoC described above, the VSC9959 Felix switch is PF5 of
      the ENETC root complex, and has 2 BARs:
      - BAR 4: the switch's effective registers
      - BAR 0: the MDIO controller register map lended from ENETC port 2
               (PF2), for accessing its associated PCS's.
      
      This explanation is necessary because the patch does some renaming
      "pci_bar" -> "switch_pci_bar" for clarity, which would otherwise appear
      a bit obtuse.
      
      The fact that the internal MDIO bus is "borrowed" is relevant because
      the register map is found in PF5 (the switch) but it triggers an access
      fault if PF2 (the ENETC DSA master) is not enabled. This is not treated
      in any way (and I don't think it can be treated).
      
      All of this is so SoC-specific, that it was contained as much as
      possible in the platform-integration file felix_vsc9959.c.
      
      We need to parse and pre-validate the device tree because of 2 reasons:
      - The PHY mode (SerDes protocol) cannot change at runtime due to SoC
        design.
      - There is a circular dependency in that we need to know what clause the
        PCS speaks in order to find it on the internal MDIO bus. But the
        clause of the PCS depends on what phy-mode it is configured for.
      
      The goal of this patch is to make steps towards removing the bootloader
      dependency for SGMII PCS pre-configuration, as well as to add support
      for monitoring the in-band SGMII AN between the PCS and the system-side
      link partner (PHY or other MAC).
      
      In practice the bootloader dependency is not completely removed. U-Boot
      pre-programs the PHY address at which each PCS can be found on the
      internal MDIO bus (MDEV_PORT). This is needed because the PCS of each
      port has the same out-of-reset PHY address of zero. The SerDes register
      for changing MDEV_PORT is pretty deep in the SoC (outside the addresses
      of the ENETC PCI BARs) and therefore inaccessible to us from here.
      
      Felix VSC9959 and Ocelot VSC7514 are integrated very differently in
      their respective SoCs, and for that reason Felix does not use the Ocelot
      core library for PHYLINK. On one hand we don't want to impose the
      fixed phy-mode limitation to Ocelot, and on the other hand Felix doesn't
      need to force the MAC link speed the way Ocelot does, since the MAC is
      connected to the PCS through a fixed GMII, and the PCS is the one who
      does the rate adaptation at lower link speeds, which the MAC does not
      even need to know about. In fact changing the GMII speed for Felix
      irrecoverably breaks transmission through that port until a reset.
      
      The pair with ENETC port 3 and Felix port 5 is optional and doesn't
      support tagging. When we enable it, swp5 is a regular slave port, albeit
      an internal one. The trouble is that it doesn't work, and that is
      because the DSA PHYLIB adaptation layer doesn't treat fixed-link slave
      ports. So that is yet another reason for wanting to convert Felix to the
      native PHYLINK API.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bdeced75
    • Vladimir Oltean's avatar
      net: mscc: ocelot: export ANA, DEV and QSYS registers to include/soc/mscc · 964ee5c8
      Vladimir Oltean authored
      Since the Felix DSA driver is implementing its own PHYLINK instance due
      to SoC differences, it needs access to the few registers that are
      common, mainly for flow control.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      964ee5c8
    • Vladimir Oltean's avatar
      net: mscc: ocelot: make phy_mode a member of the common struct ocelot_port · ee50d07c
      Vladimir Oltean authored
      The Ocelot switchdev driver and the Felix DSA one need it for different
      reasons. Felix (or at least the VSC9959 instantiation in NXP LS1028A) is
      integrated with the traditional NXP Layerscape PCS design which does not
      support runtime configuration of SerDes protocol. So it needs to
      pre-validate the phy-mode from the device tree and prevent PHYLINK from
      attempting to change it. For this, it needs to cache it in a private
      variable.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ee50d07c
    • Vladimir Oltean's avatar
      enetc: Set MDIO_CFG_HOLD to the recommended value of 2 · d79d3032
      Vladimir Oltean authored
      This increases the MDIO hold time to 5 enet_clk cycles from the previous
      value of 0. This is actually the out-of-reset value, that the driver was
      previously overwriting with 0. Zero worked for the external MDIO, but
      breaks communication with the internal MDIO buses on which the PCS of
      ENETC SI's and Felix switch are found.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d79d3032
    • Claudiu Manoil's avatar
      enetc: Make MDIO accessors more generic and export to include/linux/fsl · 6517798d
      Claudiu Manoil authored
      Within the LS1028A SoC, the register map for the ENETC MDIO controller
      is instantiated a few times: for the central (external) MDIO controller,
      for the internal bus of each standalone ENETC port, and for the internal
      bus of the Felix switch.
      
      Refactoring is needed to support multiple MDIO buses from multiple
      drivers. The enetc_hw structure is made an opaque type and a smaller
      enetc_mdio_priv is created.
      
      'mdio_base' - MDIO registers base address - is being parameterized, to
      be able to work with different MDIO register bases.
      
      The ENETC MDIO bus operations are exported from the fsl-enetc-mdio
      kernel object, the same that registers the central MDIO controller (the
      dedicated PF). The ENETC main driver has been changed to select it, and
      use its exported helpers to further register its private MDIO bus. The
      DSA Felix driver will do the same.
      Signed-off-by: default avatarClaudiu Manoil <claudiu.manoil@nxp.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6517798d
    • Vladimir Oltean's avatar
      net: dsa: Pass pcs_poll flag from driver to PHYLINK · 787cac3f
      Vladimir Oltean authored
      The DSA drivers that implement .phylink_mac_link_state should normally
      register an interrupt for the PCS, from which they should call
      phylink_mac_change(). However not all switches implement this, and those
      who don't should set this flag in dsa_switch in the .setup callback, so
      that PHYLINK will poll for a few ms until the in-band AN link timer
      expires and the PCS state settles.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      787cac3f
    • Vladimir Oltean's avatar
      net: phylink: add support for polling MAC PCS · 1511ed0a
      Vladimir Oltean authored
      Some MAC PCS blocks are unable to provide interrupts when their status
      changes. As we already have support in phylink for polling status, use
      this to provide a hook for MACs to enable polling mode.
      
      The patch idea was picked up from Russell King's suggestion on the macb
      phylink patch thread here [0] but the implementation was changed.
      Instead of introducing a new phylink_start_poll() function, which would
      make the implementation cumbersome for common PHYLINK implementations
      for multiple types of devices, like DSA, just add a boolean property to
      the phylink_config structure, which is just as backwards-compatible.
      
      https://lkml.org/lkml/2019/12/16/603Suggested-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1511ed0a
    • Vladimir Oltean's avatar
      net: phylink: make QSGMII a valid PHY mode for in-band AN · 3a68ba6f
      Vladimir Oltean authored
      QSGMII is a SerDes protocol clocked at 5 Gbaud (4 times higher than
      SGMII which is clocked at 1.25 Gbaud), with the same 8b/10b encoding and
      some extra symbols for synchronization. Logically it offers 4 SGMII
      interfaces multiplexed onto the same physical lanes. Each MAC PCS has
      its own in-band AN process with the system side of the QSGMII PHY, which
      is identical to the regular SGMII AN process.
      
      So allow QSGMII as a valid in-band AN mode, since it is no different
      from software perspective from regular SGMII.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3a68ba6f
    • Vladimir Oltean's avatar
      mii: Add helpers for parsing SGMII auto-negotiation · 6c930994
      Vladimir Oltean authored
      Typically a MAC PCS auto-configures itself after it receives the
      negotiated copper-side link settings from the PHY, but some MAC devices
      are more special and need manual interpretation of the SGMII AN result.
      
      In other cases, the PCS exposes the entire tx_config_reg base page as it
      is transmitted on the wire during auto-negotiation, so it makes sense to
      be able to decode the equivalent lp_advertised bit mask from the raw u16
      (of course, "lp" considering the PCS to be the local PHY).
      
      Therefore, add the bit definitions for the SGMII registers 4 and 5
      (local device ability, link partner ability), as well as a link_mode
      conversion helper that can be used to feed the AN results into
      phy_resolve_aneg_linkmode.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6c930994
  2. 05 Jan, 2020 31 commits