blob: 8ac15b30930bd78d3df1fa53462cd9edbcd6b702 [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 Georgi8fa27872011-11-24 13:19:57 +010040typedef volatile u32 portsc_t;
41#define P_CURR_CONN_STATUS (1 << 0)
42#define P_CONN_STATUS_CHANGE (1 << 1)
43#define P_PORT_ENABLE (1 << 2)
44#define P_PORT_RESET (1 << 8)
45#define P_LINE_STATUS (3 << 10)
46#define P_LINE_STATUS_LOWSPEED (1 << 10)
47#define P_PP (1 << 12)
48#define P_PORT_OWNER (1 << 13)
Patrick Georgi7f43dc12010-09-25 17:01:13 +000049
Patrick Georgi8bbdb612011-08-16 15:47:15 +020050typedef volatile struct {
Patrick Georgi8fa27872011-11-24 13:19:57 +010051#define HCS_NPORTS_MASK 0xf
Nico Huber5c4e7aa2012-05-21 14:56:21 +020052#define HCS_PORT_POWER_CONTROL 0x10
Patrick Georgi7f43dc12010-09-25 17:01:13 +000053 u8 caplength;
54 u8 res1;
55 u16 hciversion;
Patrick Georgi8fa27872011-11-24 13:19:57 +010056 u32 hcsparams;
57 u32 hccparams;
58 u64 hcsp_portroute;
Patrick Georgi7f43dc12010-09-25 17:01:13 +000059} __attribute__ ((packed)) hc_cap_t;
60
Patrick Georgi8bbdb612011-08-16 15:47:15 +020061typedef volatile struct {
Patrick Georgi8fa27872011-11-24 13:19:57 +010062 u32 usbcmd;
63#define HC_OP_RS 1
64#define HC_OP_ASYNC_SCHED_EN_SHIFT 5
65#define HC_OP_ASYNC_SCHED_EN (1 << HC_OP_ASYNC_SCHED_EN_SHIFT)
66 u32 usbsts;
67#define HC_OP_ASYNC_SCHED_STAT_SHIFT 15
68#define HC_OP_ASYNC_SCHED_STAT (1 << HC_OP_ASYNC_SCHED_STAT_SHIFT)
69 u32 usbintr;
Patrick Georgi7f43dc12010-09-25 17:01:13 +000070 u32 frindex;
71 u32 ctrldssegment;
72 u32 periodiclistbase;
73 u32 asynclistaddr;
74 u8 res1[0x3f-0x1c];
75 u32 configflag;
76 portsc_t portsc[0];
77} hc_op_t;
78
Patrick Georgi8bbdb612011-08-16 15:47:15 +020079typedef volatile struct {
Patrick Georgi8fa27872011-11-24 13:19:57 +010080#define QTD_TERMINATE 1
81 u32 next_qtd;
82 u32 alt_next_qtd;
83 u32 token;
84#define QTD_STATUS_MASK 0xff
Patrick Georgi3e0bd192012-01-31 14:37:59 +010085#define QTD_HALTED (1 << 6)
86#define QTD_ACTIVE (1 << 7)
Patrick Georgi8fa27872011-11-24 13:19:57 +010087#define QTD_PID_SHIFT 8
88#define QTD_PID_MASK (3 << QTD_PID_SHIFT)
89#define QTD_CERR_SHIFT 10
90#define QTD_CERR_MASK (3 << QTD_CERR_SHIFT)
91#define QTD_CPAGE_SHIFT 12
92#define QTD_CPAGE_MASK (7 << QTD_CPAGE_SHIFT)
93#define QTD_TOTAL_LEN_SHIFT 16
94#define QTD_TOTAL_LEN_MASK (((1<<15)-1) << QTD_TOTAL_LEN_SHIFT)
95#define QTD_TOGGLE_SHIFT 31
96#define QTD_TOGGLE_MASK (1 << 31)
97#define QTD_TOGGLE_DATA0 0
98#define QTD_TOGGLE_DATA1 (1 << QTD_TOGGLE_SHIFT)
99 u32 bufptrs[5];
Patrick Georgi7f43dc12010-09-25 17:01:13 +0000100 u32 bufptrs64[5];
101} __attribute__ ((packed)) qtd_t;
102
Patrick Georgi8bbdb612011-08-16 15:47:15 +0200103typedef volatile struct {
Patrick Georgi8fa27872011-11-24 13:19:57 +0100104 u32 horiz_link_ptr;
105#define QH_TERMINATE 1
106#define QH_iTD (0<<1)
107#define QH_QH (1<<1)
108#define QH_siTD (2<<1)
109#define QH_FSTN (3<<1)
110 u32 epchar;
111#define QH_EP_SHIFT 8
112#define QH_EPS_SHIFT 12
113#define QH_DTC_SHIFT 14
114#define QH_RECLAIM_HEAD_SHIFT 15
115#define QH_MPS_SHIFT 16
116#define QH_NON_HS_CTRL_EP_SHIFT 27
117#define QH_NAK_CNT_SHIFT 28
118 u32 epcaps;
119#define QH_PIPE_MULTIPLIER_SHIFT 30
Patrick Georgi7f43dc12010-09-25 17:01:13 +0000120 volatile u32 current_td_ptr;
121 volatile qtd_t td;
122} ehci_qh_t;
123
124typedef struct ehci {
125 hc_cap_t *capabilities;
126 hc_op_t *operation;
127} ehci_t;
128
129
130#define EHCI_INST(controller) ((ehci_t*)((controller)->instance))
131
132#endif