drivers: sdhc: add support for configurable power on delay to SPI SDHC

Add support for configuring power on delay when using SPI SDHC. This
allows cards that reliably initialize with a shorter (1ms) delay to
avoid the long initialize delay otherwise imposed.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2023-03-02 10:27:45 -06:00 committed by Carles Cufí
parent 2f9335d20a
commit 01b9a9cdbb
2 changed files with 12 additions and 1 deletions

View file

@ -82,6 +82,7 @@ struct sdhc_spi_config {
const struct device *spi_dev;
const struct gpio_dt_spec pwr_gpio;
const uint32_t spi_max_freq;
uint32_t power_delay_ms;
};
struct sdhc_spi_data {
@ -718,7 +719,7 @@ static int sdhc_spi_get_host_props(const struct device *dev,
props->f_min = SDMMC_CLOCK_400KHZ;
props->f_max = cfg->spi_max_freq;
props->power_delay = 1000; /* SPI always needs 1ms power delay */
props->power_delay = cfg->power_delay_ms;
props->host_caps.vol_330_support = true;
props->is_spi = true;
return 0;
@ -762,6 +763,7 @@ static struct sdhc_driver_api sdhc_spi_api = {
.spi_dev = DEVICE_DT_GET(DT_INST_PARENT(n)), \
.pwr_gpio = GPIO_DT_SPEC_INST_GET_OR(n, pwr_gpios, {0}), \
.spi_max_freq = DT_INST_PROP(n, spi_max_frequency), \
.power_delay_ms = DT_INST_PROP(n, power_delay_ms), \
}; \
\
struct sdhc_spi_data sdhc_spi_data_##n = { \

View file

@ -4,4 +4,13 @@ compatible: "zephyr,sdhc-spi-slot"
include: [spi-device.yaml]
properties:
power-delay-ms:
type: int
default: 1
description: |
Time in ms for SPI SDHC to delay when toggling power to the SD card. This
delay gives the card time to power up or down fully. It can be increased
if you observe issues initializing your card.
bus: sd