fusee: cleanup sdmmc related code
This commit is contained in:
@@ -494,7 +494,7 @@ static int sdmmc_sd_send_op_cond(sdmmc_device_t *device, bool is_sd_ver2, bool i
|
||||
device->is_block_sdhc = true;
|
||||
|
||||
/* We asked for low voltage support and the card accepted. */
|
||||
if (false && is_uhs_en && (resp & SD_ROCR_S18A))
|
||||
if (is_uhs_en && (resp & SD_ROCR_S18A))
|
||||
{
|
||||
/* Voltage switching is only valid for SDMMC1. */
|
||||
if (device->sdmmc->controller == SDMMC_1)
|
||||
@@ -727,11 +727,11 @@ static int sdmmc_sd_switch_hs_low(sdmmc_device_t *device, uint8_t *status)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_SDR104))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_UHS_SDR104))
|
||||
return 0;
|
||||
|
||||
/* Run tuning. */
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_SDR104, MMC_SEND_TUNING_BLOCK))
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_UHS_SDR104, MMC_SEND_TUNING_BLOCK))
|
||||
return 0;
|
||||
}
|
||||
else if (status[13] & SD_MODE_UHS_SDR50) /* High-speed SDR50 is supported. */
|
||||
@@ -741,11 +741,11 @@ static int sdmmc_sd_switch_hs_low(sdmmc_device_t *device, uint8_t *status)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_SDR50))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_UHS_SDR50))
|
||||
return 0;
|
||||
|
||||
/* Run tuning. */
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_SDR50, MMC_SEND_TUNING_BLOCK))
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_UHS_SDR50, MMC_SEND_TUNING_BLOCK))
|
||||
return 0;
|
||||
}
|
||||
else if (status[13] & SD_MODE_UHS_SDR12) /* High-speed SDR12 is supported. */
|
||||
@@ -755,11 +755,11 @@ static int sdmmc_sd_switch_hs_low(sdmmc_device_t *device, uint8_t *status)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_SDR12))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_UHS_SDR12))
|
||||
return 0;
|
||||
|
||||
/* Run tuning. */
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_SDR12, MMC_SEND_TUNING_BLOCK))
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_UHS_SDR12, MMC_SEND_TUNING_BLOCK))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@@ -784,7 +784,7 @@ static int sdmmc_sd_switch_hs_high(sdmmc_device_t *device, uint8_t *status)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_SDR25))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_UHS_SDR25))
|
||||
return 0;
|
||||
|
||||
/* Peek the SD card's status. */
|
||||
@@ -841,7 +841,7 @@ int sdmmc_device_sd_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth b
|
||||
memset(device, 0, sizeof(sdmmc_device_t));
|
||||
|
||||
/* Try to initialize the driver. */
|
||||
if (!sdmmc_init(sdmmc, SDMMC_1, SDMMC_VOLTAGE_3V3, SDMMC_BUS_WIDTH_1BIT, SDMMC_SPEED_INIT_SDR))
|
||||
if (!sdmmc_init(sdmmc, SDMMC_1, SDMMC_VOLTAGE_3V3, SDMMC_BUS_WIDTH_1BIT, SDMMC_SPEED_SD_INIT))
|
||||
{
|
||||
sdmmc_error(sdmmc, "Failed to initialize the SDMMC driver!");
|
||||
return 0;
|
||||
@@ -874,7 +874,7 @@ int sdmmc_device_sd_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth b
|
||||
sdmmc_info(sdmmc, "Sent if cond to SD card!");
|
||||
|
||||
/* Get the SD card's operating conditions. */
|
||||
if (!sdmmc_sd_send_op_cond(device, is_sd_ver2, (bus_width == SDMMC_BUS_WIDTH_4BIT) && (bus_speed == SDMMC_SPEED_SDR104)))
|
||||
if (!sdmmc_sd_send_op_cond(device, is_sd_ver2, (bus_width == SDMMC_BUS_WIDTH_4BIT) && (bus_speed == SDMMC_SPEED_UHS_SDR104)))
|
||||
{
|
||||
sdmmc_error(sdmmc, "Failed to send op cond!");
|
||||
return 0;
|
||||
@@ -920,7 +920,7 @@ int sdmmc_device_sd_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth b
|
||||
if (!device->is_180v)
|
||||
{
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_UNK6))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_SD_LEGACY))
|
||||
{
|
||||
sdmmc_error(sdmmc, "Failed to apply the correct bus speed!");
|
||||
return 0;
|
||||
@@ -998,7 +998,7 @@ int sdmmc_device_sd_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth b
|
||||
|
||||
sdmmc_info(sdmmc, "Switched to high-speed from low voltage!");
|
||||
}
|
||||
else if ((device->scr.sda_vsn & (SD_SCR_SPEC_VER_1 | SD_SCR_SPEC_VER_2)) && ((bus_speed != SDMMC_SPEED_UNK6)))
|
||||
else if ((device->scr.sda_vsn & (SD_SCR_SPEC_VER_1 | SD_SCR_SPEC_VER_2)) && ((bus_speed != SDMMC_SPEED_SD_LEGACY)))
|
||||
{
|
||||
/* Switch to high-speed from high voltage (if possible). */
|
||||
if (!sdmmc_sd_switch_hs_high(device, switch_status))
|
||||
@@ -1273,7 +1273,7 @@ static int sdmmc_mmc_select_hs(sdmmc_device_t *device, bool ignore_status)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_HS52))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_MMC_HS))
|
||||
return 0;
|
||||
|
||||
/* Check the status if necessary. */
|
||||
@@ -1292,11 +1292,11 @@ static int sdmmc_mmc_select_hs200(sdmmc_device_t *device)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_HS200))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_MMC_HS200))
|
||||
return 0;
|
||||
|
||||
/* Execute tuning procedure. */
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_HS200, MMC_SEND_TUNING_BLOCK_HS200))
|
||||
if (!sdmmc_execute_tuning(device->sdmmc, SDMMC_SPEED_MMC_HS200, MMC_SEND_TUNING_BLOCK_HS200))
|
||||
return 0;
|
||||
|
||||
/* Peek the current status. */
|
||||
@@ -1331,7 +1331,7 @@ static int sdmmc_mmc_select_hs400(sdmmc_device_t *device)
|
||||
return 0;
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_HS400))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_MMC_HS400))
|
||||
return 0;
|
||||
|
||||
/* Peek the current status. */
|
||||
@@ -1340,14 +1340,14 @@ static int sdmmc_mmc_select_hs400(sdmmc_device_t *device)
|
||||
|
||||
static int sdmmc_mmc_select_timing(sdmmc_device_t *device, SdmmcBusSpeed bus_speed)
|
||||
{
|
||||
if ((bus_speed == SDMMC_SPEED_HS400) &&
|
||||
if ((bus_speed == SDMMC_SPEED_MMC_HS400) &&
|
||||
(device->sdmmc->bus_width == SDMMC_BUS_WIDTH_8BIT) &&
|
||||
(device->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_HS400_1_8V))
|
||||
{
|
||||
/* Switch to HS400. */
|
||||
return sdmmc_mmc_select_hs400(device);
|
||||
}
|
||||
else if (((bus_speed == SDMMC_SPEED_HS400) || (bus_speed == SDMMC_SPEED_HS200)) &&
|
||||
else if (((bus_speed == SDMMC_SPEED_MMC_HS400) || (bus_speed == SDMMC_SPEED_MMC_HS200)) &&
|
||||
((device->sdmmc->bus_width == SDMMC_BUS_WIDTH_8BIT) || (device->sdmmc->bus_width == SDMMC_BUS_WIDTH_4BIT)) &&
|
||||
(device->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_HS200_1_8V))
|
||||
{
|
||||
@@ -1397,7 +1397,7 @@ int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth
|
||||
memset(device, 0, sizeof(sdmmc_device_t));
|
||||
|
||||
/* Try to initialize the driver. */
|
||||
if (!sdmmc_init(sdmmc, SDMMC_4, SDMMC_VOLTAGE_1V8, SDMMC_BUS_WIDTH_1BIT, SDMMC_SPEED_INIT_HS))
|
||||
if (!sdmmc_init(sdmmc, SDMMC_4, SDMMC_VOLTAGE_1V8, SDMMC_BUS_WIDTH_1BIT, SDMMC_SPEED_MMC_INIT))
|
||||
{
|
||||
sdmmc_error(sdmmc, "Failed to initialize the SDMMC driver!");
|
||||
return 0;
|
||||
@@ -1464,7 +1464,7 @@ int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth
|
||||
sdmmc_warn(sdmmc, "Got unknown CSD structure (0x%08x)!", device->csd.structure);
|
||||
|
||||
/* Reconfigure the internal clock. */
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_HS26))
|
||||
if (!sdmmc_select_speed(device->sdmmc, SDMMC_SPEED_MMC_LEGACY))
|
||||
{
|
||||
sdmmc_error(sdmmc, "Failed to apply the correct bus speed!");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user