|
|
|
|
@@ -220,10 +220,10 @@ static int _mmc_storage_get_op_cond_inner(sdmmc_storage_t *storage, u32 *pout, u
|
|
|
|
|
switch (power)
|
|
|
|
|
{
|
|
|
|
|
case SDMMC_POWER_1_8:
|
|
|
|
|
arg = 0x40000080; //Sector access, voltage.
|
|
|
|
|
arg = SD_OCR_CCS | SD_OCR_VDD_18;
|
|
|
|
|
break;
|
|
|
|
|
case SDMMC_POWER_3_3:
|
|
|
|
|
arg = 0x403F8000; //Sector access, voltage.
|
|
|
|
|
arg = SD_OCR_CCS | SD_OCR_VDD_27_34;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
@@ -248,7 +248,7 @@ static int _mmc_storage_get_op_cond(sdmmc_storage_t *storage, u32 power)
|
|
|
|
|
|
|
|
|
|
if (cond & MMC_CARD_BUSY)
|
|
|
|
|
{
|
|
|
|
|
if (cond & 0x40000000)
|
|
|
|
|
if (cond & SD_OCR_CCS)
|
|
|
|
|
storage->has_sector_access = 1;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
@@ -569,7 +569,7 @@ DPRINTF("[MMC] BKOPS disabled\n");
|
|
|
|
|
|
|
|
|
|
if (!_mmc_storage_enable_highspeed(storage, storage->ext_csd.card_type, type))
|
|
|
|
|
return 0;
|
|
|
|
|
DPRINTF("[MMC] succesfully switched to highspeed mode\n");
|
|
|
|
|
DPRINTF("[MMC] succesfully switched to HS mode\n");
|
|
|
|
|
|
|
|
|
|
sdmmc_sd_clock_ctrl(storage->sdmmc, 1);
|
|
|
|
|
|
|
|
|
|
@@ -819,17 +819,17 @@ void _sd_storage_set_current_limit(sdmmc_storage_t *storage, u8 *buf)
|
|
|
|
|
switch (pwr)
|
|
|
|
|
{
|
|
|
|
|
case SD_SET_CURRENT_LIMIT_800:
|
|
|
|
|
DPRINTF("[SD] Power limit raised to 800mA\n");
|
|
|
|
|
DPRINTF("[SD] power limit raised to 800mA\n");
|
|
|
|
|
break;
|
|
|
|
|
case SD_SET_CURRENT_LIMIT_600:
|
|
|
|
|
DPRINTF("[SD] Power limit raised to 600mA\n");
|
|
|
|
|
DPRINTF("[SD] power limit raised to 600mA\n");
|
|
|
|
|
break;
|
|
|
|
|
case SD_SET_CURRENT_LIMIT_400:
|
|
|
|
|
DPRINTF("[SD] Power limit raised to 800mA\n");
|
|
|
|
|
DPRINTF("[SD] power limit raised to 800mA\n");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case SD_SET_CURRENT_LIMIT_200:
|
|
|
|
|
DPRINTF("[SD] Power limit defaulted to 200mA\n");
|
|
|
|
|
DPRINTF("[SD] power limit defaulted to 200mA\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -857,7 +857,7 @@ DPRINTF("[SD] SD supports selected (U)HS mode\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _sd_storage_enable_highspeed_low_volt(sdmmc_storage_t *storage, u32 type, u8 *buf)
|
|
|
|
|
int _sd_storage_enable_uhs_low_volt(sdmmc_storage_t *storage, u32 type, u8 *buf)
|
|
|
|
|
{
|
|
|
|
|
// Try to raise the current limit to let the card perform better.
|
|
|
|
|
_sd_storage_set_current_limit(storage, buf);
|
|
|
|
|
@@ -878,7 +878,7 @@ int _sd_storage_enable_highspeed_low_volt(sdmmc_storage_t *storage, u32 type, u8
|
|
|
|
|
{
|
|
|
|
|
type = 11;
|
|
|
|
|
hs_type = UHS_SDR104_BUS_SPEED;
|
|
|
|
|
DPRINTF("[SD] Bus speed set to SDR104\n");
|
|
|
|
|
DPRINTF("[SD] bus speed set to SDR104\n");
|
|
|
|
|
storage->csd.busspeed = 104;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
@@ -887,7 +887,7 @@ DPRINTF("[SD] Bus speed set to SDR104\n");
|
|
|
|
|
{
|
|
|
|
|
type = 10;
|
|
|
|
|
hs_type = UHS_SDR50_BUS_SPEED;
|
|
|
|
|
DPRINTF("[SD] Bus speed set to SDR50\n");
|
|
|
|
|
DPRINTF("[SD] bus speed set to SDR50\n");
|
|
|
|
|
storage->csd.busspeed = 50;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
@@ -896,7 +896,7 @@ DPRINTF("[SD] Bus speed set to SDR50\n");
|
|
|
|
|
return 0;
|
|
|
|
|
type = 8;
|
|
|
|
|
hs_type = UHS_SDR12_BUS_SPEED;
|
|
|
|
|
DPRINTF("[SD] Bus speed set to SDR12\n");
|
|
|
|
|
DPRINTF("[SD] bus speed set to SDR12\n");
|
|
|
|
|
storage->csd.busspeed = 12;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
@@ -916,7 +916,7 @@ DPRINTF("[SD] config tuning\n");
|
|
|
|
|
return _sdmmc_storage_check_status(storage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _sd_storage_enable_highspeed_high_volt(sdmmc_storage_t *storage, u8 *buf)
|
|
|
|
|
int _sd_storage_enable_hs_high_volt(sdmmc_storage_t *storage, u8 *buf)
|
|
|
|
|
{
|
|
|
|
|
if (!_sd_storage_switch_get(storage, buf))
|
|
|
|
|
return 0;
|
|
|
|
|
@@ -1065,7 +1065,7 @@ int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32
|
|
|
|
|
{
|
|
|
|
|
int is_version_1 = 0;
|
|
|
|
|
|
|
|
|
|
// Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms.
|
|
|
|
|
// Some cards (SanDisk U1), do not like a fast power cycle. Wait min 100ms.
|
|
|
|
|
sdmmc_storage_init_wait_sd();
|
|
|
|
|
|
|
|
|
|
memset(storage, 0, sizeof(sdmmc_storage_t));
|
|
|
|
|
@@ -1166,7 +1166,7 @@ DPRINTF("[SD] SD does not support wide bus width\n");
|
|
|
|
|
|
|
|
|
|
if (storage->is_low_voltage)
|
|
|
|
|
{
|
|
|
|
|
if (!_sd_storage_enable_highspeed_low_volt(storage, type, buf))
|
|
|
|
|
if (!_sd_storage_enable_uhs_low_volt(storage, type, buf))
|
|
|
|
|
{
|
|
|
|
|
free(buf);
|
|
|
|
|
return 0;
|
|
|
|
|
@@ -1175,7 +1175,7 @@ DPRINTF("[SD] enabled UHS\n");
|
|
|
|
|
}
|
|
|
|
|
else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0)
|
|
|
|
|
{
|
|
|
|
|
if (!_sd_storage_enable_highspeed_high_volt(storage, buf))
|
|
|
|
|
if (!_sd_storage_enable_hs_high_volt(storage, buf))
|
|
|
|
|
{
|
|
|
|
|
free(buf);
|
|
|
|
|
return 0;
|
|
|
|
|
|