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