imxusb.c revision 1.15 1 1.15 skrll /* $NetBSD: imxusb.c,v 1.15 2019/07/26 06:57:54 skrll Exp $ */
2 1.1 bsh /*
3 1.1 bsh * Copyright (c) 2009, 2010 Genetec Corporation. All rights reserved.
4 1.1 bsh * Written by Hashimoto Kenichi and Hiroyuki Bessho for Genetec Corporation.
5 1.1 bsh *
6 1.1 bsh * Redistribution and use in source and binary forms, with or without
7 1.1 bsh * modification, are permitted provided that the following conditions
8 1.1 bsh * are met:
9 1.1 bsh * 1. Redistributions of source code must retain the above copyright
10 1.1 bsh * notice, this list of conditions and the following disclaimer.
11 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 bsh * notice, this list of conditions and the following disclaimer in the
13 1.1 bsh * documentation and/or other materials provided with the distribution.
14 1.1 bsh *
15 1.1 bsh * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
16 1.1 bsh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 bsh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 bsh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
19 1.1 bsh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 bsh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 bsh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 bsh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 bsh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 bsh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 bsh * POSSIBILITY OF SUCH DAMAGE.
26 1.1 bsh */
27 1.1 bsh #include <sys/cdefs.h>
28 1.15 skrll __KERNEL_RCSID(0, "$NetBSD: imxusb.c,v 1.15 2019/07/26 06:57:54 skrll Exp $");
29 1.6 hkenken
30 1.14 hkenken #include "locators.h"
31 1.1 bsh
32 1.1 bsh #include <sys/param.h>
33 1.1 bsh #include <sys/systm.h>
34 1.1 bsh #include <sys/conf.h>
35 1.1 bsh #include <sys/kernel.h>
36 1.1 bsh #include <sys/device.h>
37 1.1 bsh #include <sys/intr.h>
38 1.1 bsh #include <sys/bus.h>
39 1.1 bsh
40 1.1 bsh #include <dev/usb/usb.h>
41 1.1 bsh #include <dev/usb/usbdi.h>
42 1.1 bsh #include <dev/usb/usbdivar.h>
43 1.1 bsh #include <dev/usb/usb_mem.h>
44 1.1 bsh
45 1.1 bsh #include <dev/usb/ehcireg.h>
46 1.1 bsh #include <dev/usb/ehcivar.h>
47 1.1 bsh
48 1.5 matt #include <arm/pic/picvar.h> /* XXX: for intr_establish! */
49 1.5 matt
50 1.1 bsh #include <arm/imx/imxusbreg.h>
51 1.1 bsh #include <arm/imx/imxusbvar.h>
52 1.1 bsh
53 1.1 bsh #include <dev/usb/ulpireg.h> /* for test */
54 1.1 bsh
55 1.1 bsh static int imxehci_match(device_t, cfdata_t, void *);
56 1.1 bsh static void imxehci_attach(device_t, device_t, void *);
57 1.10 skrll
58 1.1 bsh uint8_t imxusb_ulpi_read(struct imxehci_softc *sc, int addr);
59 1.1 bsh void imxusb_ulpi_write(struct imxehci_softc *sc, int addr, uint8_t data);
60 1.1 bsh static void ulpi_reset(struct imxehci_softc *sc);
61 1.1 bsh
62 1.9 hkenken static void imxehci_select_interface(struct imxehci_softc *, enum imx_usb_if);
63 1.9 hkenken static void imxehci_init(struct ehci_softc *);
64 1.1 bsh
65 1.1 bsh /* attach structures */
66 1.1 bsh CFATTACH_DECL_NEW(imxehci, sizeof(struct imxehci_softc),
67 1.1 bsh imxehci_match, imxehci_attach, NULL, NULL);
68 1.1 bsh
69 1.1 bsh static int
70 1.1 bsh imxehci_match(device_t parent, cfdata_t cf, void *aux)
71 1.1 bsh {
72 1.1 bsh struct imxusbc_attach_args *aa = aux;
73 1.10 skrll
74 1.14 hkenken if (aa->aa_unit < 0 || 3 < aa->aa_unit)
75 1.1 bsh return 0;
76 1.10 skrll
77 1.1 bsh return 1;
78 1.1 bsh }
79 1.1 bsh
80 1.1 bsh static void
81 1.1 bsh imxehci_attach(device_t parent, device_t self, void *aux)
82 1.1 bsh {
83 1.1 bsh struct imxusbc_attach_args *aa = aux;
84 1.1 bsh struct imxusbc_softc *usbc = device_private(parent);
85 1.1 bsh struct imxehci_softc *sc = device_private(self);
86 1.1 bsh ehci_softc_t *hsc = &sc->sc_hsc;
87 1.1 bsh bus_space_tag_t iot;
88 1.1 bsh uint16_t hcirev;
89 1.1 bsh uint32_t id, hwhost, hwdevice;
90 1.1 bsh const char *comma;
91 1.7 ryo
92 1.14 hkenken iot = aa->aa_iot;
93 1.14 hkenken
94 1.14 hkenken sc->sc_dev = self;
95 1.1 bsh sc->sc_unit = aa->aa_unit;
96 1.1 bsh sc->sc_usbc = usbc;
97 1.14 hkenken sc->sc_iot = iot;
98 1.14 hkenken
99 1.14 hkenken hsc->sc_dev = self;
100 1.14 hkenken hsc->iot = iot;
101 1.11 skrll hsc->sc_bus.ub_hcpriv = sc;
102 1.14 hkenken hsc->sc_bus.ub_dmatag = aa->aa_dmat;
103 1.4 matt hsc->sc_flags |= EHCIF_ETTF;
104 1.9 hkenken hsc->sc_vendor_init = imxehci_init;
105 1.1 bsh
106 1.7 ryo aprint_naive("\n");
107 1.7 ryo aprint_normal(": i.MX USB Controller\n");
108 1.1 bsh
109 1.12 ryo if (usbc->sc_ehci_size == 0)
110 1.12 ryo usbc->sc_ehci_size = IMXUSB_EHCI_SIZE; /* use default */
111 1.12 ryo
112 1.1 bsh /* per unit registers */
113 1.10 skrll if (bus_space_subregion(iot, aa->aa_ioh,
114 1.14 hkenken sc->sc_unit * usbc->sc_ehci_offset, usbc->sc_ehci_size,
115 1.1 bsh &sc->sc_ioh) ||
116 1.1 bsh bus_space_subregion(iot, aa->aa_ioh,
117 1.14 hkenken sc->sc_unit * usbc->sc_ehci_offset + IMXUSB_EHCIREGS,
118 1.12 ryo usbc->sc_ehci_size - IMXUSB_EHCIREGS,
119 1.14 hkenken &hsc->ioh)) {
120 1.1 bsh
121 1.1 bsh aprint_error_dev(self, "can't subregion\n");
122 1.1 bsh return;
123 1.1 bsh }
124 1.1 bsh
125 1.1 bsh id = bus_space_read_4(iot, sc->sc_ioh, IMXUSB_ID);
126 1.14 hkenken hcirev = bus_space_read_2(iot, hsc->ioh, EHCI_HCIVERSION);
127 1.1 bsh
128 1.1 bsh aprint_normal_dev(self,
129 1.10 skrll "id=%d revision=%d HCI revision=0x%x\n",
130 1.6 hkenken (int)__SHIFTOUT(id, IMXUSB_ID_ID),
131 1.6 hkenken (int)__SHIFTOUT(id, IMXUSB_ID_REVISION),
132 1.1 bsh hcirev);
133 1.10 skrll
134 1.1 bsh hwhost = bus_space_read_4(iot, sc->sc_ioh, IMXUSB_HWHOST);
135 1.1 bsh hwdevice = bus_space_read_4(iot, sc->sc_ioh, IMXUSB_HWDEVICE);
136 1.1 bsh
137 1.1 bsh aprint_normal_dev(self, "");
138 1.1 bsh
139 1.1 bsh comma = "";
140 1.1 bsh if (hwhost & HWHOST_HC) {
141 1.6 hkenken int n_ports = 1 + __SHIFTOUT(hwhost, HWHOST_NPORT);
142 1.1 bsh aprint_normal("%d host port%s",
143 1.1 bsh n_ports, n_ports > 1 ? "s" : "");
144 1.1 bsh comma = ", ";
145 1.1 bsh }
146 1.1 bsh
147 1.1 bsh if (hwdevice & HWDEVICE_DC) {
148 1.6 hkenken int n_endpoints = __SHIFTOUT(hwdevice, HWDEVICE_DEVEP);
149 1.1 bsh aprint_normal("%sdevice capable, %d endpoint%s",
150 1.1 bsh comma,
151 1.1 bsh n_endpoints, n_endpoints > 1 ? "s" : "");
152 1.1 bsh }
153 1.1 bsh aprint_normal("\n");
154 1.1 bsh
155 1.14 hkenken hsc->sc_offs = bus_space_read_1(iot, hsc->ioh,
156 1.1 bsh EHCI_CAPLENGTH);
157 1.1 bsh
158 1.1 bsh /* Platform dependent setup */
159 1.1 bsh if (usbc->sc_init_md_hook)
160 1.1 bsh usbc->sc_init_md_hook(sc);
161 1.11 skrll
162 1.1 bsh imxehci_reset(sc);
163 1.1 bsh imxehci_select_interface(sc, sc->sc_iftype);
164 1.1 bsh
165 1.1 bsh if (sc->sc_iftype == IMXUSBC_IF_ULPI) {
166 1.1 bsh bus_space_write_4(sc->sc_iot, sc->sc_ioh, IMXUSB_ULPIVIEW, 0);
167 1.1 bsh
168 1.1 bsh aprint_normal_dev(hsc->sc_dev,
169 1.1 bsh "ULPI phy VID 0x%04x PID 0x%04x\n",
170 1.1 bsh (imxusb_ulpi_read(sc, ULPI_VENDOR_ID_LOW) |
171 1.1 bsh imxusb_ulpi_read(sc, ULPI_VENDOR_ID_HIGH) << 8),
172 1.1 bsh (imxusb_ulpi_read(sc, ULPI_PRODUCT_ID_LOW) |
173 1.1 bsh imxusb_ulpi_read(sc, ULPI_PRODUCT_ID_HIGH) << 8));
174 1.1 bsh
175 1.1 bsh ulpi_reset(sc);
176 1.1 bsh
177 1.1 bsh }
178 1.1 bsh
179 1.1 bsh if (usbc->sc_setup_md_hook)
180 1.1 bsh usbc->sc_setup_md_hook(sc, IMXUSB_HOST);
181 1.6 hkenken
182 1.6 hkenken if (sc->sc_iftype == IMXUSBC_IF_ULPI) {
183 1.6 hkenken #if 0
184 1.11 skrll if(hsc->sc_bus.ub_revision == USBREV_2_0)
185 1.6 hkenken ulpi_write(hsc, ULPI_FUNCTION_CONTROL + ULPI_REG_CLEAR, (1 << 0));
186 1.6 hkenken else
187 1.6 hkenken ulpi_write(hsc, ULPI_FUNCTION_CONTROL + ULPI_REG_SET, (1 << 2));
188 1.6 hkenken #endif
189 1.6 hkenken
190 1.1 bsh imxusb_ulpi_write(sc, ULPI_FUNCTION_CONTROL + ULPI_REG_CLEAR,
191 1.1 bsh OTG_CONTROL_IDPULLUP);
192 1.1 bsh
193 1.1 bsh imxusb_ulpi_write(sc, ULPI_OTG_CONTROL + ULPI_REG_SET,
194 1.1 bsh OTG_CONTROL_USEEXTVBUSIND |
195 1.1 bsh OTG_CONTROL_DRVVBUSEXT |
196 1.1 bsh OTG_CONTROL_DRVVBUS |
197 1.14 hkenken OTG_CONTROL_CHRGVBUS);
198 1.1 bsh }
199 1.1 bsh
200 1.1 bsh /* Disable interrupts, so we don't get any spurious ones. */
201 1.2 matt EOWRITE4(hsc, EHCI_USBINTR, 0);
202 1.1 bsh
203 1.14 hkenken if (usbc->sc_intr_establish_md_hook)
204 1.14 hkenken sc->sc_ih = usbc->sc_intr_establish_md_hook(sc);
205 1.14 hkenken else if (aa->aa_irq > 0)
206 1.14 hkenken sc->sc_ih = intr_establish(aa->aa_irq, IPL_USB, IST_LEVEL, ehci_intr, hsc);
207 1.14 hkenken KASSERT(sc->sc_ih != NULL);
208 1.1 bsh
209 1.11 skrll int err = ehci_init(hsc);
210 1.11 skrll if (err) {
211 1.11 skrll aprint_error_dev(self, "init failed, error=%d\n", err);
212 1.1 bsh return;
213 1.1 bsh }
214 1.1 bsh
215 1.1 bsh /* Attach usb device. */
216 1.1 bsh hsc->sc_child = config_found(self, &hsc->sc_bus, usbctlprint);
217 1.1 bsh }
218 1.1 bsh
219 1.9 hkenken static void
220 1.1 bsh imxehci_select_interface(struct imxehci_softc *sc, enum imx_usb_if interface)
221 1.1 bsh {
222 1.1 bsh uint32_t reg;
223 1.1 bsh struct ehci_softc *hsc = &sc->sc_hsc;
224 1.1 bsh
225 1.1 bsh reg = EOREAD4(hsc, EHCI_PORTSC(1));
226 1.12 ryo reg &= ~(PORTSC_PTS | PORTSC_PTW | PORTSC_PTS2);
227 1.6 hkenken switch (interface) {
228 1.6 hkenken case IMXUSBC_IF_UTMI_WIDE:
229 1.6 hkenken reg |= PORTSC_PTW_16;
230 1.6 hkenken case IMXUSBC_IF_UTMI:
231 1.6 hkenken reg |= PORTSC_PTS_UTMI;
232 1.6 hkenken break;
233 1.6 hkenken case IMXUSBC_IF_PHILIPS:
234 1.6 hkenken reg |= PORTSC_PTS_PHILIPS;
235 1.6 hkenken break;
236 1.6 hkenken case IMXUSBC_IF_ULPI:
237 1.6 hkenken reg |= PORTSC_PTS_ULPI;
238 1.6 hkenken break;
239 1.6 hkenken case IMXUSBC_IF_SERIAL:
240 1.6 hkenken reg |= PORTSC_PTS_SERIAL;
241 1.6 hkenken break;
242 1.12 ryo case IMXUSBC_IF_HSIC:
243 1.12 ryo reg |= PORTSC_PTS2;
244 1.12 ryo break;
245 1.6 hkenken }
246 1.1 bsh EOWRITE4(hsc, EHCI_PORTSC(1), reg);
247 1.1 bsh }
248 1.1 bsh
249 1.1 bsh static uint32_t
250 1.1 bsh ulpi_wakeup(struct imxehci_softc *sc, int tout)
251 1.1 bsh {
252 1.14 hkenken struct ehci_softc *hsc = &sc->sc_hsc;
253 1.1 bsh uint32_t ulpi_view;
254 1.14 hkenken
255 1.1 bsh ulpi_view = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IMXUSB_ULPIVIEW);
256 1.1 bsh
257 1.14 hkenken if (!(ulpi_view & ULPI_SS)) {
258 1.1 bsh bus_space_write_4(sc->sc_iot, sc->sc_ioh,
259 1.1 bsh IMXUSB_ULPIVIEW, ULPI_WU);
260 1.14 hkenken while (tout-- > 0) {
261 1.1 bsh ulpi_view = bus_space_read_4(sc->sc_iot,
262 1.1 bsh sc->sc_ioh, IMXUSB_ULPIVIEW);
263 1.14 hkenken if (!(ulpi_view & ULPI_WU))
264 1.1 bsh break;
265 1.1 bsh delay(1);
266 1.1 bsh };
267 1.1 bsh }
268 1.1 bsh
269 1.14 hkenken if (tout == 0)
270 1.14 hkenken aprint_error_dev(hsc->sc_dev, "%s: timeout\n", __func__);
271 1.1 bsh
272 1.1 bsh return ulpi_view;
273 1.1 bsh }
274 1.1 bsh
275 1.1 bsh static uint32_t
276 1.1 bsh ulpi_wait(struct imxehci_softc *sc, int tout)
277 1.1 bsh {
278 1.14 hkenken struct ehci_softc *hsc = &sc->sc_hsc;
279 1.1 bsh uint32_t ulpi_view;
280 1.14 hkenken
281 1.1 bsh ulpi_view = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IMXUSB_ULPIVIEW);
282 1.1 bsh
283 1.14 hkenken while (tout-- > 0) {
284 1.1 bsh ulpi_view = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
285 1.1 bsh IMXUSB_ULPIVIEW);
286 1.1 bsh if (!(ulpi_view & ULPI_RUN))
287 1.1 bsh break;
288 1.1 bsh delay(1);
289 1.1 bsh }
290 1.1 bsh
291 1.14 hkenken if (tout == 0)
292 1.14 hkenken aprint_error_dev(hsc->sc_dev, "%s: timeout\n", __func__);
293 1.1 bsh
294 1.1 bsh return ulpi_view;
295 1.1 bsh }
296 1.1 bsh
297 1.1 bsh #define TIMEOUT 100000
298 1.10 skrll
299 1.1 bsh uint8_t
300 1.1 bsh imxusb_ulpi_read(struct imxehci_softc *sc, int addr)
301 1.1 bsh {
302 1.14 hkenken uint32_t reg;
303 1.1 bsh
304 1.1 bsh ulpi_wakeup(sc, TIMEOUT);
305 1.1 bsh
306 1.14 hkenken reg = ULPI_RUN | __SHIFTIN(addr, ULPI_ADDR);
307 1.14 hkenken bus_space_write_4(sc->sc_iot, sc->sc_ioh, IMXUSB_ULPIVIEW, reg);
308 1.1 bsh
309 1.14 hkenken reg = ulpi_wait(sc, TIMEOUT);
310 1.1 bsh
311 1.14 hkenken return __SHIFTOUT(reg, ULPI_DATRD);
312 1.1 bsh }
313 1.1 bsh
314 1.1 bsh void
315 1.1 bsh imxusb_ulpi_write(struct imxehci_softc *sc, int addr, uint8_t data)
316 1.1 bsh {
317 1.1 bsh uint32_t reg;
318 1.1 bsh
319 1.1 bsh ulpi_wakeup(sc, TIMEOUT);
320 1.1 bsh
321 1.6 hkenken reg = ULPI_RUN | ULPI_RW | __SHIFTIN(addr, ULPI_ADDR) | __SHIFTIN(data, ULPI_DATWR);
322 1.1 bsh bus_space_write_4(sc->sc_iot, sc->sc_ioh, IMXUSB_ULPIVIEW, reg);
323 1.1 bsh
324 1.1 bsh ulpi_wait(sc, TIMEOUT);
325 1.1 bsh
326 1.1 bsh return;
327 1.1 bsh }
328 1.1 bsh
329 1.1 bsh static void
330 1.1 bsh ulpi_reset(struct imxehci_softc *sc)
331 1.1 bsh {
332 1.14 hkenken struct ehci_softc *hsc = &sc->sc_hsc;
333 1.1 bsh uint8_t data;
334 1.1 bsh int timo = 1000 * 1000; /* XXXX: 1sec */
335 1.1 bsh
336 1.1 bsh imxusb_ulpi_write(sc, ULPI_FUNCTION_CONTROL + ULPI_REG_SET,
337 1.1 bsh FUNCTION_CONTROL_RESET /*0x20*/);
338 1.1 bsh do {
339 1.1 bsh data = imxusb_ulpi_read(sc, ULPI_FUNCTION_CONTROL);
340 1.1 bsh if (!(data & FUNCTION_CONTROL_RESET))
341 1.1 bsh break;
342 1.1 bsh delay(100);
343 1.1 bsh timo -= 100;
344 1.1 bsh } while (timo > 0);
345 1.14 hkenken
346 1.1 bsh if (timo <= 0) {
347 1.14 hkenken aprint_error_dev(hsc->sc_dev, "%s: reset failed!!\n",
348 1.1 bsh __func__);
349 1.1 bsh return;
350 1.1 bsh }
351 1.1 bsh
352 1.1 bsh return;
353 1.1 bsh }
354 1.1 bsh
355 1.1 bsh void
356 1.1 bsh imxehci_reset(struct imxehci_softc *sc)
357 1.1 bsh {
358 1.3 skrll uint32_t reg;
359 1.1 bsh struct ehci_softc *hsc = &sc->sc_hsc;
360 1.14 hkenken int tout;
361 1.1 bsh #define RESET_TIMEOUT 100
362 1.1 bsh
363 1.1 bsh reg = EOREAD4(hsc, EHCI_USBCMD);
364 1.1 bsh reg &= ~EHCI_CMD_RS;
365 1.1 bsh EOWRITE4(hsc, EHCI_USBCMD, reg);
366 1.1 bsh
367 1.14 hkenken for (tout = RESET_TIMEOUT; tout > 0; tout--) {
368 1.1 bsh reg = EOREAD4(hsc, EHCI_USBCMD);
369 1.1 bsh if ((reg & EHCI_CMD_RS) == 0)
370 1.1 bsh break;
371 1.1 bsh usb_delay_ms(&hsc->sc_bus, 1);
372 1.1 bsh }
373 1.1 bsh
374 1.1 bsh EOWRITE4(hsc, EHCI_USBCMD, reg | EHCI_CMD_HCRESET);
375 1.14 hkenken
376 1.14 hkenken for (tout = RESET_TIMEOUT; tout > 0; tout--) {
377 1.1 bsh reg = EOREAD4(hsc, EHCI_USBCMD);
378 1.1 bsh if ((reg & EHCI_CMD_HCRESET) == 0)
379 1.1 bsh break;
380 1.1 bsh usb_delay_ms(&hsc->sc_bus, 1);
381 1.1 bsh }
382 1.14 hkenken
383 1.14 hkenken if (tout == 0)
384 1.1 bsh aprint_error_dev(hsc->sc_dev, "reset timeout (%x)\n", reg);
385 1.1 bsh
386 1.1 bsh usb_delay_ms(&hsc->sc_bus, 100);
387 1.1 bsh }
388 1.1 bsh
389 1.9 hkenken static void
390 1.9 hkenken imxehci_init(struct ehci_softc *hsc)
391 1.1 bsh {
392 1.9 hkenken struct imxehci_softc *sc = device_private(hsc->sc_dev);
393 1.1 bsh uint32_t reg;
394 1.1 bsh
395 1.1 bsh reg = EOREAD4(hsc, EHCI_PORTSC(1));
396 1.1 bsh reg &= ~(EHCI_PS_CSC | EHCI_PS_PEC | EHCI_PS_OCC);
397 1.1 bsh reg |= EHCI_PS_PP | EHCI_PS_PE;
398 1.1 bsh EOWRITE4(hsc, EHCI_PORTSC(1), reg);
399 1.1 bsh
400 1.1 bsh reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IMXUSB_OTGSC);
401 1.1 bsh reg |= OTGSC_IDPU;
402 1.5 matt /* disable IDIE not to conflict with SSP1_DETECT. */
403 1.5 matt //reg |= OTGSC_DPIE | OTGSC_IDIE;
404 1.5 matt reg |= OTGSC_DPIE;
405 1.1 bsh bus_space_write_4(sc->sc_iot, sc->sc_ioh, IMXUSB_OTGSC, reg);
406 1.1 bsh
407 1.8 skrll reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IMXUSB_USBMODE);
408 1.9 hkenken reg &= ~USBMODE_CM;
409 1.6 hkenken reg |= USBMODE_CM_HOST;
410 1.8 skrll bus_space_write_4(sc->sc_iot, sc->sc_ioh, IMXUSB_USBMODE, reg);
411 1.1 bsh }
412