xref: /qemu/include/hw/misc/stm32l4x5_exti.h (revision 9c4887e3b68a362f2f5a4e86daab98a51b3b769e)
1c9948fddSInès Varhol /*
2c9948fddSInès Varhol  * STM32L4x5 EXTI (Extended interrupts and events controller)
3c9948fddSInès Varhol  *
4c9948fddSInès Varhol  * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
5c9948fddSInès Varhol  * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
6c9948fddSInès Varhol  *
7c9948fddSInès Varhol  * SPDX-License-Identifier: GPL-2.0-or-later
8c9948fddSInès Varhol  *
9c9948fddSInès Varhol  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10c9948fddSInès Varhol  * See the COPYING file in the top-level directory.
11c9948fddSInès Varhol  *
12c9948fddSInès Varhol  * This work is based on the stm32f4xx_exti by Alistair Francis.
13c9948fddSInès Varhol  * Original code is licensed under the MIT License:
14c9948fddSInès Varhol  *
15c9948fddSInès Varhol  * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me>
16c9948fddSInès Varhol  */
17c9948fddSInès Varhol 
18c9948fddSInès Varhol /*
19c9948fddSInès Varhol  * The reference used is the STMicroElectronics RM0351 Reference manual
20c9948fddSInès Varhol  * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
21c9948fddSInès Varhol  * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html
22c9948fddSInès Varhol  */
23c9948fddSInès Varhol 
24c9948fddSInès Varhol #ifndef HW_STM32L4X5_EXTI_H
25c9948fddSInès Varhol #define HW_STM32L4X5_EXTI_H
26c9948fddSInès Varhol 
27c9948fddSInès Varhol #include "hw/sysbus.h"
28c9948fddSInès Varhol #include "qom/object.h"
29c9948fddSInès Varhol 
30c9948fddSInès Varhol #define TYPE_STM32L4X5_EXTI "stm32l4x5-exti"
31c9948fddSInès Varhol OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5ExtiState, STM32L4X5_EXTI)
32c9948fddSInès Varhol 
33c9948fddSInès Varhol #define EXTI_NUM_INTERRUPT_OUT_LINES 40
34c9948fddSInès Varhol #define EXTI_NUM_REGISTER 2
35c9948fddSInès Varhol 
36c9948fddSInès Varhol struct Stm32l4x5ExtiState {
37c9948fddSInès Varhol     SysBusDevice parent_obj;
38c9948fddSInès Varhol 
39c9948fddSInès Varhol     MemoryRegion mmio;
40c9948fddSInès Varhol 
41c9948fddSInès Varhol     uint32_t imr[EXTI_NUM_REGISTER];
42c9948fddSInès Varhol     uint32_t emr[EXTI_NUM_REGISTER];
43c9948fddSInès Varhol     uint32_t rtsr[EXTI_NUM_REGISTER];
44c9948fddSInès Varhol     uint32_t ftsr[EXTI_NUM_REGISTER];
45c9948fddSInès Varhol     uint32_t swier[EXTI_NUM_REGISTER];
46c9948fddSInès Varhol     uint32_t pr[EXTI_NUM_REGISTER];
47c9948fddSInès Varhol 
48*9c4887e3SInès Varhol     /* used for edge detection */
49*9c4887e3SInès Varhol     uint32_t irq_levels[EXTI_NUM_REGISTER];
50c9948fddSInès Varhol     qemu_irq irq[EXTI_NUM_INTERRUPT_OUT_LINES];
51c9948fddSInès Varhol };
52c9948fddSInès Varhol 
53c9948fddSInès Varhol #endif
54