summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorn_hibma <n_hibma@FreeBSD.org>1998-12-09 23:36:15 +0000
committern_hibma <n_hibma@FreeBSD.org>1998-12-09 23:36:15 +0000
commitff213ddb78391d3b7987d882cee8311e71bfcee6 (patch)
tree250fd09c4c1fabc311884a9c64176e48dc077267 /sys/dev/usb
parent1e167561f8097938bd2ee681a27aa32b3b30ce93 (diff)
downloadFreeBSD-src-ff213ddb78391d3b7987d882cee8311e71bfcee6.zip
FreeBSD-src-ff213ddb78391d3b7987d882cee8311e71bfcee6.tar.gz
Various bug fixes:
1) Removed 'emulation' of bitmaps in printfs, FreeBSD seems to have caught up on that one 2) Fixed a few bugs in the timeout/timo timeout variables 3) First attempt at fixing a bug mentioned by Kazu: uhci_run is not able start/stop his USB host on his motherboard.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/ohcireg.h12
-rw-r--r--sys/dev/usb/ohcivar.h17
-rw-r--r--sys/dev/usb/uhci.c59
-rw-r--r--sys/dev/usb/uhcivar.h3
-rw-r--r--sys/dev/usb/uhub.c5
-rw-r--r--sys/dev/usb/usb.c2
-rw-r--r--sys/dev/usb/usb_port.h1
-rw-r--r--sys/dev/usb/usb_subr.c5
-rw-r--r--sys/dev/usb/usbdivar.h5
9 files changed, 65 insertions, 44 deletions
diff --git a/sys/dev/usb/ohcireg.h b/sys/dev/usb/ohcireg.h
index 3f62ddf..33f1b72 100644
--- a/sys/dev/usb/ohcireg.h
+++ b/sys/dev/usb/ohcireg.h
@@ -1,11 +1,12 @@
-/* $NetBSD: ohcireg.h,v 1.2 1998/07/26 00:40:59 augustss Exp $ */
+/* $NetBSD: ohcireg.h,v 1.6 1998/11/25 22:32:04 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
- * Author: Lennart Augustsson <augustss@carlstedt.se>
- * Carlstedt Research & Technology
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (augustss@carlstedt.se) at
+ * Carlstedt Research & Technology.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -105,8 +106,8 @@
#define OHCI_LS_THRESHOLD 0x44
#define OHCI_RH_DESCRIPTOR_A 0x48
#define OHCI_GET_NDP(s) ((s) & 0xff)
-#define OHCI_PSM 0x0100 /* Power Switching Mode */
-#define OHCI_NPS 0x0200 /* No Power Switching */
+#define OHCI_PSM 0x0100 /* Power Switching Mode */
+#define OHCI_NPS 0x0200 /* No Power Switching */
#define OHCI_GET_POTPGT(s) ((s) >> 24)
#define OHCI_RH_DESCRIPTOR_B 0x4c
#define OHCI_RH_STATUS 0x50
@@ -154,6 +155,7 @@ typedef struct {
#define OHCI_ED_FORMAT_ISO 0x00008000
#define OHCI_ED_GET_MAXP(s) (((s) >> 16) & 0x07ff)
#define OHCI_ED_SET_MAXP(s) ((s) << 16)
+#define OHCI_ED_MAXPMASK (0x7ff << 16)
ohci_physaddr_t ed_tailp;
#define OHCI_HALTED 0x00000002
#define OHCI_TOGGLECARRY 0x00000001
diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h
index dfafdb9..e314de2 100644
--- a/sys/dev/usb/ohcivar.h
+++ b/sys/dev/usb/ohcivar.h
@@ -1,11 +1,12 @@
-/* $NetBSD: ohcivar.h,v 1.2 1998/07/24 21:09:07 augustss Exp $ */
+/* $NetBSD: ohcivar.h,v 1.3 1998/11/25 22:32:04 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
- * Author: Lennart Augustsson <augustss@carlstedt.se>
- * Carlstedt Research & Technology
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (augustss@carlstedt.se) at
+ * Carlstedt Research & Technology.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -61,6 +62,7 @@ typedef struct ohci_soft_td {
typedef struct ohci_softc {
struct usbd_bus sc_bus; /* base device */
+#if defined(__NetBSD__)
void *sc_ih; /* interrupt vectoring */
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -68,7 +70,16 @@ typedef struct ohci_softc {
bus_dma_tag_t sc_dmatag; /* DMA tag */
/* XXX should keep track of all DMA memory */
+#elif defined(__FreeBSD__)
+ int sc_iobase;
+ int unit;
+#endif
+
+#if defined(__NetBSD__)
usb_dma_t sc_hccadma;
+#elif defined(__FreeBSD__)
+ void *sc_hccadma;
+#endif
struct ohci_hcca *sc_hcca;
ohci_soft_ed_t *sc_eds[OHCI_NO_EDS];
u_int sc_bws[OHCI_NO_INTRS];
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 5065195..972b0c3 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -78,11 +78,6 @@
#include "dev/usb/queue.addendum.h"
#define delay(d) DELAY(d)
-
-static struct callout_handle uhci_timeout_handle
- = CALLOUT_HANDLE_INITIALIZER(&uhci_timeout_handle);
-static struct callout_handle uhci_timo_handle
- = CALLOUT_HANDLE_INITIALIZER(&uhci_timo_handle);
#endif
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
@@ -392,7 +387,6 @@ uhci_dump_td(p)
(long)p->td->td_token,
(long)p->td->td_buffer);
if (uhci_longtd)
-#if defined(__NetBSD__)
printf(" %b %b,errcnt=%d,actlen=%d pid=%02x,addr=%d,endpt=%d,D=%d,maxlen=%d\n",
(long)p->td->td_link,
"\20\1T\2Q\3VF",
@@ -405,7 +399,7 @@ uhci_dump_td(p)
UHCI_TD_GET_ENDPT(p->td->td_token),
UHCI_TD_GET_DT(p->td->td_token),
UHCI_TD_GET_MAXLEN(p->td->td_token));
-#elif defined(__FreeBSD__)
+#if 0 && defined(__FreeBSD__)
printf(" Link=0x%08lx,Status=0x%08lx\n errcnt=%d,actlen=%d,pid=%02x,addr=%d,endpt=%d,D=%d,maxlen=%d\n",
(long)p->td->td_link,
(long)p->td->td_status,
@@ -489,10 +483,10 @@ uhci_timo(addr)
#elif defined(__FreeBSD__)
/* To avoid race conditions we first initialise the struct
* before we use it. The timeout might happen between the
- * setting of the timeout and the setting of callout_handler
+ * setting of the timeout and the setting of timo_handle
*/
- callout_handle_init(&reqh->callout_handler);
- reqh->callout_handler = timeout(uhci_timo, reqh, sc->sc_ival);
+ callout_handle_init(&reqh->timo_handle);
+ reqh->timo_handle = timeout(uhci_timo, reqh, sc->sc_ival);
#endif
} else {
usb_freemem(sc->sc_dmatag, &upipe->u.intr.datadma);
@@ -735,7 +729,7 @@ uhci_check_intr(sc, ii)
#if defined(__NetBSD__)
untimeout(uhci_timeout, ii);
#elif defined(__FreeBSD__)
- untimeout(uhci_timeout, ii, ii->callout_handler);
+ untimeout(uhci_timeout, ii, ii->timeout_handle);
#endif
}
@@ -780,16 +774,12 @@ uhci_ii_done(ii, timo)
len += UHCI_TD_GET_ACTLEN(tst);
}
status &= UHCI_TD_ERROR;
- /* NWH wrong func name also below, 'uhci_intr' 3 times
- DPRINTFN(10, ("uhci_check_intr: len=%d, status=0x%x\n", len, status));
- */
DPRINTFN(10, ("uhci_ii_done: len=%d\n", len));
if (status != 0) {
-#if defined(__NetBSD__)
DPRINTFN(-1+(status==UHCI_TD_STALLED),
("uhci_ii_done: error, status 0x%b\n", (long)status,
"\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27STALLED\30ACTIVE"));
-#elif defined(__FreeBSD__)
+#if 0 && defined(__FreeBSD__)
DPRINTFN(-1+(status==UHCI_TD_STALLED),
("uhci_ii_done: error, status 0x%08lx\n", (long)status));
#endif
@@ -914,7 +904,7 @@ uhci_run(sc, run)
{
int s, n, running;
- run = run != 0;
+ run = (run? UHCI_STS_HCH:0);
s = splusb(); /* XXX really? */
running = !(UREAD2(sc, UHCI_STS) & UHCI_STS_HCH);
if (run == running) {
@@ -923,6 +913,10 @@ uhci_run(sc, run)
}
UWRITE2(sc, UHCI_CMD, run ? UHCI_CMD_RS : 0);
for(n = 0; n < 100; n++) {
+ /* XXX NWH should this not be a delay of 2ms (>1024usecs)
+ * followed by one check? This fails in case a large transfer
+ * is going on on a fast processor.
+ */
running = !(UREAD2(sc, UHCI_STS) & UHCI_STS_HCH);
/* return when we've entered the state we want */
if (run == running) {
@@ -1200,8 +1194,19 @@ uhci_device_bulk_transfer(reqh)
uhci_add_bulk(sc, sqh);
LIST_INSERT_HEAD(&sc->sc_intrhead, ii, list);
- if (reqh->timeout && !sc->sc_bus.use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling) {
+#if defined(__NetBSD__)
timeout(uhci_timeout, ii, MS_TO_TICKS(reqh->timeout));
+#elif defined(__FreeBSD__)
+ /* To avoid race conditions we first initialise the struct
+ * before we use it. The timeout might happen between the
+ * setting of the timeout and the setting of timeout_handle
+ */
+ callout_handle_init(&ii->timeout_handle);
+ ii->timeout_handle = timeout(uhci_timeout, ii,
+ MS_TO_TICKS(reqh->timeout));
+#endif
+ }
splx(s);
#ifdef USB_DEBUG
@@ -1542,7 +1547,7 @@ uhci_device_request(reqh)
uhci_dump_tds(sqh->qh->elink);
}
#endif
- if (reqh->timeout && !sc->sc_bus.use_polling)
+ if (reqh->timeout && !sc->sc_bus.use_polling) {
#if defined(__NetBSD__)
timeout(uhci_timeout, ii, MS_TO_TICKS(reqh->timeout));
#elif defined(__FreeBSD__)
@@ -1550,9 +1555,11 @@ uhci_device_request(reqh)
* before we use it. The timeout may happen between the setting
* of the timeout and the setting of callout_handle
*/
- callout_handle_init(&ii->callout_handler);
- ii->callout_handler = timeout(uhci_timeout, ii, MS_TO_TICKS(reqh->timeout));
+ callout_handle_init(&ii->timeout_handle);
+ ii->timeout_handle = timeout(uhci_timeout, ii,
+ MS_TO_TICKS(reqh->timeout));
#endif
+ }
splx(s);
return (USBD_NORMAL_COMPLETION);
@@ -2286,7 +2293,7 @@ uhci_root_ctrl_close(pipe)
#if defined(__NetBSD__)
untimeout(uhci_timo, pipe->intrreqh);
#elif defined(__FreeBSD__)
- untimeout(uhci_timo, pipe->intrreqh, pipe->intrreqh->callout_handler);
+ untimeout(uhci_timo, pipe->intrreqh, pipe->intrreqh->timo_handle);
#endif
DPRINTF(("uhci_root_ctrl_close\n"));
}
@@ -2299,7 +2306,7 @@ uhci_root_intr_abort(reqh)
#if defined(__NetBSD__)
untimeout(uhci_timo, reqh);
#elif defined(__FreeBSD__)
- untimeout(uhci_timo, reqh, reqh->callout_handler);
+ untimeout(uhci_timo, reqh, reqh->timo_handle);
#endif
}
@@ -2335,8 +2342,8 @@ uhci_root_intr_transfer(reqh)
* before we use it. The timeout happen between the setting
* of the timeout and the setting of callout_handle
*/
- callout_handle_init(&reqh->callout_handler);
- reqh->callout_handler = timeout(uhci_timo, reqh, sc->sc_ival);
+ callout_handle_init(&reqh->timo_handle);
+ reqh->timo_handle = timeout(uhci_timo, reqh, sc->sc_ival);
#endif
return (USBD_IN_PROGRESS);
}
@@ -2349,7 +2356,7 @@ uhci_root_intr_close(pipe)
#if defined(__NetBSD__)
untimeout(uhci_timo, pipe->intrreqh);
#elif defined(__FreeBSD__)
- untimeout(uhci_timo, pipe->intrreqh, pipe->intrreqh->callout_handler);
+ untimeout(uhci_timo, pipe->intrreqh, pipe->intrreqh->timo_handle);
#endif
DPRINTF(("uhci_root_intr_close\n"));
}
diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h
index b7102f3..9891908 100644
--- a/sys/dev/usb/uhcivar.h
+++ b/sys/dev/usb/uhcivar.h
@@ -63,7 +63,7 @@ typedef struct uhci_soft_td uhci_soft_td_t;
*/
typedef struct uhci_intr_info {
#if defined(__FreeBSD__)
- struct callout_handle callout_handler;
+ struct callout_handle timeout_handle;
#endif
struct uhci_softc *sc;
usbd_request_handle reqh;
@@ -124,7 +124,6 @@ typedef struct uhci_softc {
/* XXX should keep track of all DMA memory */
#elif defined(__FreeBSD__)
int sc_iobase;
- int sc_int;
int unit;
#endif
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index a2f759f..204326a 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -76,9 +76,11 @@ struct uhub_softc {
#if defined(__NetBSD__)
int uhub_match __P((struct device *, struct cfdata *, void *));
void uhub_attach __P((struct device *, struct device *, void *));
+void uhub_detach __P((struct device *));
#elif defined(__FreeBSD__)
static device_probe_t uhub_match;
static device_attach_t uhub_attach;
+static device_detach_t uhub_detach;
#endif
usbd_status uhub_init_port __P((int, struct usbd_port *, usbd_device_handle));
@@ -105,6 +107,7 @@ static devclass_t uhub_devclass;
static device_method_t uhub_methods[] = {
DEVMETHOD(device_probe, uhub_match),
DEVMETHOD(device_attach, uhub_attach),
+ DEVMETHOD(device_detach, uhub_detach),
{0,0}
};
@@ -137,7 +140,7 @@ uhub_match(device_t device)
#endif
usb_device_descriptor_t *dd = usbd_get_device_descriptor(uaa->device);
- DPRINTFN(1,("uhub_match, dd=%p\n", dd));
+ DPRINTFN(5,("uhub_match, dd=%p\n", dd));
/*
* The subclass for hubs seems to be 0 for some and 1 for others,
* so we just ignore the subclass.
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 3cea6ba..04640d2 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -264,7 +264,7 @@ usb_print_child(device_t parent, device_t child)
*/
int
-usb_driver_load(module_t mod, modeventtype_t what, void *arg)
+usb_driver_load(module_t mod, int what, void *arg)
{
/* subroutine is there but inactive at the moment
* the reconfiguration process has not been thought through yet.
diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h
index df66674..956163d 100644
--- a/sys/dev/usb/usb_port.h
+++ b/sys/dev/usb/usb_port.h
@@ -11,7 +11,6 @@
#define DEVICE_NAME(bdev) \
printf("%s: ", (bdev).dv_xname)
-#define DEVICE_MSG(bdev
typedef struct device bdevice; /* base device */
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 63fc7e4..c589153 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -816,8 +816,9 @@ usbd_remove_device(dev, up)
#if defined(__NetBSD__)
/* XXX bit of a hack, only for hubs the detach is called
- * the code should register a detach function and use that one
- * to detach a device porperly
+ *
+ * easiest solution, register a detach method in the softc, call that
+ * one and pass the device struct to it, or the softc. Whatever.
*/
if (dev->bdev && dev->hub)
uhub_detach(dev->hub->hubdata);
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 40e7947..9d0db26 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -174,7 +174,7 @@ struct usbd_request {
void *hcpriv; /* XXX private use by the HC driver */
#if defined(__FreeBSD__)
- struct callout_handle callout_handler;
+ struct callout_handle timo_handle;
#endif
};
@@ -205,8 +205,7 @@ usbd_status usb_get_bus_handle __P((int, usbd_bus_handle *));
void usb_needs_explore __P((usbd_bus_handle));
#if defined(__FreeBSD__)
-int usb_driver_load __P((module_t mod, modeventtype_t what,
- void *arg));
+int usb_driver_load __P((module_t mod, int what, void *arg));
void usb_device_set_desc __P((device_t device, char *devinfo));
#endif
OpenPOWER on IntegriCloud