From 724970f795519f8f0d3c2b5d72e2dc385b2f01f7 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Sun, 6 May 2018 20:26:30 +0300 Subject: [PATCH] Add lv support back and fix its change logic --- ipl/sdmmc.c | 5 +++-- ipl/sdmmc_driver.c | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ipl/sdmmc.c b/ipl/sdmmc.c index 161cf63..8f0f96d 100755 --- a/ipl/sdmmc.c +++ b/ipl/sdmmc.c @@ -520,7 +520,7 @@ static int _sd_storage_get_op_cond(sdmmc_storage_t *storage, int is_version_1, i storage->has_sector_access = 1; // TODO: Some SD Card incorrectly report low voltage support // Disable it for now - if (cond & 0x1000000 && supports_low_voltage && 0) + if (cond & 0x1000000 && supports_low_voltage) { //The low voltage regulator configuration is valid for SDMMC1 only. if (storage->sdmmc->id == SDMMC_1 && @@ -794,7 +794,8 @@ int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 memcpy(storage->scr, buf, 8); DPRINTF("[sd] got scr\n"); - if (bus_width == SDMMC_BUS_WIDTH_4 && storage->scr[1] & 4) + // Check if card supports a wider bus and if it's not SD Version 1.0 + if (bus_width == SDMMC_BUS_WIDTH_4 && storage->scr[1] & 4 && (storage->scr[0] & 0xF)) { if (!_sd_storage_execute_app_cmd_type1(storage, &tmp, SD_APP_SET_BUS_WIDTH, SD_BUS_WIDTH_4, 0, R1_STATE_TRAN)) { diff --git a/ipl/sdmmc_driver.c b/ipl/sdmmc_driver.c index e5c9b37..0443455 100755 --- a/ipl/sdmmc_driver.c +++ b/ipl/sdmmc_driver.c @@ -54,24 +54,30 @@ int sdmmc_get_voltage(sdmmc_t *sdmmc) static int _sdmmc_set_voltage(sdmmc_t *sdmmc, u32 power) { + u8 pwr = 0; + switch (power) { case SDMMC_POWER_OFF: sdmmc->regs->pwrcon &= ~TEGRA_MMC_PWRCTL_SD_BUS_POWER; break; case SDMMC_POWER_1_8: - sdmmc->regs->pwrcon = - (sdmmc->regs->pwrcon & TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_MASK) | - TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8; + sdmmc->regs->pwrcon = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8; + pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8; break; case SDMMC_POWER_3_3: sdmmc->regs->pwrcon = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3; + pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3; break; default: return 0; } - sdmmc->regs->pwrcon |= TEGRA_MMC_PWRCTL_SD_BUS_POWER; + if (power != SDMMC_POWER_OFF) + { + pwr |= TEGRA_MMC_PWRCTL_SD_BUS_POWER; + sdmmc->regs->pwrcon = pwr; + } return 1; }