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