xref: /openbsd-src/sys/arch/armv7/omap/omwugen.c (revision 9fdf0c627b1fec102f212f847a6f7676c1829e65)
1*9fdf0c62Smpi /*	$OpenBSD: omwugen.c,v 1.2 2021/10/24 17:52:28 mpi Exp $	*/
2243ce539Sjsg /*
3243ce539Sjsg  * Copyright (c) 2016 Mark Kettenis
4243ce539Sjsg  *
5243ce539Sjsg  * Permission to use, copy, modify, and distribute this software for any
6243ce539Sjsg  * purpose with or without fee is hereby granted, provided that the above
7243ce539Sjsg  * copyright notice and this permission notice appear in all copies.
8243ce539Sjsg  *
9243ce539Sjsg  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10243ce539Sjsg  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11243ce539Sjsg  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12243ce539Sjsg  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13243ce539Sjsg  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14243ce539Sjsg  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15243ce539Sjsg  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16243ce539Sjsg  */
17243ce539Sjsg 
18243ce539Sjsg #include <sys/param.h>
19243ce539Sjsg #include <sys/systm.h>
20243ce539Sjsg #include <sys/device.h>
21243ce539Sjsg 
22243ce539Sjsg #include <machine/fdt.h>
23243ce539Sjsg 
24243ce539Sjsg #include <dev/ofw/openfirm.h>
25243ce539Sjsg 
26243ce539Sjsg struct omwugen_softc {
27243ce539Sjsg 	struct device	sc_dev;
28243ce539Sjsg 	struct interrupt_controller sc_ic;
29243ce539Sjsg };
30243ce539Sjsg 
31243ce539Sjsg int	omwugen_match(struct device *, void *, void *);
32243ce539Sjsg void	omwugen_attach(struct device *, struct device *, void *);
33243ce539Sjsg 
34*9fdf0c62Smpi const struct cfattach omwugen_ca = {
35243ce539Sjsg 	sizeof(struct omwugen_softc), omwugen_match, omwugen_attach
36243ce539Sjsg };
37243ce539Sjsg 
38243ce539Sjsg struct cfdriver omwugen_cd = {
39243ce539Sjsg 	NULL, "omwugen", DV_DULL
40243ce539Sjsg };
41243ce539Sjsg 
42243ce539Sjsg int
omwugen_match(struct device * parent,void * match,void * aux)43243ce539Sjsg omwugen_match(struct device *parent, void *match, void *aux)
44243ce539Sjsg {
45243ce539Sjsg 	struct fdt_attach_args *faa = aux;
46243ce539Sjsg 
47243ce539Sjsg 	return OF_is_compatible(faa->fa_node, "ti,omap4-wugen-mpu");
48243ce539Sjsg }
49243ce539Sjsg 
50243ce539Sjsg void
omwugen_attach(struct device * parent,struct device * self,void * aux)51243ce539Sjsg omwugen_attach(struct device *parent, struct device *self, void *aux)
52243ce539Sjsg {
53243ce539Sjsg 	struct fdt_attach_args *faa = aux;
54243ce539Sjsg 	struct omwugen_softc *sc = (struct omwugen_softc *)self;
55243ce539Sjsg 
56243ce539Sjsg 	sc->sc_ic.ic_node = faa->fa_node;
57243ce539Sjsg 	sc->sc_ic.ic_cookie = &sc->sc_ic;
58243ce539Sjsg 	sc->sc_ic.ic_establish = arm_intr_parent_establish_fdt;
59243ce539Sjsg 	sc->sc_ic.ic_disestablish = arm_intr_parent_disestablish_fdt;
60243ce539Sjsg 	arm_intr_register_fdt(&sc->sc_ic);
61243ce539Sjsg 
62243ce539Sjsg 	printf("\n");
63243ce539Sjsg }
64