Remove the code which disables port status change interrupts for 1 second
[dragonfly.git] / sys / bus / usb / ehcivar.h
CommitLineData
281cf3c2
SZ
1/* $NetBSD: ehcivar.h,v 1.19 2005/04/29 15:04:29 augustss Exp $ */
2/* $FreeBSD: src/sys/dev/usb/ehcivar.h,v 1.9.2.1 2006/01/26 01:43:13 iedowse Exp $ */
cd43bb2f 3/* $DragonFly: src/sys/bus/usb/ehcivar.h,v 1.12 2008/06/10 10:04:06 hasso Exp $ */
1550dfd9
MD
4
5/*
6 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Lennart Augustsson (lennart@augustsson.net).
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41typedef struct ehci_soft_qtd {
42 ehci_qtd_t qtd;
43 struct ehci_soft_qtd *nextqtd; /* mirrors nextqtd in TD */
44 ehci_physaddr_t physaddr;
45 usbd_xfer_handle xfer;
46 LIST_ENTRY(ehci_soft_qtd) hnext;
47 u_int16_t len;
48} ehci_soft_qtd_t;
49#define EHCI_SQTD_SIZE ((sizeof (struct ehci_soft_qtd) + EHCI_QTD_ALIGN - 1) / EHCI_QTD_ALIGN * EHCI_QTD_ALIGN)
50#define EHCI_SQTD_CHUNK (EHCI_PAGE_SIZE / EHCI_SQTD_SIZE)
51
52typedef struct ehci_soft_qh {
53 ehci_qh_t qh;
54 struct ehci_soft_qh *next;
281cf3c2 55 struct ehci_soft_qh *prev;
1550dfd9
MD
56 struct ehci_soft_qtd *sqtd;
57 ehci_physaddr_t physaddr;
281cf3c2 58 int islot; /* Interrupt list slot. */
1550dfd9
MD
59} ehci_soft_qh_t;
60#define EHCI_SQH_SIZE ((sizeof (struct ehci_soft_qh) + EHCI_QH_ALIGN - 1) / EHCI_QH_ALIGN * EHCI_QH_ALIGN)
61#define EHCI_SQH_CHUNK (EHCI_PAGE_SIZE / EHCI_SQH_SIZE)
62
63struct ehci_xfer {
64 struct usbd_xfer xfer;
65 struct usb_task abort_task;
66 LIST_ENTRY(ehci_xfer) inext; /* list of active xfers */
67 ehci_soft_qtd_t *sqtdstart;
68 ehci_soft_qtd_t *sqtdend;
281cf3c2 69 u_int32_t ehci_xfer_flags;
1550dfd9
MD
70#ifdef DIAGNOSTIC
71 int isdone;
72#endif
73};
281cf3c2
SZ
74#define EHCI_XFER_ABORTING 0x0001 /* xfer is aborting. */
75#define EHCI_XFER_ABORTWAIT 0x0002 /* abort completion is being awaited. */
76
1550dfd9
MD
77#define EXFER(xfer) ((struct ehci_xfer *)(xfer))
78
66a0b45c
JR
79/* Information about an entry in the interrupt list. */
80struct ehci_soft_islot {
81 ehci_soft_qh_t *sqh; /* Queue Head. */
82};
83
84#define EHCI_FRAMELIST_MAXCOUNT 1024
85#define EHCI_IPOLLRATES 8 /* Poll rates (1ms, 2, 4, 8 .. 128) */
86#define EHCI_INTRQHS ((1 << EHCI_IPOLLRATES) - 1)
87#define EHCI_MAX_POLLRATE (1 << (EHCI_IPOLLRATES - 1))
88#define EHCI_IQHIDX(lev, pos) \
89 ((((pos) & ((1 << (lev)) - 1)) | (1 << (lev))) - 1)
90#define EHCI_ILEV_IVAL(lev) (1 << (lev))
91
1550dfd9
MD
92
93#define EHCI_HASH_SIZE 128
94#define EHCI_COMPANION_MAX 8
281cf3c2
SZ
95
96#define EHCI_SCFLG_DONEINIT 0x0001 /* ehci_init() has been called. */
97#define EHCI_SCFLG_LOSTINTRBUG 0x0002 /* workaround for VIA / ATI chipsets */
1550dfd9
MD
98
99typedef struct ehci_softc {
100 struct usbd_bus sc_bus; /* base device */
101 bus_space_tag_t iot;
102 bus_space_handle_t ioh;
103 bus_size_t sc_size;
1550dfd9
MD
104 void *ih;
105
106 struct resource *io_res;
107 struct resource *irq_res;
1550dfd9 108 u_int sc_offs; /* offset to operational regs */
8e4265b9 109 int sc_flags; /* misc flags */
1550dfd9 110
f88813ad 111 char sc_vendor[32]; /* vendor string for root hub */
1550dfd9
MD
112 int sc_id_vendor; /* vendor ID for root hub */
113
66a0b45c 114 u_int32_t sc_cmd; /* shadow of cmd reg during suspend */
1550dfd9
MD
115
116 u_int sc_ncomp;
117 u_int sc_npcomp;
118 struct usbd_bus *sc_comps[EHCI_COMPANION_MAX];
119
120 usb_dma_t sc_fldma;
66a0b45c 121 ehci_link_t *sc_flist;
1550dfd9 122 u_int sc_flsize;
66a0b45c
JR
123
124 struct ehci_soft_islot sc_islots[EHCI_INTRQHS];
1550dfd9
MD
125
126 LIST_HEAD(, ehci_xfer) sc_intrhead;
127
128 ehci_soft_qh_t *sc_freeqhs;
129 ehci_soft_qtd_t *sc_freeqtds;
130
131 int sc_noport;
132 u_int8_t sc_addr; /* device address */
133 u_int8_t sc_conf; /* device configuration */
134 usbd_xfer_handle sc_intrxfer;
135 char sc_isreset;
136#ifdef USB_USE_SOFTINTR
137 char sc_softwake;
138#endif /* USB_USE_SOFTINTR */
139
140 u_int32_t sc_eintrs;
141 ehci_soft_qh_t *sc_async_head;
142
fc1ef497 143 STAILQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
1550dfd9
MD
144
145 struct lock sc_doorbell_lock;
146
67743126 147 struct callout sc_tmo_intrlist;
1550dfd9 148
1550dfd9
MD
149 char sc_dying;
150} ehci_softc_t;
151
152#define EREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (a))
153#define EREAD2(sc, a) bus_space_read_2((sc)->iot, (sc)->ioh, (a))
154#define EREAD4(sc, a) bus_space_read_4((sc)->iot, (sc)->ioh, (a))
155#define EWRITE1(sc, a, x) bus_space_write_1((sc)->iot, (sc)->ioh, (a), (x))
156#define EWRITE2(sc, a, x) bus_space_write_2((sc)->iot, (sc)->ioh, (a), (x))
157#define EWRITE4(sc, a, x) bus_space_write_4((sc)->iot, (sc)->ioh, (a), (x))
158#define EOREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
159#define EOREAD2(sc, a) bus_space_read_2((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
160#define EOREAD4(sc, a) bus_space_read_4((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
161#define EOWRITE1(sc, a, x) bus_space_write_1((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
162#define EOWRITE2(sc, a, x) bus_space_write_2((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
163#define EOWRITE4(sc, a, x) bus_space_write_4((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
164
165usbd_status ehci_init(ehci_softc_t *);
166int ehci_intr(void *);
1550dfd9 167int ehci_detach(ehci_softc_t *, int);
281cf3c2
SZ
168void ehci_power(int state, void *priv);
169void ehci_shutdown(void *v);
1550dfd9
MD
170
171#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
172