1 /* $OpenBSD: omwugen.c,v 1.1 2016/09/15 21:55:51 jsg Exp $ */ 2 /* 3 * Copyright (c) 2016 Mark Kettenis 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/systm.h> 20 #include <sys/device.h> 21 22 #include <machine/fdt.h> 23 24 #include <dev/ofw/openfirm.h> 25 26 struct omwugen_softc { 27 struct device sc_dev; 28 struct interrupt_controller sc_ic; 29 }; 30 31 int omwugen_match(struct device *, void *, void *); 32 void omwugen_attach(struct device *, struct device *, void *); 33 34 struct cfattach omwugen_ca = { 35 sizeof(struct omwugen_softc), omwugen_match, omwugen_attach 36 }; 37 38 struct cfdriver omwugen_cd = { 39 NULL, "omwugen", DV_DULL 40 }; 41 42 int 43 omwugen_match(struct device *parent, void *match, void *aux) 44 { 45 struct fdt_attach_args *faa = aux; 46 47 return OF_is_compatible(faa->fa_node, "ti,omap4-wugen-mpu"); 48 } 49 50 void 51 omwugen_attach(struct device *parent, struct device *self, void *aux) 52 { 53 struct fdt_attach_args *faa = aux; 54 struct omwugen_softc *sc = (struct omwugen_softc *)self; 55 56 sc->sc_ic.ic_node = faa->fa_node; 57 sc->sc_ic.ic_cookie = &sc->sc_ic; 58 sc->sc_ic.ic_establish = arm_intr_parent_establish_fdt; 59 sc->sc_ic.ic_disestablish = arm_intr_parent_disestablish_fdt; 60 arm_intr_register_fdt(&sc->sc_ic); 61 62 printf("\n"); 63 } 64