summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoraugustss <augustss@NetBSD.org>1998-08-01 18:16:19 +0000
committeraugustss <augustss@NetBSD.org>1998-08-01 18:16:19 +0000
commitf654e0188ea10a4b2a0aeb5f6ec82bf191a69ff8 (patch)
tree52236802f053c90a24577a3e81dd9303ac6fdf54 /sys/dev
parent5a1f4dd6bc1ea5b1220649282a444dd6d73aaf68 (diff)
Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/ohci.c27
-rw-r--r--sys/dev/usb/uhci.c23
-rw-r--r--sys/dev/usb/uhub.c10
-rw-r--r--sys/dev/usb/ukbd.c16
-rw-r--r--sys/dev/usb/usb.c8
-rw-r--r--sys/dev/usb/usb_subr.c9
-rw-r--r--sys/dev/usb/usbdi.c14
-rw-r--r--sys/dev/usb/usbdi.h3
-rw-r--r--sys/dev/usb/usbdivar.h5
9 files changed, 64 insertions, 51 deletions
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index a9e62942f3e..ea2242ab910 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.5 1998/07/26 17:42:48 augustss Exp $ */
+/* $NetBSD: ohci.c,v 1.6 1998/08/01 18:16:19 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -962,7 +962,7 @@ ohci_device_request(reqh)
sed->ed->ed_tailp = tail->physaddr;
opipe->tail = tail;
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_CLF);
- if (reqh->timeout && !usbd_use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling)
timeout(ohci_timeout, reqh, MS_TO_TICKS(reqh->timeout));
splx(s);
@@ -1560,7 +1560,7 @@ ohci_root_ctrl_transfer(reqh)
DPRINTFN(5,("ohci_root_ctrl_transfer: reset port %d\n", index));
OWRITE4(sc, port, UPS_RESET);
for (i = 0; i < 10; i++) {
- usbd_delay_ms(10);
+ usbd_delay_ms(&sc->sc_bus, 10);
if ((OREAD4(sc, port) & UPS_RESET) == 0)
break;
}
@@ -1653,6 +1653,7 @@ usbd_status
ohci_device_ctrl_transfer(reqh)
usbd_request_handle reqh;
{
+ ohci_softc_t *sc = (ohci_softc_t *)reqh->pipe->device->bus;
usbd_status r;
if (!reqh->isreq) {
@@ -1665,8 +1666,8 @@ ohci_device_ctrl_transfer(reqh)
if (r != USBD_NORMAL_COMPLETION)
return (r);
- if (usbd_use_polling)
- ohci_waitintr((ohci_softc_t *)reqh->pipe->device->bus, reqh);
+ if (sc->sc_bus.use_polling)
+ ohci_waitintr(sc, reqh);
return (USBD_IN_PROGRESS);
}
@@ -1676,7 +1677,7 @@ ohci_device_ctrl_abort(reqh)
usbd_request_handle reqh;
{
/* XXX inactivate */
- usbd_delay_ms(1); /* make sure it is finished */
+ usbd_delay_ms(reqh->pipe->device->bus, 1); /* make sure it is finished */
/* XXX call done */
}
@@ -1693,7 +1694,7 @@ ohci_device_ctrl_close(pipe)
s = splusb();
sed->ed->ed_flags |= OHCI_ED_SKIP;
if ((sed->ed->ed_tailp & OHCI_TAILMASK) != sed->ed->ed_headp)
- usbd_delay_ms(2);
+ usbd_delay_ms(&sc->sc_bus, 2);
ohci_rem_ed(sed, sc->sc_ctrl_head);
splx(s);
ohci_free_std(sc, opipe->tail);
@@ -1770,7 +1771,7 @@ ohci_device_bulk_transfer(reqh)
sed->ed->ed_tailp = tail->physaddr;
opipe->tail = tail;
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_BLF);
- if (reqh->timeout && !usbd_use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling)
timeout(ohci_timeout, reqh, MS_TO_TICKS(reqh->timeout));
splx(s);
@@ -1790,10 +1791,10 @@ ohci_device_bulk_abort(reqh)
#if 0
sed->ed->ed_flags |= OHCI_ED_SKIP;
if ((sed->ed->ed_tailp & OHCI_TAILMASK) != sed->ed->ed_headp)
- usbd_delay_ms(2);
+ usbd_delay_ms(reqh->pipe->device->bus, 2);
#endif
/* XXX inactivate */
- usbd_delay_ms(1); /* make sure it is finished */
+ usbd_delay_ms(reqh->pipe->device->bus, 1); /* make sure it is finished */
/* XXX call done */
}
@@ -1880,7 +1881,7 @@ ohci_device_intr_transfer(reqh)
sed->ed->ed_tailp = tail->physaddr;
opipe->tail = tail;
#if 0
- if (reqh->timeout && !usbd_use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling)
timeout(ohci_timeout, reqh, MS_TO_TICKS(reqh->timeout));
#endif
sed->ed->ed_flags &= ~OHCI_ED_SKIP;
@@ -1912,7 +1913,7 @@ ohci_device_intr_abort(reqh)
struct uhci_pipe *opipe;
/* XXX inactivate */
- usbd_delay_ms(1); /* make sure it is finished */
+ usbd_delay_ms(reqh->pipe->device->bus, 1); /* make sure it is finished */
if (reqh->pipe->intrreqh == reqh) {
DPRINTF(("ohci_device_intr_abort: remove\n"));
reqh->pipe->intrreqh = 0;
@@ -1939,7 +1940,7 @@ ohci_device_intr_close(pipe)
s = splusb();
sed->ed->ed_flags |= OHCI_ED_SKIP;
if ((sed->ed->ed_tailp & OHCI_TAILMASK) != sed->ed->ed_headp)
- usbd_delay_ms(2);
+ usbd_delay_ms(&sc->sc_bus, 2);
for (p = sc->sc_eds[pos]; p && p->next != sed; p = p->next)
;
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 4276e462dde..ade76bbdadd 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.8 1998/07/26 17:42:48 augustss Exp $ */
+/* $NetBSD: uhci.c,v 1.9 1998/08/01 18:16:19 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -230,7 +230,7 @@ uhci_busreset(sc)
uhci_softc_t *sc;
{
UHCICMD(sc, UHCI_CMD_GRESET); /* global reset */
- usbd_delay_ms(USB_RESET_DELAY); /* wait at least 10ms */
+ usbd_delay_ms(&sc->sc_bus, USB_RESET_DELAY); /* wait at least 10ms */
UHCICMD(sc, 0); /* do nothing */
}
@@ -1129,7 +1129,7 @@ uhci_device_bulk_transfer(reqh)
uhci_add_bulk(sc, sqh);
LIST_INSERT_HEAD(&sc->sc_intrhead, ii, list);
- if (reqh->timeout && !usbd_use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling)
timeout(uhci_timeout, ii, MS_TO_TICKS(reqh->timeout));
splx(s);
@@ -1155,7 +1155,7 @@ uhci_device_bulk_abort(reqh)
usbd_request_handle reqh;
{
/* XXX inactivate */
- usbd_delay_ms(1); /* make sure it is finished */
+ usbd_delay_ms(reqh->pipe->device->bus, 1); /* make sure it is finished */
/* XXX call done */
}
@@ -1177,6 +1177,7 @@ usbd_status
uhci_device_ctrl_transfer(reqh)
usbd_request_handle reqh;
{
+ uhci_softc_t *sc = (uhci_softc_t *)reqh->pipe->device->bus;
usbd_status r;
if (!reqh->isreq)
@@ -1186,8 +1187,8 @@ uhci_device_ctrl_transfer(reqh)
if (r != USBD_NORMAL_COMPLETION)
return (r);
- if (usbd_use_polling)
- uhci_waitintr((uhci_softc_t *)reqh->pipe->device->bus, reqh);
+ if (sc->sc_bus.use_polling)
+ uhci_waitintr(sc, reqh);
return (USBD_IN_PROGRESS);
}
@@ -1273,7 +1274,7 @@ uhci_device_ctrl_abort(reqh)
usbd_request_handle reqh;
{
/* XXX inactivate */
- usbd_delay_ms(1); /* make sure it is finished */
+ usbd_delay_ms(reqh->pipe->device->bus, 1); /* make sure it is finished */
/* XXX call done */
}
@@ -1297,7 +1298,7 @@ uhci_device_intr_abort(reqh)
DPRINTFN(1, ("uhci_device_intr_abort: reqh=%p\n", reqh));
/* XXX inactivate */
- usbd_delay_ms(2); /* make sure it is finished */
+ usbd_delay_ms(reqh->pipe->device->bus, 2); /* make sure it is finished */
if (reqh->pipe->intrreqh == reqh) {
DPRINTF(("uhci_device_intr_abort: remove\n"));
reqh->pipe->intrreqh = 0;
@@ -1329,7 +1330,7 @@ uhci_device_intr_close(pipe)
* We now have to wait for any activity on the physical
* descriptors to stop.
*/
- usbd_delay_ms(2);
+ usbd_delay_ms(&sc->sc_bus, 2);
for(i = 0; i < npoll; i++)
uhci_free_sqh(sc, upipe->u.intr.qhs[i]);
@@ -1461,7 +1462,7 @@ uhci_device_request(reqh)
uhci_dump_tds(sqh->qh->elink);
}
#endif
- if (reqh->timeout && !usbd_use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling)
timeout(uhci_timeout, ii, MS_TO_TICKS(reqh->timeout));
splx(s);
@@ -2144,7 +2145,7 @@ uhci_root_ctrl_transfer(reqh)
case UHF_PORT_RESET:
x = UREAD2(sc, port);
UWRITE2(sc, port, x | UHCI_PORTSC_PR);
- usbd_delay_ms(10);
+ usbd_delay_ms(&sc->sc_bus, 10);
UWRITE2(sc, port, x & ~UHCI_PORTSC_PR);
delay(100);
x = UREAD2(sc, port);
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index 8de7ed4800c..5f5e896bd03 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhub.c,v 1.2 1998/07/22 12:22:08 augustss Exp $ */
+/* $NetBSD: uhub.c,v 1.3 1998/08/01 18:16:19 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -243,8 +243,8 @@ uhub_init_port(port, uport, dev)
port, UGETW(uport->status.wPortStatus),
UGETW(uport->status.wPortChange)));
/* Wait for stable power. */
- usbd_delay_ms(dev->hub->hubdesc.bPwrOn2PwrGood *
- UHD_PWRON_FACTOR);
+ usbd_delay_ms(dev->bus, dev->hub->hubdesc.bPwrOn2PwrGood *
+ UHD_PWRON_FACTOR);
}
if (dev->self_powered)
/* Self powered hub, give ports maximum current. */
@@ -317,14 +317,14 @@ uhub_explore(parent, dev)
/* Connected */
/* Wait for maximum device power up time. */
- usbd_delay_ms(USB_PORT_POWERUP_DELAY);
+ usbd_delay_ms(dev->bus, USB_PORT_POWERUP_DELAY);
/* Reset port, which implies enabling it. */
if (usbd_reset_port(dev, port, &up->status) !=
USBD_NORMAL_COMPLETION)
continue;
/* Wait for power to settle in device. */
- usbd_delay_ms(USB_POWER_SETTLE);
+ usbd_delay_ms(dev->bus, USB_POWER_SETTLE);
/* Get device info and set its address. */
r = usbd_new_device((struct device *)sc, dev->bus,
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 00ad71b54ed..6da30781c7c 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ukbd.c,v 1.5 1998/08/01 17:46:22 augustss Exp $ */
+/* $NetBSD: ukbd.c,v 1.6 1998/08/01 18:16:19 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -267,6 +267,7 @@ bLength=%d bDescriptorType=%d bEndpointAddress=%d-%s bmAttributes=%d wMaxPacketS
return;
}
}
+ /* Ignore if SETIDLE fails since it is not crucial. */
usbd_set_idle(iface, 0, 0);
sc->sc_ep_addr = ed->bEndpointAddress;
@@ -384,7 +385,7 @@ ukbd_intr(reqh, addr, status)
if (sc->sc_polling) {
if (nkeys > 0)
- sc->sc_pollchar = ibuf[0];
+ sc->sc_pollchar = ibuf[0]; /* XXX lost keys? */
return;
}
for (i = 0; i < nkeys; i++) {
@@ -453,21 +454,18 @@ ukbd_cngetc(v, type, data)
{
struct ukbd_softc *sc = v;
usbd_lock_token s;
- extern int usbd_use_polling;
int c;
DPRINTFN(1,("ukbd_cngetc: enter\n"));
s = usbd_lock();
- usbd_use_polling = 1;
sc->sc_polling = 1;
sc->sc_pollchar = -1;
while(sc->sc_pollchar == -1)
usbd_dopoll(sc->sc_iface);
sc->sc_polling = 0;
- usbd_use_polling = 0;
c = sc->sc_pollchar;
- *type = c & 0x80 ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
- *data = c & 0x7f;
+ *type = c & RELEASE ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
+ *data = c & 0xff;
usbd_unlock(s);
DPRINTFN(1,("ukbd_cngetc: return 0x%02x\n", c));
}
@@ -477,5 +475,9 @@ ukbd_cnpollc(v, on)
void *v;
int on;
{
+ struct ukbd_softc *sc = v;
+
DPRINTFN(1,("ukbd_cnpollc: sc=%p on=%d\n", v, on));
+
+ usbd_set_polling(sc->sc_iface, on);
}
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index ab628c861a2..ad440f8956b 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.2 1998/07/25 15:22:11 augustss Exp $ */
+/* $NetBSD: usb.c,v 1.3 1998/08/01 18:16:20 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -89,8 +89,6 @@ int usbpoll __P((dev_t, int, struct proc *));
usbd_status usb_discover __P((struct usb_softc *));
-int usbd_use_polling; /* use polling instead of interrupts */
-
extern struct cfdriver usb_cd;
struct cfattach usb_ca = {
@@ -123,7 +121,7 @@ usb_attach(parent, self, aux)
printf("\n");
sc->sc_running = 1;
- usbd_use_polling = 1;
+ sc->sc_bus->use_polling = 1;
sc->sc_port.power = USB_MAX_POWER;
r = usbd_new_device(&sc->sc_dev, sc->sc_bus, 0, 0, 0, &sc->sc_port);
if (r == USBD_NORMAL_COMPLETION) {
@@ -141,7 +139,7 @@ usb_attach(parent, self, aux)
sc->sc_dev.dv_xname, r);
sc->sc_running = 0;
}
- usbd_use_polling = 0;
+ sc->sc_bus->use_polling = 0;
}
int
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index f675595a1b1..73d1a8cb760 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.4 1998/07/23 01:46:27 augustss Exp $ */
+/* $NetBSD: usb_subr.c,v 1.5 1998/08/01 18:16:20 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -217,11 +217,12 @@ usbd_devinfo(dev, showclass, cp)
/* Delay for a certain number of ms */
void
-usbd_delay_ms(ms)
+usbd_delay_ms(bus, ms)
+ usbd_bus_handle bus;
int ms;
{
/* Wait at least two clock ticks so we know the time has passed. */
- if (usbd_use_polling)
+ if (bus->use_polling)
delay((ms+1) * 1000);
else
tsleep(&ms, PRIBIO, "usbdly", (ms*hz+999)/1000 + 1);
@@ -250,7 +251,7 @@ usbd_reset_port(dev, port, ps)
n = 10;
do {
/* Wait for device to recover from reset. */
- usbd_delay_ms(USB_PORT_RESET_DELAY);
+ usbd_delay_ms(dev->bus, USB_PORT_RESET_DELAY);
r = usbd_get_port_status(dev, port, ps);
if (r != USBD_NORMAL_COMPLETION) {
DPRINTF(("usbd_reset_port: get status failed %d\n",r));
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index caf0f3d53cf..05f0b975479 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.7 1998/07/29 20:50:12 augustss Exp $ */
+/* $NetBSD: usbdi.c,v 1.8 1998/08/01 18:16:20 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -898,7 +898,7 @@ usbd_sync_transfer_cb(reqh)
usbd_request_handle reqh;
{
usbd_transfer_cb(reqh);
- if (!usbd_use_polling)
+ if (!reqh->pipe->device->bus->use_polling)
wakeup(reqh);
}
@@ -916,7 +916,7 @@ usbd_sync_transfer(reqh)
return (r);
s = splusb();
if (!reqh->done) {
- if (usbd_use_polling)
+ if (reqh->pipe->device->bus->use_polling)
panic("usbd_sync_transfer: not done\n");
tsleep(reqh, PRIBIO, "usbsyn", 0);
}
@@ -1040,3 +1040,11 @@ usbd_dopoll(iface)
{
iface->device->bus->do_poll(iface->device->bus);
}
+
+void
+usbd_set_polling(iface, on)
+ usbd_interface_handle iface;
+ int on;
+{
+ iface->device->bus->use_polling = on;
+}
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 0ad1575ad1a..de0565cf260 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.h,v 1.4 1998/07/29 20:50:12 augustss Exp $ */
+/* $NetBSD: usbdi.h,v 1.5 1998/08/01 18:16:20 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -219,6 +219,7 @@ usb_device_descriptor_t *usbd_get_device_descriptor
usbd_status usbd_set_interface __P((usbd_interface_handle, int));
void usbd_dopoll __P((usbd_interface_handle));
+void usbd_set_polling __P((usbd_interface_handle iface, int on));
/* NetBSD attachment information */
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 86cbdc7d018..96f12acb367 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdivar.h,v 1.5 1998/07/26 17:42:49 augustss Exp $ */
+/* $NetBSD: usbdivar.h,v 1.6 1998/08/01 18:16:20 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -83,6 +83,7 @@ struct usbd_bus {
struct usbd_device *root_hub;
usbd_device_handle devices[USB_MAX_DEVICES];
char needs_explore;/* a hub a signalled a change */
+ char use_polling;
struct usb_softc *usbctl;
struct usb_device_stats stats;
};
@@ -162,7 +163,7 @@ void usbd_init __P((void));
/* Routines from usb_subr.c */
int usbctlprint __P((void *, const char *));
-void usbd_delay_ms __P((int));
+void usbd_delay_ms __P((usbd_bus_handle, int));
void usbd_devinfo_vp __P((usbd_device_handle, char *, char *));
usbd_status usbd_set_config_no __P((usbd_device_handle, int));
usbd_status usbd_reset_port __P((usbd_device_handle dev,