Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1470380
| From | robert.foss@collabora.com |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 4/5] net: asix: see 802.3 spec for phy reset |
| Date | 2016-08-25 22:20 +0200 |
| Message-ID | <sa9i2-5Ly-15@gated-at.bofh.it> (permalink) |
| References | <sa9i1-5Ly-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Grant Grundler <grundler@chromium.org>
https://lkml.org/lkml/2014/11/11/947
Ben Hutchings is correct. IEEE 802.3 spec section "22.2.4.1.1 Reset" requires
up to 500ms delay. Mitigate the "max" delay by polling the phy until BCM_RESET
bit is clear.
Signed-off-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
---
drivers/net/usb/asix_devices.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 083dc2e..dbcdda2 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -212,6 +212,28 @@ static const struct net_device_ops ax88172_netdev_ops = {
.ndo_set_rx_mode = ax88172_set_multicast,
};
+static void asix_phy_reset(struct usbnet *dev, unsigned int reset_bits)
+{
+ unsigned int timeout = 5000;
+
+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, reset_bits);
+
+ /* give phy_id a chance to process reset */
+ udelay(500);
+
+ /* See IEEE 802.3 "22.2.4.1.1 Reset": 500ms max */
+ while (timeout--) {
+ if (asix_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR)
+ & BMCR_RESET)
+ udelay(100);
+ else
+ return;
+ }
+
+ netdev_err(dev->net, "BMCR_RESET timeout on phy_id %d\n",
+ dev->mii.phy_id);
+}
+
static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
{
int ret = 0;
@@ -258,7 +280,7 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */
dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */
- asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
+ asix_phy_reset(dev, BMCR_RESET);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
mii_nway_restart(&dev->mii);
@@ -900,8 +922,7 @@ static int ax88178_reset(struct usbnet *dev)
} else if (data->phymode == PHY_MODE_RTL8211CL)
rtl8211cl_phy_init(dev);
- asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
- BMCR_RESET | BMCR_ANENABLE);
+ asix_phy_reset(dev, BMCR_RESET | BMCR_ANENABLE);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 0/5] net/usb: asix driver improvements robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 4/5] net: asix: see 802.3 spec for phy reset robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 4/5] net: asix: see 802.3 spec for phy reset robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 3/5] net: asix: Fix AX88772x resume failures robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 1/5] net: asix: Add in_pm parameter robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 3/5] net: asix: Fix AX88772x resume failures robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg robert.foss@collabora.com - 2016-08-25 22:20 +0200
Re: [PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg Robert Foss <robert.foss@collabora.com> - 2016-09-01 18:50 +0200
Re: [PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg Eric Dumazet <eric.dumazet@gmail.com> - 2016-09-01 23:10 +0200
Re: [PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg Grant Grundler <grundler@google.com> - 2016-09-06 18:50 +0200
Re: [PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg Robert Foss <robert.foss@collabora.com> - 2016-09-06 23:50 +0200
Re: [PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg Eric Dumazet <eric.dumazet@gmail.com> - 2016-09-01 18:50 +0200
[PATCH v3 2/5] net: asix: Avoid looping when the device is disconnected robert.foss@collabora.com - 2016-08-25 22:20 +0200
[PATCH v3 1/5] net: asix: Add in_pm parameter robert.foss@collabora.com - 2016-08-25 22:20 +0200
Re: [PATCH v3 0/5] net/usb: asix driver improvements David Miller <davem@davemloft.net> - 2016-08-27 06:30 +0200
[PATCH v3 3/5] net: asix: Fix AX88772x resume failures robert.foss@collabora.com - 2016-08-29 15:40 +0200
[PATCH v3 5/5] net: asix: autoneg will set WRITE_MEDIUM reg robert.foss@collabora.com - 2016-08-29 15:40 +0200
[PATCH v3 2/5] net: asix: Avoid looping when the device is disconnected robert.foss@collabora.com - 2016-08-29 15:40 +0200
[PATCH v3 1/5] net: asix: Add in_pm parameter robert.foss@collabora.com - 2016-08-29 15:40 +0200
[PATCH v3 4/5] net: asix: see 802.3 spec for phy reset robert.foss@collabora.com - 2016-08-29 15:40 +0200
Re: [PATCH v3 0/5] net/usb: asix driver improvements Robert Foss <robert.foss@collabora.com> - 2016-08-31 19:30 +0200
Re: [PATCH v3 0/5] net/usb: asix driver improvements David Miller <davem@davemloft.net> - 2016-09-01 06:10 +0200
csiph-web