blob: f914ec604bd7e98bf0a8d1ef881287db3f8573a3 [file] [log] [blame]
Brian Swetland3e7e21a2009-01-19 19:41:24 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
Eugene Yasman7b7b6282013-02-26 13:13:20 +02005 * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
Shashank Mittal23b8f422010-04-16 19:27:21 -07006 *
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
Eugene Yasman7b7b6282013-02-26 13:13:20 +020014 * the documentation and/or other materials provided with the
Brian Swetland3e7e21a2009-01-19 19:41:24 -080015 * 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
Eugene Yasman7b7b6282013-02-26 13:13:20 +020024 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
Brian Swetland3e7e21a2009-01-19 19:41:24 -080025 * 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 Dudani7d605522010-10-01 19:52:37 -070034#ifndef MSM_USB_BASE
Brian Swetland3e7e21a2009-01-19 19:41:24 -080035#define MSM_USB_BASE 0xA0800000
Ajay Dudani232ce812009-12-02 00:14:11 -080036#endif
Brian Swetland3e7e21a2009-01-19 19:41:24 -080037
38#define USB_ID (MSM_USB_BASE + 0x0000)
39#define USB_HWGENERAL (MSM_USB_BASE + 0x0004)
40#define USB_HWHOST (MSM_USB_BASE + 0x0008)
41#define USB_HWDEVICE (MSM_USB_BASE + 0x000C)
42#define USB_HWTXBUF (MSM_USB_BASE + 0x0010)
43#define USB_HWRXBUF (MSM_USB_BASE + 0x0014)
44#define USB_SBUSCFG (MSM_USB_BASE + 0x0090)
Deepa Dinamani0687ecd2012-08-10 16:00:26 -070045#define USB_AHB_MODE (MSM_USB_BASE + 0x0098)
Brian Swetland3e7e21a2009-01-19 19:41:24 -080046
Amol Jadi71303ad2013-02-28 20:56:08 -080047#define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00A0)
48
Ajay Dudanib01e5062011-12-03 23:23:42 -080049#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */
50#define USB_HCIVERSION (MSM_USB_BASE + 0x0102) /* 16 bit */
Brian Swetland3e7e21a2009-01-19 19:41:24 -080051#define USB_HCSPARAMS (MSM_USB_BASE + 0x0104)
52#define USB_HCCPARAMS (MSM_USB_BASE + 0x0108)
Ajay Dudanib01e5062011-12-03 23:23:42 -080053#define USB_DCIVERSION (MSM_USB_BASE + 0x0120) /* 16 bit */
Brian Swetland3e7e21a2009-01-19 19:41:24 -080054#define USB_USBCMD (MSM_USB_BASE + 0x0140)
55#define USB_USBSTS (MSM_USB_BASE + 0x0144)
56#define USB_USBINTR (MSM_USB_BASE + 0x0148)
57#define USB_FRINDEX (MSM_USB_BASE + 0x014C)
58#define USB_DEVICEADDR (MSM_USB_BASE + 0x0154)
59#define USB_ENDPOINTLISTADDR (MSM_USB_BASE + 0x0158)
60#define USB_BURSTSIZE (MSM_USB_BASE + 0x0160)
61#define USB_TXFILLTUNING (MSM_USB_BASE + 0x0164)
62#define USB_ULPI_VIEWPORT (MSM_USB_BASE + 0x0170)
63#define USB_ENDPTNAK (MSM_USB_BASE + 0x0178)
64#define USB_ENDPTNAKEN (MSM_USB_BASE + 0x017C)
65#define USB_PORTSC (MSM_USB_BASE + 0x0184)
66#define USB_OTGSC (MSM_USB_BASE + 0x01A4)
67#define USB_USBMODE (MSM_USB_BASE + 0x01A8)
68#define USB_ENDPTSETUPSTAT (MSM_USB_BASE + 0x01AC)
69#define USB_ENDPTPRIME (MSM_USB_BASE + 0x01B0)
70#define USB_ENDPTFLUSH (MSM_USB_BASE + 0x01B4)
71#define USB_ENDPTSTAT (MSM_USB_BASE + 0x01B8)
72#define USB_ENDPTCOMPLETE (MSM_USB_BASE + 0x01BC)
73#define USB_ENDPTCTRL(n) (MSM_USB_BASE + 0x01C0 + (4 * (n)))
Eugene Yasman7b7b6282013-02-26 13:13:20 +020074#define USB_OTG_HS_PHY_CTRL (MSM_USB_BASE + 0x0240)
75#define USB_OTG_HS_PHY_SEC_CTRL (MSM_USB_BASE + 0x0278)
Brian Swetland3e7e21a2009-01-19 19:41:24 -080076
Amol Jadi71303ad2013-02-28 20:56:08 -080077/* ULPI registers */
78#define ULPI_MISC_A_READ 0x96
79#define ULPI_MISC_A_SET 0x97
80#define ULPI_MISC_A_CLEAR 0x98
81
Brian Swetland3e7e21a2009-01-19 19:41:24 -080082#define USBCMD_RESET 2
83#define USBCMD_ATTACH 1
84
85#define USBMODE_DEVICE 2
86#define USBMODE_HOST 3
87
Ajay Dudanib01e5062011-12-03 23:23:42 -080088struct ept_queue_head {
89 unsigned config;
90 unsigned current; /* read-only */
Brian Swetland3e7e21a2009-01-19 19:41:24 -080091
Ajay Dudanib01e5062011-12-03 23:23:42 -080092 unsigned next;
93 unsigned info;
94 unsigned page0;
95 unsigned page1;
96 unsigned page2;
97 unsigned page3;
98 unsigned page4;
99 unsigned reserved_0;
100
101 unsigned char setup_data[8];
102
103 unsigned reserved_1;
104 unsigned reserved_2;
105 unsigned reserved_3;
106 unsigned reserved_4;
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800107};
108
109#define CONFIG_MAX_PKT(n) ((n) << 16)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800110#define CONFIG_ZLT (1 << 29) /* stop on zero-len xfer */
111#define CONFIG_IOS (1 << 15) /* IRQ on setup */
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800112
Ajay Dudanib01e5062011-12-03 23:23:42 -0800113struct ept_queue_item {
114 unsigned next;
115 unsigned info;
116 unsigned page0;
117 unsigned page1;
118 unsigned page2;
119 unsigned page3;
120 unsigned page4;
121 unsigned reserved;
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800122};
123
124#define TERMINATE 1
125
126#define INFO_BYTES(n) ((n) << 16)
127#define INFO_IOC (1 << 15)
128#define INFO_ACTIVE (1 << 7)
129#define INFO_HALTED (1 << 6)
130#define INFO_BUFFER_ERROR (1 << 5)
131#define INFO_TX_ERROR (1 << 3)
132
Ajay Dudanib01e5062011-12-03 23:23:42 -0800133#define STS_NAKI (1 << 16) /* */
134#define STS_SLI (1 << 8) /* R/WC - suspend state entered */
135#define STS_SRI (1 << 7) /* R/WC - SOF recv'd */
136#define STS_URI (1 << 6) /* R/WC - RESET recv'd - write to clear */
137#define STS_FRI (1 << 3) /* R/WC - Frame List Rollover */
138#define STS_PCI (1 << 2) /* R/WC - Port Change Detect */
139#define STS_UEI (1 << 1) /* R/WC - USB Error */
140#define STS_UI (1 << 0) /* R/WC - USB Transaction Complete */
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800141
142/* bits used in all the endpoint status registers */
143#define EPT_TX(n) (1 << ((n) + 16))
144#define EPT_RX(n) (1 << (n))
145
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800146#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
Amol Jadi71303ad2013-02-28 20:56:08 -0800167#define GEN2_SESS_VLD_CTRL_EN (1 << 7)
168#define SESS_VLD_CTRL (1 << 25)
169
170
171/* ULPI bit map */
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800172#define ULPI_WAKEUP (1 << 31)
173#define ULPI_RUN (1 << 30)
174#define ULPI_WRITE (1 << 29)
175#define ULPI_READ (0 << 29)
176#define ULPI_STATE_NORMAL (1 << 27)
177#define ULPI_ADDR(n) (((n) & 255) << 16)
178#define ULPI_DATA(n) ((n) & 255)
179#define ULPI_DATA_READ(n) (((n) >> 8) & 255)
Chandan Uddaraju7f5b9012010-02-06 16:37:48 -0800180
Amol Jadi71303ad2013-02-28 20:56:08 -0800181#define ULPI_MISC_A_VBUSVLDEXTSEL (1 << 1)
182#define ULPI_MISC_A_VBUSVLDEXT (1 << 0)
183
Brian Swetland3e7e21a2009-01-19 19:41:24 -0800184#endif