From: Inès Varhol <ines.varhol@telecom-paris.fr>
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
---
hw/arm/Kconfig | 1 +
hw/arm/stm32l4x5_soc.c | 24 ++++++++++++++++--------
include/hw/arm/stm32l4x5_soc.h | 2 ++
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 9c9d5bb541..ea77977d4b 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -458,6 +458,7 @@ config STM32L4X5_SOC
bool
select ARM_V7M
select OR_IRQ
+ select STM32L4XX_SYSCFG
select STM32L4X5_EXTI
config XLNX_ZYNQMP_ARM
diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c
index cf786eac1d..9b45a9e606 100644
--- a/hw/arm/stm32l4x5_soc.c
+++ b/hw/arm/stm32l4x5_soc.c
@@ -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_STM32L4XX_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,15 @@ 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);
+
+ /* EXTI device */
dev = DEVICE(&s->exti);
if (!sysbus_realize(SYS_BUS_DEVICE(&s->exti), errp)) {
return;
@@ -178,13 +190,10 @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
sysbus_connect_irq(busdev, i, qdev_get_gpio_in(armv7m, exti_irq[i]));
}
- /*
- * Uncomment when Syscfg is implemented
- * for (i = 0; i < 16; i++) {
- * qdev_connect_gpio_out(DEVICE(&s->syscfg), i,
- * qdev_get_gpio_in(dev, 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);
@@ -223,7 +232,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 */
diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h
index ac47158596..5ff757f15b 100644
--- a/include/hw/arm/stm32l4x5_soc.h
+++ b/include/hw/arm/stm32l4x5_soc.h
@@ -37,6 +37,7 @@
#include "qemu/units.h"
#include "hw/qdev-core.h"
#include "hw/arm/armv7m.h"
+#include "hw/misc/stm32l4xx_syscfg.h"
#include "hw/misc/stm32l4x5_exti.h"
#include "qom/object.h"
@@ -52,6 +53,7 @@ struct Stm32l4x5SocState {
ARMv7MState armv7m;
Stm32l4x5ExtiState exti;
+ STM32L4xxSyscfgState syscfg;
MemoryRegion sram1;
MemoryRegion sram2;
--
2.38.5
On Mon, Dec 11, 2023 at 5:06 AM ~inesvarhol <inesvarhol@git.sr.ht> wrote:
>
> From: Inès Varhol <ines.varhol@telecom-paris.fr>
>
> Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
> ---
> hw/arm/Kconfig | 1 +
> hw/arm/stm32l4x5_soc.c | 24 ++++++++++++++++--------
> include/hw/arm/stm32l4x5_soc.h | 2 ++
> 3 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 9c9d5bb541..ea77977d4b 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -458,6 +458,7 @@ config STM32L4X5_SOC
> bool
> select ARM_V7M
> select OR_IRQ
> + select STM32L4XX_SYSCFG
> select STM32L4X5_EXTI
>
> config XLNX_ZYNQMP_ARM
> diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c
> index cf786eac1d..9b45a9e606 100644
> --- a/hw/arm/stm32l4x5_soc.c
> +++ b/hw/arm/stm32l4x5_soc.c
> @@ -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_STM32L4XX_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,15 @@ 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);
What about the SYSCFG in GPIOs?
You don't have to connect them now, but it would be worth mentioning
in the commit message that they aren't connected and why
Alistair
> +
> + /* EXTI device */
> dev = DEVICE(&s->exti);
> if (!sysbus_realize(SYS_BUS_DEVICE(&s->exti), errp)) {
> return;
> @@ -178,13 +190,10 @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
> sysbus_connect_irq(busdev, i, qdev_get_gpio_in(armv7m, exti_irq[i]));
> }
>
> - /*
> - * Uncomment when Syscfg is implemented
> - * for (i = 0; i < 16; i++) {
> - * qdev_connect_gpio_out(DEVICE(&s->syscfg), i,
> - * qdev_get_gpio_in(dev, 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);
> @@ -223,7 +232,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 */
> diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h
> index ac47158596..5ff757f15b 100644
> --- a/include/hw/arm/stm32l4x5_soc.h
> +++ b/include/hw/arm/stm32l4x5_soc.h
> @@ -37,6 +37,7 @@
> #include "qemu/units.h"
> #include "hw/qdev-core.h"
> #include "hw/arm/armv7m.h"
> +#include "hw/misc/stm32l4xx_syscfg.h"
> #include "hw/misc/stm32l4x5_exti.h"
> #include "qom/object.h"
>
> @@ -52,6 +53,7 @@ struct Stm32l4x5SocState {
> ARMv7MState armv7m;
>
> Stm32l4x5ExtiState exti;
> + STM32L4xxSyscfgState syscfg;
>
> MemoryRegion sram1;
> MemoryRegion sram2;
> --
> 2.38.5
>
© 2016 - 2025 Red Hat, Inc.