104a7c7b1SInès Varhol /* 204a7c7b1SInès Varhol * STM32L4x5 SoC family 304a7c7b1SInès Varhol * 404a7c7b1SInès Varhol * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> 504a7c7b1SInès Varhol * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> 604a7c7b1SInès Varhol * 704a7c7b1SInès Varhol * SPDX-License-Identifier: GPL-2.0-or-later 804a7c7b1SInès Varhol * 904a7c7b1SInès Varhol * This work is licensed under the terms of the GNU GPL, version 2 or later. 1004a7c7b1SInès Varhol * See the COPYING file in the top-level directory. 1104a7c7b1SInès Varhol * 1204a7c7b1SInès Varhol * This work is heavily inspired by the stm32f405_soc by Alistair Francis. 1304a7c7b1SInès Varhol * Original code is licensed under the MIT License: 1404a7c7b1SInès Varhol * 1504a7c7b1SInès Varhol * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> 1604a7c7b1SInès Varhol */ 1704a7c7b1SInès Varhol 1804a7c7b1SInès Varhol /* 1904a7c7b1SInès Varhol * The reference used is the STMicroElectronics RM0351 Reference manual 2004a7c7b1SInès Varhol * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. 2104a7c7b1SInès Varhol * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html 2204a7c7b1SInès Varhol */ 2304a7c7b1SInès Varhol 2404a7c7b1SInès Varhol #ifndef HW_ARM_STM32L4x5_SOC_H 2504a7c7b1SInès Varhol #define HW_ARM_STM32L4x5_SOC_H 2604a7c7b1SInès Varhol 2704a7c7b1SInès Varhol #include "exec/memory.h" 2804a7c7b1SInès Varhol #include "hw/arm/armv7m.h" 295928ed26SInès Varhol #include "hw/or-irq.h" 307dfe2312SInès Varhol #include "hw/misc/stm32l4x5_syscfg.h" 3152671f69SInès Varhol #include "hw/misc/stm32l4x5_exti.h" 32d6b55a0fSArnaud Minier #include "hw/misc/stm32l4x5_rcc.h" 331c38129dSInès Varhol #include "hw/gpio/stm32l4x5_gpio.h" 34*92741432SArnaud Minier #include "hw/char/stm32l4x5_usart.h" 3504a7c7b1SInès Varhol #include "qom/object.h" 3604a7c7b1SInès Varhol 3704a7c7b1SInès Varhol #define TYPE_STM32L4X5_SOC "stm32l4x5-soc" 3804a7c7b1SInès Varhol #define TYPE_STM32L4X5XC_SOC "stm32l4x5xc-soc" 3904a7c7b1SInès Varhol #define TYPE_STM32L4X5XE_SOC "stm32l4x5xe-soc" 4004a7c7b1SInès Varhol #define TYPE_STM32L4X5XG_SOC "stm32l4x5xg-soc" 4104a7c7b1SInès Varhol OBJECT_DECLARE_TYPE(Stm32l4x5SocState, Stm32l4x5SocClass, STM32L4X5_SOC) 4204a7c7b1SInès Varhol 435928ed26SInès Varhol #define NUM_EXTI_OR_GATES 4 445928ed26SInès Varhol 45*92741432SArnaud Minier #define STM_NUM_USARTS 3 46*92741432SArnaud Minier #define STM_NUM_UARTS 2 47*92741432SArnaud Minier 4804a7c7b1SInès Varhol struct Stm32l4x5SocState { 4904a7c7b1SInès Varhol SysBusDevice parent_obj; 5004a7c7b1SInès Varhol 5104a7c7b1SInès Varhol ARMv7MState armv7m; 5204a7c7b1SInès Varhol 5352671f69SInès Varhol Stm32l4x5ExtiState exti; 545928ed26SInès Varhol OrIRQState exti_or_gates[NUM_EXTI_OR_GATES]; 557dfe2312SInès Varhol Stm32l4x5SyscfgState syscfg; 56d6b55a0fSArnaud Minier Stm32l4x5RccState rcc; 571c38129dSInès Varhol Stm32l4x5GpioState gpio[NUM_GPIOS]; 58*92741432SArnaud Minier Stm32l4x5UsartBaseState usart[STM_NUM_USARTS]; 59*92741432SArnaud Minier Stm32l4x5UsartBaseState uart[STM_NUM_UARTS]; 60*92741432SArnaud Minier Stm32l4x5UsartBaseState lpuart; 6152671f69SInès Varhol 6204a7c7b1SInès Varhol MemoryRegion sram1; 6304a7c7b1SInès Varhol MemoryRegion sram2; 6404a7c7b1SInès Varhol MemoryRegion flash; 6504a7c7b1SInès Varhol MemoryRegion flash_alias; 6604a7c7b1SInès Varhol }; 6704a7c7b1SInès Varhol 6804a7c7b1SInès Varhol struct Stm32l4x5SocClass { 6904a7c7b1SInès Varhol SysBusDeviceClass parent_class; 7004a7c7b1SInès Varhol 7104a7c7b1SInès Varhol size_t flash_size; 7204a7c7b1SInès Varhol }; 7304a7c7b1SInès Varhol 7404a7c7b1SInès Varhol #endif 75