Skip to content
  • Thomas Petazzoni's avatar
    net: mvneta: properly configure the MAC <-> PHY connection in all situations · 3f1dd4bc
    Thomas Petazzoni authored
    Commit 5445eaf3
    
     ('mvneta: Try to fix mvneta when compiled as
    module') fixed the mvneta driver to make it work properly when loaded
    as a module in SGMII configuration, which was tested successful by the
    author on the Armada XP OpenBlocks AX3, which uses SGMII.
    
    However, some other platforms, namely the Armada XP GP don't use
    SGMII, but a QSGMII connection between the MAC and the PHY, and this
    case was not supported by the mvneta driver, which was relying on
    configuration put in place by the bootloader. While this works when
    the mvneta driver is built-in (because clocks are not gated), it
    breaks when mvneta is built as a module, because the clock is gated
    (all configuration is lost) and then re-enabled when the mvneta driver
    is loaded.
    
    In order to support all of RGMII, SGMII and QSGMII, this commit
    reworks how the PHY interface configuration is done, and simplifies
    it: it removes the mvneta_port_sgmii_config() and
    mvneta_gmac_rgmii_set() functions, which were strange because
    mvneta_gmac_rgmii_set() was called in all cases, even for SGMII
    configurations. Also, the mvneta_gmac_rgmii_set() function was taking
    a boolean as argument, which was always true.
    
    Instead, all the PHY interface configuration logic is moved into the
    mvneta_port_power_up() function, in a much simpler 'switch' construct,
    with four cases:
    
     - QSGMII: the RGMIIEn bit, the PCSEn bit in GMAC_CTRL_2 are set, and
       the SERDES is configured in QSGMII. Technically speaking,
       configuring the SERDES of the first port would be sufficient, but
       it is simpler to do it on all ports.
    
     - SGMII: the RGMIIEn bit, the PCSEn bit in GMAC_CTRL_2 are set, and
       the SERDES is configured as SGMII.
    
     - RGMII: the RGMIIEn bit in GMAC_CTRL_2 is set. The PCSEn bit is kept
       cleared, and no SERDES configuration is done, because RGMII is not
       using SERDES lanes.
    
     - other: an error is returned. For this reason, the
       mvneta_port_power_up() now returns an int instead of nothing, and
       the return value is checked by mvneta_probe().
    
    This has been successfully tested on:
    
     * Armada XP DB, which has two RGMII and two SGMII connections
     * Armada XP GP, which uses QSGMII for its four interfaces
     * Armada 370 Mirabox, which has two RGMII connections
    
    Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    3f1dd4bc