[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 08/21] xen/arm: use device api to detect GIC version
From: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxx> --- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/gic-v2.c | 27 ++++++++++++++++----------- xen/arch/arm/gic.c | 24 +++++++++++++++++++++++- xen/include/asm-arm/device.h | 1 + xen/include/asm-arm/gic.h | 7 +++++-- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index ddbb88d..018f2f8 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -793,7 +793,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 = diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 8eb8f0b..134815a 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -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> @@ -574,20 +575,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); @@ -657,8 +648,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_MATCH_GIC_V2_STRING_1, + DT_MATCH_GIC_V2_STRING_2, + NULL +}; + +DT_DEVICE_START(gicv2, "GICv2:", DEVICE_GIC) + .compatible = gicv2_dt_compat, + .init = gicv2_init, +DT_DEVICE_END + /* * Local variables: * mode: C diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 4580d96..bf1367b 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -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,28 @@ 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; + bool_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"); } void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index 60109cc..74a80c6 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -8,6 +8,7 @@ enum device_type { DEVICE_SERIAL, DEVICE_IOMMU, + DEVICE_GIC, /* Use for error */ DEVICE_UNKNOWN, }; diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 978a968..eb687b8 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -144,8 +144,11 @@ #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_MATCH_GIC_V2_STRING_1 "arm,cortex-a15-gic" +#define DT_MATCH_GIC_V2_STRING_2 "arm,cortex-a7-gic" + +#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_MATCH_GIC_V2_STRING_1), \ + DT_MATCH_COMPATIBLE(DT_MATCH_GIC_V2_STRING_2) /* * GICv2 register that needs to be saved/restored -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |