sdmmc_host: add helper to get bus frequency from enum

Change-Id: I5796d19a4c28986bbb3674a39cc93f3fa473ae3c
This commit is contained in:
Aidan MacDonald 2026-08-18 16:19:07 +01:00
parent e3f622a851
commit b621a519e2
2 changed files with 17 additions and 0 deletions

View file

@ -144,6 +144,17 @@ void sdmmc_host_set_medium_present(struct sdmmc_host *host, bool present)
}
#endif
size_t sdmmc_host_get_bus_freq(uint32_t clock)
{
switch (clock)
{
case SDMMC_BUS_CLOCK_400KHZ: return 400000;
case SDMMC_BUS_CLOCK_25MHZ: return 25000000;
case SDMMC_BUS_CLOCK_50MHZ: return 50000000;
default: return 0;
}
}
#ifdef CONFIG_STORAGE_MULTI
static int sdmmc_host_count_drives(struct sdmmc_host **array,
size_t array_size)

View file

@ -291,4 +291,10 @@ void sdmmc_host_init_medium_present(struct sdmmc_host *host, bool present) INIT_
*/
void sdmmc_host_set_medium_present(struct sdmmc_host *host, bool present);
/**
* Returns clock frequency in Hz for an `SDMMC_BUS_CLOCK_*` constant.
* Returns zero if fed an invalid constant.
*/
size_t sdmmc_host_get_bus_freq(uint32_t clock);
#endif /* __SDMMC_HOST_H__ */