change(sdmmc): move SD power control logic into sdmmc_test_sd_begin

This simplifies the code a bit,
- removing SOC_SDMMC_IO_POWER_EXTERNAL ifdefs from error paths
- moving the LDO code next to where sdmmc_test_board_card_power_set
  is called for the same purpose
pull/13651/head
Ivan Grokhotkov 2024-04-04 15:02:11 +02:00
rodzic 2bd1a8706d
commit 344439dfaa
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 1E050E141B280628
2 zmienionych plików z 12 dodań i 19 usunięć

Wyświetl plik

@ -35,18 +35,6 @@ void sdmmc_test_board_get_config_sdmmc(int slot_index, sdmmc_host_t *out_host_co
out_host_config->max_freq_khz = slot->max_freq_khz;
}
#if SOC_SDMMC_IO_POWER_EXTERNAL
#define SDMMC_PWR_LDO_CHANNEL 4
sd_pwr_ctrl_ldo_config_t ldo_config = {
.ldo_chan_id = SDMMC_PWR_LDO_CHANNEL,
};
sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL;
TEST_ESP_OK(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle));
out_host_config->pwr_ctrl_handle = pwr_ctrl_handle;
#endif
#if SOC_SDMMC_USE_GPIO_MATRIX
out_slot_config->clk = slot->clk;
out_slot_config->cmd = slot->cmd_mosi;

Wyświetl plik

@ -30,15 +30,9 @@ void sdmmc_test_sd_skip_if_board_incompatible(int slot, int width, int freq_khz,
int board_max_freq_khz = sdmmc_test_board_get_slot_info(slot)->max_freq_khz;
if (board_max_freq_khz > 0 && board_max_freq_khz < freq_khz) {
#if SOC_SDMMC_IO_POWER_EXTERNAL
TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(config.pwr_ctrl_handle));
#endif
TEST_IGNORE_MESSAGE("Board doesn't support required max_freq_khz");
}
if (slot_config.width < width) {
#if SOC_SDMMC_IO_POWER_EXTERNAL
TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(config.pwr_ctrl_handle));
#endif
TEST_IGNORE_MESSAGE("Board doesn't support required bus width");
}
}
@ -84,6 +78,17 @@ void sdmmc_test_sd_begin(int slot, int width, int freq_khz, int ddr, sdmmc_card_
config.flags |= SDMMC_HOST_FLAG_DDR;
}
#if SOC_SDMMC_IO_POWER_EXTERNAL
#define SDMMC_PWR_LDO_CHANNEL 4
sd_pwr_ctrl_ldo_config_t ldo_config = {
.ldo_chan_id = SDMMC_PWR_LDO_CHANNEL,
};
sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL;
TEST_ESP_OK(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle));
config.pwr_ctrl_handle = pwr_ctrl_handle;
#endif
sdmmc_test_board_card_power_set(true);
TEST_ESP_OK(sdmmc_host_init());
TEST_ESP_OK(sdmmc_host_init_slot(slot, &slot_config));
@ -123,7 +128,7 @@ void sdmmc_test_sd_end(sdmmc_card_t *card)
}
esp_log_level_set("gpio", old_level);
//Need to reset GPIO first, otherrwise cannot discharge VDD of card completely.
//Need to reset GPIO first, otherwise cannot discharge VDD of card completely.
sdmmc_test_board_card_power_set(false);
#if SOC_SDMMC_IO_POWER_EXTERNAL
TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(card->host.pwr_ctrl_handle));