Fri Jan 7 02:50:47 2011 UTC ()
Add Embedded Transaction Translator Function support.  No proof it works
yet.


(matt)
diff -r1.154.4.2 -r1.154.4.2.4.1 src/sys/dev/usb/ehci.c
diff -r1.28.4.1 -r1.28.4.1.8.1 src/sys/dev/usb/ehcireg.h
diff -r1.33 -r1.33.16.1 src/sys/dev/usb/ehcivar.h

cvs diff -r1.154.4.2 -r1.154.4.2.4.1 src/sys/dev/usb/ehci.c (expand / switch to unified diff)

--- src/sys/dev/usb/ehci.c 2010/06/12 01:05:44 1.154.4.2
+++ src/sys/dev/usb/ehci.c 2011/01/07 02:50:47 1.154.4.2.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehci.c,v 1.154.4.2 2010/06/12 01:05:44 riz Exp $ */ 1/* $NetBSD: ehci.c,v 1.154.4.2.4.1 2011/01/07 02:50:47 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004-2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004-2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum and 8 * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum and
9 * Jeremy Morse (jeremy.morse@gmail.com). 9 * Jeremy Morse (jeremy.morse@gmail.com).
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -42,27 +42,27 @@ @@ -42,27 +42,27 @@
42 42
43/* 43/*
44 * TODO: 44 * TODO:
45 * 1) hold off explorations by companion controllers until ehci has started. 45 * 1) hold off explorations by companion controllers until ehci has started.
46 * 46 *
47 * 2) The hub driver needs to handle and schedule the transaction translator, 47 * 2) The hub driver needs to handle and schedule the transaction translator,
48 * to assign place in frame where different devices get to go. See chapter 48 * to assign place in frame where different devices get to go. See chapter
49 * on hubs in USB 2.0 for details. 49 * on hubs in USB 2.0 for details.
50 * 50 *
51 * 3) command failures are not recovered correctly 51 * 3) command failures are not recovered correctly
52 */ 52 */
53 53
54#include <sys/cdefs.h> 54#include <sys/cdefs.h>
55__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.154.4.2 2010/06/12 01:05:44 riz Exp $"); 55__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.154.4.2.4.1 2011/01/07 02:50:47 matt Exp $");
56 56
57#include "ohci.h" 57#include "ohci.h"
58#include "uhci.h" 58#include "uhci.h"
59 59
60#include <sys/param.h> 60#include <sys/param.h>
61#include <sys/systm.h> 61#include <sys/systm.h>
62#include <sys/kernel.h> 62#include <sys/kernel.h>
63#include <sys/malloc.h> 63#include <sys/malloc.h>
64#include <sys/device.h> 64#include <sys/device.h>
65#include <sys/select.h> 65#include <sys/select.h>
66#include <sys/proc.h> 66#include <sys/proc.h>
67#include <sys/queue.h> 67#include <sys/queue.h>
68#include <sys/mutex.h> 68#include <sys/mutex.h>
@@ -386,26 +386,37 @@ ehci_init(ehci_softc_t *sc) @@ -386,26 +386,37 @@ ehci_init(ehci_softc_t *sc)
386 usb_delay_ms(&sc->sc_bus, 1); 386 usb_delay_ms(&sc->sc_bus, 1);
387 EOWRITE4(sc, EHCI_USBCMD, EHCI_CMD_HCRESET); 387 EOWRITE4(sc, EHCI_USBCMD, EHCI_CMD_HCRESET);
388 for (i = 0; i < 100; i++) { 388 for (i = 0; i < 100; i++) {
389 usb_delay_ms(&sc->sc_bus, 1); 389 usb_delay_ms(&sc->sc_bus, 1);
390 hcr = EOREAD4(sc, EHCI_USBCMD) & EHCI_CMD_HCRESET; 390 hcr = EOREAD4(sc, EHCI_USBCMD) & EHCI_CMD_HCRESET;
391 if (!hcr) 391 if (!hcr)
392 break; 392 break;
393 } 393 }
394 if (hcr) { 394 if (hcr) {
395 aprint_error("%s: reset timeout\n", device_xname(sc->sc_dev)); 395 aprint_error("%s: reset timeout\n", device_xname(sc->sc_dev));
396 return (USBD_IOERROR); 396 return (USBD_IOERROR);
397 } 397 }
398 398
 399 /*
 400 * If we are doing embedded transaction translation function, force
 401 * the controller to host mode.
 402 */
 403 if (sc->sc_flags & EHCIF_ETTF) {
 404 uint32_t usbmode = EREAD4(sc, EHCI_USBMODE);
 405 usbmode &= ~EHCI_USBMODE_CM;
 406 usbmode |= EHCI_USBMODE_CM_HOST;
 407 EWRITE4(sc, EHCI_USBMODE, usbmode);
 408 }
 409
