aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2013-09-04 10:21:18 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-14 09:54:56 -0400
commit4c54b9db01842eb0f4eb54af6949b7606ea39e7a (patch)
treed2c373c75b2014a4f753d09916c421d02928ce3a /drivers/net/ethernet
parenta22eb149b18ed385c72d527c42dc398c97b6387f (diff)
net: mvneta: properly disable HW PHY polling and ensure adjust_link() works
[ Upstream commit 714086029116b6b0a34e67ba1dd2f0d1cf26770c ] This commit fixes a long-standing bug that has been reported by many users: on some Armada 370 platforms, only the network interface that has been used in U-Boot to tftp the kernel works properly in Linux. The other network interfaces can see a 'link up', but are unable to transmit data. The reports were generally made on the Armada 370-based Mirabox, but have also been given on the Armada 370-RD board. The network MAC in the Armada 370/XP (supported by the mvneta driver in Linux) has a functionality that allows it to continuously poll the PHY and directly update the MAC configuration accordingly (speed, duplex, etc.). The very first versions of the driver submitted for review were using this hardware mechanism, but due to this, the driver was not integrated with the kernel phylib. Following reviews, the driver was changed to use the phylib, and therefore a software based polling. In software based polling, Linux regularly talks to the PHY over the MDIO bus, and sees if the link status has changed. If it's the case then the adjust_link() callback of the driver is called to update the MAC configuration accordingly. However, it turns out that the adjust_link() callback was not configuring the hardware in a completely correct way: while it was setting the speed and duplex bits correctly, it wasn't telling the hardware to actually take into account those bits rather than what the hardware-based PHY polling mechanism has concluded. So, in fact the adjust_link() callback was basically a no-op. However, the network happened to be working because on the network interfaces used by U-Boot for tftp on Armada 370 platforms because the hardware PHY polling was enabled by the bootloader, and left enabled by Linux. However, the second network interface not used for tftp (or both network interfaces if the kernel is loaded from USB, NAND or SD card) didn't had the hardware PHY polling enabled. This patch fixes this situation by: (1) Making sure that the hardware PHY polling is disabled by clearing the MVNETA_PHY_POLLING_ENABLE bit in the MVNETA_UNIT_CONTROL register in the driver ->probe() function. (2) Making sure that the duplex and speed selections made by the adjust_link() callback are taken into account by clearing the MVNETA_GMAC_AN_SPEED_EN and MVNETA_GMAC_AN_DUPLEX_EN bits in the MVNETA_GMAC_AUTONEG_CONFIG register. This patch has been tested on Armada 370 Mirabox, and now both network interfaces are usable after boot. [ Problem introduced by commit c5aff18 ("net: mvneta: driver for Marvell Armada 370/XP network unit") ] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Willy Tarreau <w@1wt.eu> Cc: Jochen De Smet <jochen.armkernel@leahnim.org> Cc: Peter Sanford <psanford@nearbuy.io> Cc: Ethan Tuttle <ethan@ethantuttle.com> Cc: Chény Yves-Gael <yves@cheny.fr> Cc: Ryan Press <ryan@presslab.us> Cc: Simon Guinot <simon.guinot@sequanux.org> Cc: vdonnefort@lacie.com Cc: stable@vger.kernel.org Acked-by: Jason Cooper <jason@lakedaemon.net> Tested-by: Vincent Donnefort <vdonnefort@gmail.com> Tested-by: Yves-Gael Cheny <yves@cheny.fr> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index c96678555233..254f255204f9 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -136,7 +136,9 @@
136#define MVNETA_GMAC_FORCE_LINK_PASS BIT(1) 136#define MVNETA_GMAC_FORCE_LINK_PASS BIT(1)
137#define MVNETA_GMAC_CONFIG_MII_SPEED BIT(5) 137#define MVNETA_GMAC_CONFIG_MII_SPEED BIT(5)
138#define MVNETA_GMAC_CONFIG_GMII_SPEED BIT(6) 138#define MVNETA_GMAC_CONFIG_GMII_SPEED BIT(6)
139#define MVNETA_GMAC_AN_SPEED_EN BIT(7)
139#define MVNETA_GMAC_CONFIG_FULL_DUPLEX BIT(12) 140#define MVNETA_GMAC_CONFIG_FULL_DUPLEX BIT(12)
141#define MVNETA_GMAC_AN_DUPLEX_EN BIT(13)
140#define MVNETA_MIB_COUNTERS_BASE 0x3080 142#define MVNETA_MIB_COUNTERS_BASE 0x3080
141#define MVNETA_MIB_LATE_COLLISION 0x7c 143#define MVNETA_MIB_LATE_COLLISION 0x7c
142#define MVNETA_DA_FILT_SPEC_MCAST 0x3400 144#define MVNETA_DA_FILT_SPEC_MCAST 0x3400
@@ -911,6 +913,13 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
911 /* Assign port SDMA configuration */ 913 /* Assign port SDMA configuration */
912 mvreg_write(pp, MVNETA_SDMA_CONFIG, val); 914 mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
913 915
916 /* Disable PHY polling in hardware, since we're using the
917 * kernel phylib to do this.
918 */
919 val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
920 val &= ~MVNETA_PHY_POLLING_ENABLE;
921 mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
922
914 mvneta_set_ucast_table(pp, -1); 923 mvneta_set_ucast_table(pp, -1);
915 mvneta_set_special_mcast_table(pp, -1); 924 mvneta_set_special_mcast_table(pp, -1);
916 mvneta_set_other_mcast_table(pp, -1); 925 mvneta_set_other_mcast_table(pp, -1);
@@ -2288,7 +2297,9 @@ static void mvneta_adjust_link(struct net_device *ndev)
2288 val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG); 2297 val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
2289 val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED | 2298 val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
2290 MVNETA_GMAC_CONFIG_GMII_SPEED | 2299 MVNETA_GMAC_CONFIG_GMII_SPEED |
2291 MVNETA_GMAC_CONFIG_FULL_DUPLEX); 2300 MVNETA_GMAC_CONFIG_FULL_DUPLEX |
2301 MVNETA_GMAC_AN_SPEED_EN |
2302 MVNETA_GMAC_AN_DUPLEX_EN);
2292 2303
2293 if (phydev->duplex) 2304 if (phydev->duplex)
2294 val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX; 2305 val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;