summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2003-06-15 21:45:43 +0000
committerwpaul <wpaul@FreeBSD.org>2003-06-15 21:45:43 +0000
commit441816c04b0f07b84e8f0e4dc26d405b0dfad020 (patch)
tree3b38bb19c4a88729e25be3e30bf68b16e2bb77c3 /sys/dev
parentd1edf6fb0eef6529331786e891d80e88e426f00b (diff)
downloadFreeBSD-src-441816c04b0f07b84e8f0e4dc26d405b0dfad020.zip
FreeBSD-src-441816c04b0f07b84e8f0e4dc26d405b0dfad020.tar.gz
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.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/if_axe.c27
-rw-r--r--sys/dev/usb/if_axereg.h1
2 files changed, 24 insertions, 4 deletions
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index bb5db38..b31247a 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, ":");
diff --git a/sys/dev/usb/if_axereg.h b/sys/dev/usb/if_axereg.h
index b293f04..c880785 100644
--- a/sys/dev/usb/if_axereg.h
+++ b/sys/dev/usb/if_axereg.h
@@ -105,6 +105,7 @@
#define AXE_CTL_WRITE 0x02
#define AXE_CONFIG_NO 1
+#define AXE_IFACE_IDX 0
/*
* The interrupt endpoint is currently unused
OpenPOWER on IntegriCloud