2 * This file is part of the libpayload project.
4 * Copyright (C) 2008-2010 coresystems GmbH
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #ifndef __UHCI_PRIVATE_H
31 #define __UHCI_PRIVATE_H
33 typedef enum { UHCI_SETUP = 0x2d, UHCI_IN = 0x69, UHCI_OUT = 0xe1 } uhci_pid_t;
37 unsigned long terminate:1;
38 unsigned long queue_head:1;
40 unsigned long ptr_part:28;
43 } __attribute__ ((packed)) flistp_t;
48 unsigned long terminate:1;
49 unsigned long queue_head:1;
50 unsigned long depth_first:1;
52 } __attribute__ ((packed));
54 } __attribute__ ((packed));
56 volatile unsigned long actlen:11;
57 volatile unsigned long:5;
60 unsigned long:1; // bit 0
61 unsigned long status_bitstuff_err:1;
62 unsigned long status_crc_err:1;
63 unsigned long status_nakrcvd:1;
64 unsigned long status_babble:1;
65 unsigned long status_databuf_err:1;
66 unsigned long status_stalled:1;
67 unsigned long status_active:1; // bit 7
68 } __attribute__ ((packed));
70 } __attribute__ ((packed));
71 volatile unsigned long ioc:1; /* interrupt on complete */
72 volatile unsigned long isochronous:1;
73 volatile unsigned long lowspeed:1;
74 volatile unsigned long counter:2;
75 volatile unsigned long shortpck:1;
76 volatile unsigned long:2;
79 unsigned long dev_addr:7;
81 unsigned long data_toggle:1;
83 unsigned long maxlen:11;
87 } __attribute__ ((packed))
92 volatile flistp_t elementlinkptr;
93 } __attribute__ ((packed))
96 typedef enum { USBCMD = 0, USBSTS = 2, USBINTR = 4, FRNUM =
97 6, FLBASEADD = 8, SOFMOD = 0xc, PORTSC1 = 0x10, PORTSC2 =
101 void uhci_reg_write32 (hci_t *ctrl, usbreg reg, u32 value);
102 u32 uhci_reg_read32 (hci_t *ctrl, usbreg reg);
103 void uhci_reg_write16 (hci_t *ctrl, usbreg reg, u16 value);
104 u16 uhci_reg_read16 (hci_t *ctrl, usbreg reg);
105 void uhci_reg_write8 (hci_t *ctrl, usbreg reg, u8 value);
106 u8 uhci_reg_read8 (hci_t *ctrl, usbreg reg);
108 typedef struct uhci {
109 flistp_t *framelistptr;
110 qh_t *qh_prei, *qh_intr, *qh_data, *qh_last;
114 #define UHCI_INST(controller) ((uhci_t*)((controller)->instance))