exynos_ohci.c revision 1.1.2.2 1 1.1.2.2 skrll /* $NetBSD: exynos_ohci.c,v 1.1.2.2 2016/03/19 11:29:57 skrll Exp $ */
2 1.1.2.2 skrll
3 1.1.2.2 skrll /*-
4 1.1.2.2 skrll * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 1.1.2.2 skrll * All rights reserved.
6 1.1.2.2 skrll *
7 1.1.2.2 skrll * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.2 skrll * by Reinoud Zandijk.
9 1.1.2.2 skrll *
10 1.1.2.2 skrll * Redistribution and use in source and binary forms, with or without
11 1.1.2.2 skrll * modification, are permitted provided that the following conditions
12 1.1.2.2 skrll * are met:
13 1.1.2.2 skrll * 1. Redistributions of source code must retain the above copyright
14 1.1.2.2 skrll * notice, this list of conditions and the following disclaimer.
15 1.1.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.2 skrll * notice, this list of conditions and the following disclaimer in the
17 1.1.2.2 skrll * documentation and/or other materials provided with the distribution.
18 1.1.2.2 skrll *
19 1.1.2.2 skrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.2 skrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.2 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.2 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.2 skrll * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.2 skrll */
31 1.1.2.2 skrll
32 1.1.2.2 skrll #include "locators.h"
33 1.1.2.2 skrll #include "ohci.h"
34 1.1.2.2 skrll #include "ehci.h"
35 1.1.2.2 skrll
36 1.1.2.2 skrll #include <sys/cdefs.h>
37 1.1.2.2 skrll
38 1.1.2.2 skrll __KERNEL_RCSID(1, "$NetBSD: exynos_ohci.c,v 1.1.2.2 2016/03/19 11:29:57 skrll Exp $");
39 1.1.2.2 skrll
40 1.1.2.2 skrll #include <sys/param.h>
41 1.1.2.2 skrll #include <sys/systm.h>
42 1.1.2.2 skrll #include <sys/kernel.h>
43 1.1.2.2 skrll #include <sys/intr.h>
44 1.1.2.2 skrll #include <sys/bus.h>
45 1.1.2.2 skrll #include <sys/device.h>
46 1.1.2.2 skrll #include <sys/proc.h>
47 1.1.2.2 skrll #include <sys/queue.h>
48 1.1.2.2 skrll #include <sys/kmem.h>
49 1.1.2.2 skrll #include <sys/gpio.h>
50 1.1.2.2 skrll
51 1.1.2.2 skrll #include <dev/usb/usb.h>
52 1.1.2.2 skrll #include <dev/usb/usbdi.h>
53 1.1.2.2 skrll #include <dev/usb/usbdivar.h>
54 1.1.2.2 skrll #include <dev/usb/usb_mem.h>
55 1.1.2.2 skrll
56 1.1.2.2 skrll #include <dev/usb/ohcireg.h>
57 1.1.2.2 skrll #include <dev/usb/ohcivar.h>
58 1.1.2.2 skrll
59 1.1.2.2 skrll #include <arm/samsung/exynos_reg.h>
60 1.1.2.2 skrll #include <arm/samsung/exynos_var.h>
61 1.1.2.2 skrll
62 1.1.2.2 skrll #include <dev/fdt/fdtvar.h>
63 1.1.2.2 skrll
64 1.1.2.2 skrll static int exynos_ohci_match(device_t, cfdata_t, void *);
65 1.1.2.2 skrll static void exynos_ohci_attach(device_t, device_t, void *);
66 1.1.2.2 skrll
67 1.1.2.2 skrll CFATTACH_DECL_NEW(exynos_ohci, sizeof(struct ohci_softc),
68 1.1.2.2 skrll exynos_ohci_match, exynos_ohci_attach, NULL, NULL);
69 1.1.2.2 skrll
70 1.1.2.2 skrll
71 1.1.2.2 skrll static int
72 1.1.2.2 skrll exynos_ohci_match(device_t parent, cfdata_t cf, void *aux)
73 1.1.2.2 skrll {
74 1.1.2.2 skrll const char * const compatible[] = { "samsung,exynos5-ohci",
75 1.1.2.2 skrll NULL };
76 1.1.2.2 skrll struct fdt_attach_args * const faa = aux;
77 1.1.2.2 skrll return of_match_compatible(faa->faa_phandle, compatible);
78 1.1.2.2 skrll }
79 1.1.2.2 skrll
80 1.1.2.2 skrll
81 1.1.2.2 skrll static void
82 1.1.2.2 skrll exynos_ohci_attach(device_t parent, device_t self, void *aux)
83 1.1.2.2 skrll {
84 1.1.2.2 skrll struct ohci_softc *sc = device_private(self);
85 1.1.2.2 skrll struct fdt_attach_args * const faa = aux;
86 1.1.2.2 skrll bus_addr_t addr;
87 1.1.2.2 skrll bus_size_t size;
88 1.1.2.2 skrll int error;
89 1.1.2.2 skrll
90 1.1.2.2 skrll if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) {
91 1.1.2.2 skrll aprint_error(": couldn't get registers\n");
92 1.1.2.2 skrll return;
93 1.1.2.2 skrll }
94 1.1.2.2 skrll
95 1.1.2.2 skrll sc->sc_dev = self;
96 1.1.2.2 skrll sc->iot = faa->faa_bst;
97 1.1.2.2 skrll sc->sc_size = size;
98 1.1.2.2 skrll sc->sc_bus.dmatag = faa->faa_dmat;
99 1.1.2.2 skrll sc->sc_bus.hci_private = sc;
100 1.1.2.2 skrll
101 1.1.2.2 skrll error = bus_space_map(sc->iot, addr, size, 0, &sc->ioh);
102 1.1.2.2 skrll if (error) {
103 1.1.2.2 skrll aprint_error(": couldn't map %#llx: %d",
104 1.1.2.2 skrll (uint64_t)addr, error);
105 1.1.2.2 skrll return;
106 1.1.2.2 skrll }
107 1.1.2.2 skrll
108 1.1.2.2 skrll aprint_naive(": OHCI USB controller\n");
109 1.1.2.2 skrll aprint_normal(": OHCI NOT IMPLEMENTED\n");
110 1.1.2.2 skrll
111 1.1.2.2 skrll /* attach */
112 1.1.2.2 skrll error = ohci_init(sc);
113 1.1.2.2 skrll if (error) {
114 1.1.2.2 skrll aprint_error_dev(self, "init failed, error = %d\n", error);
115 1.1.2.2 skrll /* disable : TBD */
116 1.1.2.2 skrll return;
117 1.1.2.2 skrll }
118 1.1.2.2 skrll sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
119 1.1.2.2 skrll }
120 1.1.2.2 skrll
121