Add device STM32L4x5 SYSCFG
Subsystems (2)
v2 cover Add device STM32L4x5 SYSCFG
Hello Alistair, thank you for your comments.
Changes from v1 to v2:
- explain in 3rd commit why SYSCFG input GPIOs aren't connected and add a TODO comment in stm32l4x5_soc.c
- use macros NUM_GPIOS and GPIO_NUM_PINS in stm32l4x5_syscfg_set_irq
- rename STM32L4XX to STM32L4X5, Stm32l4xx to Stm32l4x5
(the SYSCFG implementation is only valid for STM32L4x5 and STM32L4x6 but not for STM32L41xx/42xx/43xx/44xx)
- refactor STM32L4x5SyscfgState to Stm32l4x5SyscfgState to be consistent with other peripherals
Based-on: <[email protected]> ([PATCH qemu v3 0/3] Add device STM32L4x5 EXTI)
Inès Varhol (3):
hw/misc: Implement STM32L4x5 SYSCFG tests/qtest: Add STM32L4x5 SYSCFG QTest testcase hw/arm: Connect STM32L4x5 SYSCFG to STM32L4x5 SoC
hw/arm/Kconfig | 1 + hw/arm/stm32l4x5_soc.c | 23 +- hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/stm32l4x5_syscfg.c | 265 ++++++++++++++++++ hw/misc/trace-events | 6 + include/hw/arm/stm32l4x5_soc.h | 2 + include/hw/misc/stm32l4x5_syscfg.h | 54 ++++ tests/qtest/meson.build | 3 +- tests/qtest/stm32l4x5_syscfg-test.c | 408 ++++++++++++++++++++++++++++ 10 files changed, 764 insertions(+), 2 deletions(-) create mode 100644 hw/misc/stm32l4x5_syscfg.c create mode 100644 include/hw/misc/stm32l4x5_syscfg.h create mode 100644 tests/qtest/stm32l4x5_syscfg-test.c
Signature · 1 line
2.38.5
PATCH v2 1/3 hw/misc: Implement STM32L4x5 SYSCFG
From: Inès Varhol <[email protected]>
--- hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/stm32l4x5_syscfg.c | 265 +++++++++++++++++++++++++++++ hw/misc/trace-events | 6 + include/hw/misc/stm32l4x5_syscfg.h | 54 ++++++ 5 files changed, 329 insertions(+) create mode 100644 hw/misc/stm32l4x5_syscfg.c create mode 100644 include/hw/misc/stm32l4x5_syscfg.h
hw/misc/Kconfig +3 -0
@@ -90,6 +90,9 @@ config STM32F4XX_EXTI config STM32L4X5_EXTI bool +config STM32L4X5_SYSCFG + bool + config MIPS_ITU bool
hw/misc/meson.build +1 -0
@@ -111,6 +111,7 @@ system_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_syscfg. system_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_syscfg.c')) system_ss.add(when: 'CONFIG_STM32F4XX_EXTI', if_true: files('stm32f4xx_exti.c')) system_ss.add(when: 'CONFIG_STM32L4X5_EXTI', if_true: files('stm32l4x5_exti.c')) +system_ss.add(when: 'CONFIG_STM32L4X5_SYSCFG', if_true: files('stm32l4x5_syscfg.c')) system_ss.add(when: 'CONFIG_MPS2_FPGAIO', if_true: files('mps2-fpgaio.c')) system_ss.add(when: 'CONFIG_MPS2_SCC', if_true: files('mps2-scc.c'))
hw/misc/stm32l4x5_syscfg.c new file +265 -0
265 lines not on this page · raw message
hw/misc/trace-events +6 -0
@@ -163,6 +163,12 @@ stm32f4xx_exti_set_irq(int irq, int level) "Set EXTI: %d to %d" stm32f4xx_exti_read(uint64_t addr) "reg read: addr: 0x%" PRIx64 " " stm32f4xx_exti_write(uint64_t addr, uint64_t data) "reg write: addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" +# stm32l4x5_syscfg.c +stm32l4x5_syscfg_set_irq(int gpio, int line, int level) "irq from GPIO: %d, line: %d, level: %d" +stm32l4x5_syscfg_pulse_exti(int irq) "irq %d forwarded to EXTI" +stm32l4x5_syscfg_read(uint64_t addr) "reg read: addr: 0x%" PRIx64 " " +stm32l4x5_syscfg_write(uint64_t addr, uint64_t data) "reg write: addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" + # stm32l4x5_exti.c stm32l4x5_exti_set_irq(int irq, int level) "Set EXTI: %d to %d" stm32l4x5_exti_read(uint64_t addr, uint64_t data) "reg read: addr: 0x%" PRIx64 " val: 0x%" PRIx64 ""
include/hw/misc/stm32l4x5_syscfg.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.38.5
PATCH v2 2/3 tests/qtest: Add STM32L4x5 SYSCFG QTest testcase
In reply to ~inesvarholFrom: Inès Varhol <[email protected]>
--- tests/qtest/meson.build | 3 +- tests/qtest/stm32l4x5_syscfg-test.c | 408 ++++++++++++++++++++++++++++ 2 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/stm32l4x5_syscfg-test.c
tests/qtest/meson.build +2 -1
@@ -196,7 +196,8 @@ qtests_aspeed = \ 'aspeed_gpio-test'] qtests_stm32l4x5 = \ - ['stm32l4x5_exti-test'] + ['stm32l4x5_exti-test', + 'stm32l4x5_syscfg-test'] qtests_arm = \ (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
tests/qtest/stm32l4x5_syscfg-test.c new file +408 -0
408 lines not on this page · raw message
Signature · 1 line
2.38.5
PATCH v2 3/3 hw/arm: Connect STM32L4x5 SYSCFG to STM32L4x5 SoC
In reply to ~inesvarholFrom: Inès Varhol <[email protected]>
The SYSCFG input GPIOs aren't connected yet. When the STM32L4x5 GPIO device will be implemented, its output GPIOs will be connected to the SYSCFG input GPIOs.
--- hw/arm/Kconfig | 1 + hw/arm/stm32l4x5_soc.c | 23 ++++++++++++++++++++++- include/hw/arm/stm32l4x5_soc.h | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
@@ -458,6 +458,7 @@ config STM32L4X5_SOC bool select ARM_V7M select OR_IRQ + select STM32L4X5_SYSCFG select STM32L4X5_EXTI config XLNX_ZYNQMP_ARM
hw/arm/stm32l4x5_soc.c +22 -1
@@ -46,6 +46,7 @@#define SRAM2_SIZE (32 * KiB)#define EXTI_ADDR 0x40010400 +#define SYSCFG_ADDR 0x40010000#define NUM_EXTI_IRQ 40/* Match exti line connections with their CPU IRQ number */
@@ -90,6 +91,8 @@ static void stm32l4x5_soc_initfn(Object *obj)object_initialize_child (obj,"exti" , &s->exti,TYPE_STM32L4X5_EXTI ); +object_initialize_child (obj,"syscfg" , &s->syscfg,TYPE_STM32L4X5_SYSCFG ); + s->sysclk =qdev_init_clock_in (DEVICE (s),"sysclk" ,NULL ,NULL ,0 ); s->refclk =qdev_init_clock_in (DEVICE (s),"refclk" ,NULL ,NULL ,0 ); }
@@ -167,6 +170,20 @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)return ; } +/* System configuration controller */ + dev =DEVICE (&s->syscfg); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->syscfg), errp)) { +return ; + } + busdev =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (busdev,0 ,SYSCFG_ADDR ); +/* +* TODO: when the GPIO device is implemented, connect it +* to SYCFG using `qdev_connect_gpio_out`, NUM_GPIOS and +* GPIO_NUM_PINS. +*/ + +/* EXTI device */ dev =DEVICE (&s->exti);if (!sysbus_realize (SYS_BUS_DEVICE (&s->exti), errp)) {return ;
@@ -177,6 +194,11 @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)sysbus_connect_irq (busdev, i,qdev_get_gpio_in (armv7m, exti_irq[i])); } +for (i =0 ; i <16 ; i++) { +qdev_connect_gpio_out (DEVICE (&s->syscfg), i, +qdev_get_gpio_in (dev, i)); + } +/* APB1 BUS */ create_unimplemented_device ("TIM2" ,0x40000000 ,0x400 );create_unimplemented_device ("TIM3" ,0x40000400 ,0x400 );
@@ -214,7 +236,6 @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)/* RESERVED: 0x40009800, 0x6800 */ /* APB2 BUS */ -create_unimplemented_device ("SYSCFG" ,0x40010000 ,0x30 );create_unimplemented_device ("VREFBUF" ,0x40010030 ,0x1D0 );create_unimplemented_device ("COMP" ,0x40010200 ,0x200 );/* RESERVED: 0x40010800, 0x1400 */
include/hw/arm/stm32l4x5_soc.h +2 -0
@@ -37,6 +37,7 @@#include "qemu/units.h" #include "hw/qdev-core.h" #include "hw/arm/armv7m.h" +#include "hw/misc/stm32l4x5_syscfg.h" #include "hw/misc/stm32l4x5_exti.h" #include "qom/object.h"
@@ -52,6 +53,7 @@ struct Stm32l4x5SocState {ARMv7MState armv7m;Stm32l4x5ExtiState exti; +Stm32l4x5SyscfgState syscfg;MemoryRegion sram1;MemoryRegion sram2;
Signature · 1 line
2.38.5