blob: f4890cc3c0c6c6e353121f74a7660d71a8333298 [file] [log] [blame]
Patrick Georgi7f43dc12010-09-25 17:01:13 +00001/*
2 * This file is part of the libpayload project.
3 *
4 * Copyright (C) 2010 coresystems GmbH
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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.
16 *
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
27 * SUCH DAMAGE.
28 */
29
30#ifndef __EHCI_PRIVATE_H
31#define __EHCI_PRIVATE_H
32
33#include <pci.h>
34#include <usb/usb.h>
35
36#define USBBASE 0x10
37#define FLADJ 0x61
38#define FLADJ_framelength(x) (((x)-59488)/16)
39
Patrick Georgi8bbdb612011-08-16 15:47:15 +020040typedef volatile union {
Patrick Georgi7f43dc12010-09-25 17:01:13 +000041 u32 val;
42 volatile struct {
43 unsigned long current_conn_status:1;
44 unsigned long conn_status_change:1;
45 unsigned long port_enable:1;
46 unsigned long port_enable_change:1;
47 unsigned long overcurrent:1;
48 unsigned long overcurrent_change:1;
49 unsigned long force_port_resume:1;
50 unsigned long suspend:1;
51 unsigned long port_reset:1;
52 unsigned long:1;
53 unsigned long line_status:2;
54 unsigned long pp:1;
55 unsigned long port_owner:1;
56 unsigned long port_indicator_control:2;
57 unsigned long port_test_control:4;
58 unsigned long wake_on_connect_en:1;
59 unsigned long wake_on_disconnect_en:1;
60 unsigned long wake_on_overcurrent_en:1;
61 unsigned long:9;
62 } __attribute__ ((packed));
63} __attribute__ ((packed)) portsc_t;
64
Patrick Georgi8bbdb612011-08-16 15:47:15 +020065typedef volatile struct {
Patrick Georgi7f43dc12010-09-25 17:01:13 +000066 u8 caplength;
67 u8 res1;
68 u16 hciversion;
69 union {
70 u32 hcsparams;
71 struct {
72 unsigned long n_ports:4;
73 unsigned long ppc:1;
74 unsigned long:2;
75 unsigned long port_routing_rules:1;
76 unsigned long n_pcc:4;
77 unsigned long n_cc:4;
78 unsigned long p_indicator:1;
79 unsigned long:3;
80 unsigned long debug_port_number:4;
81 unsigned long:8;
82 } __attribute__ ((packed));
83 };
84 union {
85 u32 hccparams;
86 struct {
87 unsigned long cap_64b_addr:1;
88 unsigned long cap_prog_framelist_size:1;
89 unsigned long cap_async_park:1;
90 unsigned long:1;
91 unsigned long isoc_sched_threshold:4;
92 unsigned long eecp:8;
93 unsigned long:16;
94 } __attribute__ ((packed));
95 };
96 union {
97 u64 hcsp_portroute;
98 struct {
99 unsigned long portroute0:4;
100 unsigned long portroute1:4;
101 unsigned long portroute2:4;
102 unsigned long portroute3:4;
103 unsigned long portroute4:4;
104 unsigned long portroute5:4;
105 unsigned long portroute6:4;
106 unsigned long portroute7:4;
107 unsigned long portroute8:4;
108 unsigned long portroute9:4;
109 unsigned long portroute10:4;
110 unsigned long portroute11:4;
111 unsigned long portroute12:4;
112 unsigned long portroute13:4;
113 unsigned long portroute14:4;
114 unsigned long portroute15:4;
115 unsigned long:4;
116 } __attribute__ ((packed));
117 };
118} __attribute__ ((packed)) hc_cap_t;
119
Patrick Georgi8bbdb612011-08-16 15:47:15 +0200120typedef volatile struct {
Patrick Georgi7f43dc12010-09-25 17:01:13 +0000121 union {
122 u32 usbcmd;
123 volatile struct {
124 unsigned long rs:1;
125 unsigned long hcreset:1;
126 unsigned long frame_list_size:2;
127 unsigned long periodic_sched_enable:1;
128 unsigned long async_sched_enable:1;
129 unsigned long irq_on_async_advance_doorbell:1;
130 unsigned long light_hc_reset:1;
131 unsigned long async_sched_park_mode_count:2;
132 unsigned long:1;
133 unsigned long async_sched_park_mode_enable:1;
134 unsigned long:4;
135 unsigned long irq_threshold_count:8;
136 unsigned long:8;
137 } __attribute__ ((packed));
138 };
139 union {
140 u32 usbsts;
141 struct {
142 unsigned long usbint:1;
143 unsigned long usberrint:1;
144 unsigned long port_change_detect:1;
145 unsigned long frame_list_rollover:1;
146 unsigned long host_system_error:1;
147 unsigned long irq_on_async_advance:1;
148 unsigned long:6;
149 unsigned long hchalted:1;
150 unsigned long reclamation:1;
151 unsigned long periodic_sched_status:1;
152 unsigned long async_sched_status:1;
153 unsigned long:16;
154 } __attribute__ ((packed));
155 };
156 union {
157 u32 usbintr;
158 struct {
159 unsigned long en_usb_irq:1;
160 unsigned long en_usb_err_irq:1;
161 unsigned long en_port_change_irq:1;
162 unsigned long en_frame_list_rollover_irq:1;
163 unsigned long en_host_system_error_irq:1;
164 unsigned long en_irq_on_async_advance:1;
165 unsigned long:26;
166 } __attribute__ ((packed));
167 };
168 u32 frindex;
169 u32 ctrldssegment;
170 u32 periodiclistbase;
171 u32 asynclistaddr;
172 u8 res1[0x3f-0x1c];
173 u32 configflag;
174 portsc_t portsc[0];
175} hc_op_t;
176
Patrick Georgi8bbdb612011-08-16 15:47:15 +0200177typedef volatile struct {
Patrick Georgi7f43dc12010-09-25 17:01:13 +0000178 union {
179 u32 next_qtd;
180 struct {
181 unsigned long terminate:1;
182 unsigned long:4;
183 unsigned long:27;
184 } __attribute__ ((packed));
185 };
186 union {
187 u32 alt_next_qtd;
188 struct {
189 unsigned long alt_terminate:1;
190 unsigned long:4;
191 unsigned long:27;
192 } __attribute__ ((packed));
193 };
194 struct {
195 union {
196 volatile u8 status;
197 struct {
198 volatile unsigned long perr:1;
199 volatile unsigned long splitxstate:1;
200 volatile unsigned long missed_mframe:1;
201 volatile unsigned long xact_err:1;
202 volatile unsigned long babble:1;
203 volatile unsigned long data_buf_err:1;
204 volatile unsigned long halted:1;
205 volatile unsigned long active:1;
206 } __attribute__ ((packed));
207 };
208 unsigned long pid:2;
209 volatile unsigned long cerr:2;
210 volatile unsigned long c_page:3;
211 unsigned long ioc:1;
212 volatile unsigned long total_len:15;
213 volatile unsigned long dt:1;
214 } __attribute__ ((packed));
215 union {
216 u32 bufptr0;
217 struct {
218 volatile unsigned long cur_off:12;
219 unsigned long:20;
220 } __attribute__ ((packed));
221 };
222 u32 bufptrs[4];
223 u32 bufptrs64[5];
224} __attribute__ ((packed)) qtd_t;
225
Patrick Georgi8bbdb612011-08-16 15:47:15 +0200226typedef volatile struct {
Patrick Georgi7f43dc12010-09-25 17:01:13 +0000227 union {
228 u32 horiz_link_ptr;
229 struct {
230 unsigned long terminate:1;
231 unsigned long type:2;
232 unsigned long:1;
233 unsigned long:28;
234 } __attribute__ ((packed));
235 };
236 struct {
237 unsigned long addr:7;
238 unsigned long inactivate:1;
239 unsigned long ep:4;
240 unsigned long eps:2;
241 unsigned long dtc:1;
242 unsigned long reclaim_head:1;
243 unsigned long max_packet_len:11;
244 unsigned long non_hs_control_ep:1;
245 unsigned long nak_cnt_reload:4;
246 } __attribute__ ((packed));
247 struct {
248 unsigned long irq_sched_mask:8;
249 unsigned long split_compl_mask:8;
250 unsigned long hub_addr:7;
251 unsigned long port_num:7;
252 unsigned long pipe_multiplier:2;
253 } __attribute__ ((packed));
254 volatile u32 current_td_ptr;
255 volatile qtd_t td;
256} ehci_qh_t;
257
258typedef struct ehci {
259 hc_cap_t *capabilities;
260 hc_op_t *operation;
261} ehci_t;
262
263
264#define EHCI_INST(controller) ((ehci_t*)((controller)->instance))
265
266#endif