aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_axe.c
diff options
context:
space:
mode:
authorBill Paul <wpaul@FreeBSD.org>2003-06-15 21:45:43 +0000
committerBill Paul <wpaul@FreeBSD.org>2003-06-15 21:45:43 +0000
commit20ea6dd5807b2d17cef5858966235c13909b5194 (patch)
tree3b38bb19c4a88729e25be3e30bf68b16e2bb77c3 /sys/dev/usb/if_axe.c
parent5169db8c9633ad94ed42e07262e90ca40ad456e4 (diff)
downloadsrc-20ea6dd5807b2d17cef5858966235c13909b5194.tar.gz
src-20ea6dd5807b2d17cef5858966235c13909b5194.zip
In the device attach routine, don't depend on uaa->iface being
populated. Apparently, if you use an ehci controller, it's not. Use usbd_device2interface_handle() to retrieve the interface handle. NOTE: uaa->iface is populated in the probe routine, so I suspect the fact that it's NULL in the attach routine is a bug in the ehci driver. Also, don't depend on the PHY addresses returned by the AXE_CMD_READ_PHYID command. The address is correct for my LinkSys NIC, but a user has reported that with a D-Link NIC, the PHYID command returns address 4 while the attached Broadcom PHY is in fact strapped for address 0. Instead, latch onto the first PHY address that returns valid data during a readreg operation.
Notes
Notes: svn path=/head/; revision=116422
Diffstat (limited to 'sys/dev/usb/if_axe.c')
-rw-r--r--sys/dev/usb/if_axe.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index bb5db389b513..b31247ae91f3 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -213,6 +213,7 @@ axe_miibus_readreg(device_ptr_t dev, int phy, int reg)
if (sc->axe_dying)
return(0);
+#ifdef notdef
/*
* The chip tells us the MII address of any supported
* PHYs attached to the chip, so only read from those.
@@ -223,6 +224,9 @@ axe_miibus_readreg(device_ptr_t dev, int phy, int reg)
if (sc->axe_phyaddrs[1] != AXE_NOPHY && phy != sc->axe_phyaddrs[1])
return (0);
+#endif
+ if (sc->axe_phyaddrs[0] != 0xFF && sc->axe_phyaddrs[0] != phy)
+ return (0);
AXE_LOCK(sc);
axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
@@ -235,6 +239,9 @@ axe_miibus_readreg(device_ptr_t dev, int phy, int reg)
return(-1);
}
+ if (val)
+ sc->axe_phyaddrs[0] = phy;
+
return (val);
}
@@ -377,7 +384,7 @@ axe_reset(struct axe_softc *sc)
return;
if (usbd_set_config_no(sc->axe_udev, AXE_CONFIG_NO, 1) ||
- usbd_device2interface_handle(sc->axe_udev, 0 /*AXE_IFACE_IDX*/,
+ usbd_device2interface_handle(sc->axe_udev, AXE_IFACE_IDX,
&sc->axe_iface)) {
printf("axe%d: getting interface handle failed\n",
sc->axe_unit);
@@ -426,7 +433,6 @@ USB_ATTACH(axe)
int i;
bzero(sc, sizeof(struct axe_softc));
- sc->axe_iface = uaa->iface;
sc->axe_udev = uaa->device;
sc->axe_dev = self;
sc->axe_unit = device_get_unit(self);
@@ -437,7 +443,14 @@ USB_ATTACH(axe)
USB_ATTACH_ERROR_RETURN;
}
- id = usbd_get_interface_descriptor(uaa->iface);
+ if (usbd_device2interface_handle(uaa->device,
+ AXE_IFACE_IDX, &sc->axe_iface)) {
+ printf("axe%d: getting interface handle failed\n",
+ sc->axe_unit);
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ id = usbd_get_interface_descriptor(sc->axe_iface);
usbd_devinfo(uaa->device, 0, devinfo);
device_set_desc_copy(self, devinfo);
@@ -445,7 +458,7 @@ USB_ATTACH(axe)
/* Find endpoints. */
for (i = 0; i < id->bNumEndpoints; i++) {
- ed = usbd_interface2endpoint_descriptor(uaa->iface, i);
+ ed = usbd_interface2endpoint_descriptor(sc->axe_iface, i);
if (!ed) {
printf("axe%d: couldn't get ep %d\n",
sc->axe_unit, i);
@@ -479,6 +492,12 @@ USB_ATTACH(axe)
axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, (void *)&sc->axe_phyaddrs);
/*
+ * Work around broken adapters that appear to lie about
+ * their PHY addresses.
+ */
+ sc->axe_phyaddrs[0] = sc->axe_phyaddrs[1] = 0xFF;
+
+ /*
* An ASIX chip was detected. Inform the world.
*/
printf("axe%d: Ethernet address: %6D\n", sc->axe_unit, eaddr, ":");