blob: 0035851f91ab1095723eb1eb6efc44fb97bbd13f [file] [log] [blame]
Brian Swetland3e7e21a2009-01-19 19:41:24 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
Shashank Mittal23b8f422010-04-16 19:27:21 -07005 * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
6 *
Brian Swetland3e7e21a2009-01-19 19:41:24 -08007 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#ifndef _MSM7200_USB_H_
32#define _MSM7200_USB_H_
33
Ajay Dudani232ce812009-12-02 00:14:11 -080034#ifdef PLATFORM_MSM7X30
35#define MSM_USB_BASE 0xA3600000
Shashank Mittal23b8f422010-04-16 19:27:21 -070036#elif PLATFORM_MSM8X60
37#define MSM_USB_BASE 0x12500000
Ajay Dudani232ce812009-12-02 00:14:11 -080038#else
Brian Swetland3e7e21a2009-01-19 19:41:24 -080039#define MSM_USB_BASE 0xA0800000
Ajay Dudani232ce812009-12-02 00:14:11 -080040#endif
Brian Swetland3e7e21a2009-01-19 19:41:24 -080041
42#define USB_ID (MSM_USB_BASE + 0x0000)
43#define USB_HWGENERAL (MSM_USB_BASE + 0x0004)
44#define USB_HWHOST (MSM_USB_BASE + 0x0008)
45#define USB_HWDEVICE (MSM_USB_BASE + 0x000C)
46#define USB_HWTXBUF (MSM_USB_BASE + 0x0010)
47#define USB_HWRXBUF (MSM_USB_BASE + 0x0014)
48#define USB_SBUSCFG (MSM_USB_BASE + 0x0090)
49
50#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */
51#define USB_HCIVERSION (MSM_USB_BASE + 0x0102) /* 16 bit */
52#define USB_HCSPARAMS (MSM_USB_BASE + 0x0104)
53#define USB_HCCPARAMS (MSM_USB_BASE + 0x0108)
54#define USB_DCIVERSION (MSM_USB_BASE + 0x0120) /* 16 bit */
55#define USB_USBCMD (MSM_USB_BASE + 0x0140)
56#define USB_USBSTS (MSM_USB_BASE + 0x0144)
57#define USB_USBINTR (MSM_USB_BASE + 0x0148)
58#define USB_FRINDEX (MSM_USB_BASE + 0x014C)
59#define USB_DEVICEADDR (MSM_USB_BASE + 0x0154)
60#define USB_ENDPOINTLISTADDR (MSM_USB_BASE + 0x0158)
61#define USB_BURSTSIZE (MSM_USB_BASE + 0x0160)
62#define USB_TXFILLTUNING (MSM_USB_BASE + 0x0164)
63#define USB_ULPI_VIEWPORT (MSM_USB_BASE + 0x0170)
64#define USB_ENDPTNAK (MSM_USB_BASE + 0x0178)
65#define USB_ENDPTNAKEN (MSM_USB_BASE + 0x017C)
66#define USB_PORTSC (MSM_USB_BASE + 0x0184)
67#define USB_OTGSC (MSM_USB_BASE + 0x01A4)
68#define USB_USBMODE (MSM_USB_BASE + 0x01A8)
69#define USB_ENDPTSETUPSTAT (MSM_USB_BASE + 0x01AC)
70#define USB_ENDPTPRIME (MSM_USB_BASE + 0x01B0)
71#define USB_ENDPTFLUSH (MSM_USB_BASE + 0x01B4)
72#define USB_ENDPTSTAT (MSM_USB_BASE + 0x01B8)
73#define USB_ENDPTCOMPLETE (MSM_USB_BASE + 0x01BC)
74#define USB_ENDPTCTRL(n) (MSM_USB_BASE + 0x01C0 + (4 * (n)))
75
76
77#define USBCMD_RESET 2
78#define USBCMD_ATTACH 1
79
80#define USBMODE_DEVICE 2
81#define USBMODE_HOST 3
82
83struct ept_queue_head
84{
85 unsigned config;
86 unsigned current; /* read-only */
87
88 unsigned next;
89 unsigned info;
90 unsigned page0;
91 unsigned page1;
92 unsigned page2;
93 unsigned page3;
94 unsigned page4;
95 unsigned reserved_0;
96
97 unsigned char setup_data[8];
98
99 unsigned reserved_1;
100 unsigned reserved_2;
101 unsigned reserved_3;
102 unsigned reserved_4;
103};
104
105#define CONFIG_MAX_PKT(n) ((n) << 16)
106#define CONFIG_ZLT (1 << 29) /* stop on zero-len xfer */
107#define CONFIG_IOS (1 << 15) /* IRQ on setup */
108
109struct ept_queue_item
110{
111 unsigned next;
112 unsigned info;
113 unsigned page0;
114 unsigned page1;
115 unsigned page2;
116 unsigned page3;
117 unsigned page4;
118 unsigned reserved;
119};
120
121#define TERMINATE 1
122
123#define INFO_BYTES(n) ((n) << 16)
124#define INFO_IOC (1 << 15)
125#define INFO_ACTIVE (1 << 7)
126#define INFO_HALTED (1 << 6)
127#define INFO_BUFFER_ERROR (1 << 5)
128#define INFO_TX_ERROR (1 << 3)
129
130
131#define STS_NAKI (1 << 16) /* */
132#define STS_SLI (1 << 8) /* R/WC - suspend state entered */
133#define STS_SRI (1 << 7) /* R/WC - SOF recv'd */
134#define STS_URI (1 << 6) /* R/WC - RESET recv'd - write to clear */
135#define STS_FRI (1 << 3) /* R/WC - Frame List Rollover */
136#define STS_PCI (1 << 2) /* R/WC - Port Change Detect */
137#define STS_UEI (1 << 1) /* R/WC - USB Error */
138#define STS_UI (1 << 0) /* R/WC - USB Transaction Complete */
139
140
141/* bits used in all the endpoint status registers */
142#define EPT_TX(n) (1 << ((n) + 16))
143#define EPT_RX(n) (1 << (n))
144
145
146#define CTRL_TXE (1 << 23)
147#define CTRL_TXR (1 << 22)
148#define CTRL_TXI (1 << 21)
149#define CTRL_TXD (1 << 17)
150#define CTRL_TXS (1 << 16)
151#define CTRL_RXE (1 << 7)
152#define CTRL_RXR (1 << 6)
153#define CTRL_RXI (1 << 5)
154#define CTRL_RXD (1 << 1)
155#define CTRL_RXS (1 << 0)
156
157#define CTRL_TXT_CTRL (0 << 18)
158#define CTRL_TXT_ISOCH (1 << 18)
159#define CTRL_TXT_BULK (2 << 18)
160#define CTRL_TXT_INT (3 << 18)
161
162#define CTRL_RXT_CTRL (0 << 2)
163#define CTRL_RXT_ISOCH (1 << 2)
164#define CTRL_RXT_BULK (2 << 2)
165#define CTRL_RXT_INT (3 << 2)
166
167#define ULPI_WAKEUP (1 << 31)
168#define ULPI_RUN (1 << 30)
169#define ULPI_WRITE (1 << 29)
170#define ULPI_READ (0 << 29)
171#define ULPI_STATE_NORMAL (1 << 27)
172#define ULPI_ADDR(n) (((n) & 255) << 16)
173#define ULPI_DATA(n) ((n) & 255)
174#define ULPI_DATA_READ(n) (((n) >> 8) & 255)
Ajay Dudani232ce812009-12-02 00:14:11 -0800175#ifdef PLATFORM_MSM7X30
176#define USBH_NS_REG (0xAB8002C0)
177#endif
Chandan Uddaraju7f5b9012010-02-06 16:37:48 -0800178
179/* for USB charging */
180#define TRUE 1
181#define FALSE 0
182#define PORTSC_LS (3 << 10) /* Read - Port's Line status */
183#define B_SESSION_VALID (1 << 11)
184
185static unsigned WALL_CHARGER = FALSE;
186static unsigned HOST_CHARGER = FALSE;
187static unsigned ENABLE_CHARGING = TRUE;
188static unsigned charger_connected = FALSE;
189
190enum charger_type {
191 CHG_HOST_PC,
192 CHG_WALL,
193 CHG_UNDEFINED,
194};
195
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800196#endif