A9 global timer + mpcore trivials
v3 cover A9 global timer + mpcore trivials
Hi Peter,
Another spin of the ARM MPCore global timer work. Patches 1 & 2 are some trivial cleanup to MPCore I did along the way.
Regards,
Peter
François LEGAL (1):
cpu/a9mpcore: Add Global Timer
Peter Crosthwaite (3):
cpu/a9mpcore: rename timerbusdev variable
cpu/a9mpcore: reorder operations/declarations
hw/timer: Introduce ARM A9 Global Timer.
hw/cpu/a9mpcore.c | 44 ++++-- hw/timer/Makefile.objs | 2 +- hw/timer/a9gtimer.c | 369 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/cpu/a9mpcore.h | 4 +- include/hw/timer/a9gtimer.h | 97 ++++++++++++ 5 files changed, 500 insertions(+), 16 deletions(-) create mode 100644 hw/timer/a9gtimer.c create mode 100644 include/hw/timer/a9gtimer.h
Signature · 1 line
1.8.4.4
PATCH v3 1/4 cpu/a9mpcore: rename timerbusdev variable
Rename this variable for consistency with the above defined mptimerdev variable.
---
hw/cpu/a9mpcore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/cpu/a9mpcore.c +4 -4
@@ -42,7 +42,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (dev);A9MPPrivState *s =A9MPCORE_PRIV (dev);DeviceState *gicdev, *scudev, *mptimerdev, *wdtdev; -SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev; +SysBusDevice *mptimerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;Error *err =NULL ;int i;
@@ -78,7 +78,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)error_propagate (errp, err);return ; } - timerbusdev =SYS_BUS_DEVICE (&s->mptimer); + mptimerbusdev =SYS_BUS_DEVICE (&s->mptimer); wdtdev =DEVICE (&s->wdt);qdev_prop_set_uint32 (wdtdev,"num-cpu" , s->num_cpu);
@@ -109,7 +109,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)* memory region, not the "timer/watchdog for core X" ones 11MPcore has. */ memory_region_add_subregion (&s->container,0x600 , -sysbus_mmio_get_region (timerbusdev,0 )); +sysbus_mmio_get_region (mptimerbusdev,0 ));memory_region_add_subregion (&s->container,0x620 ,sysbus_mmio_get_region (wdtbusdev,0 )); memory_region_add_subregion(&s->container, 0x1000,
@@ -120,7 +120,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)*/ for (i =0 ; i < s->num_cpu; i++) {int ppibase = (s->num_irq -32 ) + i *32 ; -sysbus_connect_irq (timerbusdev, i, +sysbus_connect_irq (mptimerbusdev, i,qdev_get_gpio_in (gicdev, ppibase +29 ));sysbus_connect_irq (wdtbusdev, i,qdev_get_gpio_in (gicdev, ppibase +30 ));
Signature · 1 line
1.8.4.4
Re: [Qemu-devel] [PATCH arm-devs v3 1/4] cpu/a9mpcore: rename timerbusdev variable
Quoted 4 lines · Peter Crosthwaite
Rename this variable for consistency with the above defined mptimerdev variable.
Signed-off-by Peter Crosthwaite <[email protected]>
-- PMM
PATCH v3 2/4 cpu/a9mpcore: reorder operations/declarations
In reply to Peter CrosthwaiteTo make it consistent for easier code reading. The order in which variables are defined and functions are called is set to match the address map ordering.
The new consistent order of doing stuff is:
SCU -> GIC -> MPTimer -> WDT.
0 functional change.
---
hw/cpu/a9mpcore.c | 28 ++++++++++++++-------------- include/hw/cpu/a9mpcore.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-)
hw/cpu/a9mpcore.c +14 -14
@@ -24,12 +24,12 @@ static void a9mp_priv_initfn(Object *obj)memory_region_init (&s->container, obj,"a9mp-priv-container" ,0x2000 );sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container); -object_initialize (&s->gic,sizeof (s->gic),TYPE_ARM_GIC ); -qdev_set_parent_bus (DEVICE (&s->gic),sysbus_get_default ()); -object_initialize (&s->scu,sizeof (s->scu),TYPE_A9_SCU );qdev_set_parent_bus (DEVICE (&s->scu),sysbus_get_default ()); +object_initialize (&s->gic,sizeof (s->gic),TYPE_ARM_GIC ); +qdev_set_parent_bus (DEVICE (&s->gic),sysbus_get_default ()); +object_initialize (&s->mptimer,sizeof (s->mptimer),TYPE_ARM_MPTIMER );qdev_set_parent_bus (DEVICE (&s->mptimer),sysbus_get_default ());
@@ -41,11 +41,20 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp) {SysBusDevice *sbd =SYS_BUS_DEVICE (dev);A9MPPrivState *s =A9MPCORE_PRIV (dev); -DeviceState *gicdev, *scudev, *mptimerdev, *wdtdev; -SysBusDevice *mptimerbusdev, *wdtbusdev, *gicbusdev, *scubusdev; +DeviceState *scudev, *gicdev, *mptimerdev, *wdtdev; +SysBusDevice *scubusdev, *gicbusdev, *mptimerbusdev, *wdtbusdev;Error *err =NULL ;int i; + scudev =DEVICE (&s->scu); +qdev_prop_set_uint32 (scudev,"num-cpu" , s->num_cpu); +object_property_set_bool (OBJECT (&s->scu), true,"realized" , &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; + } + scubusdev =SYS_BUS_DEVICE (&s->scu); + gicdev =DEVICE (&s->gic);qdev_prop_set_uint32 (gicdev,"num-cpu" , s->num_cpu);qdev_prop_set_uint32 (gicdev,"num-irq" , s->num_irq);
@@ -62,15 +71,6 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)/* Pass through inbound GPIO lines to the GIC */ qdev_init_gpio_in (dev, a9mp_priv_set_irq, s->num_irq -32 ); - scudev =DEVICE (&s->scu); -qdev_prop_set_uint32 (scudev,"num-cpu" , s->num_cpu); -object_property_set_bool (OBJECT (&s->scu), true,"realized" , &err); -if (err !=NULL ) { -error_propagate (errp, err); -return ; - } - scubusdev =SYS_BUS_DEVICE (&s->scu); - mptimerdev =DEVICE (&s->mptimer);qdev_prop_set_uint32 (mptimerdev,"num-cpu" , s->num_cpu);object_property_set_bool (OBJECT (&s->mptimer), true,"realized" , &err);
include/hw/cpu/a9mpcore.h +1 -1
@@ -28,8 +28,8 @@ typedef struct A9MPPrivState {MemoryRegion container;uint32_t num_irq; -GICState gic;A9SCUState scu; +GICState gic;ARMMPTimerState mptimer;ARMMPTimerState wdt; } A9MPPrivState;
Signature · 1 line
1.8.4.4
Re: [Qemu-devel] [PATCH arm-devs v3 2/4] cpu/a9mpcore: reorder operations/declarations
Quoted 11 lines · Peter Crosthwaite
To make it consistent for easier code reading. The order in which variables are defined and functions are called is set to match the address map ordering.
The new consistent order of doing stuff is:
SCU -> GIC -> MPTimer -> WDT.
0 functional change.
Signed-off-by Peter Crosthwaite <[email protected]>
-- PMM
PATCH v3 3/4 hw/timer: Introduce ARM A9 Global Timer.
In reply to Peter CrosthwaiteThe ARM A9 MPCore has a timer that is global to all CPUs in the mpcore. The timer is shared but each CPU has a private independent comparator and interrupt.
Based on version contributed by Francois LEGAL.
[PC changes:
* New commit message
* Re-implemented as single timer model
* Fixed backwards counting issue in polled mode
* completed VMSD fields
* macroified magic numbers (and headerified reg definitions)
* split of as device-model-only patch
* use bitops for 64 bit register access
* Fixed auto increment mode to check condition properly
* general cleanup (names/style etc).
]
---
Changed since v2 (PMM - review):
Refactored for container embedding
Made frequency scaler consistent with mptimer Fixed missing VMSD ref_counter field
Fixed missing gtb->inc reset
Changed Memory region names
Changed since v1:
Added /*< private >*/ to struct definition. Pulled register definitions out into a header (AF review) SOB Francois LEGAL with PC changes indicated.
hw/timer/Makefile.objs | 2 +- hw/timer/a9gtimer.c | 369 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/timer/a9gtimer.h | 97 ++++++++++++ 3 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 hw/timer/a9gtimer.c create mode 100644 include/hw/timer/a9gtimer.h
hw/timer/Makefile.objs +1 -1
@@ -1,5 +1,5 @@ common-obj-$(CONFIG_ARM_TIMER) += arm_timer.o -common-obj-$(CONFIG_ARM_MPTIMER) += arm_mptimer.o +common-obj-$(CONFIG_ARM_MPTIMER) += arm_mptimer.o a9gtimer.o common-obj-$(CONFIG_CADENCE) += cadence_ttc.o common-obj-$(CONFIG_DS1338) += ds1338.o common-obj-$(CONFIG_HPET) += hpet.o
hw/timer/a9gtimer.c new file +369 -0
369 lines not on this page · raw message
include/hw/timer/a9gtimer.h new file +97 -0
97 lines not on this page · raw message
Signature · 1 line
1.8.4.4
PATCH v3 4/4 cpu/a9mpcore: Add Global Timer
In reply to Peter CrosthwaiteFrom: François LEGAL <[email protected]>
Add the global timer to A9 MPCore.
[PC Changes:
* new commit message
* split off original version as a separate patch
* Rebased against new mpcore implementation (with struct embedding)
]
---
changed from v2:
Rebased against major mpcore changed.
Changed from v1:
Set authorship to Francois and added SOB.
hw/cpu/a9mpcore.c | 26 +++++++++++++++++++++----- include/hw/cpu/a9mpcore.h | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-)
hw/cpu/a9mpcore.c +21 -5
@@ -30,6 +30,9 @@ static void a9mp_priv_initfn(Object *obj)object_initialize (&s->gic,sizeof (s->gic),TYPE_ARM_GIC );qdev_set_parent_bus (DEVICE (&s->gic),sysbus_get_default ()); +object_initialize (&s->gtimer,sizeof (s->gtimer),TYPE_A9_GTIMER ); +qdev_set_parent_bus (DEVICE (&s->gtimer),sysbus_get_default ()); +object_initialize (&s->mptimer,sizeof (s->mptimer),TYPE_ARM_MPTIMER );qdev_set_parent_bus (DEVICE (&s->mptimer),sysbus_get_default ());
@@ -41,8 +44,9 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp) {SysBusDevice *sbd =SYS_BUS_DEVICE (dev);A9MPPrivState *s =A9MPCORE_PRIV (dev); -DeviceState *scudev, *gicdev, *mptimerdev, *wdtdev; -SysBusDevice *scubusdev, *gicbusdev, *mptimerbusdev, *wdtbusdev; +DeviceState *scudev, *gicdev, *gtimerdev, *mptimerdev, *wdtdev; +SysBusDevice *scubusdev, *gicbusdev, *gtimerbusdev, *mptimerbusdev, + *wdtbusdev;Error *err =NULL ;int i;
@@ -71,6 +75,15 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)/* Pass through inbound GPIO lines to the GIC */ qdev_init_gpio_in (dev, a9mp_priv_set_irq, s->num_irq -32 ); + gtimerdev =DEVICE (&s->gtimer); +qdev_prop_set_uint32 (gtimerdev,"num-cpu" , s->num_cpu); +object_property_set_bool (OBJECT (&s->gtimer), true,"realized" , &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; + } + gtimerbusdev =SYS_BUS_DEVICE (&s->gtimer); + mptimerdev =DEVICE (&s->mptimer);qdev_prop_set_uint32 (mptimerdev,"num-cpu" , s->num_cpu);object_property_set_bool (OBJECT (&s->mptimer), true,"realized" , &err);
@@ -97,14 +110,14 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)* 0x0600-0x06ff -- private timers and watchdogs * 0x0700-0x0fff -- nothing * 0x1000-0x1fff -- GIC Distributor -* -* We should implement the global timer but don't currently do so. */ memory_region_add_subregion (&s->container,0 ,sysbus_mmio_get_region (scubusdev,0 ));/* GIC CPU interface */ memory_region_add_subregion (&s->container,0x100 ,sysbus_mmio_get_region (gicbusdev,1 )); +memory_region_add_subregion (&s->container,0x200 , +sysbus_mmio_get_region (gtimerbusdev,0 ));/* Note that the A9 exposes only the "timer/watchdog for this core" * memory region, not the "timer/watchdog for core X" ones 11MPcore has. */
@@ -116,10 +129,13 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp) sysbus_mmio_get_region(gicbusdev, 0));/* Wire up the interrupt from each watchdog and timer. -* For each core the timer is PPI 29 and the watchdog PPI 30. +* For each core the global timer is PPI 27, the private +* timer is PPI 29 and the watchdog PPI 30. */ for (i =0 ; i < s->num_cpu; i++) {int ppibase = (s->num_irq -32 ) + i *32 ; +sysbus_connect_irq (gtimerbusdev, i, +qdev_get_gpio_in (gicdev, ppibase +27 ));sysbus_connect_irq (mptimerbusdev, i,qdev_get_gpio_in (gicdev, ppibase +29 )); sysbus_connect_irq(wdtbusdev, i,
include/hw/cpu/a9mpcore.h +2 -0
@@ -14,6 +14,7 @@#include "hw/intc/arm_gic.h" #include "hw/misc/a9scu.h" #include "hw/timer/arm_mptimer.h" +#include "hw/timer/a9gtimer.h" #define TYPE_A9MPCORE_PRIV "a9mpcore_priv"#define A9MPCORE_PRIV (obj) \
@@ -30,6 +31,7 @@ typedef struct A9MPPrivState {A9SCUState scu;GICState gic; +A9GTimerState gtimer;ARMMPTimerState mptimer;ARMMPTimerState wdt; } A9MPPrivState;
Signature · 1 line
1.8.4.4
Re: [Qemu-devel] [PATCH arm-devs v3 4/4] cpu/a9mpcore: Add Global Timer
Quoted 11 lines · Peter Crosthwaite
From: François LEGAL <[email protected]>
Add the global timer to A9 MPCore.
Signed-off-by François LEGAL <[email protected]>[PC Changes:
* new commit message
* split off original version as a separate patch
* Rebased against new mpcore implementation (with struct embedding)
]Signed-off-by Peter Crosthwaite <[email protected]>
-- PMM
Quoted 4 lines · Peter Crosthwaite
Hi Peter,
Another spin of the ARM MPCore global timer work. Patches 1 & 2 are some trivial cleanup to MPCore I did along the way.
I'm happy with all of these, except that I think the idea is that each device gets its own CONFIG_ define, so we should have CONFIG_A9GTIMER or something rather than piggybacking on CONFIG_ARM_MPTIMER.
I can just fix that nit as I put these into my target-arm queue, assuming that nobody has any other review comments that demand a respin for some other reason.
thanks
-- PMM
Quoted 4 lines · Peter Maydell
Quoted 2 lines · Peter Crosthwaite
Hi Peter,
Quoted 8 lines
Quoted 2 lines
Another spin of the ARM MPCore global timer work. Patches 1 & 2 are some trivial cleanup to MPCore I did along the way.
I'm happy with all of these, except that I think the idea is that each device gets its own
CONFIG_define, so we should haveCONFIG_A9GTIMERor something rather than piggybacking onCONFIG_ARM_MPTIMER.
Doh! I saw your comment in V2 but it slipped thorugh the cracks when I came to actioning your review. Sorry.
Quoted 4 lines
I can just fix that nit as I put these into my target-arm queue, assuming that nobody has any other review comments that demand a respin for some other reason.
Ill let it cool for a few days then I can respin.
Regards,
Peter
Quoted 3 lines
thanks
-- PMM