This peripheral has 1 free-running timer and 4 compare registers. Only the free-running timer is implemented. Add support the COMPARE registers (each register is wired to an IRQ). Reference: "BCM2835 ARM Peripherals" datasheet [*] chapter 12 "System Timer": The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter. Each channel has an output compare register, which is compared against the 32 least significant bits of the free running counter values. When the two values match, the system timer peripheral generates a signal to indicate a match for the appropriate channel. The match signal is then fed into the interrupt controller. This peripheral is used since Linux 3.7, commit ee4af5696720 ("ARM: bcm2835: add system timer"). [*] https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Luc Michel <luc@lmichel.fr> Message-id: 20201010203709.3116542-4-f4bug@amsat.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
43 lines
895 B
C
43 lines
895 B
C
/*
|
|
* BCM2835 SYS timer emulation
|
|
*
|
|
* Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#ifndef BCM2835_SYSTIMER_H
|
|
#define BCM2835_SYSTIMER_H
|
|
|
|
#include "hw/sysbus.h"
|
|
#include "hw/irq.h"
|
|
#include "qemu/timer.h"
|
|
#include "qom/object.h"
|
|
|
|
#define TYPE_BCM2835_SYSTIMER "bcm2835-sys-timer"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(BCM2835SystemTimerState, BCM2835_SYSTIMER)
|
|
|
|
#define BCM2835_SYSTIMER_COUNT 4
|
|
|
|
typedef struct {
|
|
unsigned id;
|
|
QEMUTimer timer;
|
|
qemu_irq irq;
|
|
BCM2835SystemTimerState *state;
|
|
} BCM2835SystemTimerCompare;
|
|
|
|
struct BCM2835SystemTimerState {
|
|
/*< private >*/
|
|
SysBusDevice parent_obj;
|
|
|
|
/*< public >*/
|
|
MemoryRegion iomem;
|
|
struct {
|
|
uint32_t ctrl_status;
|
|
uint32_t compare[BCM2835_SYSTIMER_COUNT];
|
|
} reg;
|
|
BCM2835SystemTimerCompare tmr[BCM2835_SYSTIMER_COUNT];
|
|
};
|
|
|
|
#endif
|