imx51_usb.c revision 1.1.6.2 1 1.1.6.2 rmind /* $NetBSD: imx51_usb.c,v 1.1.6.2 2011/03/05 20:49:34 rmind Exp $ */
2 1.1.6.2 rmind /*
3 1.1.6.2 rmind * Copyright (c) 2010 Genetec Corporation. All rights reserved.
4 1.1.6.2 rmind * Written by Hiroyuki Bessho for Genetec Corporation.
5 1.1.6.2 rmind *
6 1.1.6.2 rmind * Redistribution and use in source and binary forms, with or without
7 1.1.6.2 rmind * modification, are permitted provided that the following conditions
8 1.1.6.2 rmind * are met:
9 1.1.6.2 rmind * 1. Redistributions of source code must retain the above copyright
10 1.1.6.2 rmind * notice, this list of conditions and the following disclaimer.
11 1.1.6.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.6.2 rmind * notice, this list of conditions and the following disclaimer in the
13 1.1.6.2 rmind * documentation and/or other materials provided with the distribution.
14 1.1.6.2 rmind *
15 1.1.6.2 rmind * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
16 1.1.6.2 rmind * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1.6.2 rmind * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1.6.2 rmind * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
19 1.1.6.2 rmind * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1.6.2 rmind * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1.6.2 rmind * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1.6.2 rmind * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1.6.2 rmind * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1.6.2 rmind * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1.6.2 rmind * POSSIBILITY OF SUCH DAMAGE.
26 1.1.6.2 rmind */
27 1.1.6.2 rmind #include <sys/cdefs.h>
28 1.1.6.2 rmind __KERNEL_RCSID(0, "$NetBSD: imx51_usb.c,v 1.1.6.2 2011/03/05 20:49:34 rmind Exp $");
29 1.1.6.2 rmind
30 1.1.6.2 rmind #include <sys/param.h>
31 1.1.6.2 rmind #include <sys/systm.h>
32 1.1.6.2 rmind #include <sys/conf.h>
33 1.1.6.2 rmind #include <sys/kernel.h>
34 1.1.6.2 rmind #include <sys/device.h>
35 1.1.6.2 rmind #include <sys/intr.h>
36 1.1.6.2 rmind #include <sys/bus.h>
37 1.1.6.2 rmind
38 1.1.6.2 rmind #include <dev/usb/usb.h>
39 1.1.6.2 rmind #include <dev/usb/usbdi.h>
40 1.1.6.2 rmind #include <dev/usb/usbdivar.h>
41 1.1.6.2 rmind #include <dev/usb/usb_mem.h>
42 1.1.6.2 rmind
43 1.1.6.2 rmind #include <dev/usb/ehcireg.h>
44 1.1.6.2 rmind #include <dev/usb/ehcivar.h>
45 1.1.6.2 rmind
46 1.1.6.2 rmind #include <arm/imx/imx51reg.h>
47 1.1.6.2 rmind #include <arm/imx/imx51var.h>
48 1.1.6.2 rmind #include <arm/imx/imxusbvar.h>
49 1.1.6.2 rmind #include "locators.h"
50 1.1.6.2 rmind
51 1.1.6.2 rmind static int imxusbc_search(device_t, cfdata_t, const int *, void *);
52 1.1.6.2 rmind
53 1.1.6.2 rmind
54 1.1.6.2 rmind int
55 1.1.6.2 rmind imxusbc_attach_common(device_t parent, device_t self, bus_space_tag_t iot)
56 1.1.6.2 rmind {
57 1.1.6.2 rmind struct imxusbc_softc *sc = device_private(self);
58 1.1.6.2 rmind
59 1.1.6.2 rmind sc->sc_iot = iot;
60 1.1.6.2 rmind
61 1.1.6.2 rmind /* Map entire USBOH3 registers. Host controller drivers
62 1.1.6.2 rmind * re-use subregions of this. */
63 1.1.6.2 rmind if (bus_space_map(iot, USBOH3_BASE, USBOH3_SIZE, 0, &sc->sc_ioh))
64 1.1.6.2 rmind return -1;
65 1.1.6.2 rmind
66 1.1.6.2 rmind /* attach OTG/EHCI host controllers */
67 1.1.6.2 rmind config_search_ia(imxusbc_search, self, "imxusbc", NULL);
68 1.1.6.2 rmind
69 1.1.6.2 rmind return 0;
70 1.1.6.2 rmind }
71 1.1.6.2 rmind
72 1.1.6.2 rmind static int
73 1.1.6.2 rmind imxusbc_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
74 1.1.6.2 rmind {
75 1.1.6.2 rmind struct imxusbc_softc *sc = device_private(parent);
76 1.1.6.2 rmind struct imxusbc_attach_args aa;
77 1.1.6.2 rmind
78 1.1.6.2 rmind aa.aa_iot = sc->sc_iot;
79 1.1.6.2 rmind aa.aa_ioh = sc->sc_ioh;
80 1.1.6.2 rmind aa.aa_dmat = &imx_bus_dma_tag;
81 1.1.6.2 rmind aa.aa_unit = cf->cf_loc[IMXUSBCCF_UNIT];
82 1.1.6.2 rmind aa.aa_irq = cf->cf_loc[IMXUSBCCF_IRQ];
83 1.1.6.2 rmind
84 1.1.6.2 rmind if (config_match(parent, cf, &aa) > 0)
85 1.1.6.2 rmind config_attach(parent, cf, &aa, NULL);
86 1.1.6.2 rmind
87 1.1.6.2 rmind return 0;
88 1.1.6.2 rmind }
89 1.1.6.2 rmind
90