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