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