Skip to content

Commit

Permalink
Tentative fix for #145
Browse files Browse the repository at this point in the history
  • Loading branch information
vintagepc committed Mar 3, 2024
1 parent e9f167d commit 0fd3eb3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion hw/arm/prusa/stm32_chips/stm32f030xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static const stm32_soc_cfg_t stm32f030xx_cfg =
PER_LNI(P_ADC1, TYPE_STM32F030_ADC, 0x40012400, F030_ADC_IRQ),
PER_LN(P_ADCC, TYPE_STM32F030_ADCC, 0x40012400 + 0x308),

PER_LNI(P_RCC, TYPE_STM32F030_RCC, 0x40021000, F030_RCC_IRQ),
PER_LNIF(P_RCC, TYPE_STM32F030_RCC, 0x40021000, PERIPH_CFG_FLAG_NON_STM32P, F030_RCC_IRQ),
PER_LNI(P_FINT, TYPE_STM32F40x_F41x_FINT, 0x40022000, F030_FLASH_IRQ),
PER_LN(P_IWDG, TYPE_STM32F030_IWDG, 0x40003000),
PER_LN(P_CRC, TYPE_STM32F030_CRC, 0x40023000),
Expand Down
8 changes: 4 additions & 4 deletions hw/arm/prusa/stm32_chips/stm32f407xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ static const stm32_soc_cfg_t stm32f407xx_cfg =
[10 ... 15] = F4xx_EXTI_10_15_IRQ
),
PER_LNI(P_ETH, "stm32f4xx-ethernet", 0x40028000, F4xx_ETH_IRQ, F4xx_ETH_WKUP_IRQ),
PER_LNI(P_RCC, TYPE_STM32F407_RCC, 0x40023800, F4xx_RCC_IRQ),
PER_LNIF(P_RCC, TYPE_STM32F407_RCC, 0x40023800, PERIPH_CFG_FLAG_NON_STM32P, F4xx_RCC_IRQ),
PER_LNI(P_FINT, TYPE_STM32F40x_F41x_FINT, 0x40023C00, F4xx_FLASH_IRQ),
PER_LN(P_IWDG, TYPE_STM32F4xx_IWDG, 0x40003000),
PER_LN(P_CRC, TYPE_STM32F4xx_CRC, 0x40023000),
PER_LN(P_RTC, TYPE_STM32F2XX_RTC, 0x40002800),
PER_LN(P_ITM, TYPE_STM32F4xx_ITM, 0xE0000000),
PER_LN(P_PWR, TYPE_STM32F2XX_PWR, 0x40007000),
PER_LNF(P_RTC, TYPE_STM32F2XX_RTC, 0x40002800, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNF(P_ITM, TYPE_STM32F4xx_ITM, 0xE0000000, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNF(P_PWR, TYPE_STM32F2XX_PWR, 0x40007000, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNI(P_RNG, TYPE_STM32F4XX_RNG, 0x50060800, F4xx_HASH_RNG_IRQ),
PER_LN(P_OTP, TYPE_STM32F4xx_OTP, 0x1FFF7800),
PER_LNI(P_USBHS, TYPE_STM32F4xx_USB, 0x40040000, F4xx_OTG_HS_IRQ),
Expand Down
10 changes: 5 additions & 5 deletions hw/arm/prusa/stm32_chips/stm32f427xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ static const stm32_soc_cfg_t stm32f427xx_cfg =
[10 ... 15] = F4xx_EXTI_10_15_IRQ
),
PER_LNI(P_ETH, "stm32f4xx-ethernet", 0x40028000, F4xx_ETH_IRQ, F4xx_ETH_WKUP_IRQ),
PER_LNI(P_RCC, TYPE_STM32F427_RCC, 0x40023800, F4xx_RCC_IRQ),
PER_LNIF(P_RCC, TYPE_STM32F427_RCC, 0x40023800, PERIPH_CFG_FLAG_NON_STM32P, F4xx_RCC_IRQ),
PER_LNI(P_FINT, TYPE_STM32F42x_F43x_FINT, 0x40023C00, F4xx_FLASH_IRQ),
PER_LN(P_IWDG, TYPE_STM32F4xx_IWDG, 0x40003000),
PER_LN(P_CRC, TYPE_STM32F4xx_CRC, 0x40023000),
PER_LN(P_RTC, TYPE_STM32F2XX_RTC, 0x40002800),
PER_LN(P_ITM, TYPE_STM32F4xx_ITM, 0xE0000000),
PER_LN(P_DWT, TYPE_STM32F4xx_DWT, 0xE0001000),
PER_LN(P_PWR, TYPE_STM32F2XX_PWR, 0x40007000),
PER_LNF(P_RTC, TYPE_STM32F2XX_RTC, 0x40002800, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNF(P_ITM, TYPE_STM32F4xx_ITM, 0xE0000000, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNF(P_DWT, TYPE_STM32F4xx_DWT, 0xE0001000, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNF(P_PWR, TYPE_STM32F2XX_PWR, 0x40007000, PERIPH_CFG_FLAG_NON_STM32P),
PER_LNI(P_RNG, TYPE_STM32F4XX_RNG, 0x50060800, F4xx_HASH_RNG_IRQ),
PER_LN(P_OTP, TYPE_STM32F4xx_OTP, 0x1FFF7800),
PER_LNI(P_USBHS, TYPE_STM32F4xx_USB, 0x40040000, F4xx_OTG_HS_IRQ),
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/prusa/stm32_chips/stm32g070xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static const stm32_soc_cfg_t stm32g070xx_cfg =
PER_LNI(P_ADC1, TYPE_STM32G070_ADC, 0x40012400, G070_ADC_IRQ),
PER_LN(P_ADCC, TYPE_STM32G070_ADCC, 0x40012400 + 0x308),

PER_LNI(P_RCC, TYPE_STM32G070_RCC, 0x40021000, G070_RCC_IRQ),
PER_LNIF(P_RCC, TYPE_STM32G070_RCC, 0x40021000, PERIPH_CFG_FLAG_NON_STM32P, G070_RCC_IRQ),
PER_LNI(P_FINT, TYPE_STM32G070_FINT, 0x40022000, G070_FLASH_IRQ),
PER_LN(P_IWDG, TYPE_STM32G070_IWDG, 0x40003000),
PER_LN(P_CRC, TYPE_STM32G070_CRC, 0x40023000),
Expand Down
15 changes: 12 additions & 3 deletions hw/arm/prusa/stm32_common/stm32_chip_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@
#include "stm32_shared.h"
#include "hw/core/split-irq.h"

enum {
PERIPH_CFG_FLAG_NONE = 0,
PERIPH_CFG_FLAG_NON_STM32P = 1,
};

// Add a single-line scalar entry with id and base address only.
#define PER_LN(id, typename, addr) [STM32_##id] = {typename, addr, 0, {-1} }
// Add a single-line scalar entry with id, base address, and IRQ
#define PER_LNI(id, typename, addr, ...) [STM32_##id] = {typename, addr, 0, {__VA_ARGS__, -1}}
#define PER_LN(id, typename, addr) [STM32_##id] = {typename, addr, 0, PERIPH_CFG_FLAG_NONE, {-1} }
// Add a single-line scalar entry with id, flags, and base address only.
#define PER_LNF(id, typename, addr, flags) [STM32_##id] = {typename, addr, 0, flags, {-1} }
// Add a single-line scalar entry with id, base address, and IRQ vector
#define PER_LNI(id, typename, addr, ...) [STM32_##id] = {typename, addr, 0, PERIPH_CFG_FLAG_NONE, {__VA_ARGS__, -1}}
// Add a single-line scalar entry with id, base address, flags, and IRQ vector
#define PER_LNIF(id, typename, addr, flags, ...) [STM32_##id] = {typename, addr, 0, flags, {__VA_ARGS__, -1}}

typedef struct stm32_periph_cfg_t
{
const char* type;
const hwaddr base_addr;
const uint32_t size;
const uint8_t flags;
const int irq[17];
} stm32_periph_cfg_t;

Expand Down
2 changes: 1 addition & 1 deletion hw/arm/prusa/stm32_common/stm32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ extern void stm32_soc_realize_peripheral(DeviceState* soc_state, stm32_periph_t
sysbus_mmio_map(SYS_BUS_DEVICE(s->perhiperhals[id]), 0, cfg->base_addr);
}
}
if (id > STM32_P_RCC && stm32_rcc_if_has_clk(STM32_PERIPHERAL(s->perhiperhals[id])))
if ((cfg->flags & PERIPH_CFG_FLAG_NON_STM32P) == 0 && stm32_rcc_if_has_clk(STM32_PERIPHERAL(s->perhiperhals[id])))
{
stm32_rcc_if_set_periph_clk_irq(STM32_PERIPHERAL(s->perhiperhals[id]), qdev_get_gpio_in_named(s->perhiperhals[id],"clock-change",0));
}
Expand Down

0 comments on commit 0fd3eb3

Please sign in to comment.