Tue Mar 3 10:06:01 2015 UTC ()
Convert to __BIT and friends.

No functional change.


(skrll)
diff -r1.234.2.37 -r1.234.2.38 src/sys/dev/usb/ehci.c
diff -r1.34.14.5 -r1.34.14.6 src/sys/dev/usb/ehcireg.h

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

--- src/sys/dev/usb/ehci.c 2015/03/03 06:36:53 1.234.2.37
+++ src/sys/dev/usb/ehci.c 2015/03/03 10:06:01 1.234.2.38
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehci.c,v 1.234.2.37 2015/03/03 06:36:53 skrll Exp $ */ 1/* $NetBSD: ehci.c,v 1.234.2.38 2015/03/03 10:06:01 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004-2012 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, 8 * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum,
9 * Jeremy Morse (jeremy.morse@gmail.com), Jared D. McNeill 9 * Jeremy Morse (jeremy.morse@gmail.com), Jared D. McNeill
10 * (jmcneill@invisible.ca) and Matthew R. Green (mrg@eterna.com.au). 10 * (jmcneill@invisible.ca) and Matthew R. Green (mrg@eterna.com.au).
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -43,27 +43,27 @@ @@ -43,27 +43,27 @@
43 43
44/* 44/*
45 * TODO: 45 * TODO:
46 * 1) hold off explorations by companion controllers until ehci has started. 46 * 1) hold off explorations by companion controllers until ehci has started.
47 * 47 *
48 * 2) The hub driver needs to handle and schedule the transaction translator, 48 * 2) The hub driver needs to handle and schedule the transaction translator,
49 * to assign place in frame where different devices get to go. See chapter 49 * to assign place in frame where different devices get to go. See chapter
50 * on hubs in USB 2.0 for details. 50 * on hubs in USB 2.0 for details.
51 * 51 *
52 * 3) Command failures are not recovered correctly. 52 * 3) Command failures are not recovered correctly.
53 */ 53 */
54 54
55#include <sys/cdefs.h> 55#include <sys/cdefs.h>
56__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.37 2015/03/03 06:36:53 skrll Exp $"); 56__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.38 2015/03/03 10:06:01 skrll Exp $");
57 57
58#include "ohci.h" 58#include "ohci.h"
59#include "uhci.h" 59#include "uhci.h"
60#include "opt_usb.h" 60#include "opt_usb.h"
61 61
62#include <sys/param.h> 62#include <sys/param.h>
63 63
64#include <sys/bus.h> 64#include <sys/bus.h>
65#include <sys/cpu.h> 65#include <sys/cpu.h>
66#include <sys/device.h> 66#include <sys/device.h>
67#include <sys/kernel.h> 67#include <sys/kernel.h>
68#include <sys/kmem.h> 68#include <sys/kmem.h>
69#include <sys/mutex.h> 69#include <sys/mutex.h>
@@ -3525,31 +3525,31 @@ ehci_device_request(usbd_xfer_handle xfe @@ -3525,31 +3525,31 @@ ehci_device_request(usbd_xfer_handle xfe
3525 goto bad1; 3525 goto bad1;
3526 } 3526 }
3527 stat = ehci_alloc_sqtd(sc); 3527 stat = ehci_alloc_sqtd(sc);
3528 if (stat == NULL) { 3528 if (stat == NULL) {
3529 err = USBD_NOMEM; 3529 err = USBD_NOMEM;
3530 goto bad2; 3530 goto bad2;
3531 } 3531 }
3532 3532
3533 mutex_enter(&sc->sc_lock); 3533 mutex_enter(&sc->sc_lock);
3534 3534
3535 sqh = epipe->sqh; 3535 sqh = epipe->sqh;
3536 3536
3537 KASSERTMSG(EHCI_QH_GET_ADDR(le32toh(sqh->qh.qh_endp)) == dev->ud_addr, 3537 KASSERTMSG(EHCI_QH_GET_ADDR(le32toh(sqh->qh.qh_endp)) == dev->ud_addr,
3538 "address QH %d pipe %d\n", 3538 "address QH %" __PRIuBIT " pipe %d\n",
3539 EHCI_QH_GET_ADDR(le32toh(sqh->qh.qh_endp)), dev->ud_addr); 3539 EHCI_QH_GET_ADDR(le32toh(sqh->qh.qh_endp)), dev->ud_addr);
3540 KASSERTMSG(EHCI_QH_GET_MPL(le32toh(sqh->qh.qh_endp)) == 3540 KASSERTMSG(EHCI_QH_GET_MPL(le32toh(sqh->qh.qh_endp)) ==
3541 UGETW(epipe->pipe.up_endpoint->ue_edesc->wMaxPacketSize), 3541 UGETW(epipe->pipe.up_endpoint->ue_edesc->wMaxPacketSize),
3542 "MPS QH %d pipe %d\n", 3542 "MPS QH %" __PRIuBIT " pipe %d\n",
3543 EHCI_QH_GET_MPL(le32toh(sqh->qh.qh_endp)), 3543 EHCI_QH_GET_MPL(le32toh(sqh->qh.qh_endp)),
3544 UGETW(epipe->pipe.up_endpoint->ue_edesc->wMaxPacketSize)); 3544 UGETW(epipe->pipe.up_endpoint->ue_edesc->wMaxPacketSize));
3545 3545
3546 /* Set up data transaction */ 3546 /* Set up data transaction */
3547 if (len != 0) { 3547 if (len != 0) {
3548 ehci_soft_qtd_t *end; 3548 ehci_soft_qtd_t *end;
3549 3549
3550 /* Start toggle at 1. */ 3550 /* Start toggle at 1. */
3551 epipe->nexttoggle = 1; 3551 epipe->nexttoggle = 1;
3552 err = ehci_alloc_sqtd_chain(epipe, sc, len, isread, xfer, 3552 err = ehci_alloc_sqtd_chain(epipe, sc, len, isread, xfer,
3553 &next, &end); 3553 &next, &end);
3554 if (err) 3554 if (err)
3555 goto bad3; 3555 goto bad3;

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

--- src/sys/dev/usb/ehcireg.h 2015/03/03 06:36:53 1.34.14.5
+++ src/sys/dev/usb/ehcireg.h 2015/03/03 10:06:01 1.34.14.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehcireg.h,v 1.34.14.5 2015/03/03 06:36:53 skrll Exp $ */ 1/* $NetBSD: ehcireg.h,v 1.34.14.6 2015/03/03 10:06:01 skrll 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.
@@ -186,189 +186,217 @@ @@ -186,189 +186,217 @@
186 186
187#define EHCI_FLALIGN_ALIGN 0x1000 187#define EHCI_FLALIGN_ALIGN 0x1000
188#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 */
189 189
190/* No data structure may cross a page boundary. */ 190/* No data structure may cross a page boundary. */
191#define EHCI_PAGE_SHIFT 12 191#define EHCI_PAGE_SHIFT 12
192#define EHCI_PAGE_SIZE (1 << EHCI_PAGE_SHIFT) 192#define EHCI_PAGE_SIZE (1 << EHCI_PAGE_SHIFT)
193#define EHCI_PAGE_MASK (EHCI_PAGE_SIZE - 1) 193#define EHCI_PAGE_MASK (EHCI_PAGE_SIZE - 1)
194#define EHCI_PAGE(x) ((x) & ~EHCI_PAGE_MASK) 194#define EHCI_PAGE(x) ((x) & ~EHCI_PAGE_MASK)
195#define EHCI_PAGE_OFFSET(x) ((x) & EHCI_PAGE_MASK) 195#define EHCI_PAGE_OFFSET(x) ((x) & EHCI_PAGE_MASK)
196#define EHCI_NPAGES(x) (((x) + EHCI_PAGE_MASK) >> EHCI_PAGE_SHIFT) 196#define EHCI_NPAGES(x) (((x) + EHCI_PAGE_MASK) >> EHCI_PAGE_SHIFT)
197 197
198typedef uint32_t ehci_link_t; 198typedef uint32_t ehci_link_t;
199#define EHCI_LINK_TERMINATE 0x00000001 199#define EHCI_LINK_TERMINATE __BIT(0)
200#define EHCI_LINK_TYPE(x) ((x) & 0x00000006) 200#define EHCI_LINK_TYPE(x) ((x) & 0x00000006)
201#define EHCI_LINK_ITD 0x0 201#define EHCI_LINK_ITD 0x0
202#define EHCI_LINK_QH 0x2 202#define EHCI_LINK_QH 0x2
203#define EHCI_LINK_SITD 0x4 203#define EHCI_LINK_SITD 0x4
204#define EHCI_LINK_FSTN 0x6 204#define EHCI_LINK_FSTN 0x6
205#define EHCI_LINK_ADDR(x) ((x) &~ 0x1f) 205#define EHCI_LINK_ADDR(x) ((x) &~ 0x1f)
206 206
207typedef uint32_t ehci_physaddr_t; 207typedef uint32_t ehci_physaddr_t;
208 208
209typedef uint32_t ehci_isoc_trans_t; 209typedef uint32_t ehci_isoc_trans_t;
210typedef uint32_t ehci_isoc_bufr_ptr_t; 210typedef uint32_t ehci_isoc_bufr_ptr_t;
211 211
212/* Isochronous Transfer Descriptor */ 212/* Isochronous Transfer Descriptor */
213#define EHCI_ITD_NUFRAMES USB_UFRAMES_PER_FRAME 213#define EHCI_ITD_NUFRAMES USB_UFRAMES_PER_FRAME
214#define EHCI_ITD_NBUFFERS 7 214#define EHCI_ITD_NBUFFERS 7
215typedef struct { 215typedef struct {
216 volatile ehci_link_t itd_next; 216 volatile ehci_link_t itd_next;
217 volatile ehci_isoc_trans_t itd_ctl[EHCI_ITD_NUFRAMES]; 217 volatile ehci_isoc_trans_t itd_ctl[EHCI_ITD_NUFRAMES];
218#define EHCI_ITD_GET_STATUS(x) (((x) >> 28) & 0xf) 218#define EHCI_ITD_STATUS_MASK __BITS(31,28)
219#define EHCI_ITD_SET_STATUS(x) (((x) & 0xf) << 28) 219#define EHCI_ITD_GET_STATUS(x) __SHIFTOUT((x), EHCI_ITD_STATUS_MASK)
220#define EHCI_ITD_ACTIVE 0x80000000 220#define EHCI_ITD_SET_STATUS(x) __SHIFTIN((x), EHCI_ITD_STATUS_MASK)
221#define EHCI_ITD_BUF_ERR 0x40000000 221#define EHCI_ITD_ACTIVE __BIT(31)
222#define EHCI_ITD_BABBLE 0x20000000 222#define EHCI_ITD_BUF_ERR __BIT(30)
223#define EHCI_ITD_ERROR 0x10000000 223#define EHCI_ITD_BABBLE __BIT(29)
224#define EHCI_ITD_GET_LEN(x) (((x) >> 16) & 0xfff) 224#define EHCI_ITD_ERROR __BIT(28)
225#define EHCI_ITD_SET_LEN(x) (((x) & 0xfff) << 16) 225#define EHCI_ITD_LEN_MASK __BITS(27,16)
226#define EHCI_ITD_IOC 0x8000 226#define EHCI_ITD_GET_LEN(x) __SHIFTOUT((x), EHCI_ITD_LEN_MASK)
227#define EHCI_ITD_GET_IOC(x) (((x) >> 15) & 1) 227#define EHCI_ITD_SET_LEN(x) __SHIFTIN((x), EHCI_ITD_LEN_MASK)
228#define EHCI_ITD_SET_IOC(x) (((x) << 15) & EHCI_ITD_IOC) 228#define EHCI_ITD_IOC __BIT(15)
229#define EHCI_ITD_GET_PG(x) (((x) >> 12) & 0x7) 229#define EHCI_ITD_GET_IOC(x) __SHIFTOUT((x), EHCI_ITD_IOC)
230#define EHCI_ITD_SET_PG(x) (((x) & 0x7) << 12) 230#define EHCI_ITD_SET_IOC(x) __SHIFTIN((x), EHCI_ITD_IOC)
231#define EHCI_ITD_GET_OFFS(x) (((x) >> 0) & 0xfff) 231#define EHCI_ITD_PG_MASK __BITS(14,12)
232#define EHCI_ITD_SET_OFFS(x) (((x) & 0xfff) << 0) 232#define EHCI_ITD_GET_PG(x) __SHIFTOUT((x), EHCI_ITD_PG_MASK)
 233#define EHCI_ITD_SET_PG(x) __SHIFTIN((x), EHCI_ITD_PG_MASK)
 234#define EHCI_ITD_OFFSET_MASK __BITS(11,0)
 235#define EHCI_ITD_GET_OFFS(x) __SHIFTOUT((x), EHCI_ITD_OFFSET_MASK)
 236#define EHCI_ITD_SET_OFFS(x) __SHIFTIN((x), EHCI_ITD_OFFSET_MASK)
233 volatile ehci_isoc_bufr_ptr_t itd_bufr[EHCI_ITD_NBUFFERS]; 237 volatile ehci_isoc_bufr_ptr_t itd_bufr[EHCI_ITD_NBUFFERS];
234#define EHCI_ITD_GET_BPTR(x) ((x) & 0xfffff000) 238#define EHCI_ITD_BPTR_MASK __BITS(31,12)
235#define EHCI_ITD_SET_BPTR(x) ((x) & 0xfffff000) 239#define EHCI_ITD_GET_BPTR(x) __SHIFTOUT((x), EHCI_ITD_BPTR_MASK)
236#define EHCI_ITD_GET_EP(x) (((x) >> 8) & 0xf) 240#define EHCI_ITD_SET_BPTR(x) __SHIFTIN((x), EHCI_ITD_BPTR_MASK)
237#define EHCI_ITD_SET_EP(x) (((x) & 0xf) << 8) 241#define EHCI_ITD_EP_MASK __BITS(11,8)
238#define EHCI_ITD_GET_DADDR(x) ((x) & 0x7f) 242#define EHCI_ITD_GET_EP(x) __SHIFTOUT((x), EHCI_ITD_EP_MASK)
239#define EHCI_ITD_SET_DADDR(x) ((x) & 0x7f) 243#define EHCI_ITD_SET_EP(x) __SHIFTIN((x), EHCI_ITD_EP_MASK)
240#define EHCI_ITD_GET_DIR(x) (((x) >> 11) & 1) 244#define EHCI_ITD_DADDR_MASK __BITS(6,0)
241#define EHCI_ITD_SET_DIR(x) (((x) & 1) << 11) 245#define EHCI_ITD_GET_DADDR(x) __SHIFTOUT((x), EHCI_ITD_DADDR_MASK)
242#define EHCI_ITD_GET_MAXPKT(x) ((x) & 0x7ff) 246#define EHCI_ITD_SET_DADDR(x) __SHIFTIN((x), EHCI_ITD_DADDR_MASK)
243#define EHCI_ITD_SET_MAXPKT(x) ((x) & 0x7ff) 247#define EHCI_ITD_DIR_MASK __BIT(11)
244#define EHCI_ITD_GET_MULTI(x) ((x) & 0x3) 248#define EHCI_ITD_GET_DIR(x) __SHIFTOUT((x), EHCI_ITD_DIR_MASK)
245#define EHCI_ITD_SET_MULTI(x) ((x) & 0x3) 249#define EHCI_ITD_SET_DIR(x) __SHIFTIN((x), EHCI_ITD_DIR_MASK)
 250#define EHCI_ITD_MAXPKT_MASK __BITS(10,0)
 251#define EHCI_ITD_GET_MAXPKT(x) __SHIFTOUT((x), EHCI_ITD_MAXPKT_MASK)
 252#define EHCI_ITD_SET_MAXPKT(x) __SHIFTIN((x), EHCI_ITD_MAXPKT_MASK)
 253#define EHCI_ITD_MULTI_MASK __BITS(1,0)
 254#define EHCI_ITD_GET_MULTI(x) __SHIFTOUT((x), EHCI_ITD_MULTI_MASK)
 255#define EHCI_ITD_SET_MULTI(x) __SHIFTIN((x), EHCI_ITD_MULTI_MASK)
246 volatile ehci_isoc_bufr_ptr_t itd_bufr_hi[EHCI_ITD_NBUFFERS]; 256 volatile ehci_isoc_bufr_ptr_t itd_bufr_hi[EHCI_ITD_NBUFFERS];
247} ehci_itd_t; 257} ehci_itd_t;
248#define EHCI_ITD_ALIGN 32 258#define EHCI_ITD_ALIGN 32
249 259
250/* Split Transaction Isochronous Transfer Descriptor */ 260/* Split Transaction Isochronous Transfer Descriptor */
251typedef struct { 261typedef struct {
252 volatile ehci_link_t sitd_next; 262 volatile ehci_link_t sitd_next;
253 volatile uint32_t sitd_endp; 263 volatile uint32_t sitd_endp;
254#define EHCI_SITD_SET_DIR(x) (((x) & 0x01) << 31) 264#define EHCI_SITD_DIR_MASK __BIT(31)
255#define EHCI_SITD_SET_PORT(x) (((x) & 0x7f) << 24) 265#define EHCI_SITD_PORT_MASK __BITS(30,24)
256#define EHCI_SITD_SET_HUBA(x) (((x) & 0x7f) << 16) 266#define EHCI_SITD_HUBA_MASK __BITS(22,16)
257#define EHCI_SITD_SET_ENDPT(x) (((x) & 0x0f) << 8) 267#define EHCI_SITD_ENDPT_MASK __BITS(11,8)
258#define EHCI_SITD_SET_DADDR(x) ((x) & 0x7f) 268#define EHCI_SITD_DADDR_MASK __BITS(6,0)
259 269#define EHCI_SITD_SET_DIR(x) __SHIFTIN((x), EHCI_SITD_DIR_MASK)
 270#define EHCI_SITD_SET_PORT(x) __SHIFTIN((x), EHCI_SITD_PORT_MASK)
 271#define EHCI_SITD_SET_HUBA(x) __SHIFTIN((x), EHCI_SITD_HUBA_MASK)
 272#define EHCI_SITD_SET_ENDPT(x) __SHIFTIN((x), EHCI_SITD_ENDPT_MASK)
 273#define EHCI_SITD_SET_DADDR(x) __SHIFTIN((x), EHCI_SITD_DADDR_MASK)
260 volatile uint32_t sitd_sched; 274 volatile uint32_t sitd_sched;
261#define EHCI_SITD_SET_SMASK(x) ((x) & 0xff) 275#define EHCI_SITD_SMASK_MASK __BITS(7,0)
262#define EHCI_SITD_SET_CMASK(x) (((x) & 0xff) << 8) 276#define EHCI_SITD_CMASK_MASK __BITS(15,8)
263 277#define EHCI_SITD_SET_SMASK(x) __SHIFTIN((x), EHCI_SITD_SMASK_MASK)
 278#define EHCI_SITD_SET_CMASK(x) __SHIFTIN((x), EHCI_SITD_CMASK_MASK)
264 volatile uint32_t sitd_trans; 279 volatile uint32_t sitd_trans;
265#define EHCI_SITD_IOC 0x80000000 280#define EHCI_SITD_IOC __BIT(31)
266#define EHCI_SITD_P 0x40000000 281#define EHCI_SITD_P __BIT(30)
267#define EHCI_SITD_GET_LEN(x) (((x) & 0x03ff0000) >> 16) 282#define EHCI_SITD_LENGTH_MASK __BITS(25,16)
268#define EHCI_SITD_SET_LEN(x) (((x) & 0x3ff) << 16) 283#define EHCI_SITD_GET_LEN(x) __SHIFTOUT((x), EHCI_SITD_LENGTH_MASK)
 284#define EHCI_SITD_SET_LEN(x) __SHIFTIN((x), EHCI_SITD_LENGTH_MASK)
269#define EHCI_SITD_ACTIVE 0x00000080 285#define EHCI_SITD_ACTIVE 0x00000080
270#define EHCI_SITD_ERR 0x00000040 286#define EHCI_SITD_ERR 0x00000040
271#define EHCI_SITD_BUFERR 0x00000020 287#define EHCI_SITD_BUFERR 0x00000020
272#define EHCI_SITD_BABBLE 0x00000010 288#define EHCI_SITD_BABBLE 0x00000010
273#define EHCI_SITD_XACTERR 0x00000008 289#define EHCI_SITD_XACTERR 0x00000008
274#define EHCI_SITD_MISS 0x00000004 290#define EHCI_SITD_MISS 0x00000004
275#define EHCI_SITD_SPLITXSTATE 0x00000002 291#define EHCI_SITD_SPLITXSTATE 0x00000002
276 
277 volatile uint32_t sitd_buffer[2]; 292 volatile uint32_t sitd_buffer[2];
278#define EHCI_SITD_SET_BPTR(x) ((x) & 0xfffff000) 293#define EHCI_SITD_SET_BPTR(x) ((x) & 0xfffff000)
279#define EHCI_SITD_SET_OFFS(x) ((x) & 0xfff) 294#define EHCI_SITD_SET_OFFS(x) ((x) & 0xfff)
280 295
281 volatile uint32_t sitd_back; 296 volatile uint32_t sitd_back;
282} ehci_sitd_t; 297} ehci_sitd_t;
283#define EHCI_SITD_ALIGN 32 298#define EHCI_SITD_ALIGN 32
284 299
285/* Queue Element Transfer Descriptor */ 300/* Queue Element Transfer Descriptor */
286#define EHCI_QTD_NBUFFERS 5 301#define EHCI_QTD_NBUFFERS 5
287#define EHCI_QTD_MAXTRANSFER (EHCI_QTD_NBUFFERS * EHCI_PAGE_SIZE) 302#define EHCI_QTD_MAXTRANSFER (EHCI_QTD_NBUFFERS * EHCI_PAGE_SIZE)
288typedef struct { 303typedef struct {
289 volatile ehci_link_t qtd_next; 304 volatile ehci_link_t qtd_next;
290 volatile ehci_link_t qtd_altnext; 305 volatile ehci_link_t qtd_altnext;
291 volatile uint32_t qtd_status; 306 volatile uint32_t qtd_status;
292#define EHCI_QTD_GET_STATUS(x) (((x) >> 0) & 0xff) 307#define EHCI_QTD_STATUS_MASK __BITS(7,0)
293#define EHCI_QTD_SET_STATUS(x) ((x) << 0) 308#define EHCI_QTD_GET_STATUS(x) __SHIFTOUT((x), EHCI_QTD_STATUS_MASK)
 309#define EHCI_QTD_SET_STATUS(x) __SHIFTIN((x), EHCI_QTD_STATUS_MASK)
294#define EHCI_QTD_ACTIVE 0x80 310#define EHCI_QTD_ACTIVE 0x80
295#define EHCI_QTD_HALTED 0x40 311#define EHCI_QTD_HALTED 0x40
296#define EHCI_QTD_BUFERR 0x20 312#define EHCI_QTD_BUFERR 0x20
297#define EHCI_QTD_BABBLE 0x10 313#define EHCI_QTD_BABBLE 0x10
298#define EHCI_QTD_XACTERR 0x08 314#define EHCI_QTD_XACTERR 0x08
299#define EHCI_QTD_MISSEDMICRO 0x04 315#define EHCI_QTD_MISSEDMICRO 0x04
300#define EHCI_QTD_SPLITXSTATE 0x02 316#define EHCI_QTD_SPLITXSTATE 0x02
301#define EHCI_QTD_PINGSTATE 0x01 317#define EHCI_QTD_PINGSTATE 0x01
302#define EHCI_QTD_STATERRS 0x3c 318#define EHCI_QTD_STATERRS 0x3c
303#define EHCI_QTD_GET_PID(x) (((x) >> 8) & 0x3) 319#define EHCI_QTD_PID_MASK __BITS(9,8)
304#define EHCI_QTD_SET_PID(x) ((x) << 8) 320#define EHCI_QTD_GET_PID(x) __SHIFTOUT((x), EHCI_QTD_PID_MASK)
 321#define EHCI_QTD_SET_PID(x) __SHIFTIN((x), EHCI_QTD_PID_MASK)
305#define EHCI_QTD_PID_OUT 0x0 322#define EHCI_QTD_PID_OUT 0x0
306#define EHCI_QTD_PID_IN 0x1 323#define EHCI_QTD_PID_IN 0x1
307#define EHCI_QTD_PID_SETUP 0x2 324#define EHCI_QTD_PID_SETUP 0x2
308#define EHCI_QTD_GET_CERR(x) (((x) >> 10) & 0x3) 325#define EHCI_QTD_CERR_MASK __BITS(11,10)
309#define EHCI_QTD_SET_CERR(x) ((x) << 10) 326#define EHCI_QTD_GET_CERR(x) __SHIFTOUT((x), EHCI_QTD_CERR_MASK)
310#define EHCI_QTD_GET_C_PAGE(x) (((x) >> 12) & 0x7) 327#define EHCI_QTD_SET_CERR(x) __SHIFTIN((x), EHCI_QTD_CERR_MASK)
311#define EHCI_QTD_SET_C_PAGE(x) ((x) << 12) 328#define EHCI_QTD_C_PAGE_MASK __BITS(14,12)
312#define EHCI_QTD_GET_IOC(x) (((x) >> 15) & 0x1) 329#define EHCI_QTD_GET_C_PAGE(x) __SHIFTOUT((x), EHCI_QTD_C_PAGE_MASK)
313#define EHCI_QTD_IOC 0x00008000 330#define EHCI_QTD_SET_C_PAGE(x) __SHIFTIN((x), EHCI_QTD_C_PAGE_MASK)
314#define EHCI_QTD_GET_BYTES(x) (((x) >> 16) & 0x7fff) 331#define EHCI_QTD_IOC __BIT(15)
315#define EHCI_QTD_SET_BYTES(x) ((x) << 16) 332#define EHCI_QTD_GET_IOC(x) __SHIFTOUT((x), EHCI_QTD_IOC)
316#define EHCI_QTD_GET_TOGGLE(x) (((x) >> 31) & 0x1) 333#define EHCI_QTD_BYTES_MASK __BITS(30,16)
317#define EHCI_QTD_SET_TOGGLE(x) ((x) << 31) 334#define EHCI_QTD_GET_BYTES(x) __SHIFTOUT((x), EHCI_QTD_BYTES_MASK)
318#define EHCI_QTD_TOGGLE_MASK 0x80000000 335#define EHCI_QTD_SET_BYTES(x) __SHIFTIN((x), EHCI_QTD_BYTES_MASK)
 336#define EHCI_QTD_TOGGLE_MASK __BIT(31)
 337#define EHCI_QTD_GET_TOGGLE(x) __SHIFTOUT((x), EHCI_QTD_TOGGLE_MASK)
 338#define EHCI_QTD_SET_TOGGLE(x) __SHIFTIN((x), EHCI_QTD_TOGGLE_MASK)
319 volatile ehci_physaddr_t qtd_buffer[EHCI_QTD_NBUFFERS]; 339 volatile ehci_physaddr_t qtd_buffer[EHCI_QTD_NBUFFERS];
320 volatile ehci_physaddr_t qtd_buffer_hi[EHCI_QTD_NBUFFERS]; 340 volatile ehci_physaddr_t qtd_buffer_hi[EHCI_QTD_NBUFFERS];
321} ehci_qtd_t; 341} ehci_qtd_t;
322#define EHCI_QTD_ALIGN 32 342#define EHCI_QTD_ALIGN 32
323 343
324/* Queue Head */ 344/* Queue Head */
325typedef struct { 345typedef struct {
326 volatile ehci_link_t qh_link; 346 volatile ehci_link_t qh_link;
327 volatile uint32_t qh_endp; 347 volatile uint32_t qh_endp;
328#define EHCI_QH_GET_ADDR(x) (((x) >> 0) & 0x7f) /* endpoint addr */ 348#define EHCI_QH_ADDR_MASK __BITS(6,0) /* endpoint addr */
329#define EHCI_QH_SET_ADDR(x) (x) 349#define EHCI_QH_GET_ADDR(x) __SHIFTOUT((x), EHCI_QH_ADDR_MASK)
330#define EHCI_QH_ADDRMASK 0x0000007f 350#define EHCI_QH_SET_ADDR(x) __SHIFTIN((x), EHCI_QH_ADDR_MASK)
331#define EHCI_QH_GET_INACT(x) (((x) >> 7) & 0x01) /* inactivate on next */ 351#define EHCI_QH_INACT __BIT(7) /* inactivate on next */
332#define EHCI_QH_INACT 0x00000080 352#define EHCI_QH_GET_INACT(x) __SHIFTOUT((x), EHCI_QH_INACT)
333#define EHCI_QH_GET_ENDPT(x) (((x) >> 8) & 0x0f) /* endpoint no */ 353#define EHCI_QH_ENDPT_MASK __BITS(11,8) /* endpoint no */
334#define EHCI_QH_SET_ENDPT(x) ((x) << 8) 354#define EHCI_QH_GET_ENDPT(x) __SHIFTOUT((x), EHCI_QH_ENDPT_MASK)
335#define EHCI_QH_GET_EPS(x) (((x) >> 12) & 0x03) /* endpoint speed */ 355#define EHCI_QH_SET_ENDPT(x) __SHIFTIN((x), EHCI_QH_ENDPT_MASK)
336#define EHCI_QH_SET_EPS(x) ((x) << 12) 356#define EHCI_QH_EPS_MASK __BITS(13,12) /* endpoint speed */
 357#define EHCI_QH_GET_EPS(x) __SHIFTOUT((x), EHCI_QH_EPS_MASK)
 358#define EHCI_QH_SET_EPS(x) __SHIFTIN((x), EHCI_QH_EPS_MASK)
337#define EHCI_QH_SPEED_FULL 0x0 359#define EHCI_QH_SPEED_FULL 0x0
338#define EHCI_QH_SPEED_LOW 0x1 360#define EHCI_QH_SPEED_LOW 0x1
339#define EHCI_QH_SPEED_HIGH 0x2 361#define EHCI_QH_SPEED_HIGH 0x2
340#define EHCI_QH_GET_DTC(x) (((x) >> 14) & 0x01) /* data toggle control */ 362#define EHCI_QH_DTC __BIT(14) /* data toggle control */
341#define EHCI_QH_DTC 0x00004000 363#define EHCI_QH_GET_DTC(x) __SHIFTOUT((x), EHCI_QH_DTC)
342#define EHCI_QH_GET_HRECL(x) (((x) >> 15) & 0x01) /* head of reclamation */ 364#define EHCI_QH_HRECL __BIT(15) /* head of reclamation */
343#define EHCI_QH_HRECL 0x00008000 365#define EHCI_QH_GET_HRECL(x) __SHIFTOUT((x), EHCI_QH_HRECL)
344#define EHCI_QH_GET_MPL(x) (((x) >> 16) & 0x7ff) /* max packet len */ 366#define EHCI_QH_MPL_MASK __BITS(26,16) /* max packet len */
345#define EHCI_QH_SET_MPL(x) ((x) << 16) 367#define EHCI_QH_GET_MPL(x) __SHIFTOUT((x), EHCI_QH_MPL_MASK)
346#define EHCI_QH_MPLMASK 0x07ff0000 368#define EHCI_QH_SET_MPL(x) __SHIFTIN((x), EHCI_QH_MPL_MASK)
347#define EHCI_QH_GET_CTL(x) (((x) >> 27) & 0x01) /* control endpoint */ 369#define EHCI_QH_CTL __BIT(27) /* control endpoint */
348#define EHCI_QH_CTL 0x08000000 370#define EHCI_QH_GET_CTL(x) __SHIFTOUT((x), EHCI_QH_CTL)
349#define EHCI_QH_GET_NRL(x) (((x) >> 28) & 0x0f) /* NAK reload */ 371#define EHCI_QH_NRL_MASK __BITS(31,28) /* NAK reload */
350#define EHCI_QH_SET_NRL(x) ((x) << 28) 372#define EHCI_QH_GET_NRL(x) __SHIFTOUT((x), EHCI_QH_NRL_MASK)
 373#define EHCI_QH_SET_NRL(x) __SHIFTIN((x), EHCI_QH_NRL_MASK)
351 volatile uint32_t qh_endphub; 374 volatile uint32_t qh_endphub;
352#define EHCI_QH_GET_SMASK(x) (((x) >> 0) & 0xff) /* intr sched mask */ 375#define EHCI_QH_SMASK_MASK __BITS(7,0) /* intr sched mask */
353#define EHCI_QH_SET_SMASK(x) ((x) << 0) 376#define EHCI_QH_GET_SMASK(x) __SHIFTOUT((x), EHCI_QH_SMASK_MASK)
354#define EHCI_QH_GET_CMASK(x) (((x) >> 8) & 0xff) /* split completion mask */ 377#define EHCI_QH_SET_SMASK(x) __SHIFTIN((x), EHCI_QH_SMASK_MASK)
355#define EHCI_QH_SET_CMASK(x) ((x) << 8) 378#define EHCI_QH_CMASK_MASK __BITS(15,8) /* split completion mask */
356#define EHCI_QH_GET_HUBA(x) (((x) >> 16) & 0x7f) /* hub address */ 379#define EHCI_QH_GET_CMASK(x) __SHIFTOUT((x), EHCI_QH_CMASK_MASK)
357#define EHCI_QH_SET_HUBA(x) ((x) << 16) 380#define EHCI_QH_SET_CMASK(x) __SHIFTIN((x), EHCI_QH_CMASK_MASK)
358#define EHCI_QH_GET_PORT(x) (((x) >> 23) & 0x7f) /* hub port */ 381#define EHCI_QH_HUBA_MASK __BITS(22,16) /* hub address */
359#define EHCI_QH_SET_PORT(x) ((x) << 23) 382#define EHCI_QH_GET_HUBA(x) __SHIFTOUT((x), EHCI_QH_HUBA_MASK)
360#define EHCI_QH_GET_MULT(x) (((x) >> 30) & 0x03) /* pipe multiplier */ 383#define EHCI_QH_SET_HUBA(x) __SHIFTIN((x), EHCI_QH_HUBA_MASK)
361#define EHCI_QH_SET_MULT(x) ((x) << 30) 384#define EHCI_QH_PORT_MASK __BITS(29,23) /* hub port */
 385#define EHCI_QH_GET_PORT(x) __SHIFTOUT((x), EHCI_QH_PORT_MASK)
 386#define EHCI_QH_SET_PORT(x) __SHIFTIN((x), EHCI_QH_PORT_MASK)
 387#define EHCI_QH_MULTI_MASK __BITS(31,30) /* pipe multiplier */
 388#define EHCI_QH_GET_MULT(x) __SHIFTOUT((x), EHCI_QH_MULTI_MASK)
 389#define EHCI_QH_SET_MULT(x) __SHIFTIN((x), EHCI_QH_MULTI_MASK)
362 volatile ehci_link_t qh_curqtd; 390 volatile ehci_link_t qh_curqtd;
363 ehci_qtd_t qh_qtd; 391 ehci_qtd_t qh_qtd;
364} ehci_qh_t; 392} ehci_qh_t;
365#define EHCI_QH_ALIGN 32 393#define EHCI_QH_ALIGN 32
366 394
367/* Periodic Frame Span Traversal Node */ 395/* Periodic Frame Span Traversal Node */
368typedef struct { 396typedef struct {
369 volatile ehci_link_t fstn_link; 397 volatile ehci_link_t fstn_link;
370 volatile ehci_link_t fstn_back; 398 volatile ehci_link_t fstn_back;
371} ehci_fstn_t; 399} ehci_fstn_t;
372#define EHCI_FSTN_ALIGN 32 400#define EHCI_FSTN_ALIGN 32
373 401
374/* Debug Port */ 402/* Debug Port */