Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Devices/lilygo-thmi/lilygo,thmi.dts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
pin-clk = <&gpio0 12 GPIO_FLAG_NONE>;
pin-cmd = <&gpio0 11 GPIO_FLAG_NONE>;
pin-d0 = <&gpio0 13 GPIO_FLAG_NONE>;
pin-d3 = <&gpio0 10 GPIO_FLAG_NONE>;
bus-width = <1>;
pullups;
};
};
10 changes: 9 additions & 1 deletion Platforms/platform-esp32/bindings/espressif,esp32-sdmmc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ properties:
enable-uhs:
type: boolean
default: false
description: Enable UHS mode
description: Enable UHS mode
pullups:
type: boolean
default: false
description: Enable internal pullups for SDMMC pins
on-chip-ldo-chan:
type: int
default: -1
description: On-chip LDO channel for SD power (e.g. 4 for LDO4). Set to -1 to disable.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct Esp32SdmmcConfig {
uint8_t bus_width;
bool wp_active_high;
bool enable_uhs;
bool pullups;
int32_t on_chip_ldo_chan;
};

/**
Expand Down
21 changes: 13 additions & 8 deletions Platforms/platform-esp32/source/drivers/esp32_sdmmc_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,24 @@ static error_t mount(void* data) {
sdmmc_host_t host = SDMMC_HOST_DEFAULT();

#if SOC_SD_PWR_CTRL_SUPPORTED
sd_pwr_ctrl_ldo_config_t ldo_config = {
.ldo_chan_id = 4, // LDO4 is typically used for SDMMC on ESP32-S3
};
esp_err_t pwr_err = sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &fs_data->pwr_ctrl_handle);
if (pwr_err != ESP_OK) {
LOG_E(TAG, "Failed to create SD power control driver, err=0x%x", pwr_err);
return ERROR_NOT_SUPPORTED;
// Treat non-positive values as disabled to remain safe with zero-initialized configs.
if (config->on_chip_ldo_chan > 0) {
sd_pwr_ctrl_ldo_config_t ldo_config = {
.ldo_chan_id = (uint32_t)config->on_chip_ldo_chan,
};
esp_err_t pwr_err = sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &fs_data->pwr_ctrl_handle);
if (pwr_err != ESP_OK) {
LOG_E(TAG, "Failed to create SD power control driver, err=0x%x", pwr_err);
return ERROR_NOT_SUPPORTED;
}
host.pwr_ctrl_handle = fs_data->pwr_ctrl_handle;
}
host.pwr_ctrl_handle = fs_data->pwr_ctrl_handle;
#endif

uint32_t slot_config_flags = 0;
if (config->enable_uhs) slot_config_flags |= SDMMC_SLOT_FLAG_UHS1;
if (config->wp_active_high) slot_config_flags |= SDMMC_SLOT_FLAG_WP_ACTIVE_HIGH;
if (config->pullups) slot_config_flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;

sdmmc_slot_config_t slot_config = {
.clk = to_native_pin(config->pin_clk),
Expand Down Expand Up @@ -127,6 +131,7 @@ static error_t mount(void* data) {
return ERROR_UNDEFINED;
}

sdmmc_card_print_info(stdout, fs_data->card);
LOG_I(TAG, "Mounted %s", fs_data->mount_path.c_str());

return ERROR_NONE;
Expand Down
Loading