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 <gregor.molter@secretlab.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
H. Gregor Molter
2023-02-20 19:52:36 -05:00
committed by Kevin O'Connor
parent 848a78d1a5
commit d7bd7f1f4b
12 changed files with 1050 additions and 11 deletions

View File

@@ -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
}