Message ID | 1377701263-3319-23-git-send-email-julien.grall@linaro.org |
---|---|
State | Superseded, archived |
Headers | show |
On Wed, 2013-08-28 at 15:47 +0100, Julien Grall wrote: [...] > + static const struct dt_device_match timer_ids[] __initconst = > + { > + DT_MATCH_COMPATIBLE("arm,armv7-timer"), > + DT_MATCH_COMPATIBLE("arm,armv8-timer"), > + { /* sentinel */ }, > + }; [...] > @@ -588,6 +649,8 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, > DT_MATCH_COMPATIBLE("arm,psci"), > DT_MATCH_PATH("/cpus"), > DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), > + DT_MATCH_COMPATIBLE("arm,armv7-timer"), > + DT_MATCH_COMPATIBLE("arm,armv8-timer"), Both of these now need to be kept in sync with time.c. Can we find a better way? Ian
On 09/09/2013 12:51 PM, Ian Campbell wrote: > On Wed, 2013-08-28 at 15:47 +0100, Julien Grall wrote: > [...] >> + static const struct dt_device_match timer_ids[] __initconst = >> + { >> + DT_MATCH_COMPATIBLE("arm,armv7-timer"), >> + DT_MATCH_COMPATIBLE("arm,armv8-timer"), >> + { /* sentinel */ }, >> + }; > [...] >> @@ -588,6 +649,8 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, >> DT_MATCH_COMPATIBLE("arm,psci"), >> DT_MATCH_PATH("/cpus"), >> DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), >> + DT_MATCH_COMPATIBLE("arm,armv7-timer"), >> + DT_MATCH_COMPATIBLE("arm,armv8-timer"), > > Both of these now need to be kept in sync with time.c. Can we find a > better way? What about the same solution as for the GIC? #define TIMER_COMPATIBLE \ DT_MATCH_COMPATIBLE("arm,armv7-timer"), \ DT_MATCH_COMPATIBLE("arm,armv8-timer")
On Tue, 2013-09-10 at 11:56 +0100, Julien Grall wrote: > On 09/09/2013 12:51 PM, Ian Campbell wrote: > > On Wed, 2013-08-28 at 15:47 +0100, Julien Grall wrote: > > [...] > >> + static const struct dt_device_match timer_ids[] __initconst = > >> + { > >> + DT_MATCH_COMPATIBLE("arm,armv7-timer"), > >> + DT_MATCH_COMPATIBLE("arm,armv8-timer"), > >> + { /* sentinel */ }, > >> + }; > > [...] > >> @@ -588,6 +649,8 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, > >> DT_MATCH_COMPATIBLE("arm,psci"), > >> DT_MATCH_PATH("/cpus"), > >> DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), > >> + DT_MATCH_COMPATIBLE("arm,armv7-timer"), > >> + DT_MATCH_COMPATIBLE("arm,armv8-timer"), > > > > Both of these now need to be kept in sync with time.c. Can we find a > > better way? > > What about the same solution as for the GIC? Sure.
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c57a79d..3afe48f 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -498,6 +498,67 @@ static int make_gic_node(const struct domain *d, void *fdt, return res; } +static int make_timer_node(const struct domain *d, void *fdt, + const struct dt_device_node *parent) +{ + static const struct dt_device_match timer_ids[] __initconst = + { + DT_MATCH_COMPATIBLE("arm,armv7-timer"), + DT_MATCH_COMPATIBLE("arm,armv8-timer"), + { /* sentinel */ }, + }; + struct dt_device_node *dev; + u32 len; + const void *compatible; + int res; + const struct dt_irq *irq; + interrupt_t intrs[3]; + + DPRINT("Create timer node\n"); + + dev = dt_find_matching_node(NULL, timer_ids); + if ( !dev ) + { + dprintk(XENLOG_ERR, "Missing timer node in the device tree?\n"); + return -FDT_ERR_XEN(ENOENT); + } + + compatible = dt_get_property(dev, "compatible", &len); + if ( !compatible ) + { + dprintk(XENLOG_ERR, "Can't find compatible property for timer node\n"); + return -FDT_ERR_XEN(ENOENT); + } + + res = fdt_begin_node(fdt, "timer"); + if ( res ) + return res; + + res = fdt_property(fdt, "compatible", compatible, len); + if ( res ) + return res; + + irq = timer_dt_irq(TIMER_PHYS_SECURE_PPI); + DPRINT(" Secure interrupt %u\n", irq->irq); + set_interrupts(intrs[0], irq->irq, 0xf, irq->type); + + irq = timer_dt_irq(TIMER_PHYS_NONSECURE_PPI); + DPRINT(" Non secure interrupt %u\n", irq->irq); + set_interrupts(intrs[1], irq->irq, 0xf, irq->type); + + irq = timer_dt_irq(TIMER_VIRT_PPI); + DPRINT(" Virt interrupt %u\n", irq->irq); + set_interrupts(intrs[2], irq->irq, 0xf, irq->type); + + res = fdt_property(fdt, "interrupts", intrs, sizeof (intrs[0]) * 3); + if ( res ) + return res; + + res = fdt_end_node(fdt); + + return res; +} + /* Map the device in the domain */ static int map_device(struct domain *d, const struct dt_device_node *dev) { @@ -588,6 +649,8 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, DT_MATCH_COMPATIBLE("arm,psci"), DT_MATCH_PATH("/cpus"), DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), + DT_MATCH_COMPATIBLE("arm,armv7-timer"), + DT_MATCH_COMPATIBLE("arm,armv8-timer"), { /* sentinel */ }, }; const struct dt_device_node *child; @@ -665,6 +728,10 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, res = make_gic_node(d, kinfo->fdt, np); if ( res ) return res; + + res = make_timer_node(d, kinfo->fdt, np); + if ( res ) + return res; } res = fdt_end_node(kinfo->fdt);
Recreate the timer node and remove hypervisor specific interrupt. Signed-off-by: Julien Grall <julien.grall@linaro.org> --- xen/arch/arm/domain_build.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)