]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm64/arm64/gic_fdt.c
Teach the GICv2 driver about the Qualcomm GICv2 compatible string.
[FreeBSD/FreeBSD.git] / sys / arm64 / arm64 / gic_fdt.c
1 /*-
2  * Copyright (c) 2015 The FreeBSD Foundation
3  * All rights reserved.
4  *
5  * This software was developed by Andrew Turner under
6  * sponsorship from the FreeBSD Foundation.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
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.
16  *
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
27  * SUCH DAMAGE.
28  */
29
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
32
33 #include <sys/types.h>
34 #include <sys/bus.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
37
38 #include <machine/bus.h>
39
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>
44
45 #include <arm64/arm64/gic.h>
46
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},
56         {NULL,                  false}
57 };
58
59 static int
60 arm_gic_fdt_probe(device_t dev)
61 {
62
63         if (!ofw_bus_status_okay(dev))
64                 return (ENXIO);
65
66         if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
67                 return (ENXIO);
68
69         device_set_desc(dev, "ARM Generic Interrupt Controller");
70         return (BUS_PROBE_DEFAULT);
71 }
72
73 static device_method_t arm_gic_fdt_methods[] = {
74         /* Device interface */
75         DEVMETHOD(device_probe,         arm_gic_fdt_probe),
76
77         DEVMETHOD_END
78 };
79
80 DEFINE_CLASS_1(gic, arm_gic_fdt_driver, arm_gic_fdt_methods,
81     sizeof(struct arm_gic_softc), arm_gic_driver);
82
83 static devclass_t arm_gic_fdt_devclass;
84
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);