qemu-patch-raspberry4/hw/intc
Adrian Huang 165cdaf857 armv7m_nvic: systick: Reload the RELOAD value and count down only if ENABLE bit is set
Consider the following pseudo code to configure SYSTICK (The
recommended programming sequence from "the definitive guide to the
arm cortex-m3"):
    SYSTICK Reload Value Register = 0xffff
    SYSTICK Current Value Register = 0
    SYSTICK Control and Status Register = 0x7

The pseudo code "SYSTICK Current Value Register = 0" leads to invoking
systick_reload(). As a consequence, the systick.tick member is updated
and the systick timer starts to count down when the ENABLE bit of
SYSTICK Control and Status Register is cleared.

The worst case is that: during the system initialization, the reset
value of the SYSTICK Control and Status Register is 0x00000000.
When the code "SYSTICK Current Value Register = 0" is executed, the
systick.tick member is accumulated with "(s->systick.reload + 1) *
systick_scale(s)". The systick_scale() gets the external_ref_clock
scale because the CLKSOURCE bit of the SYSTICK Control and Status
Register is cleared. This is the incorrect behavior because of the
code "SYSTICK Control and Status Register = 0x7". Actually, we want
the processor clock instead of the external reference clock.

This incorrect behavior defers the generation of the first interrupt.

The patch fixes the above-mentioned issue by setting the systick.tick
member and modifying the systick timer only if the ENABLE bit of
the SYSTICK Control and Status Register is set.

In addition, the Cortex-M3 Devices Generic User Guide mentioned that
"When ENABLE is set to 1, the counter loads the RELOAD value from the
SYST RVR register and then counts down". This patch adheres to the
statement of the user guide.

Signed-off-by: Adrian Huang <adrianhuang0701@gmail.com>
Reviewed-by: Jim Huang <jserv.tw@gmail.com>
[PMM: minor tweak to comment text]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-05-12 11:57:16 +01:00
..
allwinner-a10-pic.c Convert ffs() != 0 callers to ctz32() 2015-04-28 15:36:08 +02:00
apic.c apic: fix incorrect handling of ExtINT interrupts wrt processor priority 2014-11-24 14:37:45 +01:00
apic_common.c apic_common: improve readability of apic_reset_common 2015-04-30 16:55:16 +02:00
arm_gic.c Fix remaining warnings from Sparse (void return) 2015-03-19 11:11:55 +03:00
arm_gic_common.c arm_gic: Use GIC_NR_SGIS constant 2014-08-29 15:00:29 +01:00
arm_gic_kvm.c hw/intc: arm_gic_kvm.c restore config first 2015-04-01 17:57:30 +01:00
armv7m_nvic.c armv7m_nvic: systick: Reload the RELOAD value and count down only if ENABLE bit is set 2015-05-12 11:57:16 +01:00
etraxfs_pic.c Fix remaining warnings from Sparse (void return) 2015-03-19 11:11:55 +03:00
exynos4210_combiner.c savevm: Remove all the unneeded version_minimum_id_old (arm) 2014-05-13 16:09:35 +01:00
exynos4210_gic.c savevm: Remove all the unneeded version_minimum_id_old (arm) 2014-05-13 16:09:35 +01:00
gic_internal.h arm_gic: remove unused parameter. 2014-10-24 12:19:11 +01:00
grlib_irqmp.c hw: cannot_instantiate_with_device_add_yet due to pointer props 2013-12-24 17:27:17 +01:00
heathrow_pic.c savevm: Remove all the unneeded version_minimum_id_old (ppc) 2014-06-16 04:55:26 +02:00
i8259.c hmp: Name HMP info handler functions hmp_info_SUBCOMMAND() 2015-02-18 11:58:50 +01:00
i8259_common.c savevm: Remove all the unneeded version_minimum_id_old (x86) 2014-06-16 04:55:26 +02:00
imx_avic.c hw/intc/imx_avic.c: Remove unused function imx_avic_set_prio() 2014-09-29 18:48:47 +01:00
ioapic.c qemu: x86: ignore ioapic polarity 2014-03-09 21:09:38 +02:00
ioapic_common.c savevm: Remove all the unneeded version_minimum_id_old (x86) 2014-06-16 04:55:26 +02:00
lm32_pic.c hmp: Name HMP info handler functions hmp_info_SUBCOMMAND() 2015-02-18 11:58:50 +01:00
Makefile.objs s390x: split flic into kvm and non-kvm parts 2014-05-20 13:05:57 +02:00
omap_intc.c omap_intc: convert ffs(3) to ctz32() in omap_inth_sir_update() 2015-04-28 15:36:08 +02:00
openpic.c openpic: convert to vmstate 2015-03-09 15:00:07 +01:00
openpic_kvm.c KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks 2014-12-15 12:21:01 +01:00
pl190.c sysbus: Set cannot_instantiate_with_device_add_yet 2013-12-23 00:27:22 +01:00
puv3_intc.c puv3_intc: QOM cast cleanup 2013-07-29 21:06:58 +02:00
realview_gic.c realview_gic: Prepare for QOM embedding 2013-11-05 17:47:30 +01:00
s390_flic.c s390x: Replace unchecked qdev_init() by qdev_init_nofail() 2015-03-16 10:15:44 +01:00
s390_flic_kvm.c s390x/kvm: inject via flic 2014-06-10 09:50:27 +02:00
sh_intc.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
slavio_intctl.c savevm: Remove all the unneeded version_minimum_id_old (rest) 2014-05-14 15:24:51 +02:00
xics.c xics: Implement xics_ics_free() 2014-06-27 13:48:26 +02:00
xics_kvm.c KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks 2014-12-15 12:21:01 +01:00
xilinx_intc.c intc: xilinx_uartlite: Convert SBD::init -> instance_init 2014-06-09 00:33:03 +02:00