blob: 90b137ad018d0c346a9c8921be7426140fbcdef5 [file] [log] [blame]
Michael Trimarchiaaf098c2008-11-28 13:20:46 +01001/*-
2 * Copyright (c) 2007-2008, Juniper Networks, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation version 2 of
8 * the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 */
20
21#ifndef USB_EHCI_H
22#define USB_EHCI_H
23
24/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
25#define DeviceRequest \
26 ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
michaeldb632992008-12-10 17:55:19 +010027
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010028#define DeviceOutRequest \
29 ((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
30
31#define InterfaceRequest \
32 ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
33
34#define EndpointRequest \
35 ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
michaeldb632992008-12-10 17:55:19 +010036
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010037#define EndpointOutRequest \
38 ((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
39
40/*
41 * Register Space.
42 */
43struct ehci_hccr {
michaeldb632992008-12-10 17:55:19 +010044 uint32_t cr_capbase;
45#define HC_LENGTH(p) (((p) >> 0) & 0x00ff)
46#define HC_VERSION(p) (((p) >> 16) & 0xffff)
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010047 uint32_t cr_hcsparams;
michael51ab1422008-12-11 13:43:55 +010048#define HCS_N_PORTS(p) (((p) >> 0) & 0xf)
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010049 uint32_t cr_hccparams;
50 uint8_t cr_hcsp_portrt[8];
51};
52
53struct ehci_hcor {
54 uint32_t or_usbcmd;
michael51ab1422008-12-11 13:43:55 +010055#define CMD_PARK (1 << 11) /* enable "park" */
56#define CMD_PARK_CNT(c) (((c) >> 8) & 3) /* how many transfers to park */
57#define CMD_ASE (1 << 5) /* async schedule enable */
58#define CMD_LRESET (1 << 7) /* partial reset */
59#define CMD_IAAD (1 << 5) /* "doorbell" interrupt */
60#define CMD_PSE (1 << 4) /* periodic schedule enable */
61#define CMD_RESET (1 << 1) /* reset HC not bus */
62#define CMD_RUN (1 << 0) /* start/stop HC */
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010063 uint32_t or_usbsts;
michaeldb632992008-12-10 17:55:19 +010064#define STD_ASS (1 << 15)
michael51ab1422008-12-11 13:43:55 +010065#define STS_HALT (1 << 12)
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010066 uint32_t or_usbintr;
67 uint32_t or_frindex;
68 uint32_t or_ctrldssegment;
69 uint32_t or_periodiclistbase;
70 uint32_t or_asynclistaddr;
71 uint32_t _reserved_[9];
72 uint32_t or_configflag;
michael51ab1422008-12-11 13:43:55 +010073#define FLAG_CF (1 << 0) /* true: we'll support "high speed" */
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010074 uint32_t or_portsc[2];
75 uint32_t or_systune;
76};
77
michael51ab1422008-12-11 13:43:55 +010078#define USBMODE 0x68 /* USB Device mode */
79#define USBMODE_SDIS (1 << 3) /* Stream disable */
80#define USBMODE_BE (1 << 2) /* BE/LE endiannes select */
81#define USBMODE_CM_HC (3 << 0) /* host controller mode */
82#define USBMODE_CM_IDLE (0 << 0) /* idle state */
83
michaeldb632992008-12-10 17:55:19 +010084/* Interface descriptor */
85struct usb_linux_interface_descriptor {
86 unsigned char bLength;
87 unsigned char bDescriptorType;
88 unsigned char bInterfaceNumber;
89 unsigned char bAlternateSetting;
90 unsigned char bNumEndpoints;
91 unsigned char bInterfaceClass;
92 unsigned char bInterfaceSubClass;
93 unsigned char bInterfaceProtocol;
94 unsigned char iInterface;
95} __attribute__ ((packed));
96
97/* Configuration descriptor information.. */
98struct usb_linux_config_descriptor {
99 unsigned char bLength;
100 unsigned char bDescriptorType;
101 unsigned short wTotalLength;
102 unsigned char bNumInterfaces;
103 unsigned char bConfigurationValue;
104 unsigned char iConfiguration;
105 unsigned char bmAttributes;
106 unsigned char MaxPower;
107} __attribute__ ((packed));
108
109#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
michael51ab1422008-12-11 13:43:55 +0100110#define ehci_readl(x) (*((volatile u32 *)(x)))
111#define ehci_writel(a, b) (*((volatile u32 *)(a)) = ((volatile u32)b))
michaeldb632992008-12-10 17:55:19 +0100112#else
michael51ab1422008-12-11 13:43:55 +0100113#define ehci_readl(x) cpu_to_le32((*((volatile u32 *)(x))))
114#define ehci_writel(a, b) (*((volatile u32 *)(a)) = \
115 cpu_to_le32(((volatile u32)b)))
michaeldb632992008-12-10 17:55:19 +0100116#endif
117
118#if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
119#define hc32_to_cpu(x) be32_to_cpu((x))
120#define cpu_to_hc32(x) cpu_to_be32((x))
121#else
122#define hc32_to_cpu(x) le32_to_cpu((x))
123#define cpu_to_hc32(x) cpu_to_le32((x))
124#endif
125
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100126#define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over current */
127#define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect */
128#define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect */
129#define EHCI_PS_PTC 0x000f0000 /* RW port test control */
130#define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */
131#define EHCI_PS_PO 0x00002000 /* RW port owner */
132#define EHCI_PS_PP 0x00001000 /* RW,RO port power */
133#define EHCI_PS_LS 0x00000c00 /* RO line status */
134#define EHCI_PS_PR 0x00000100 /* RW port reset */
135#define EHCI_PS_SUSP 0x00000080 /* RW suspend */
136#define EHCI_PS_FPR 0x00000040 /* RW force port resume */
137#define EHCI_PS_OCC 0x00000020 /* RWC over current change */
138#define EHCI_PS_OCA 0x00000010 /* RO over current active */
139#define EHCI_PS_PEC 0x00000008 /* RWC port enable change */
140#define EHCI_PS_PE 0x00000004 /* RW port enable */
141#define EHCI_PS_CSC 0x00000002 /* RWC connect status change */
142#define EHCI_PS_CS 0x00000001 /* RO connect status */
143#define EHCI_PS_CLEAR (EHCI_PS_OCC | EHCI_PS_PEC | EHCI_PS_CSC)
144
145#define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400)
146
147/*
148 * Schedule Interface Space.
149 *
150 * IMPORTANT: Software must ensure that no interface data structure
151 * reachable by the EHCI host controller spans a 4K page boundary!
152 *
153 * Periodic transfers (i.e. isochronous and interrupt transfers) are
154 * not supported.
155 */
156
157/* Queue Element Transfer Descriptor (qTD). */
158struct qTD {
159 uint32_t qt_next;
160#define QT_NEXT_TERMINATE 1
161 uint32_t qt_altnext;
162 uint32_t qt_token;
163 uint32_t qt_buffer[5];
164};
165
166/* Queue Head (QH). */
167struct QH {
168 uint32_t qh_link;
169#define QH_LINK_TERMINATE 1
170#define QH_LINK_TYPE_ITD 0
171#define QH_LINK_TYPE_QH 2
172#define QH_LINK_TYPE_SITD 4
173#define QH_LINK_TYPE_FSTN 6
174 uint32_t qh_endpt1;
175 uint32_t qh_endpt2;
176 uint32_t qh_curtd;
177 struct qTD qh_overlay;
178};
179
180/* Low level intit functions */
181
182int ehci_hcd_init(void);
183int ehci_hcd_stop(void);
184#endif /* USB_EHCI_H */