399 /* XXX need proper intr scheduling */ 410 /* XXX need proper intr scheduling */
400 sc->sc_rand = 96; 411 sc->sc_rand = 96;
401 412
402 /* frame list size at default, read back what we got and use that */ 413 /* frame list size at default, read back what we got and use that */
403 switch (EHCI_CMD_FLS(EOREAD4(sc, EHCI_USBCMD))) { 414 switch (EHCI_CMD_FLS(EOREAD4(sc, EHCI_USBCMD))) {
404 case 0: sc->sc_flsize = 1024; break; 415 case 0: sc->sc_flsize = 1024; break;
405 case 1: sc->sc_flsize = 512; break; 416 case 1: sc->sc_flsize = 512; break;
406 case 2: sc->sc_flsize = 256; break; 417 case 2: sc->sc_flsize = 256; break;
407 case 3: return (USBD_IOERROR); 418 case 3: return (USBD_IOERROR);
408 } 419 }
409 err = usb_allocmem(&sc->sc_bus, sc->sc_flsize * sizeof(ehci_link_t), 420 err = usb_allocmem(&sc->sc_bus, sc->sc_flsize * sizeof(ehci_link_t),
410 EHCI_FLALIGN_ALIGN, &sc->sc_fldma); 421 EHCI_FLALIGN_ALIGN, &sc->sc_fldma);
411 if (err) 422 if (err)
@@ -1537,27 +1548,37 @@ ehci_open(usbd_pipe_handle pipe) @@ -1537,27 +1548,37 @@ ehci_open(usbd_pipe_handle pipe)
1537 u_int8_t addr = dev->address; 1548 u_int8_t addr = dev->address;
1538 u_int8_t xfertype = ed->bmAttributes & UE_XFERTYPE; 1549 u_int8_t xfertype = ed->bmAttributes & UE_XFERTYPE;
1539 struct ehci_pipe *epipe = (struct ehci_pipe *)pipe; 1550 struct ehci_pipe *epipe = (struct ehci_pipe *)pipe;
1540 ehci_soft_qh_t *sqh; 1551 ehci_soft_qh_t *sqh;
1541 usbd_status err; 1552 usbd_status err;
1542 int s; 1553 int s;
1543 int ival, speed, naks; 1554 int ival, speed, naks;
1544 int hshubaddr, hshubport; 1555 int hshubaddr, hshubport;
1545 1556
1546 DPRINTFN(1, ("ehci_open: pipe=%p, addr=%d, endpt=%d (%d)\n", 1557 DPRINTFN(1, ("ehci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
1547 pipe, addr, ed->bEndpointAddress, sc->sc_addr)); 1558 pipe, addr, ed->bEndpointAddress, sc->sc_addr));
1548 1559
1549 if (dev->myhsport) { 1560 if (dev->myhsport) {
1550 hshubaddr = dev->myhsport->parent->address; 1561 /*
 1562 * When directly attached FS/LS device while doing embedded
 1563 * transaction translations and we are the hub, set the hub
 1564 * adddress to 0 (us).
 1565 */
 1566 if (!(sc->sc_flags & EHCIF_ETTF)
 1567 || (dev->myhsport->parent->address != sc->sc_addr)) {
 1568 hshubaddr = dev->myhsport->parent->address;
 1569 } else {
 1570 hshubaddr = 0;
 1571 }
1551 hshubport = dev->myhsport->portno; 1572 hshubport = dev->myhsport->portno;
1552 } else { 1573 } else {
1553 hshubaddr = 0; 1574 hshubaddr = 0;
1554 hshubport = 0; 1575 hshubport = 0;
1555 } 1576 }
1556 1577
1557 if (sc->sc_dying) 1578 if (sc->sc_dying)
1558 return (USBD_IOERROR); 1579 return (USBD_IOERROR);
1559 1580
1560 epipe->nexttoggle = 0; 1581 epipe->nexttoggle = 0;
1561 1582
1562 if (addr == sc->sc_addr) { 1583 if (addr == sc->sc_addr) {
1563 switch (ed->bEndpointAddress) { 1584 switch (ed->bEndpointAddress) {
@@ -2245,27 +2266,38 @@ ehci_root_ctrl_start(usbd_xfer_handle xf @@ -2245,27 +2266,38 @@ ehci_root_ctrl_start(usbd_xfer_handle xf
2245 DPRINTFN(8,("ehci_root_ctrl_start: get port status i=%d\n", 2266 DPRINTFN(8,("ehci_root_ctrl_start: get port status i=%d\n",
2246 index)); 2267 index));
2247 if (index < 1 || index > sc->sc_noport) { 2268 if (index < 1 || index > sc->sc_noport) {
2248 err = USBD_IOERROR; 2269 err = USBD_IOERROR;
2249 goto ret; 2270 goto ret;
2250 } 2271 }
2251 if (len != 4) { 2272 if (len != 4) {
2252 err = USBD_IOERROR; 2273 err = USBD_IOERROR;
2253 goto ret; 2274 goto ret;
2254 } 2275 }
2255 v = EOREAD4(sc, EHCI_PORTSC(index)); 2276 v = EOREAD4(sc, EHCI_PORTSC(index));
2256 DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n", 2277 DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n",
2257 v)); 2278 v));
2258 i = UPS_HIGH_SPEED; 2279
 2280 if (sc->sc_flags & EHCIF_ETTF) {
 2281 /*
 2282 * If we are doing embedded transaction translation,
 2283 * then directly attached LS/FS devices are reset by
 2284 * the EHCI controller itself. PSPD is encoded
 2285 * the same way as in USBSTATUS.
 2286 */
 2287 i = __SHIFTOUT(v, EHCI_PS_PSPD) * UPS_LOW_SPEED;
 2288 } else {
 2289 i = UPS_HIGH_SPEED;
 2290 }
2259 if (v & EHCI_PS_CS) i |= UPS_CURRENT_CONNECT_STATUS; 2291 if (v & EHCI_PS_CS) i |= UPS_CURRENT_CONNECT_STATUS;
2260 if (v & EHCI_PS_PE) i |= UPS_PORT_ENABLED; 2292 if (v & EHCI_PS_PE) i |= UPS_PORT_ENABLED;
2261 if (v & EHCI_PS_SUSP) i |= UPS_SUSPEND; 2293 if (v & EHCI_PS_SUSP) i |= UPS_SUSPEND;
2262 if (v & EHCI_PS_OCA) i |= UPS_OVERCURRENT_INDICATOR; 2294 if (v & EHCI_PS_OCA) i |= UPS_OVERCURRENT_INDICATOR;
2263 if (v & EHCI_PS_PR) i |= UPS_RESET; 2295 if (v & EHCI_PS_PR) i |= UPS_RESET;
2264 if (v & EHCI_PS_PP) i |= UPS_PORT_POWER; 2296 if (v & EHCI_PS_PP) i |= UPS_PORT_POWER;
2265 USETW(ps.wPortStatus, i); 2297 USETW(ps.wPortStatus, i);
2266 i = 0; 2298 i = 0;
2267 if (v & EHCI_PS_CSC) i |= UPS_C_CONNECT_STATUS; 2299 if (v & EHCI_PS_CSC) i |= UPS_C_CONNECT_STATUS;
2268 if (v & EHCI_PS_PEC) i |= UPS_C_PORT_ENABLED; 2300 if (v & EHCI_PS_PEC) i |= UPS_C_PORT_ENABLED;
2269 if (v & EHCI_PS_OCC) i |= UPS_C_OVERCURRENT_INDICATOR; 2301 if (v & EHCI_PS_OCC) i |= UPS_C_OVERCURRENT_INDICATOR;
2270 if (sc->sc_isreset[index]) i |= UPS_C_PORT_RESET; 2302 if (sc->sc_isreset[index]) i |= UPS_C_PORT_RESET;
2271 USETW(ps.wPortChange, i); 2303 USETW(ps.wPortChange, i);
@@ -2287,48 +2319,61 @@ ehci_root_ctrl_start(usbd_xfer_handle xf @@ -2287,48 +2319,61 @@ ehci_root_ctrl_start(usbd_xfer_handle xf
2287 v = EOREAD4(sc, port); 2319 v = EOREAD4(sc, port);
2288 DPRINTFN(4, ("ehci_root_ctrl_start: portsc=0x%08x\n", v)); 2320 DPRINTFN(4, ("ehci_root_ctrl_start: portsc=0x%08x\n", v));
2289 v &= ~EHCI_PS_CLEAR; 2321 v &= ~EHCI_PS_CLEAR;
2290 switch(value) { 2322 switch(value) {
2291 case UHF_PORT_ENABLE: 2323 case UHF_PORT_ENABLE:
2292 EOWRITE4(sc, port, v | EHCI_PS_PE); 2324 EOWRITE4(sc, port, v | EHCI_PS_PE);
2293 break; 2325 break;
2294 case UHF_PORT_SUSPEND: 2326 case UHF_PORT_SUSPEND:
2295 EOWRITE4(sc, port, v | EHCI_PS_SUSP); 2327 EOWRITE4(sc, port, v | EHCI_PS_SUSP);
2296 break; 2328 break;
2297 case UHF_PORT_RESET: 2329 case UHF_PORT_RESET:
2298 DPRINTFN(5,("ehci_root_ctrl_start: reset port %d\n", 2330 DPRINTFN(5,("ehci_root_ctrl_start: reset port %d\n",
2299 index)); 2331 index));
2300 if (EHCI_PS_IS_LOWSPEED(v)) { 2332 if (EHCI_PS_IS_LOWSPEED(v)
2301 /* Low speed device, give up ownership. */ 2333 && !(sc->sc_flags & EHCIF_ETTF)) {
 2334 /*
 2335 * Low speed device on non-ETTF controller,
 2336 * give up ownership.
 2337 */
2302 ehci_disown(sc, index, 1); 2338 ehci_disown(sc, index, 1);
2303 break; 2339 break;
2304 } 2340 }
2305 /* Start reset sequence. */ 2341 /* Start reset sequence. */
2306 v &= ~ (EHCI_PS_PE | EHCI_PS_PR); 2342 v &= ~ (EHCI_PS_PE | EHCI_PS_PR);
2307 EOWRITE4(sc, port, v | EHCI_PS_PR); 2343 EOWRITE4(sc, port, v | EHCI_PS_PR);
2308 /* Wait for reset to complete. */ 2344 /* Wait for reset to complete. */
2309 usb_delay_ms(&sc->sc_bus, USB_PORT_ROOT_RESET_DELAY); 2345 usb_delay_ms(&sc->sc_bus, USB_PORT_ROOT_RESET_DELAY);
2310 if (sc->sc_dying) { 2346 if (sc->sc_dying) {
2311 err = USBD_IOERROR; 2347 err = USBD_IOERROR;
2312 goto ret; 2348 goto ret;
2313 } 2349 }
2314 /* Terminate reset sequence. */ 2350 /*
2315 EOWRITE4(sc, port, v); 2351 * An embedded transaction translater will automatically
2316 /* Wait for HC to complete reset. */ 2352 * terminate the reset sequence so there's no need to
2317 usb_delay_ms(&sc->sc_bus, EHCI_PORT_RESET_COMPLETE); 2353 * it.
2318 if (sc->sc_dying) { 2354 */
2319 err = USBD_IOERROR; 2355 if (!(sc->sc_flags & EHCIF_ETTF)) {
2320 goto ret; 2356 /* Terminate reset sequence. */
 2357 EOWRITE4(sc, port, v);
 2358 /* Wait for HC to complete reset. */
 2359 usb_delay_ms(&sc->sc_bus,
 2360 EHCI_PORT_RESET_COMPLETE);
 2361 if (sc->sc_dying) {
 2362 err = USBD_IOERROR;
 2363 goto ret;
 2364 }
2321 } 2365 }
 2366
2322 v = EOREAD4(sc, port); 2367 v = EOREAD4(sc, port);
2323 DPRINTF(("ehci after reset, status=0x%08x\n", v)); 2368 DPRINTF(("ehci after reset, status=0x%08x\n", v));
2324 if (v & EHCI_PS_PR) { 2369 if (v & EHCI_PS_PR) {
2325 printf("%s: port reset timeout\n", 2370 printf("%s: port reset timeout\n",
2326 device_xname(sc->sc_dev)); 2371 device_xname(sc->sc_dev));
2327 return (USBD_TIMEOUT); 2372 return (USBD_TIMEOUT);
2328 } 2373 }
2329 if (!(v & EHCI_PS_PE)) { 2374 if (!(v & EHCI_PS_PE)) {
2330 /* Not a high speed device, give up ownership.*/ 2375 /* Not a high speed device, give up ownership.*/
2331 ehci_disown(sc, index, 0); 2376 ehci_disown(sc, index, 0);
2332 break; 2377 break;
2333 } 2378 }
2334 sc->sc_isreset[index] = 1; 2379 sc->sc_isreset[index] = 1;

cvs diff -r1.28.4.1 -r1.28.4.1.8.1 src/sys/dev/usb/ehcireg.h (expand / switch to unified diff)

--- src/sys/dev/usb/ehcireg.h 2008/11/29 20:47:05 1.28.4.1
+++ src/sys/dev/usb/ehcireg.h 2011/01/07 02:50:47 1.28.4.1.8.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehcireg.h,v 1.28.4.1 2008/11/29 20:47:05 bouyer Exp $ */ 1/* $NetBSD: ehcireg.h,v 1.28.4.1.8.1 2011/01/07 02:50:47 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net). 8 * by Lennart Augustsson (lennart@augustsson.net).
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -66,26 +66,28 @@ @@ -66,26 +66,28 @@
66#define EHCI_LEG_EXT_SMI_OS_CHANGE 0x20000000 66#define EHCI_LEG_EXT_SMI_OS_CHANGE 0x20000000
67 67
68#define EHCI_CAP_GET_ID(cap) ((cap) & 0xff) 68#define EHCI_CAP_GET_ID(cap) ((cap) & 0xff)
69#define EHCI_CAP_GET_NEXT(cap) (((cap) >> 8) & 0xff) 69#define EHCI_CAP_GET_NEXT(cap) (((cap) >> 8) & 0xff)
70#define EHCI_CAP_ID_LEGACY 1 70#define EHCI_CAP_ID_LEGACY 1
71 71
72/*** EHCI capability registers ***/ 72/*** EHCI capability registers ***/
73 73
74#define EHCI_CAPLENGTH 0x00 /*RO Capability register length field */ 74#define EHCI_CAPLENGTH 0x00 /*RO Capability register length field */
75/* reserved 0x01 */ 75/* reserved 0x01 */
76#define EHCI_HCIVERSION 0x02 /* RO Interface version number */ 76#define EHCI_HCIVERSION 0x02 /* RO Interface version number */
77 77
78#define EHCI_HCSPARAMS 0x04 /* RO Structural parameters */ 78#define EHCI_HCSPARAMS 0x04 /* RO Structural parameters */
 79#define EHCI_HCS_N_TT(x) (((x) >> 20) & 0xf) /* # of xacts xlater ETTF */
 80#define EHCI_HCS_N_PTT(x) (((x) >> 20) & 0xf) /* ports per xlater ETTF */
79#define EHCI_HCS_DEBUGPORT(x) (((x) >> 20) & 0xf) 81#define EHCI_HCS_DEBUGPORT(x) (((x) >> 20) & 0xf)
80#define EHCI_HCS_P_INDICATOR(x) ((x) & 0x10000) 82#define EHCI_HCS_P_INDICATOR(x) ((x) & 0x10000)
81#define EHCI_HCS_N_CC(x) (((x) >> 12) & 0xf) /* # of companion ctlrs */ 83#define EHCI_HCS_N_CC(x) (((x) >> 12) & 0xf) /* # of companion ctlrs */
82#define EHCI_HCS_N_PCC(x) (((x) >> 8) & 0xf) /* # of ports per comp. */ 84#define EHCI_HCS_N_PCC(x) (((x) >> 8) & 0xf) /* # of ports per comp. */
83#define EHCI_HCS_PPC(x) ((x) & 0x10) /* port power control */ 85#define EHCI_HCS_PPC(x) ((x) & 0x10) /* port power control */
84#define EHCI_HCS_N_PORTS(x) ((x) & 0xf) /* # of ports */ 86#define EHCI_HCS_N_PORTS(x) ((x) & 0xf) /* # of ports */
85 87
86#define EHCI_HCCPARAMS 0x08 /* RO Capability parameters */ 88#define EHCI_HCCPARAMS 0x08 /* RO Capability parameters */
87#define EHCI_HCC_EECP(x) (((x) >> 8) & 0xff) /* extended ports caps */ 89#define EHCI_HCC_EECP(x) (((x) >> 8) & 0xff) /* extended ports caps */
88#define EHCI_HCC_IST(x) (((x) >> 4) & 0xf) /* isoc sched threshold */ 90#define EHCI_HCC_IST(x) (((x) >> 4) & 0xf) /* isoc sched threshold */
89#define EHCI_HCC_ASPC(x) ((x) & 0x4) /* async sched park cap */ 91#define EHCI_HCC_ASPC(x) ((x) & 0x4) /* async sched park cap */
90#define EHCI_HCC_PFLF(x) ((x) & 0x2) /* prog frame list flag */ 92#define EHCI_HCC_PFLF(x) ((x) & 0x2) /* prog frame list flag */
91#define EHCI_HCC_64BIT(x) ((x) & 0x1) /* 64 bit address cap */ 93#define EHCI_HCC_64BIT(x) ((x) & 0x1) /* 64 bit address cap */
@@ -137,48 +139,61 @@ @@ -137,48 +139,61 @@
137#define EHCI_INTR_UIE 0x00000001 /* USB intr ena */ 139#define EHCI_INTR_UIE 0x00000001 /* USB intr ena */
138 140
139#define EHCI_FRINDEX 0x0c /* RW Frame Index register */ 141#define EHCI_FRINDEX 0x0c /* RW Frame Index register */
140 142
141#define EHCI_CTRLDSSEGMENT 0x10 /* RW Control Data Structure Segment */ 143#define EHCI_CTRLDSSEGMENT 0x10 /* RW Control Data Structure Segment */
142 144
143#define EHCI_PERIODICLISTBASE 0x14 /* RW Periodic List Base */ 145#define EHCI_PERIODICLISTBASE 0x14 /* RW Periodic List Base */
144#define EHCI_ASYNCLISTADDR 0x18 /* RW Async List Base */ 146#define EHCI_ASYNCLISTADDR 0x18 /* RW Async List Base */
145 147
146#define EHCI_CONFIGFLAG 0x40 /* RW Configure Flag register */ 148#define EHCI_CONFIGFLAG 0x40 /* RW Configure Flag register */
147#define EHCI_CONF_CF 0x00000001 /* RW configure flag */ 149#define EHCI_CONF_CF 0x00000001 /* RW configure flag */
148 150
149#define EHCI_PORTSC(n) (0x40+4*(n)) /* RO, RW, RWC Port Status reg */ 151#define EHCI_PORTSC(n) (0x40+4*(n)) /* RO, RW, RWC Port Status reg */
 152#define EHCI_PS_PSPD 0x03000000 /* RO port speed (ETTF) */
 153#define EHCI_PS_PSPD_FS 0x00000000 /* Full speed (ETTF) */
 154#define EHCI_PS_PSPD_LS 0x01000000 /* Low speed (ETTF) */
 155#define EHCI_PS_PSPD_HS 0x02000000 /* High speed (ETTF) */
150#define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over current ena */ 156#define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over current ena */
151#define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect ena */ 157#define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect ena */
152#define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect ena */ 158#define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect ena */
153#define EHCI_PS_PTC 0x000f0000 /* RW port test control */ 159#define EHCI_PS_PTC 0x000f0000 /* RW port test control */
154#define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */ 160#define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */
155#define EHCI_PS_PO 0x00002000 /* RW port owner */ 161#define EHCI_PS_PO 0x00002000 /* RW port owner */
156#define EHCI_PS_PP 0x00001000 /* RW,RO port power */ 162#define EHCI_PS_PP 0x00001000 /* RW,RO port power */
157#define EHCI_PS_LS 0x00000c00 /* RO line status */ 163#define EHCI_PS_LS 0x00000c00 /* RO line status */
158#define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400) 164#define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400)
159#define EHCI_PS_PR 0x00000100 /* RW port reset */ 165#define EHCI_PS_PR 0x00000100 /* RW port reset */
160#define EHCI_PS_SUSP 0x00000080 /* RW suspend */ 166#define EHCI_PS_SUSP 0x00000080 /* RW suspend */
161#define EHCI_PS_FPR 0x00000040 /* RW force port resume */ 167#define EHCI_PS_FPR 0x00000040 /* RW force port resume */
162#define EHCI_PS_OCC 0x00000020 /* RWC over current change */ 168#define EHCI_PS_OCC 0x00000020 /* RWC over current change */
163#define EHCI_PS_OCA 0x00000010 /* RO over current active */ 169#define EHCI_PS_OCA 0x00000010 /* RO over current active */
164#define EHCI_PS_PEC 0x00000008 /* RWC port enable change */ 170#define EHCI_PS_PEC 0x00000008 /* RWC port enable change */
165#define EHCI_PS_PE 0x00000004 /* RW port enable */ 171#define EHCI_PS_PE 0x00000004 /* RW port enable */
166#define EHCI_PS_CSC 0x00000002 /* RWC connect status change */ 172#define EHCI_PS_CSC 0x00000002 /* RWC connect status change */
167#define EHCI_PS_CS 0x00000001 /* RO connect status */ 173#define EHCI_PS_CS 0x00000001 /* RO connect status */
168#define EHCI_PS_CLEAR (EHCI_PS_OCC|EHCI_PS_PEC|EHCI_PS_CSC) 174#define EHCI_PS_CLEAR (EHCI_PS_OCC|EHCI_PS_PEC|EHCI_PS_CSC)
169 175
170#define EHCI_PORT_RESET_COMPLETE 2 /* ms */ 176#define EHCI_PORT_RESET_COMPLETE 2 /* ms */
171 177
 178#define EHCI_USBMODE 0xa8 /* USB Device mode */
 179#define EHCI_USBMODE_SDIS __BIT(4) /* Stream disable mode 1=act */
 180#define EHCI_USBMODE_SLOM __BIT(3) /* setup lockouts on */
 181#define EHCI_USBMODE_ES __BIT(2) /* Endian Select ES=1 */
 182#define EHCI_USBMODE_CM __BITS(0,1) /* Controller Mode */
 183#define EHCI_USBMODE_CM_IDLE 0x00 /* Idle (combo host/device) */
 184#define EHCI_USBMODE_CM_DEV 0x02 /* Device Controller */
 185#define EHCI_USBMODE_CM_HOST 0x03 /* Host Controller */
 186
172#define EHCI_FLALIGN_ALIGN 0x1000 187#define EHCI_FLALIGN_ALIGN 0x1000
173#define EHCI_MAX_PORTS 16 /* only 4 bits available in EHCI_HCS_N_PORTS */ 188#define EHCI_MAX_PORTS 16 /* only 4 bits available in EHCI_HCS_N_PORTS */
174 189
175/* No data structure may cross a page boundary. */ 190/* No data structure may cross a page boundary. */
176#define EHCI_PAGE_SIZE 0x1000 191#define EHCI_PAGE_SIZE 0x1000
177#define EHCI_PAGE(x) ((x) &~ 0xfff) 192#define EHCI_PAGE(x) ((x) &~ 0xfff)
178#define EHCI_PAGE_OFFSET(x) ((x) & 0xfff) 193#define EHCI_PAGE_OFFSET(x) ((x) & 0xfff)
179 194
180typedef u_int32_t ehci_link_t; 195typedef u_int32_t ehci_link_t;
181#define EHCI_LINK_TERMINATE 0x00000001 196#define EHCI_LINK_TERMINATE 0x00000001
182#define EHCI_LINK_TYPE(x) ((x) & 0x00000006) 197#define EHCI_LINK_TYPE(x) ((x) & 0x00000006)
183#define EHCI_LINK_ITD 0x0 198#define EHCI_LINK_ITD 0x0
184#define EHCI_LINK_QH 0x2 199#define EHCI_LINK_QH 0x2

cvs diff -r1.33 -r1.33.16.1 src/sys/dev/usb/ehcivar.h (expand / switch to unified diff)

--- src/sys/dev/usb/ehcivar.h 2008/10/14 18:12:38 1.33
+++ src/sys/dev/usb/ehcivar.h 2011/01/07 02:50:47 1.33.16.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehcivar.h,v 1.33 2008/10/14 18:12:38 jmcneill Exp $ */ 1/* $NetBSD: ehcivar.h,v 1.33.16.1 2011/01/07 02:50:47 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net). 8 * by Lennart Augustsson (lennart@augustsson.net).
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -106,26 +106,27 @@ struct ehci_soft_islot { @@ -106,26 +106,27 @@ struct ehci_soft_islot {
106#define EHCI_COMPANION_MAX 8 106#define EHCI_COMPANION_MAX 8
107 107
108#define EHCI_FREE_LIST_INTERVAL 100 108#define EHCI_FREE_LIST_INTERVAL 100
109 109
110typedef struct ehci_softc { 110typedef struct ehci_softc {
111 device_t sc_dev; 111 device_t sc_dev;
112 struct usbd_bus sc_bus; 112 struct usbd_bus sc_bus;
113 bus_space_tag_t iot; 113 bus_space_tag_t iot;
114 bus_space_handle_t ioh; 114 bus_space_handle_t ioh;
115 bus_size_t sc_size; 115 bus_size_t sc_size;
116 u_int sc_offs; /* offset to operational regs */ 116 u_int sc_offs; /* offset to operational regs */
117 int sc_flags; /* misc flags */ 117 int sc_flags; /* misc flags */
118#define EHCIF_DROPPED_INTR_WORKAROUND 0x01 118#define EHCIF_DROPPED_INTR_WORKAROUND 0x01
 119#define EHCIF_ETTF 0x02 /* Emb. Transaction Translater func. */
119 120
120 char sc_vendor[32]; /* vendor string for root hub */ 121 char sc_vendor[32]; /* vendor string for root hub */
121 int sc_id_vendor; /* vendor ID for root hub */ 122 int sc_id_vendor; /* vendor ID for root hub */
122 123
123 u_int32_t sc_cmd; /* shadow of cmd reg during suspend */ 124 u_int32_t sc_cmd; /* shadow of cmd reg during suspend */
124 125
125 u_int sc_ncomp; 126 u_int sc_ncomp;
126 u_int sc_npcomp; 127 u_int sc_npcomp;
127 device_t sc_comps[EHCI_COMPANION_MAX]; 128 device_t sc_comps[EHCI_COMPANION_MAX];
128 129
129 usb_dma_t sc_fldma; 130 usb_dma_t sc_fldma;
130 ehci_link_t *sc_flist; 131 ehci_link_t *sc_flist;
131 u_int sc_flsize; 132 u_int sc_flsize;