xref: /openbsd/sys/arch/armv7/exynos/exdwusb.c (revision 097a140d)
1 /*	$OpenBSD: exdwusb.c,v 1.4 2021/03/25 04:12:01 jsg Exp $	*/
2 /*
3  * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #include <sys/param.h>
19 #include <sys/device.h>
20 
21 #include <machine/fdt.h>
22 
23 #include <arm/simplebus/simplebusvar.h>
24 
25 #include <dev/ofw/openfirm.h>
26 #include <dev/ofw/ofw_clock.h>
27 #include <dev/ofw/fdt.h>
28 
29 struct exdwusb_softc {
30 	struct simplebus_softc	sc_sbus;
31 };
32 
33 int	exdwusb_match(struct device *, void *, void *);
34 void	exdwusb_attach(struct device *, struct device *, void *);
35 
36 struct cfattach exdwusb_ca = {
37 	sizeof(struct exdwusb_softc), exdwusb_match, exdwusb_attach
38 };
39 
40 struct cfdriver exdwusb_cd = {
41 	NULL, "exdwusb", DV_DULL
42 };
43 
44 int
45 exdwusb_match(struct device *parent, void *match, void *aux)
46 {
47 	struct fdt_attach_args *faa = aux;
48 
49 	return OF_is_compatible(faa->fa_node, "samsung,exynos5250-dwusb3");
50 }
51 
52 void
53 exdwusb_attach(struct device *parent, struct device *self, void *aux)
54 {
55 	struct exdwusb_softc *sc = (struct exdwusb_softc *)self;
56 	struct fdt_attach_args *faa = aux;
57 
58 	clock_enable_all(faa->fa_node);
59 
60 	simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa);
61 }
62