2 * Copyright (c) 2015 The FreeBSD Foundation
5 * This software was developed by Andrew Turner under
6 * sponsorship from the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/types.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
38 #include <machine/bus.h>
40 #include <dev/fdt/fdt_common.h>
41 #include <dev/ofw/openfirm.h>
42 #include <dev/ofw/ofw_bus.h>
43 #include <dev/ofw/ofw_bus_subr.h>
45 #include <arm64/arm64/gic.h>
47 static struct ofw_compat_data compat_data[] = {
48 {"arm,gic", true}, /* Non-standard, used in FreeBSD dts. */
49 {"arm,gic-400", true},
50 {"arm,cortex-a15-gic", true},
51 {"arm,cortex-a9-gic", true},
52 {"arm,cortex-a7-gic", true},
53 {"arm,arm11mp-gic", true},
54 {"brcm,brahma-b15-gic", true},
55 {"qcom,msm-qgic2", true},
60 arm_gic_fdt_probe(device_t dev)
63 if (!ofw_bus_status_okay(dev))
66 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
69 device_set_desc(dev, "ARM Generic Interrupt Controller");
70 return (BUS_PROBE_DEFAULT);
73 static device_method_t arm_gic_fdt_methods[] = {
74 /* Device interface */
75 DEVMETHOD(device_probe, arm_gic_fdt_probe),
80 DEFINE_CLASS_1(gic, arm_gic_fdt_driver, arm_gic_fdt_methods,
81 sizeof(struct arm_gic_softc), arm_gic_driver);
83 static devclass_t arm_gic_fdt_devclass;
85 EARLY_DRIVER_MODULE(gic, simplebus, arm_gic_fdt_driver,
86 arm_gic_fdt_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
87 EARLY_DRIVER_MODULE(gic, ofwbus, arm_gic_fdt_driver, arm_gic_fdt_devclass,
88 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);