xref: /openbsd/sys/arch/armv7/omap/omcm.c (revision 471aeecf)
1 /* $OpenBSD: omcm.c,v 1.3 2022/04/06 18:59:26 naddy Exp $ */
2 /*
3  * Copyright (c) 2020 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 <dev/ofw/openfirm.h>
24 
25 #include <arm/simplebus/simplebusvar.h>
26 
27 struct omcm_softc {
28 	struct simplebus_softc	sc_bus;
29 };
30 
31 int	omcm_match(struct device *, void *, void *);
32 void	omcm_attach(struct device *, struct device *, void *);
33 
34 const struct cfattach omcm_ca = {
35 	sizeof(struct omcm_softc), omcm_match, omcm_attach
36 };
37 
38 struct cfdriver omcm_cd = {
39 	NULL, "omcm", DV_DULL
40 };
41 
42 int
43 omcm_match(struct device *parent, void *cfdata, void *aux)
44 {
45 	struct fdt_attach_args *faa = aux;
46 
47 	return OF_is_compatible(faa->fa_node, "ti,omap4-cm");
48 }
49 
50 void
51 omcm_attach(struct device *parent, struct device *self, void *aux)
52 {
53 	struct omcm_softc *sc = (struct omcm_softc *)self;
54 	struct fdt_attach_args *faa = aux;
55 
56 	simplebus_attach(parent, &sc->sc_bus.sc_dev, faa);
57 }
58