[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/usb/ehcivar.h

Version: -  FREEBSD  -  FREEBSD7  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  OPENSOLARIS  -  minix-3-1-1  -  TRUSTEDBSD-SEBSD  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

  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.20 2008/10/14 07:05:20 raj Exp $        */
  3 
  4 /*-
  5  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  6  * All rights reserved.
  7  *
  8  * This code is derived from software contributed to The NetBSD Foundation
  9  * by Lennart Augustsson (lennart@augustsson.net).
 10  *
 11  * Redistribution and use in source and binary forms, with or without
 12  * modification, are permitted provided that the following conditions
 13  * are met:
 14  * 1. Redistributions of source code must retain the above copyright
 15  *    notice, this list of conditions and the following disclaimer.
 16  * 2. Redistributions in binary form must reproduce the above copyright
 17  *    notice, this list of conditions and the following disclaimer in the
 18  *    documentation and/or other materials provided with the distribution.
 19  * 3. All advertising materials mentioning features or use of this software
 20  *    must display the following acknowledgement:
 21  *        This product includes software developed by the NetBSD
 22  *        Foundation, Inc. and its contributors.
 23  * 4. Neither the name of The NetBSD Foundation nor the names of its
 24  *    contributors may be used to endorse or promote products derived
 25  *    from this software without specific prior written permission.
 26  *
 27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 37  * POSSIBILITY OF SUCH DAMAGE.
 38  */
 39 
 40 typedef struct ehci_soft_qtd {
 41         ehci_qtd_t qtd;
 42         struct ehci_soft_qtd *nextqtd; /* mirrors nextqtd in TD */
 43         ehci_physaddr_t physaddr;
 44         usbd_xfer_handle xfer;
 45         LIST_ENTRY(ehci_soft_qtd) hnext;
 46         u_int16_t len;
 47 } ehci_soft_qtd_t;
 48 #define EHCI_SQTD_SIZE ((sizeof (struct ehci_soft_qtd) + EHCI_QTD_ALIGN - 1) / EHCI_QTD_ALIGN * EHCI_QTD_ALIGN)
 49 #define EHCI_SQTD_CHUNK (EHCI_PAGE_SIZE / EHCI_SQTD_SIZE)
 50 
 51 typedef struct ehci_soft_qh {
 52         ehci_qh_t qh;
 53         struct ehci_soft_qh *next;
 54         struct ehci_soft_qh *prev;
 55         struct ehci_soft_qtd *sqtd;
 56         struct ehci_soft_qtd *inactivesqtd;
 57         ehci_physaddr_t physaddr;
 58         int islot;              /* Interrupt list slot. */
 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 
 63 typedef struct ehci_soft_itd {
 64         ehci_itd_t itd;
 65         union {
 66                 struct {
 67                         /* soft_itds links in a periodic frame*/
 68                         struct ehci_soft_itd *next;
 69                         struct ehci_soft_itd *prev;
 70                 } frame_list;
 71                 /* circular list of free itds */
 72                 LIST_ENTRY(ehci_soft_itd) free_list;
 73         } u;
 74         struct ehci_soft_itd *xfer_next; /* Next soft_itd in xfer */
 75         ehci_physaddr_t physaddr;
 76         usb_dma_t dma;
 77         int offs;
 78         int slot;
 79         struct timeval t; /* store free time */
 80 } ehci_soft_itd_t;
 81 #define EHCI_ITD_SIZE ((sizeof(struct ehci_soft_itd) + EHCI_QH_ALIGN - 1) / EHCI_ITD_ALIGN * EHCI_ITD_ALIGN)
 82 #define EHCI_ITD_CHUNK (EHCI_PAGE_SIZE / EHCI_ITD_SIZE)
 83 
 84 struct ehci_xfer {
 85         struct usbd_xfer xfer;
 86         struct usb_task abort_task;
 87         LIST_ENTRY(ehci_xfer) inext; /* list of active xfers */
 88         ehci_soft_qtd_t *sqtdstart;
 89         ehci_soft_qtd_t *sqtdend;
 90         ehci_soft_itd_t *itdstart;
 91         ehci_soft_itd_t *itdend;
 92         u_int isoc_len;
 93         u_int32_t ehci_xfer_flags;
 94 #ifdef DIAGNOSTIC
 95         int isdone;
 96 #endif
 97 };
 98 #define EHCI_XFER_ABORTING      0x0001  /* xfer is aborting. */
 99 #define EHCI_XFER_ABORTWAIT     0x0002  /* abort completion is being awaited. */
100 
101 #define EXFER(xfer) ((struct ehci_xfer *)(xfer))
102 
103 /*
104  * Information about an entry in the interrupt list.
105  */
106 struct ehci_soft_islot {
107         ehci_soft_qh_t *sqh;            /* Queue Head. */
108 };
109 
110 #define EHCI_FRAMELIST_MAXCOUNT 1024
111 #define EHCI_IPOLLRATES         8       /* Poll rates (1ms, 2, 4, 8 ... 128) */
112 #define EHCI_INTRQHS            ((1 << EHCI_IPOLLRATES) - 1)
113 #define EHCI_MAX_POLLRATE       (1 << (EHCI_IPOLLRATES - 1))
114 #define EHCI_IQHIDX(lev, pos)   \
115     ((((pos) & ((1 << (lev)) - 1)) | (1 << (lev))) - 1)
116 #define EHCI_ILEV_IVAL(lev)     (1 << (lev))
117 
118 #define EHCI_HASH_SIZE 128
119 #define EHCI_COMPANION_MAX 8
120 
121 #define EHCI_FREE_LIST_INTERVAL 100
122 
123 #define EHCI_SCFLG_DONEINIT     0x0001  /* ehci_init() has been called. */
124 #define EHCI_SCFLG_LOSTINTRBUG  0x0002  /* workaround for VIA / ATI chipsets */
125 #define EHCI_SCFLG_SETMODE      0x0004  /* set bridge mode again after init (Marvell) */
126 #define EHCI_SCFLG_FORCESPEED   0x0008  /* force speed (Marvell) */
127 #define EHCI_SCFLG_NORESTERM    0x0010  /* don't terminate reset sequence (Marvell) */
128 
129 typedef struct ehci_softc {
130         struct usbd_bus sc_bus;         /* base device */
131         int sc_flags;
132         bus_space_tag_t iot;
133         bus_space_handle_t ioh;
134         bus_size_t sc_size;
135 #if defined(__FreeBSD__)
136         void *ih;
137 
138         struct resource *io_res;
139         struct resource *irq_res;
140 #endif
141         u_int sc_offs;                  /* offset to operational regs */
142 
143         char sc_vendor[32];             /* vendor string for root hub */
144         int sc_id_vendor;               /* vendor ID for root hub */
145 
146         u_int32_t sc_cmd;               /* shadow of cmd reg during suspend */
147 #if defined(__NetBSD__) || defined(__OpenBSD__)
148         void *sc_powerhook;             /* cookie from power hook */
149         void *sc_shutdownhook;          /* cookie from shutdown hook */
150 #endif
151 
152         u_int sc_ncomp;
153         u_int sc_npcomp;
154         struct usbd_bus *sc_comps[EHCI_COMPANION_MAX];
155 
156         usb_dma_t sc_fldma;
157         ehci_link_t *sc_flist;
158         u_int sc_flsize;
159 #ifndef __FreeBSD__
160         u_int sc_rand;                  /* XXX need proper intr scheduling */
161 #endif
162 
163         struct ehci_soft_islot sc_islots[EHCI_INTRQHS];
164 
165         /* jcmm - an array matching sc_flist, but with software pointers,
166          * not hardware address pointers
167          */
168         struct ehci_soft_itd **sc_softitds;
169 
170         LIST_HEAD(, ehci_xfer) sc_intrhead;
171 
172         ehci_soft_qh_t *sc_freeqhs;
173         ehci_soft_qtd_t *sc_freeqtds;
174         LIST_HEAD(sc_freeitds, ehci_soft_itd) sc_freeitds;
175 
176         int sc_noport;
177         u_int8_t sc_addr;               /* device address */
178         u_int8_t sc_conf;               /* device configuration */
179         usbd_xfer_handle sc_intrxfer;
180         char sc_isreset;
181 #ifdef USB_USE_SOFTINTR
182         char sc_softwake;
183 #endif /* USB_USE_SOFTINTR */
184 
185         u_int32_t sc_eintrs;
186         ehci_soft_qh_t *sc_async_head;
187 
188         STAILQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
189 
190         struct lock sc_doorbell_lock;
191 
192         struct callout sc_tmo_intrlist;
193 
194         char sc_dying;
195 #if defined(__NetBSD__)
196         struct usb_dma_reserve sc_dma_reserve;
197 #endif
198 } ehci_softc_t;
199 
200 #define EREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (a))
201 #define EREAD2(sc, a) bus_space_read_2((sc)->iot, (sc)->ioh, (a))
202 #define EREAD4(sc, a) bus_space_read_4((sc)->iot, (sc)->ioh, (a))
203 #define EWRITE1(sc, a, x) bus_space_write_1((sc)->iot, (sc)->ioh, (a), (x))
204 #define EWRITE2(sc, a, x) bus_space_write_2((sc)->iot, (sc)->ioh, (a), (x))
205 #define EWRITE4(sc, a, x) bus_space_write_4((sc)->iot, (sc)->ioh, (a), (x))
206 #define EOREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
207 #define EOREAD2(sc, a) bus_space_read_2((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
208 #define EOREAD4(sc, a) bus_space_read_4((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
209 #define EOWRITE1(sc, a, x) bus_space_write_1((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
210 #define EOWRITE2(sc, a, x) bus_space_write_2((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
211 #define EOWRITE4(sc, a, x) bus_space_write_4((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
212 
213 usbd_status     ehci_init(ehci_softc_t *);
214 int             ehci_intr(void *);
215 int             ehci_detach(ehci_softc_t *, int);
216 #if defined(__NetBSD__) || defined(__OpenBSD__)
217 int             ehci_activate(device_t, enum devact);
218 #endif
219 void            ehci_power(int state, void *priv);
220 void            ehci_shutdown(void *v);
221 
222 #define MS_TO_TICKS(ms) ((ms) * hz / 1000)
223 
224 

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.