]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: use device api to detect GIC version
authorVijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
Tue, 1 Jul 2014 06:41:13 +0000 (12:11 +0530)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 2 Jul 2014 11:27:06 +0000 (12:27 +0100)
Run through the device tree to detect
compatible GIC version and initialize GIC driver

Also change DT_MATCH_GIC to DT_MATCH_GIC_V2 to point
the GIC HW version to add later GIC versions

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/domain_build.c
xen/arch/arm/gic-v2.c
xen/arch/arm/gic.c
xen/include/asm-arm/device.h
xen/include/asm-arm/gic.h

index 9d9cba959a2ee59723df8f8d636ba3d9a154cb33..8c850ca75b8e6e1425794db99643d2f83361112f 100644 (file)
@@ -804,7 +804,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
     };
     static const struct dt_device_match gic_matches[] __initconst =
     {
-        DT_MATCH_GIC,
+        DT_MATCH_GIC_V2,
         { /* sentinel */ },
     };
     static const struct dt_device_match timer_matches[] __initconst =
index c18cd4cda4337c2772bba63b4c3a28e57a4b213c..695c2325407066d62434710c475fc207244ce9fc 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
+#include <asm/device.h>
 
 #include <asm/io.h>
 #include <asm/gic.h>
@@ -584,20 +585,10 @@ const static struct gic_hw_operations gicv2_ops = {
 };
 
 /* Set up the GIC */
-void __init gicv2_init(void)
+static int __init gicv2_init(struct dt_device_node *node, const void *data)
 {
-    static const struct dt_device_match gic_ids[] __initconst =
-    {
-        DT_MATCH_GIC,
-        { /* sentinel */ },
-    };
-    struct dt_device_node *node;
     int res;
 
-    node = dt_find_interrupt_controller(gic_ids);
-    if ( !node )
-        panic("GICv2: Unable to find compatible GIC in the device tree");
-
     dt_device_set_used_by(node, DOMID_XEN);
 
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
@@ -667,8 +658,22 @@ void __init gicv2_init(void)
 
     gicv2_info.hw_version = GIC_V2;
     register_gic_ops(&gicv2_ops);
+
+    return 0;
 }
 
+static const char * const gicv2_dt_compat[] __initconst =
+{
+    DT_COMPAT_GIC_CORTEX_A15,
+    DT_COMPAT_GIC_CORTEX_A7,
+    NULL
+};
+
+DT_DEVICE_START(gicv2, "GICv2:", DEVICE_GIC)
+        .compatible = gicv2_dt_compat,
+        .init = gicv2_init,
+DT_DEVICE_END
+
 /*
  * Local variables:
  * mode: C
index 36243913e9814678d4e6aea14ef99ff24f9a388c..e1e27b359d3db6e0fe8718ae7a0e0244c62df98c 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
+#include <asm/device.h>
 #include <asm/io.h>
 #include <asm/gic.h>
 
@@ -164,7 +165,29 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
 /* Set up the GIC */
 void __init gic_init(void)
 {
-    gicv2_init();
+    int rc;
+    struct dt_device_node *node;
+    uint8_t num_gics = 0;
+
+    dt_for_each_device_node( dt_host, node )
+    {
+        if ( !dt_get_property(node, "interrupt-controller", NULL) )
+            continue;
+
+        if ( !dt_get_parent(node) )
+            continue;
+
+        rc = device_init(node, DEVICE_GIC, NULL);
+        if ( !rc )
+        {
+            /* NOTE: Only one GIC is supported */
+            num_gics = 1;
+            break;
+        }
+    }
+    if ( !num_gics )
+        panic("Unable to find compatible GIC in the device tree");
+
     /* Clear LR mask for cpu0 */
     clear_cpu_lr_mask();
 }
index 60109cc95b69f001ebb1799fd898eefef2e0f8ba..74a80c6a4e7c5f2bbfb39df7ee6aa59958993622 100644 (file)
@@ -8,6 +8,7 @@ enum device_type
 {
     DEVICE_SERIAL,
     DEVICE_IOMMU,
+    DEVICE_GIC,
     /* Use for error */
     DEVICE_UNKNOWN,
 };
index a3c5f3d6b47064f1068d861b360e92db667cb86b..5ff4477c2652847ac18d63bf1a57afd42e77f348 100644 (file)
 #include <xen/device_tree.h>
 #include <xen/irq.h>
 
-#define DT_MATCH_GIC    DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), \
-                        DT_MATCH_COMPATIBLE("arm,cortex-a7-gic")
+#define DT_COMPAT_GIC_CORTEX_A15     "arm,cortex-a15-gic"
+#define DT_COMPAT_GIC_CORTEX_A7      "arm,cortex-a7-gic"
+
+#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7)
 
 /*
  * GICv2 register that needs to be saved/restored
@@ -185,8 +188,6 @@ enum gic_version {
 };
 
 extern enum gic_version gic_hw_version(void);
-extern void gicv2_init(void);
-
 extern int domain_vgic_init(struct domain *d);
 extern void domain_vgic_free(struct domain *d);