]>
Commit | Line | Data |
---|---|---|
ff68dacb PM |
1 | /* |
2 | * ARMv7M SysTick timer | |
3 | * | |
4 | * Copyright (c) 2006-2007 CodeSourcery. | |
5 | * Written by Paul Brook | |
6 | * Copyright (c) 2017 Linaro Ltd | |
7 | * Written by Peter Maydell | |
8 | * | |
9 | * This code is licensed under the GPL (version 2 or later). | |
10 | */ | |
11 | ||
12 | #ifndef HW_TIMER_ARMV7M_SYSTICK_H | |
13 | #define HW_TIMER_ARMV7M_SYSTICK_H | |
14 | ||
15 | #include "hw/sysbus.h" | |
db1015e9 | 16 | #include "qom/object.h" |
32bd322a | 17 | #include "hw/ptimer.h" |
ff68dacb PM |
18 | |
19 | #define TYPE_SYSTICK "armv7m_systick" | |
20 | ||
8063396b | 21 | OBJECT_DECLARE_SIMPLE_TYPE(SysTickState, SYSTICK) |
ff68dacb | 22 | |
db1015e9 | 23 | struct SysTickState { |
ff68dacb PM |
24 | /*< private >*/ |
25 | SysBusDevice parent_obj; | |
26 | /*< public >*/ | |
27 | ||
28 | uint32_t control; | |
29 | uint32_t reload; | |
30 | int64_t tick; | |
32bd322a | 31 | ptimer_state *ptimer; |
ff68dacb PM |
32 | MemoryRegion iomem; |
33 | qemu_irq irq; | |
db1015e9 | 34 | }; |
ff68dacb | 35 | |
807420f0 PM |
36 | /* |
37 | * Multiplication factor to convert from system clock ticks to qemu timer | |
38 | * ticks. This should be set (by board code, usually) to a value | |
39 | * equal to NANOSECONDS_PER_SECOND / frq, where frq is the clock frequency | |
40 | * in Hz of the CPU. | |
41 | * | |
42 | * This value is used by the systick device when it is running in | |
43 | * its "use the CPU clock" mode (ie when SYST_CSR.CLKSOURCE == 1) to | |
44 | * set how fast the timer should tick. | |
45 | * | |
46 | * TODO: we should refactor this so that rather than using a global | |
47 | * we use a device property or something similar. This is complicated | |
48 | * because (a) the property would need to be plumbed through from the | |
49 | * board code down through various layers to the systick device | |
50 | * and (b) the property needs to be modifiable after realize, because | |
51 | * the stellaris board uses this to implement the behaviour where the | |
52 | * guest can reprogram the PLL registers to downclock the CPU, and the | |
53 | * systick device needs to react accordingly. Possibly this should | |
54 | * be deferred until we have a good API for modelling clock trees. | |
55 | */ | |
56 | extern int system_clock_scale; | |
57 | ||
ff68dacb | 58 | #endif |