From d7bd7f1f4ba6cecd19daa566fdc1864561269ae1 Mon Sep 17 00:00:00 2001 From: "H. Gregor Molter" Date: Mon, 20 Feb 2023 19:52:36 -0500 Subject: stm32: Add sdio support Adds sdio support for the stm32f4 to allow for SD card flash updates without power cycling some boards, e.g. BTT Octopus Pro. Signed-off-by: H. Gregor Molter Signed-off-by: Kevin O'Connor --- src/stm32/stm32f4.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/stm32/stm32f4.c') diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c index a2060d76..fd3eb0ba 100644 --- a/src/stm32/stm32f4.c +++ b/src/stm32/stm32f4.c @@ -138,8 +138,8 @@ enable_clock_stm32f446(void) while (!(PWR->CSR & PWR_CSR_ODSWRDY)) ; - // Enable 48Mhz USB clock - if (CONFIG_USB) { + // Enable 48Mhz USB clock for USB or for SDIO + if (CONFIG_USB || CONFIG_HAVE_GPIO_SDIO) { uint32_t ref = (CONFIG_STM32_CLOCK_REF_INTERNAL ? 16000000 : CONFIG_CLOCK_REF_FREQ); uint32_t plls_base = 2000000, plls_freq = FREQ_USB * 4; @@ -153,6 +153,14 @@ enable_clock_stm32f446(void) ; RCC->DCKCFGR2 = RCC_DCKCFGR2_CK48MSEL; + } else { + // Reset value just in case the booloader modified the default value + RCC->DCKCFGR2 = 0; + } + + // Set SDIO clk to PLL48CLK + if (CONFIG_HAVE_GPIO_SDIO) { + MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL, 0); } #endif } -- cgit v1.2.3-70-g09d2