Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-4.1-sf1-v3' into...
[qemu/ar7.git] / include / hw / timer / armv7m_systick.h
blob25e5ceacc8541b74a606c806527bbf36b289d5ab
1 /*
2 * ARMv7M SysTick timer
4 * Copyright (c) 2006-2007 CodeSourcery.
5 * Written by Paul Brook
6 * Copyright (c) 2017 Linaro Ltd
7 * Written by Peter Maydell
9 * This code is licensed under the GPL (version 2 or later).
12 #ifndef HW_TIMER_ARMV7M_SYSTICK_H
13 #define HW_TIMER_ARMV7M_SYSTICK_H
15 #include "hw/sysbus.h"
17 #define TYPE_SYSTICK "armv7m_systick"
19 #define SYSTICK(obj) OBJECT_CHECK(SysTickState, (obj), TYPE_SYSTICK)
21 typedef struct SysTickState {
22 /*< private >*/
23 SysBusDevice parent_obj;
24 /*< public >*/
26 uint32_t control;
27 uint32_t reload;
28 int64_t tick;
29 QEMUTimer *timer;
30 MemoryRegion iomem;
31 qemu_irq irq;
32 } SysTickState;
35 * Multiplication factor to convert from system clock ticks to qemu timer
36 * ticks. This should be set (by board code, usually) to a value
37 * equal to NANOSECONDS_PER_SECOND / frq, where frq is the clock frequency
38 * in Hz of the CPU.
40 * This value is used by the systick device when it is running in
41 * its "use the CPU clock" mode (ie when SYST_CSR.CLKSOURCE == 1) to
42 * set how fast the timer should tick.
44 * TODO: we should refactor this so that rather than using a global
45 * we use a device property or something similar. This is complicated
46 * because (a) the property would need to be plumbed through from the
47 * board code down through various layers to the systick device
48 * and (b) the property needs to be modifiable after realize, because
49 * the stellaris board uses this to implement the behaviour where the
50 * guest can reprogram the PLL registers to downclock the CPU, and the
51 * systick device needs to react accordingly. Possibly this should
52 * be deferred until we have a good API for modelling clock trees.
54 extern int system_clock_scale;
56 #endif