1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __USB_ULPI_H__
20#define __USB_ULPI_H__
21
22#define ULPI_ERROR (1 << 8)
23
24#ifndef CONFIG_USB_ULPI_TIMEOUT
25#define CONFIG_USB_ULPI_TIMEOUT 1000
26#endif
27
28
29
30
31
32
33
34struct ulpi_viewport {
35 uintptr_t viewport_addr;
36 u32 port_num;
37};
38
39
40
41
42
43
44
45int ulpi_init(struct ulpi_viewport *ulpi_vp);
46
47
48
49
50
51
52
53int ulpi_select_transceiver(struct ulpi_viewport *ulpi_vp, unsigned speed);
54
55
56
57
58
59
60
61
62int ulpi_set_vbus(struct ulpi_viewport *ulpi_vp, int on, int ext_power);
63
64
65
66
67
68
69
70
71int ulpi_set_vbus_indicator(struct ulpi_viewport *ulpi_vp, int external,
72 int passthru, int complement);
73
74
75
76
77
78
79int ulpi_set_pd(struct ulpi_viewport *ulpi_vp, int enable);
80
81
82
83
84
85
86
87
88int ulpi_opmode_sel(struct ulpi_viewport *ulpi_vp, unsigned opmode);
89
90
91
92
93
94
95
96
97
98
99
100int ulpi_serial_mode_enable(struct ulpi_viewport *ulpi_vp, unsigned smode);
101
102
103
104
105
106
107
108
109
110
111int ulpi_suspend(struct ulpi_viewport *ulpi_vp);
112
113
114
115
116
117
118int ulpi_reset(struct ulpi_viewport *ulpi_vp);
119
120
121
122
123
124
125
126
127
128
129
130
131int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value);
132
133
134
135
136
137
138
139
140u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg);
141
142
143
144
145
146
147int ulpi_reset_wait(struct ulpi_viewport *ulpi_vp);
148
149
150#define ACCESS_EXT_REGS_OFFSET 0x2f
151
152#define VENDOR_SPEC_OFFSET 0x30
153
154
155
156
157
158
159
160
161#define EXT_VENDOR_SPEC_OFFSET 0x80
162
163
164struct ulpi_regs {
165
166 u8 vendor_id_low;
167 u8 vendor_id_high;
168 u8 product_id_low;
169 u8 product_id_high;
170
171 u8 function_ctrl;
172 u8 function_ctrl_set;
173 u8 function_ctrl_clear;
174
175 u8 iface_ctrl;
176 u8 iface_ctrl_set;
177 u8 iface_ctrl_clear;
178
179 u8 otg_ctrl;
180 u8 otg_ctrl_set;
181 u8 otg_ctrl_clear;
182
183 u8 usb_ie_rising;
184 u8 usb_ie_rising_set;
185 u8 usb_ie_rising_clear;
186
187 u8 usb_ie_falling;
188 u8 usb_ie_falling_set;
189 u8 usb_ie_falling_clear;
190
191 u8 usb_int_status;
192
193 u8 usb_int_latch;
194
195 u8 debug;
196
197 u8 scratch;
198 u8 scratch_set;
199 u8 scratch_clear;
200
201
202
203
204 u8 carkit_ctrl;
205 u8 carkit_ctrl_set;
206 u8 carkit_ctrl_clear;
207
208 u8 carkit_int_delay;
209
210 u8 carkit_ie;
211 u8 carkit_ie_set;
212 u8 carkit_ie_clear;
213
214 u8 carkit_int_status;
215
216 u8 carkit_int_latch;
217
218 u8 carkit_pulse_ctrl;
219 u8 carkit_pulse_ctrl_set;
220 u8 carkit_pulse_ctrl_clear;
221
222
223
224
225 u8 transmit_pos_width;
226
227 u8 transmit_neg_width;
228
229 u8 recv_pol_recovery;
230
231
232
233
234};
235
236
237
238
239
240
241#define ULPI_FC_XCVRSEL_MASK (3 << 0)
242#define ULPI_FC_HIGH_SPEED (0 << 0)
243#define ULPI_FC_FULL_SPEED (1 << 0)
244#define ULPI_FC_LOW_SPEED (2 << 0)
245#define ULPI_FC_FS4LS (3 << 0)
246#define ULPI_FC_TERMSELECT (1 << 2)
247#define ULPI_FC_OPMODE_MASK (3 << 3)
248#define ULPI_FC_OPMODE_NORMAL (0 << 3)
249#define ULPI_FC_OPMODE_NONDRIVING (1 << 3)
250#define ULPI_FC_OPMODE_DISABLE_NRZI (2 << 3)
251#define ULPI_FC_OPMODE_NOSYNC_NOEOP (3 << 3)
252#define ULPI_FC_RESET (1 << 5)
253#define ULPI_FC_SUSPENDM (1 << 6)
254
255
256#define ULPI_IFACE_6_PIN_SERIAL_MODE (1 << 0)
257#define ULPI_IFACE_3_PIN_SERIAL_MODE (1 << 1)
258#define ULPI_IFACE_CARKITMODE (1 << 2)
259#define ULPI_IFACE_CLOCKSUSPENDM (1 << 3)
260#define ULPI_IFACE_AUTORESUME (1 << 4)
261#define ULPI_IFACE_EXTVBUS_COMPLEMENT (1 << 5)
262#define ULPI_IFACE_PASSTHRU (1 << 6)
263#define ULPI_IFACE_PROTECT_IFC_DISABLE (1 << 7)
264
265
266#define ULPI_OTG_ID_PULLUP (1 << 0)
267#define ULPI_OTG_DP_PULLDOWN (1 << 1)
268#define ULPI_OTG_DM_PULLDOWN (1 << 2)
269#define ULPI_OTG_DISCHRGVBUS (1 << 3)
270#define ULPI_OTG_CHRGVBUS (1 << 4)
271#define ULPI_OTG_DRVVBUS (1 << 5)
272#define ULPI_OTG_DRVVBUS_EXT (1 << 6)
273#define ULPI_OTG_EXTVBUSIND (1 << 7)
274
275
276
277
278
279
280
281#define ULPI_INT_HOST_DISCONNECT (1 << 0)
282#define ULPI_INT_VBUS_VALID (1 << 1)
283#define ULPI_INT_SESS_VALID (1 << 2)
284#define ULPI_INT_SESS_END (1 << 3)
285#define ULPI_INT_IDGRD (1 << 4)
286
287
288#define ULPI_DEBUG_LINESTATE0 (1 << 0)
289#define ULPI_DEBUG_LINESTATE1 (1 << 1)
290
291
292#define ULPI_CARKIT_CTRL_CARKITPWR (1 << 0)
293#define ULPI_CARKIT_CTRL_IDGNDDRV (1 << 1)
294#define ULPI_CARKIT_CTRL_TXDEN (1 << 2)
295#define ULPI_CARKIT_CTRL_RXDEN (1 << 3)
296#define ULPI_CARKIT_CTRL_SPKLEFTEN (1 << 4)
297#define ULPI_CARKIT_CTRL_SPKRIGHTEN (1 << 5)
298#define ULPI_CARKIT_CTRL_MICEN (1 << 6)
299
300
301#define ULPI_CARKIT_INT_EN_IDFLOAT_RISE (1 << 0)
302#define ULPI_CARKIT_INT_EN_IDFLOAT_FALL (1 << 1)
303#define ULPI_CARKIT_INT_EN_CARINTDET (1 << 2)
304#define ULPI_CARKIT_INT_EN_DP_RISE (1 << 3)
305#define ULPI_CARKIT_INT_EN_DP_FALL (1 << 4)
306
307
308#define ULPI_CARKIT_INT_IDFLOAT (1 << 0)
309#define ULPI_CARKIT_INT_CARINTDET (1 << 1)
310#define ULPI_CARKIT_INT_DP (1 << 2)
311
312
313#define ULPI_CARKIT_PLS_CTRL_TXPLSEN (1 << 0)
314#define ULPI_CARKIT_PLS_CTRL_RXPLSEN (1 << 1)
315#define ULPI_CARKIT_PLS_CTRL_SPKRLEFT_BIASEN (1 << 2)
316#define ULPI_CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN (1 << 3)
317
318
319#endif
320