Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / hw / timer / avr_timer16.h
bloba1a032a24dc8587a0b918493a8f414137f5ea44e
1 /*
2 * AVR 16-bit timer
4 * Copyright (c) 2018 University of Kent
5 * Author: Ed Robbins
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see
19 * <http://www.gnu.org/licenses/lgpl-2.1.html>
23 * Driver for 16 bit timers on 8 bit AVR devices.
24 * Note:
25 * On ATmega640/V-1280/V-1281/V-2560/V-2561/V timers 1, 3, 4 and 5 are 16 bit
28 #ifndef HW_TIMER_AVR_TIMER16_H
29 #define HW_TIMER_AVR_TIMER16_H
31 #include "hw/sysbus.h"
32 #include "qemu/timer.h"
33 #include "qom/object.h"
35 enum NextInterrupt {
36 OVERFLOW,
37 COMPA,
38 COMPB,
39 COMPC,
40 CAPT
43 #define TYPE_AVR_TIMER16 "avr-timer16"
44 OBJECT_DECLARE_SIMPLE_TYPE(AVRTimer16State, AVR_TIMER16)
46 struct AVRTimer16State {
47 /* <private> */
48 SysBusDevice parent_obj;
50 /* <public> */
51 MemoryRegion iomem;
52 MemoryRegion imsk_iomem;
53 MemoryRegion ifr_iomem;
54 QEMUTimer *timer;
55 qemu_irq capt_irq;
56 qemu_irq compa_irq;
57 qemu_irq compb_irq;
58 qemu_irq compc_irq;
59 qemu_irq ovf_irq;
61 bool enabled;
63 /* registers */
64 uint8_t cra;
65 uint8_t crb;
66 uint8_t crc;
67 uint8_t cntl;
68 uint8_t cnth;
69 uint8_t icrl;
70 uint8_t icrh;
71 uint8_t ocral;
72 uint8_t ocrah;
73 uint8_t ocrbl;
74 uint8_t ocrbh;
75 uint8_t ocrcl;
76 uint8_t ocrch;
78 * Reads and writes to CNT and ICR utilise a bizarre temporary
79 * register, which we emulate
81 uint8_t rtmp;
82 uint8_t imsk;
83 uint8_t ifr;
85 uint8_t id;
86 uint64_t cpu_freq_hz;
87 uint64_t freq_hz;
88 uint64_t period_ns;
89 uint64_t reset_time_ns;
90 enum NextInterrupt next_interrupt;
93 #endif /* HW_TIMER_AVR_TIMER16_H */