summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2002-02-16 00:51:26 +0000
committerjoe <joe@FreeBSD.org>2002-02-16 00:51:26 +0000
commite6201be54af255a094c24aa04232391ef85e7f58 (patch)
tree9c0ec415f0dfcb9ea00bb065aa1466311f4ea70b
parent19331922cd0fb5b41d689b594c3d4be59594b572 (diff)
downloadFreeBSD-src-e6201be54af255a094c24aa04232391ef85e7f58.zip
FreeBSD-src-e6201be54af255a094c24aa04232391ef85e7f58.tar.gz
Merge from NetBSD:
Pave the way for USB2, by replacing 'lowspeed' with 'speed', so that it can take the values USB_SPEED_LOW, USB_SPEED_FULL or in time USB_SPEED_HIGH.
-rw-r--r--sys/dev/usb/ohci.c4
-rw-r--r--sys/dev/usb/uhci.c12
-rw-r--r--sys/dev/usb/usb.h5
-rw-r--r--sys/dev/usb/usb_subr.c14
-rw-r--r--sys/dev/usb/usbdivar.h2
5 files changed, 21 insertions, 16 deletions
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index b6eaea9..9ad8ee9 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1751,7 +1751,8 @@ ohci_open(usbd_pipe_handle pipe)
OHCI_ED_SET_FA(addr) |
OHCI_ED_SET_EN(ed->bEndpointAddress) |
OHCI_ED_DIR_TD |
- (dev->lowspeed ? OHCI_ED_SPEED : 0) | fmt |
+ (dev->speed == USB_SPEED_LOW ? OHCI_ED_SPEED : 0) |
+ fmt |
OHCI_ED_SET_MAXP(UGETW(ed->wMaxPacketSize)));
sed->ed.ed_headp = sed->ed.ed_tailp = htole32(tdphys);
@@ -2171,6 +2172,7 @@ ohci_root_ctrl_start(usbd_xfer_handle xfer)
OWRITE4(sc, port, UPS_OVERCURRENT_INDICATOR);
break;
case UHF_PORT_POWER:
+ /* Yes, writing to the LOW_SPEED bit clears power. */
OWRITE4(sc, port, UPS_LOW_SPEED);
break;
case UHF_C_PORT_CONNECTION:
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index a78582b..5d20a23 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1634,9 +1634,9 @@ uhci_alloc_std_chain(struct uhci_pipe *upipe, uhci_softc_t *sc, int len,
int addr = upipe->pipe.device->address;
int endpt = upipe->pipe.endpoint->edesc->bEndpointAddress;
- DPRINTFN(8, ("uhci_alloc_std_chain: addr=%d endpt=%d len=%d ls=%d "
+ DPRINTFN(8, ("uhci_alloc_std_chain: addr=%d endpt=%d len=%d speed=%d "
"flags=0x%x\n", addr, UE_GET_ADDR(endpt), len,
- upipe->pipe.device->lowspeed, flags));
+ upipe->pipe.device->speed, flags));
maxp = UGETW(upipe->pipe.endpoint->edesc->wMaxPacketSize);
if (maxp == 0) {
printf("uhci_alloc_std_chain: maxp=0\n");
@@ -1659,7 +1659,7 @@ uhci_alloc_std_chain(struct uhci_pipe *upipe, uhci_softc_t *sc, int len,
lastlink = UHCI_PTR_T;
ntd--;
status = UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(3) | UHCI_TD_ACTIVE);
- if (upipe->pipe.device->lowspeed)
+ if (upipe->pipe.device->speed == USB_SPEED_LOW)
status |= UHCI_TD_LS;
if (flags & USBD_SHORT_XFER_OK)
status |= UHCI_TD_SPD;
@@ -2100,7 +2100,7 @@ uhci_device_request(usbd_xfer_handle xfer)
UGETW(req->wIndex), UGETW(req->wLength),
addr, endpt));
- ls = dev->lowspeed ? UHCI_TD_LS : 0;
+ ls = dev->speed == USB_SPEED_LOW ? UHCI_TD_LS : 0;
isread = req->bmRequestType & UT_READ;
len = UGETW(req->wLength);
@@ -2167,7 +2167,7 @@ uhci_device_request(usbd_xfer_handle xfer)
sqh->intr_info = ii;
s = splusb();
- if (dev->lowspeed)
+ if (dev->speed == USB_SPEED_LOW)
uhci_add_ls_ctrl(sc, sqh);
else
uhci_add_hs_ctrl(sc, sqh);
@@ -2590,7 +2590,7 @@ uhci_device_ctrl_done(usbd_xfer_handle xfer)
LIST_REMOVE(ii, list); /* remove from active list */
- if (upipe->pipe.device->lowspeed)
+ if (upipe->pipe.device->speed == USB_SPEED_LOW)
uhci_remove_ls_ctrl(sc, upipe->u.ctl.sqh);
else
uhci_remove_hs_ctrl(sc, upipe->u.ctl.sqh);
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index 8d5a3da..2951eca 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -597,7 +597,10 @@ struct usb_device_info {
u_int8_t subclass;
u_int8_t protocol;
u_int8_t config;
- u_int8_t lowspeed;
+ u_int8_t speed;
+#define USB_SPEED_LOW 1
+#define USB_SPEED_FULL 2
+#define USB_SPEED_HIGH 3
int power; /* power consumption in mA, 0 if selfpowered */
int nports;
char devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 2565c44..abbbe90 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -905,7 +905,7 @@ usbd_probe_and_attach(device_ptr_t parent, usbd_device_handle dev,
*/
usbd_status
usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
- int lowspeed, int port, struct usbd_port *up)
+ int speed, int port, struct usbd_port *up)
{
usbd_device_handle dev;
usb_device_descriptor_t *dd;
@@ -913,8 +913,8 @@ usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
int addr;
int i;
- DPRINTF(("usbd_new_device bus=%p port=%d depth=%d lowspeed=%d\n",
- bus, port, depth, lowspeed));
+ DPRINTF(("usbd_new_device bus=%p port=%d depth=%d speed=%d\n",
+ bus, port, depth, speed));
addr = usbd_getnewaddr(bus);
if (addr < 0) {
printf("%s: No free USB addresses, new device ignored.\n",
@@ -943,10 +943,10 @@ usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
dev->quirks = &usbd_no_quirk;
dev->address = USB_START_ADDR;
dev->ddesc.bMaxPacketSize = 0;
- dev->lowspeed = lowspeed != 0;
dev->depth = depth;
dev->powersrc = up;
dev->langid = USBD_NOLANG;
+ dev->speed = speed;
dev->cookie.cookie = ++usb_cookie_no;
/* Establish the default pipe. */
@@ -975,10 +975,10 @@ usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
}
DPRINTF(("usbd_new_device: adding unit addr=%d, rev=%02x, class=%d, "
- "subclass=%d, protocol=%d, maxpacket=%d, len=%d, ls=%d\n",
+ "subclass=%d, protocol=%d, maxpacket=%d, len=%d, speed=%d\n",
addr,UGETW(dd->bcdUSB), dd->bDeviceClass, dd->bDeviceSubClass,
dd->bDeviceProtocol, dd->bMaxPacketSize, dd->bLength,
- dev->lowspeed));
+ dev->speed));
if (dd->bDescriptorType != UDESC_DEVICE) {
/* Illegal device descriptor */
@@ -1169,7 +1169,7 @@ usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di,
di->protocol = dev->ddesc.bDeviceProtocol;
di->config = dev->config;
di->power = dev->self_powered ? 0 : dev->power;
- di->lowspeed = dev->lowspeed;
+ di->speed = dev->speed;
if (dev->subdevs != NULL) {
for (i = 0; dev->subdevs[i] &&
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 6057e19..4ad129d 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -123,7 +123,7 @@ struct usbd_device {
u_int8_t address; /* device addess */
u_int8_t config; /* current configuration # */
u_int8_t depth; /* distance from root hub */
- u_int8_t lowspeed; /* lowspeed flag */
+ u_int8_t speed; /* low/full/high speed */
u_int8_t self_powered; /* flag for self powered */
u_int16_t power; /* mA the device uses */
int16_t langid; /* language for strings */
OpenPOWER on IntegriCloud