diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/if_aue.c | 186 | ||||
-rw-r--r-- | sys/dev/usb/if_auereg.h | 5 | ||||
-rw-r--r-- | sys/dev/usb/usb_port.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.c | 20 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.h | 12 |
5 files changed, 128 insertions, 99 deletions
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 958d3fc79a3..6d3402c5501 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_aue.c,v 1.19 2002/03/14 03:16:08 millert Exp $ */ -/* $NetBSD: if_aue.c,v 1.67 2001/10/10 02:14:16 augustss Exp $ */ +/* $OpenBSD: if_aue.c,v 1.20 2002/04/01 21:47:07 nate Exp $ */ +/* $NetBSD: if_aue.c,v 1.75 2002/03/18 14:01:05 christos Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. @@ -80,11 +80,10 @@ #if defined(__NetBSD__) #include "opt_inet.h" #include "opt_ns.h" -#include "bpfilter.h" #include "rnd.h" -#elif defined(__OpenBSD__) +#endif + #include "bpfilter.h" -#endif /* defined(__OpenBSD__) */ #include <sys/param.h> #include <sys/systm.h> @@ -93,7 +92,9 @@ #include <sys/mbuf.h> #include <sys/malloc.h> #include <sys/kernel.h> +#if defined(__OpenBSD__) #include <sys/proc.h> +#endif #include <sys/socket.h> #include <sys/device.h> @@ -160,8 +161,7 @@ int auedebug = 0; * Various supported device vendors/products. */ struct aue_type { - u_int16_t aue_vid; - u_int16_t aue_did; + struct usb_devno aue_dev; u_int16_t aue_flags; #define LSYS 0x0001 /* use Linksys reset */ #define PNA 0x0002 /* has Home PNA */ @@ -169,59 +169,62 @@ struct aue_type { }; Static const struct aue_type aue_devs[] = { - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1, PNA|PII }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2, PII }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000, 0 }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4, PNA }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5, PNA }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6, PII }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7, PII }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8, PII }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9, PNA }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10, 0 }, - { USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA, 0 }, - { USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC, 0 }, - { USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS, PNA }, - { USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII, PII }, - { USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100, 0 }, - { USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100, PNA }, - { USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100, 0 }, - { USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100, PII }, - { USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX, 0 }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4, LSYS|PII }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1, LSYS }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX, LSYS }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA, PNA }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3, LSYS|PII }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2, LSYS|PII }, - { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650, 0 }, - { USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0, 0 }, - { USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1, 0 }, - { USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2, 0 }, - { USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3, PII }, - { USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET, 0 }, - { USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX, 0 }, - { USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS, PII }, - { USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX, 0 }, - { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1, LSYS|PII }, - { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T, LSYS }, - { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX, LSYS }, - { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1, LSYS|PNA }, - { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA, LSYS }, - { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2, LSYS|PII }, - { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1, 0 }, - { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5, 0 }, - { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5, PII }, - { USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC,PII }, - { USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB, 0 }, - { USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100, 0 }, - { 0, 0, 0 } + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1}, PNA|PII }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2}, PII }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000}, LSYS }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4}, PNA }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5}, PNA }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6}, PII }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7}, PII }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8}, PII }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9}, PNA }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10}, 0 }, + {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA}, 0 }, + {{ USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC}, 0 }, + {{ USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_SS1001}, PII }, + {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS}, PNA }, + {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII}, PII }, + {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100}, 0 }, + {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100}, PNA }, + {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100}, 0 }, + {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100}, PII }, + {{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX}, 0 }, + {{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXS},PII }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4}, LSYS|PII }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1}, LSYS }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX}, LSYS }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA}, PNA }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3}, LSYS|PII }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2}, LSYS|PII }, + {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650}, 0 }, + {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0}, 0 }, + {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1}, 0 }, + {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2}, 0 }, + {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3}, PII }, + {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBLTX}, PII }, + {{ USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET}, 0 }, + {{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX}, 0 }, + {{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS}, PII }, + {{ USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX}, 0 }, + {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1}, LSYS|PII }, + {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T}, LSYS }, + {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX}, LSYS }, + {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1}, LSYS|PNA }, + {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA}, LSYS }, + {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2}, LSYS|PII }, + {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1}, 0 }, + {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5}, 0 }, + {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5}, PII }, + {{ USB_VENDOR_SIEMENS, USB_PRODUCT_SIEMENS_SPEEDSTREAM}, PII }, + {{ USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC},PII }, + {{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB}, 0 }, + {{ USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100}, 0 }, }; +#define aue_lookup(v, p) ((struct aue_type *)usb_lookup(aue_devs, v, p)) USB_DECLARE_DRIVER(aue); Static void aue_reset_pegasus_II(struct aue_softc *sc); -Static const struct aue_type *aue_lookup(u_int16_t vendor, u_int16_t product); Static int aue_tx_list_init(struct aue_softc *); Static int aue_rx_list_init(struct aue_softc *); Static int aue_newbuf(struct aue_softc *, struct aue_chain *, struct mbuf *); @@ -421,13 +424,16 @@ aue_read_mac(struct aue_softc *sc, u_char *dest) Static void aue_lock_mii(struct aue_softc *sc) { - lockmgr(&sc->aue_mii_lock, LK_EXCLUSIVE, NULL, curproc); + sc->aue_refcnt++; + usb_lockmgr(&sc->aue_mii_lock, LK_EXCLUSIVE, NULL, curproc); } Static void aue_unlock_mii(struct aue_softc *sc) { - lockmgr(&sc->aue_mii_lock, LK_RELEASE, NULL, curproc); + usb_lockmgr(&sc->aue_mii_lock, LK_RELEASE, NULL, curproc); + if (--sc->aue_refcnt < 0) + usb_detach_wakeup(USBDEV(sc->aue_dev)); } Static int @@ -437,6 +443,13 @@ aue_miibus_readreg(device_ptr_t dev, int phy, int reg) int i; u_int16_t val; + if (sc->aue_dying) { +#ifdef DIAGNOSTIC + printf("%s: dying\n", USBDEVNAME(sc->aue_dev)); +#endif + return 0; + } + #if 0 /* * The Am79C901 HomePNA PHY actually contains @@ -541,11 +554,12 @@ aue_miibus_statchg(device_ptr_t dev) * This turns on the 'dual link LED' bin in the auxmode * register of the Broadcom PHY. */ - if (sc->aue_flags & LSYS) { + if (!sc->aue_dying && (sc->aue_flags & LSYS)) { u_int16_t auxmode; auxmode = aue_miibus_readreg(dev, 0, 0x1b); aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04); } + DPRINTFN(5,("%s: %s: exit\n", USBDEVNAME(sc->aue_dev), __FUNCTION__)); } #define AUE_POLY 0xEDB88320 @@ -642,6 +656,14 @@ aue_reset(struct aue_softc *sc) if (i == AUE_TIMEOUT) printf("%s: reset failed\n", USBDEVNAME(sc->aue_dev)); +#if 0 + /* XXX what is mii_mode supposed to be */ + if (sc->aue_mii_mode && (sc->aue_flags & PNA)) + aue_csr_write_1(sc, AUE_GPIO1, 0x34); + else + aue_csr_write_1(sc, AUE_GPIO1, 0x26); +#endif + /* * The PHY(s) attached to the Pegasus chip may be held * in reset until we flip on the GPIO outputs. Make sure @@ -651,26 +673,16 @@ aue_reset(struct aue_softc *sc) * Note: We force all of the GPIO pins low first, *then* * enable the ones we want. */ - aue_csr_write_1(sc, AUE_GPIO0, - AUE_GPIO_OUT0 | AUE_GPIO_SEL0); - aue_csr_write_1(sc, AUE_GPIO0, - AUE_GPIO_OUT0 | AUE_GPIO_SEL0 | AUE_GPIO_SEL1); - -#if 0 - /* XXX what is mii_mode supposed to be */ - if (sc->aue_mii_mode && (sc->aue_flags & PNA)) - aue_csr_write_1(sc, AUE_GPIO1, 0x34); - else - aue_csr_write_1(sc, AUE_GPIO1, 0x26); -#endif - - /* Grrr. LinkSys has to be different from everyone else. */ if (sc->aue_flags & LSYS) { + /* Grrr. LinkSys has to be different from everyone else. */ aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_SEL0 | AUE_GPIO_SEL1); - aue_csr_write_1(sc, AUE_GPIO0, - AUE_GPIO_SEL0 | AUE_GPIO_SEL1 | AUE_GPIO_OUT0); + } else { + aue_csr_write_1(sc, AUE_GPIO0, + AUE_GPIO_OUT0 | AUE_GPIO_SEL0); } + aue_csr_write_1(sc, AUE_GPIO0, + AUE_GPIO_OUT0 | AUE_GPIO_SEL0 | AUE_GPIO_SEL1); if (sc->aue_flags & PII) aue_reset_pegasus_II(sc); @@ -679,17 +691,6 @@ aue_reset(struct aue_softc *sc) delay(10000); /* XXX */ } -Static const struct aue_type * -aue_lookup(u_int16_t vendor, u_int16_t product) -{ - const struct aue_type *t; - - for (t = aue_devs; t->aue_vid != 0; t++) - if (vendor == t->aue_vid && product == t->aue_did) - return (t); - return (NULL); -} - /* * Probe for a Pegasus chip. */ @@ -879,18 +880,10 @@ USB_DETACH(aue) #if NRND > 0 rnd_detach_source(&sc->rnd_source); #endif -#endif - +#endif /* __NetBSD__ */ mii_detach(&sc->aue_mii, MII_PHY_ANY, MII_OFFSET_ANY); ifmedia_delete_instance(&sc->aue_mii.mii_media, IFM_INST_ANY); - -#if defined(__NetBSD__) -#if NBPFILTER > 0 - bpfdetach(ifp); -#endif -#endif /* __NetBSD__ */ ether_ifdetach(ifp); - if_detach(ifp); #ifdef DIAGNOSTIC @@ -902,6 +895,11 @@ USB_DETACH(aue) #endif sc->aue_attached = 0; + + if (--sc->aue_refcnt >= 0) { + /* Wait for processes to go away. */ + usb_detach_wait(USBDEV(sc->aue_dev)); + } splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->aue_udev, diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h index 67ae289bbfd..fa99c008107 100644 --- a/sys/dev/usb/if_auereg.h +++ b/sys/dev/usb/if_auereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_auereg.h,v 1.5 2001/10/31 04:24:44 nate Exp $ */ +/* $OpenBSD: if_auereg.h,v 1.6 2002/04/01 21:47:07 nate Exp $ */ /* $NetBSD: if_auereg.h,v 1.16 2001/10/10 02:14:17 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -262,8 +262,9 @@ struct aue_softc { int aue_if_flags; struct aue_cdata aue_cdata; - u_int16_t aue_flags; + u_int16_t aue_flags; + int aue_refcnt; char aue_dying; char aue_attached; u_int aue_rx_errs; diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index 24f570e2748..2922833aac9 100644 --- a/sys/dev/usb/usb_port.h +++ b/sys/dev/usb/usb_port.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_port.h,v 1.32 2002/02/27 10:47:51 art Exp $ */ +/* $OpenBSD: usb_port.h,v 1.33 2002/04/01 21:47:07 nate Exp $ */ /* $NetBSD: usb_port.h,v 1.44 2001/05/14 20:35:29 bouyer Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -297,6 +297,8 @@ typedef struct timeout usb_callout_t; { timeout_set(&(h), (f), (d)); timeout_add(&(h), (t)); } #define usb_uncallout(h, f, d) timeout_del(&(h)) +#define usb_lockmgr(l, f, sl, p) lockmgr((l), (f), (sl), (p)) + #define USB_DECLARE_DRIVER(dname) \ int __CONCAT(dname,_match)(struct device *, void *, void *); \ void __CONCAT(dname,_attach)(struct device *, struct device *, void *); \ diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 8aa3f46afd3..932ed318765 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.14 2001/05/03 02:20:34 aaron Exp $ */ +/* $OpenBSD: usbdi.c,v 1.15 2002/04/01 21:47:07 nate Exp $ */ /* $NetBSD: usbdi.c,v 1.81 2001/04/17 00:05:33 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -1055,6 +1055,24 @@ usbd_ratecheck(struct timeval *last) return (ratecheck(last, &errinterval)); } +/* + * Search for a vendor/product pair in an array. The item size is + * given as an argument. + */ +const struct usb_devno * +usb_match_device(const struct usb_devno *tbl, u_int nentries, u_int sz, + u_int16_t vendor, u_int16_t product) +{ + while (nentries-- > 0) { + u_int16_t tproduct = tbl->ud_product; + if (tbl->ud_vendor == vendor && + (tproduct == product || tproduct == USB_PRODUCT_ANY)) + return (tbl); + tbl = (struct usb_devno *)((char *)tbl + sz); + } + return (NULL); +} + #if defined(__FreeBSD__) int usbd_driver_load(module_t mod, int what, void *arg) diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index c4e2382736f..517287ea75d 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.h,v 1.13 2001/10/31 04:24:45 nate Exp $ */ +/* $OpenBSD: usbdi.h,v 1.14 2002/04/01 21:47:07 nate Exp $ */ /* $NetBSD: usbdi.h,v 1.53 2001/08/15 00:04:59 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -193,6 +193,16 @@ void usb_add_task(usbd_device_handle dev, struct usb_task *task); void usb_rem_task(usbd_device_handle dev, struct usb_task *task); #define usb_init_task(t, f, a) ((t)->fun = (f), (t)->arg = (a), (t)->onqueue = 0) +struct usb_devno { + u_int16_t ud_vendor; + u_int16_t ud_product; +}; +const struct usb_devno *usb_match_device(const struct usb_devno *tbl, + u_int nentries, u_int sz, u_int16_t vendor, u_int16_t product); +#define usb_lookup(tbl, vendor, product) \ + usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product)) +#define USB_PRODUCT_ANY 0xffff + /* NetBSD attachment information */ /* Attach data */ |