mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 19:31:12 +00:00
sdmmc: Refactor some names
This commit is contained in:
parent
55395ea4fd
commit
89a4eadab0
4 changed files with 128 additions and 75 deletions
|
@ -296,9 +296,11 @@ static int _mmc_storage_get_op_cond_inner(sdmmc_storage_t *storage, u32 *pout, u
|
||||||
case SDMMC_POWER_1_8:
|
case SDMMC_POWER_1_8:
|
||||||
arg = SD_OCR_CCS | SD_OCR_VDD_18;
|
arg = SD_OCR_CCS | SD_OCR_VDD_18;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_POWER_3_3:
|
case SDMMC_POWER_3_3:
|
||||||
arg = SD_OCR_CCS | SD_OCR_VDD_27_34;
|
arg = SD_OCR_CCS | SD_OCR_VDD_27_34;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -355,6 +357,7 @@ static void _mmc_storage_parse_cid(sdmmc_storage_t *storage)
|
||||||
storage->cid.fwrev = unstuff_bits(raw_cid, 40, 4);
|
storage->cid.fwrev = unstuff_bits(raw_cid, 40, 4);
|
||||||
storage->cid.serial = unstuff_bits(raw_cid, 16, 24);
|
storage->cid.serial = unstuff_bits(raw_cid, 16, 24);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* MMC v2.0 - v2.2 */
|
case 2: /* MMC v2.0 - v2.2 */
|
||||||
case 3: /* MMC v3.1 - v3.3 */
|
case 3: /* MMC v3.1 - v3.3 */
|
||||||
case 4: /* MMC v4 */
|
case 4: /* MMC v4 */
|
||||||
|
@ -364,6 +367,7 @@ static void _mmc_storage_parse_cid(sdmmc_storage_t *storage)
|
||||||
storage->cid.prv = unstuff_bits(raw_cid, 48, 8);
|
storage->cid.prv = unstuff_bits(raw_cid, 48, 8);
|
||||||
storage->cid.serial = unstuff_bits(raw_cid, 16, 32);
|
storage->cid.serial = unstuff_bits(raw_cid, 16, 32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -454,6 +458,7 @@ static int _mmc_storage_switch_buswidth(sdmmc_storage_t *storage, u32 bus_width)
|
||||||
case SDMMC_BUS_WIDTH_4:
|
case SDMMC_BUS_WIDTH_4:
|
||||||
arg = SDMMC_SWITCH(MMC_SWITCH_MODE_WRITE_BYTE, EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
|
arg = SDMMC_SWITCH(MMC_SWITCH_MODE_WRITE_BYTE, EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_BUS_WIDTH_8:
|
case SDMMC_BUS_WIDTH_8:
|
||||||
arg = SDMMC_SWITCH(MMC_SWITCH_MODE_WRITE_BYTE, EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_8);
|
arg = SDMMC_SWITCH(MMC_SWITCH_MODE_WRITE_BYTE, EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_8);
|
||||||
break;
|
break;
|
||||||
|
@ -512,7 +517,7 @@ static int _mmc_storage_enable_HS400(sdmmc_storage_t *storage)
|
||||||
if (!_mmc_storage_enable_HS200(storage))
|
if (!_mmc_storage_enable_HS200(storage))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sdmmc_set_tap_value(storage->sdmmc);
|
sdmmc_save_tap_value(storage->sdmmc);
|
||||||
|
|
||||||
if (!_mmc_storage_enable_HS(storage, 0))
|
if (!_mmc_storage_enable_HS(storage, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -568,7 +573,7 @@ int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 bus_wid
|
||||||
storage->sdmmc = sdmmc;
|
storage->sdmmc = sdmmc;
|
||||||
storage->rca = 2; //TODO: this could be a config item.
|
storage->rca = 2; //TODO: this could be a config item.
|
||||||
|
|
||||||
if (!sdmmc_init(sdmmc, SDMMC_4, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_1, SDHCI_TIMING_MMC_ID, SDMMC_AUTO_CAL_DISABLE))
|
if (!sdmmc_init(sdmmc, SDMMC_4, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_1, SDHCI_TIMING_MMC_ID, SDMMC_POWER_SAVE_DISABLE))
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[MMC] after init\n");
|
DPRINTF("[MMC] after init\n");
|
||||||
|
|
||||||
|
@ -639,7 +644,7 @@ DPRINTF("[MMC] BKOPS enabled\n");
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[MMC] succesfully switched to HS mode\n");
|
DPRINTF("[MMC] succesfully switched to HS mode\n");
|
||||||
|
|
||||||
sdmmc_card_clock_ctrl(storage->sdmmc, SDMMC_AUTO_CAL_ENABLE);
|
sdmmc_card_clock_powersave(storage->sdmmc, SDMMC_POWER_SAVE_ENABLE);
|
||||||
|
|
||||||
storage->initialized = 1;
|
storage->initialized = 1;
|
||||||
|
|
||||||
|
@ -694,7 +699,7 @@ static int _sd_storage_send_if_cond(sdmmc_storage_t *storage)
|
||||||
return (resp & 0xFF) == 0xAA ? 0 : 2;
|
return (resp & 0xFF) == 0xAA ? 0 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _sd_storage_get_op_cond_once(sdmmc_storage_t *storage, u32 *cond, int is_version_1, int supports_low_voltage)
|
static int _sd_storage_get_op_cond_once(sdmmc_storage_t *storage, u32 *cond, int is_version_1, int bus_low_voltage_support)
|
||||||
{
|
{
|
||||||
sdmmc_cmd_t cmdbuf;
|
sdmmc_cmd_t cmdbuf;
|
||||||
// Support for Current > 150mA
|
// Support for Current > 150mA
|
||||||
|
@ -702,7 +707,7 @@ static int _sd_storage_get_op_cond_once(sdmmc_storage_t *storage, u32 *cond, int
|
||||||
// Support for handling block-addressed SDHC cards
|
// Support for handling block-addressed SDHC cards
|
||||||
arg |= (~is_version_1 & 1) ? SD_OCR_CCS : 0;
|
arg |= (~is_version_1 & 1) ? SD_OCR_CCS : 0;
|
||||||
// Support for 1.8V
|
// Support for 1.8V
|
||||||
arg |= (supports_low_voltage & ~is_version_1 & 1) ? SD_OCR_S18R : 0;
|
arg |= (bus_low_voltage_support & ~is_version_1 & 1) ? SD_OCR_S18R : 0;
|
||||||
// This is needed for most cards. Do not set bit7 even if 1.8V is supported.
|
// This is needed for most cards. Do not set bit7 even if 1.8V is supported.
|
||||||
arg |= SD_OCR_VDD_32_33;
|
arg |= SD_OCR_VDD_32_33;
|
||||||
sdmmc_init_cmd(&cmdbuf, SD_APP_OP_COND, arg, SDMMC_RSP_TYPE_3, 0);
|
sdmmc_init_cmd(&cmdbuf, SD_APP_OP_COND, arg, SDMMC_RSP_TYPE_3, 0);
|
||||||
|
@ -712,24 +717,24 @@ static int _sd_storage_get_op_cond_once(sdmmc_storage_t *storage, u32 *cond, int
|
||||||
return sdmmc_get_rsp(storage->sdmmc, cond, 4, SDMMC_RSP_TYPE_3);
|
return sdmmc_get_rsp(storage->sdmmc, cond, 4, SDMMC_RSP_TYPE_3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _sd_storage_get_op_cond(sdmmc_storage_t *storage, int is_version_1, int supports_low_voltage)
|
static int _sd_storage_get_op_cond(sdmmc_storage_t *storage, int is_version_1, int bus_low_voltage_support)
|
||||||
{
|
{
|
||||||
u32 timeout = get_tmr_ms() + 1500;
|
u32 timeout = get_tmr_ms() + 1500;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
u32 cond = 0;
|
u32 cond = 0;
|
||||||
if (!_sd_storage_get_op_cond_once(storage, &cond, is_version_1, supports_low_voltage))
|
if (!_sd_storage_get_op_cond_once(storage, &cond, is_version_1, bus_low_voltage_support))
|
||||||
break;
|
break;
|
||||||
if (cond & MMC_CARD_BUSY)
|
if (cond & MMC_CARD_BUSY)
|
||||||
{
|
{
|
||||||
DPRINTF("[SD] cond: %08X, lv: %d\n", cond, supports_low_voltage);
|
DPRINTF("[SD] cond: %08X, lv: %d\n", cond, bus_low_voltage_support);
|
||||||
|
|
||||||
if (cond & SD_OCR_CCS)
|
if (cond & SD_OCR_CCS)
|
||||||
storage->has_sector_access = 1;
|
storage->has_sector_access = 1;
|
||||||
|
|
||||||
// Check if card supports 1.8V signaling.
|
// Check if card supports 1.8V signaling.
|
||||||
if (cond & SD_ROCR_S18A && supports_low_voltage)
|
if (cond & SD_ROCR_S18A && bus_low_voltage_support)
|
||||||
{
|
{
|
||||||
//The low voltage regulator configuration is valid for SDMMC1 only.
|
//The low voltage regulator configuration is valid for SDMMC1 only.
|
||||||
if (storage->sdmmc->id == SDMMC_1 &&
|
if (storage->sdmmc->id == SDMMC_1 &&
|
||||||
|
@ -901,12 +906,15 @@ void _sd_storage_set_current_limit(sdmmc_storage_t *storage, u16 current_limit,
|
||||||
case SD_SET_CURRENT_LIMIT_800:
|
case SD_SET_CURRENT_LIMIT_800:
|
||||||
DPRINTF("[SD] power limit raised to 800mA\n");
|
DPRINTF("[SD] power limit raised to 800mA\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_SET_CURRENT_LIMIT_600:
|
case SD_SET_CURRENT_LIMIT_600:
|
||||||
DPRINTF("[SD] power limit raised to 600mA\n");
|
DPRINTF("[SD] power limit raised to 600mA\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_SET_CURRENT_LIMIT_400:
|
case SD_SET_CURRENT_LIMIT_400:
|
||||||
DPRINTF("[SD] power limit raised to 400mA\n");
|
DPRINTF("[SD] power limit raised to 400mA\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case SD_SET_CURRENT_LIMIT_200:
|
case SD_SET_CURRENT_LIMIT_200:
|
||||||
DPRINTF("[SD] power limit defaulted to 200mA\n");
|
DPRINTF("[SD] power limit defaulted to 200mA\n");
|
||||||
|
@ -1007,6 +1015,7 @@ DPRINTF("[SD] bus speed set to SDR25\n");
|
||||||
DPRINTF("[SD] bus speed set to SDR12\n");
|
DPRINTF("[SD] bus speed set to SDR12\n");
|
||||||
storage->csd.busspeed = 12;
|
storage->csd.busspeed = 12;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1072,18 +1081,23 @@ static void _sd_storage_parse_ssr(sdmmc_storage_t *storage)
|
||||||
case 0:
|
case 0:
|
||||||
storage->ssr.speed_class = 0;
|
storage->ssr.speed_class = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
storage->ssr.speed_class = 2;
|
storage->ssr.speed_class = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
storage->ssr.speed_class = 4;
|
storage->ssr.speed_class = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
storage->ssr.speed_class = 6;
|
storage->ssr.speed_class = 6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
storage->ssr.speed_class = 10;
|
storage->ssr.speed_class = 10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
storage->ssr.speed_class = unstuff_bits(raw_ssr1, 440 - 384, 8);
|
storage->ssr.speed_class = unstuff_bits(raw_ssr1, 440 - 384, 8);
|
||||||
break;
|
break;
|
||||||
|
@ -1163,6 +1177,7 @@ static void _sd_storage_parse_csd(sdmmc_storage_t *storage)
|
||||||
case 0:
|
case 0:
|
||||||
storage->csd.capacity = (1 + unstuff_bits(raw_csd, 62, 12)) << (unstuff_bits(raw_csd, 47, 3) + 2);
|
storage->csd.capacity = (1 + unstuff_bits(raw_csd, 62, 12)) << (unstuff_bits(raw_csd, 47, 3) + 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
storage->csd.c_size = (1 + unstuff_bits(raw_csd, 48, 22));
|
storage->csd.c_size = (1 + unstuff_bits(raw_csd, 48, 22));
|
||||||
storage->csd.capacity = storage->csd.c_size << 10;
|
storage->csd.capacity = storage->csd.c_size << 10;
|
||||||
|
@ -1171,7 +1186,7 @@ static void _sd_storage_parse_csd(sdmmc_storage_t *storage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _sdmmc_storage_supports_low_voltage(u32 bus_width, u32 type)
|
static bool _sdmmc_storage_get_low_voltage_support(u32 bus_width, u32 type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -1208,7 +1223,7 @@ DPRINTF("[SD] init: bus: %d, type: %d\n", bus_width, type);
|
||||||
memset(storage, 0, sizeof(sdmmc_storage_t));
|
memset(storage, 0, sizeof(sdmmc_storage_t));
|
||||||
storage->sdmmc = sdmmc;
|
storage->sdmmc = sdmmc;
|
||||||
|
|
||||||
if (!sdmmc_init(sdmmc, SDMMC_1, SDMMC_POWER_3_3, SDMMC_BUS_WIDTH_1, SDHCI_TIMING_SD_ID, SDMMC_AUTO_CAL_DISABLE))
|
if (!sdmmc_init(sdmmc, SDMMC_1, SDMMC_POWER_3_3, SDMMC_BUS_WIDTH_1, SDHCI_TIMING_SD_ID, SDMMC_POWER_SAVE_DISABLE))
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[SD] after init\n");
|
DPRINTF("[SD] after init\n");
|
||||||
|
|
||||||
|
@ -1223,9 +1238,9 @@ DPRINTF("[SD] went to idle state\n");
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[SD] after send if cond\n");
|
DPRINTF("[SD] after send if cond\n");
|
||||||
|
|
||||||
bool supports_low_voltage = _sdmmc_storage_supports_low_voltage(bus_width, type);
|
bool bus_low_voltage_support = _sdmmc_storage_get_low_voltage_support(bus_width, type);
|
||||||
|
|
||||||
if (!_sd_storage_get_op_cond(storage, is_version_1, supports_low_voltage))
|
if (!_sd_storage_get_op_cond(storage, is_version_1, bus_low_voltage_support))
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[SD] got op cond\n");
|
DPRINTF("[SD] got op cond\n");
|
||||||
|
|
||||||
|
@ -1303,7 +1318,7 @@ DPRINTF("[SD] SD does not support wide bus width\n");
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[SD] enabled UHS\n");
|
DPRINTF("[SD] enabled UHS\n");
|
||||||
|
|
||||||
sdmmc_card_clock_ctrl(sdmmc, SDMMC_AUTO_CAL_ENABLE);
|
sdmmc_card_clock_powersave(sdmmc, SDMMC_POWER_SAVE_ENABLE);
|
||||||
}
|
}
|
||||||
else if (type != SDHCI_TIMING_SD_DS12 && (storage->scr.sda_vsn & 0xF) != 0)
|
else if (type != SDHCI_TIMING_SD_DS12 && (storage->scr.sda_vsn & 0xF) != 0)
|
||||||
{
|
{
|
||||||
|
@ -1316,6 +1331,7 @@ DPRINTF("[SD] enabled HS\n");
|
||||||
case SDMMC_BUS_WIDTH_4:
|
case SDMMC_BUS_WIDTH_4:
|
||||||
storage->csd.busspeed = 25;
|
storage->csd.busspeed = 25;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_BUS_WIDTH_1:
|
case SDMMC_BUS_WIDTH_1:
|
||||||
storage->csd.busspeed = 6;
|
storage->csd.busspeed = 6;
|
||||||
break;
|
break;
|
||||||
|
@ -1369,7 +1385,7 @@ int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
|
||||||
memset(storage, 0, sizeof(sdmmc_storage_t));
|
memset(storage, 0, sizeof(sdmmc_storage_t));
|
||||||
storage->sdmmc = sdmmc;
|
storage->sdmmc = sdmmc;
|
||||||
|
|
||||||
if (!sdmmc_init(sdmmc, SDMMC_2, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS102, SDMMC_AUTO_CAL_DISABLE))
|
if (!sdmmc_init(sdmmc, SDMMC_2, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS102, SDMMC_POWER_SAVE_DISABLE))
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[gc] after init\n");
|
DPRINTF("[gc] after init\n");
|
||||||
|
|
||||||
|
@ -1379,7 +1395,7 @@ DPRINTF("[gc] after init\n");
|
||||||
return 0;
|
return 0;
|
||||||
DPRINTF("[gc] after tuning\n");
|
DPRINTF("[gc] after tuning\n");
|
||||||
|
|
||||||
sdmmc_card_clock_ctrl(sdmmc, SDMMC_AUTO_CAL_ENABLE);
|
sdmmc_card_clock_powersave(sdmmc, SDMMC_POWER_SAVE_ENABLE);
|
||||||
|
|
||||||
storage->initialized = 1;
|
storage->initialized = 1;
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,15 @@ static int _sdmmc_set_io_power(sdmmc_t *sdmmc, u32 power)
|
||||||
case SDMMC_POWER_OFF:
|
case SDMMC_POWER_OFF:
|
||||||
sdmmc->regs->pwrcon &= ~SDHCI_POWER_ON;
|
sdmmc->regs->pwrcon &= ~SDHCI_POWER_ON;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_POWER_1_8:
|
case SDMMC_POWER_1_8:
|
||||||
sdmmc->regs->pwrcon = SDHCI_POWER_180;
|
sdmmc->regs->pwrcon = SDHCI_POWER_180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_POWER_3_3:
|
case SDMMC_POWER_3_3:
|
||||||
sdmmc->regs->pwrcon = SDHCI_POWER_330;
|
sdmmc->regs->pwrcon = SDHCI_POWER_330;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +106,7 @@ void sdmmc_set_bus_width(sdmmc_t *sdmmc, u32 bus_width)
|
||||||
sdmmc->regs->hostctl = host_control | SDHCI_CTRL_8BITBUS;
|
sdmmc->regs->hostctl = host_control | SDHCI_CTRL_8BITBUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdmmc_set_tap_value(sdmmc_t *sdmmc)
|
void sdmmc_save_tap_value(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
sdmmc->venclkctl_tap = sdmmc->regs->venclkctl >> 16;
|
sdmmc->venclkctl_tap = sdmmc->regs->venclkctl >> 16;
|
||||||
sdmmc->venclkctl_set = 1;
|
sdmmc->venclkctl_set = 1;
|
||||||
|
@ -137,14 +140,14 @@ static int _sdmmc_config_tap_val(sdmmc_t *sdmmc, u32 type)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _sdmmc_get_clkcon(sdmmc_t *sdmmc)
|
static int _sdmmc_commit_changes(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
return sdmmc->regs->clkcon;
|
return sdmmc->regs->clkcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sdmmc_pad_config_fallback(sdmmc_t *sdmmc, u32 power)
|
static void _sdmmc_pad_config_fallback(sdmmc_t *sdmmc, u32 power)
|
||||||
{
|
{
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
switch (sdmmc->id)
|
switch (sdmmc->id)
|
||||||
{
|
{
|
||||||
case SDMMC_1: // 33 Ohm 2X Driver.
|
case SDMMC_1: // 33 Ohm 2X Driver.
|
||||||
|
@ -156,7 +159,9 @@ static void _sdmmc_pad_config_fallback(sdmmc_t *sdmmc, u32 power)
|
||||||
else if (power == SDMMC_POWER_3_3)
|
else if (power == SDMMC_POWER_3_3)
|
||||||
APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = sdmmc1_pad_cfg | (0xC0C << 12); // Up: 12, Dn: 12. For 33 ohm.
|
APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = sdmmc1_pad_cfg | (0xC0C << 12); // Up: 12, Dn: 12. For 33 ohm.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_2:
|
case SDMMC_2:
|
||||||
|
|
||||||
case SDMMC_4: // 50 Ohm 2X Driver. PU:16, PD:16.
|
case SDMMC_4: // 50 Ohm 2X Driver. PU:16, PD:16.
|
||||||
APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) & 0xFFFFC003) | 0x1040;
|
APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) & 0xFFFFC003) | 0x1040;
|
||||||
break;
|
break;
|
||||||
|
@ -176,13 +181,13 @@ static void _sdmmc_autocal_execute(sdmmc_t *sdmmc, u32 power)
|
||||||
if (!(sdmmc->regs->sdmemcmppadctl & TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD))
|
if (!(sdmmc->regs->sdmemcmppadctl & TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD))
|
||||||
{
|
{
|
||||||
sdmmc->regs->sdmemcmppadctl |= TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD;
|
sdmmc->regs->sdmemcmppadctl |= TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep(1);
|
usleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable auto calibration and start auto configuration.
|
// Enable auto calibration and start auto configuration.
|
||||||
sdmmc->regs->autocalcfg |= TEGRA_MMC_AUTOCALCFG_AUTO_CAL_ENABLE | TEGRA_MMC_AUTOCALCFG_AUTO_CAL_START;
|
sdmmc->regs->autocalcfg |= TEGRA_MMC_AUTOCALCFG_AUTO_CAL_ENABLE | TEGRA_MMC_AUTOCALCFG_AUTO_CAL_START;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep(2);
|
usleep(2);
|
||||||
|
|
||||||
u32 timeout = get_tmr_ms() + 10;
|
u32 timeout = get_tmr_ms() + 10;
|
||||||
|
@ -247,7 +252,7 @@ static int _sdmmc_dll_cal_execute(sdmmc_t *sdmmc)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sdmmc->regs->vendllcalcfg |= TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE;
|
sdmmc->regs->vendllcalcfg |= TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
u32 timeout = get_tmr_ms() + 5;
|
u32 timeout = get_tmr_ms() + 5;
|
||||||
while (sdmmc->regs->vendllcalcfg & TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE)
|
while (sdmmc->regs->vendllcalcfg & TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE)
|
||||||
|
@ -278,7 +283,7 @@ out:;
|
||||||
static void _sdmmc_reset(sdmmc_t *sdmmc)
|
static void _sdmmc_reset(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
sdmmc->regs->swrst |= SDHCI_RESET_CMD | SDHCI_RESET_DATA;
|
sdmmc->regs->swrst |= SDHCI_RESET_CMD | SDHCI_RESET_DATA;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
u32 timeout = get_tmr_ms() + 2000;
|
u32 timeout = get_tmr_ms() + 2000;
|
||||||
while ((sdmmc->regs->swrst & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) && get_tmr_ms() < timeout)
|
while ((sdmmc->regs->swrst & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) && get_tmr_ms() < timeout)
|
||||||
;
|
;
|
||||||
|
@ -307,11 +312,13 @@ int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type)
|
||||||
sdmmc->regs->hostctl &= ~SDHCI_CTRL_HISPD;
|
sdmmc->regs->hostctl &= ~SDHCI_CTRL_HISPD;
|
||||||
sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_VDD_180;
|
sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_VDD_180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_MMC_HS52:
|
case SDHCI_TIMING_MMC_HS52:
|
||||||
case SDHCI_TIMING_SD_HS25:
|
case SDHCI_TIMING_SD_HS25:
|
||||||
sdmmc->regs->hostctl |= SDHCI_CTRL_HISPD;
|
sdmmc->regs->hostctl |= SDHCI_CTRL_HISPD;
|
||||||
sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_VDD_180;
|
sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_VDD_180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_MMC_HS200:
|
case SDHCI_TIMING_MMC_HS200:
|
||||||
case SDHCI_TIMING_UHS_SDR50: // T210 Errata for SDR50, the host must be set to SDR104.
|
case SDHCI_TIMING_UHS_SDR50: // T210 Errata for SDR50, the host must be set to SDR104.
|
||||||
case SDHCI_TIMING_UHS_SDR104:
|
case SDHCI_TIMING_UHS_SDR104:
|
||||||
|
@ -321,22 +328,25 @@ int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type)
|
||||||
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR104_BUS_SPEED;
|
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR104_BUS_SPEED;
|
||||||
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_MMC_HS400:
|
case SDHCI_TIMING_MMC_HS400:
|
||||||
// Non standard.
|
// Non standard.
|
||||||
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | HS400_BUS_SPEED;
|
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | HS400_BUS_SPEED;
|
||||||
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_UHS_SDR25:
|
case SDHCI_TIMING_UHS_SDR25:
|
||||||
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR25_BUS_SPEED;
|
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR25_BUS_SPEED;
|
||||||
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_UHS_SDR12:
|
case SDHCI_TIMING_UHS_SDR12:
|
||||||
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR12_BUS_SPEED;
|
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR12_BUS_SPEED;
|
||||||
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
u32 clock;
|
u32 clock;
|
||||||
u16 divisor;
|
u16 divisor;
|
||||||
|
@ -374,10 +384,10 @@ int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type)
|
||||||
static void _sdmmc_card_clock_enable(sdmmc_t *sdmmc)
|
static void _sdmmc_card_clock_enable(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
// Recalibrate conditionally.
|
// Recalibrate conditionally.
|
||||||
if ((sdmmc->id == SDMMC_1) && !sdmmc->auto_cal_enabled)
|
if ((sdmmc->id == SDMMC_1) && !sdmmc->powersave_enabled)
|
||||||
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
||||||
|
|
||||||
if (!sdmmc->auto_cal_enabled)
|
if (!sdmmc->powersave_enabled)
|
||||||
{
|
{
|
||||||
if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
|
if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
|
||||||
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
||||||
|
@ -391,14 +401,14 @@ static void _sdmmc_sd_clock_disable(sdmmc_t *sdmmc)
|
||||||
sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdmmc_card_clock_ctrl(sdmmc_t *sdmmc, int auto_cal_enable)
|
void sdmmc_card_clock_powersave(sdmmc_t *sdmmc, int powersave_enable)
|
||||||
{
|
{
|
||||||
// Recalibrate periodically for SDMMC1.
|
// Recalibrate periodically for SDMMC1.
|
||||||
if ((sdmmc->id == SDMMC_1) && !auto_cal_enable && sdmmc->card_clock_enabled)
|
if ((sdmmc->id == SDMMC_1) && !powersave_enable && sdmmc->card_clock_enabled)
|
||||||
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
||||||
|
|
||||||
sdmmc->auto_cal_enabled = auto_cal_enable;
|
sdmmc->powersave_enabled = powersave_enable;
|
||||||
if (auto_cal_enable)
|
if (powersave_enable)
|
||||||
{
|
{
|
||||||
if (sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN)
|
if (sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN)
|
||||||
sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
|
||||||
|
@ -422,6 +432,7 @@ static int _sdmmc_cache_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
|
||||||
return 0;
|
return 0;
|
||||||
rsp[0] = sdmmc->regs->rspreg0;
|
rsp[0] = sdmmc->regs->rspreg0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_RSP_TYPE_2:
|
case SDMMC_RSP_TYPE_2:
|
||||||
if (size < 0x10)
|
if (size < 0x10)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -450,9 +461,9 @@ static int _sdmmc_cache_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
|
||||||
rsp[i - 1] |= (tempreg >> 24) & 0xFF;
|
rsp[i - 1] |= (tempreg >> 24) & 0xFF;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -473,6 +484,7 @@ int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
|
||||||
return 0;
|
return 0;
|
||||||
rsp[0] = sdmmc->rsp[0];
|
rsp[0] = sdmmc->rsp[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_RSP_TYPE_2:
|
case SDMMC_RSP_TYPE_2:
|
||||||
if (size < 0x10)
|
if (size < 0x10)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -481,9 +493,9 @@ int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
|
||||||
rsp[2] = sdmmc->rsp[2];
|
rsp[2] = sdmmc->rsp[2];
|
||||||
rsp[3] = sdmmc->rsp[3];
|
rsp[3] = sdmmc->rsp[3];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -491,7 +503,7 @@ int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
|
||||||
|
|
||||||
static int _sdmmc_wait_cmd_data_inhibit(sdmmc_t *sdmmc, bool wait_dat)
|
static int _sdmmc_wait_cmd_data_inhibit(sdmmc_t *sdmmc, bool wait_dat)
|
||||||
{
|
{
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
u32 timeout = get_tmr_ms() + 2000;
|
u32 timeout = get_tmr_ms() + 2000;
|
||||||
while(sdmmc->regs->prnsts & SDHCI_CMD_INHIBIT)
|
while(sdmmc->regs->prnsts & SDHCI_CMD_INHIBIT)
|
||||||
|
@ -517,7 +529,7 @@ static int _sdmmc_wait_cmd_data_inhibit(sdmmc_t *sdmmc, bool wait_dat)
|
||||||
|
|
||||||
static int _sdmmc_wait_card_busy(sdmmc_t *sdmmc)
|
static int _sdmmc_wait_card_busy(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
u32 timeout = get_tmr_ms() + 2000;
|
u32 timeout = get_tmr_ms() + 2000;
|
||||||
while (!(sdmmc->regs->prnsts & SDHCI_DATA_0_LVL_MASK))
|
while (!(sdmmc->regs->prnsts & SDHCI_DATA_0_LVL_MASK))
|
||||||
|
@ -536,16 +548,19 @@ static int _sdmmc_setup_read_small_block(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
case SDMMC_BUS_WIDTH_1:
|
case SDMMC_BUS_WIDTH_1:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
case SDMMC_BUS_WIDTH_4:
|
case SDMMC_BUS_WIDTH_4:
|
||||||
sdmmc->regs->blksize = 64;
|
sdmmc->regs->blksize = 64;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_BUS_WIDTH_8:
|
case SDMMC_BUS_WIDTH_8:
|
||||||
sdmmc->regs->blksize = 128;
|
sdmmc->regs->blksize = 128;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdmmc->regs->blkcnt = 1;
|
sdmmc->regs->blkcnt = 1;
|
||||||
sdmmc->regs->trnmod = SDHCI_TRNS_READ;
|
sdmmc->regs->trnmod = SDHCI_TRNS_READ;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,6 +572,7 @@ static int _sdmmc_send_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, bool is_data_presen
|
||||||
{
|
{
|
||||||
case SDMMC_RSP_TYPE_0:
|
case SDMMC_RSP_TYPE_0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_RSP_TYPE_1:
|
case SDMMC_RSP_TYPE_1:
|
||||||
case SDMMC_RSP_TYPE_4:
|
case SDMMC_RSP_TYPE_4:
|
||||||
case SDMMC_RSP_TYPE_5:
|
case SDMMC_RSP_TYPE_5:
|
||||||
|
@ -565,15 +581,17 @@ static int _sdmmc_send_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, bool is_data_presen
|
||||||
else
|
else
|
||||||
cmdflags = SDHCI_CMD_RESP_LEN48 | SDHCI_CMD_INDEX | SDHCI_CMD_CRC;
|
cmdflags = SDHCI_CMD_RESP_LEN48 | SDHCI_CMD_INDEX | SDHCI_CMD_CRC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_RSP_TYPE_2:
|
case SDMMC_RSP_TYPE_2:
|
||||||
cmdflags = SDHCI_CMD_RESP_LEN136 | SDHCI_CMD_CRC;
|
cmdflags = SDHCI_CMD_RESP_LEN136 | SDHCI_CMD_CRC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_RSP_TYPE_3:
|
case SDMMC_RSP_TYPE_3:
|
||||||
cmdflags = SDHCI_CMD_RESP_LEN48;
|
cmdflags = SDHCI_CMD_RESP_LEN48;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_data_present)
|
if (is_data_present)
|
||||||
|
@ -596,7 +614,7 @@ static void _sdmmc_send_tuning_cmd(sdmmc_t *sdmmc, u32 cmd)
|
||||||
|
|
||||||
static int _sdmmc_tuning_execute_once(sdmmc_t *sdmmc, u32 cmd)
|
static int _sdmmc_tuning_execute_once(sdmmc_t *sdmmc, u32 cmd)
|
||||||
{
|
{
|
||||||
if (sdmmc->auto_cal_enabled)
|
if (sdmmc->powersave_enabled)
|
||||||
return 0;
|
return 0;
|
||||||
if (!_sdmmc_wait_cmd_data_inhibit(sdmmc, true))
|
if (!_sdmmc_wait_cmd_data_inhibit(sdmmc, true))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -608,13 +626,13 @@ static int _sdmmc_tuning_execute_once(sdmmc_t *sdmmc, u32 cmd)
|
||||||
sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
|
||||||
|
|
||||||
_sdmmc_send_tuning_cmd(sdmmc, cmd);
|
_sdmmc_send_tuning_cmd(sdmmc, cmd);
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep(1);
|
usleep(1);
|
||||||
|
|
||||||
_sdmmc_reset(sdmmc);
|
_sdmmc_reset(sdmmc);
|
||||||
|
|
||||||
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
u32 timeout = get_tmr_us() + 5000;
|
u32 timeout = get_tmr_us() + 5000;
|
||||||
while (get_tmr_us() < timeout)
|
while (get_tmr_us() < timeout)
|
||||||
|
@ -623,7 +641,7 @@ static int _sdmmc_tuning_execute_once(sdmmc_t *sdmmc, u32 cmd)
|
||||||
{
|
{
|
||||||
sdmmc->regs->norintsts = SDHCI_INT_DATA_AVAIL;
|
sdmmc->regs->norintsts = SDHCI_INT_DATA_AVAIL;
|
||||||
sdmmc->regs->norintstsen &= ~SDHCI_INT_DATA_AVAIL;
|
sdmmc->regs->norintstsen &= ~SDHCI_INT_DATA_AVAIL;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep((1000 * 8 + sdmmc->divisor - 1) / sdmmc->divisor);
|
usleep((1000 * 8 + sdmmc->divisor - 1) / sdmmc->divisor);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -632,7 +650,7 @@ static int _sdmmc_tuning_execute_once(sdmmc_t *sdmmc, u32 cmd)
|
||||||
_sdmmc_reset(sdmmc);
|
_sdmmc_reset(sdmmc);
|
||||||
|
|
||||||
sdmmc->regs->norintstsen &= ~SDHCI_INT_DATA_AVAIL;
|
sdmmc->regs->norintstsen &= ~SDHCI_INT_DATA_AVAIL;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep((1000 * 8 + sdmmc->divisor - 1) / sdmmc->divisor);
|
usleep((1000 * 8 + sdmmc->divisor - 1) / sdmmc->divisor);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -651,15 +669,18 @@ int sdmmc_tuning_execute(sdmmc_t *sdmmc, u32 type, u32 cmd)
|
||||||
max = 128;
|
max = 128;
|
||||||
flag = (2 << 13); // 128 iterations.
|
flag = (2 << 13); // 128 iterations.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_UHS_SDR50:
|
case SDHCI_TIMING_UHS_SDR50:
|
||||||
case SDHCI_TIMING_UHS_DDR50:
|
case SDHCI_TIMING_UHS_DDR50:
|
||||||
case SDHCI_TIMING_MMC_HS102:
|
case SDHCI_TIMING_MMC_HS102:
|
||||||
max = 256;
|
max = 256;
|
||||||
flag = (4 << 13); // 256 iterations.
|
flag = (4 << 13); // 256 iterations.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDHCI_TIMING_UHS_SDR12:
|
case SDHCI_TIMING_UHS_SDR12:
|
||||||
case SDHCI_TIMING_UHS_SDR25:
|
case SDHCI_TIMING_UHS_SDR25:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -688,7 +709,7 @@ static int _sdmmc_enable_internal_clock(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
//Enable internal clock and wait till it is stable.
|
//Enable internal clock and wait till it is stable.
|
||||||
sdmmc->regs->clkcon |= SDHCI_CLOCK_INT_EN;
|
sdmmc->regs->clkcon |= SDHCI_CLOCK_INT_EN;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
u32 timeout = get_tmr_ms() + 2000;
|
u32 timeout = get_tmr_ms() + 2000;
|
||||||
while (!(sdmmc->regs->clkcon & SDHCI_CLOCK_INT_STABLE))
|
while (!(sdmmc->regs->clkcon & SDHCI_CLOCK_INT_STABLE))
|
||||||
{
|
{
|
||||||
|
@ -724,6 +745,7 @@ static int _sdmmc_autocal_config_offset(sdmmc_t *sdmmc, u32 power)
|
||||||
off_pd = 5;
|
off_pd = 5;
|
||||||
off_pu = 5;
|
off_pu = 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_1:
|
case SDMMC_1:
|
||||||
if (power == SDMMC_POWER_1_8)
|
if (power == SDMMC_POWER_1_8)
|
||||||
{
|
{
|
||||||
|
@ -788,7 +810,7 @@ DPRINTF("norintsts %08X, errintsts %08X\n", norintsts, errintsts);
|
||||||
|
|
||||||
static int _sdmmc_wait_response(sdmmc_t *sdmmc)
|
static int _sdmmc_wait_response(sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
u32 timeout = get_tmr_ms() + 2000;
|
u32 timeout = get_tmr_ms() + 2000;
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -839,7 +861,7 @@ int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Recalibrate periodically for SDMMC1.
|
// Recalibrate periodically for SDMMC1.
|
||||||
if ((sdmmc->id == SDMMC_1) && sdmmc->auto_cal_enabled)
|
if ((sdmmc->id == SDMMC_1) && sdmmc->powersave_enabled)
|
||||||
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
||||||
|
|
||||||
bool should_disable_sd_clock = false;
|
bool should_disable_sd_clock = false;
|
||||||
|
@ -847,7 +869,7 @@ int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp)
|
||||||
{
|
{
|
||||||
should_disable_sd_clock = true;
|
should_disable_sd_clock = true;
|
||||||
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
|
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,6 +1069,16 @@ bool sdmmc_get_sd_inserted()
|
||||||
return (!gpio_read(GPIO_PORT_Z, GPIO_PIN_1));
|
return (!gpio_read(GPIO_PORT_Z, GPIO_PIN_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _sdmmc_config_sdmmc1_schmitt()
|
||||||
|
{
|
||||||
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_CLK) |= PINMUX_SCHMT;
|
||||||
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_CMD) |= PINMUX_SCHMT;
|
||||||
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT3) |= PINMUX_SCHMT;
|
||||||
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT2) |= PINMUX_SCHMT;
|
||||||
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT1) |= PINMUX_SCHMT;
|
||||||
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT0) |= PINMUX_SCHMT;
|
||||||
|
}
|
||||||
|
|
||||||
static int _sdmmc_config_sdmmc1()
|
static int _sdmmc_config_sdmmc1()
|
||||||
{
|
{
|
||||||
// Configure SD card detect.
|
// Configure SD card detect.
|
||||||
|
@ -1062,15 +1094,17 @@ static int _sdmmc_config_sdmmc1()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pinmux config:
|
* Pinmux config:
|
||||||
* DRV_TYPE = DRIVE_2X
|
* DRV_TYPE = DRIVE_2X (for 33 Ohm driver)
|
||||||
* E_SCHMT = ENABLE (for 1.8V), DISABLE (for 3.3V)
|
* E_SCHMT = ENABLE (for 1.8V), DISABLE (for 3.3V)
|
||||||
* E_INPUT = ENABLE
|
* E_INPUT = ENABLE
|
||||||
* TRISTATE = PASSTHROUGH
|
* TRISTATE = PASSTHROUGH
|
||||||
* APB_MISC_GP_SDMMCx_CLK_LPBK_CONTROL = SDMMCx_CLK_PAD_E_LPBK for CLK
|
* APB_MISC_GP_SDMMCx_CLK_LPBK_CONTROL = SDMMCx_CLK_PAD_E_LPBK for CLK
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Enable deep loopback for SDMMC1 CLK pad.
|
||||||
|
APB_MISC(APB_MISC_GP_SDMMC1_CLK_LPBK_CONTROL) = 1;
|
||||||
|
|
||||||
// Configure SDMMC1 pinmux.
|
// Configure SDMMC1 pinmux.
|
||||||
APB_MISC(APB_MISC_GP_SDMMC1_CLK_LPBK_CONTROL) = 1; // Enable deep loopback for SDMMC1 CLK pad.
|
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_CLK) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED;
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_CLK) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED;
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_CMD) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_CMD) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT3) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
|
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT3) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
|
||||||
|
@ -1093,7 +1127,7 @@ static int _sdmmc_config_sdmmc1()
|
||||||
gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_ENABLE);
|
gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_ENABLE);
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
|
||||||
// Enable SD card power.
|
// Enable SD card IO power.
|
||||||
max77620_regulator_set_voltage(REGULATOR_LDO2, 3300000);
|
max77620_regulator_set_voltage(REGULATOR_LDO2, 3300000);
|
||||||
max77620_regulator_enable(REGULATOR_LDO2, 1);
|
max77620_regulator_enable(REGULATOR_LDO2, 1);
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
@ -1113,6 +1147,7 @@ static void _sdmmc_config_emmc(u32 id)
|
||||||
// Unset park for pads.
|
// Unset park for pads.
|
||||||
APB_MISC(APB_MISC_GP_EMMC2_PAD_CFGPADCTRL) &= 0xF8003FFF;
|
APB_MISC(APB_MISC_GP_EMMC2_PAD_CFGPADCTRL) &= 0xF8003FFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_4:
|
case SDMMC_4:
|
||||||
// Unset park for pads.
|
// Unset park for pads.
|
||||||
APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) &= 0xF8003FFF;
|
APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) &= 0xF8003FFF;
|
||||||
|
@ -1122,8 +1157,11 @@ static void _sdmmc_config_emmc(u32 id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int auto_cal_enable)
|
int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int powersave_enable)
|
||||||
{
|
{
|
||||||
|
u32 clock;
|
||||||
|
u16 divisor;
|
||||||
|
|
||||||
const u32 trim_values[] = { 2, 8, 3, 8 };
|
const u32 trim_values[] = { 2, 8, 3, 8 };
|
||||||
|
|
||||||
if (id > SDMMC_4 || id == SDMMC_3)
|
if (id > SDMMC_4 || id == SDMMC_3)
|
||||||
|
@ -1142,37 +1180,41 @@ int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int a
|
||||||
if (!_sdmmc_config_sdmmc1())
|
if (!_sdmmc_config_sdmmc1())
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDMMC_2:
|
case SDMMC_2:
|
||||||
case SDMMC_4:
|
case SDMMC_4:
|
||||||
_sdmmc_config_emmc(id);
|
_sdmmc_config_emmc(id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable clock if enabled.
|
||||||
if (clock_sdmmc_is_not_reset_and_enabled(id))
|
if (clock_sdmmc_is_not_reset_and_enabled(id))
|
||||||
{
|
{
|
||||||
_sdmmc_sd_clock_disable(sdmmc);
|
_sdmmc_sd_clock_disable(sdmmc);
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 clock;
|
// Configure and enable selected clock.
|
||||||
u16 divisor;
|
|
||||||
clock_sdmmc_get_card_clock_div(&clock, &divisor, type);
|
clock_sdmmc_get_card_clock_div(&clock, &divisor, type);
|
||||||
clock_sdmmc_enable(id, clock);
|
clock_sdmmc_enable(id, clock);
|
||||||
|
|
||||||
sdmmc->clock_stopped = 0;
|
sdmmc->clock_stopped = 0;
|
||||||
|
|
||||||
//TODO: make this skip-able.
|
// Set default pad IO trimming configuration.
|
||||||
sdmmc->regs->iospare |= 0x80000; // Enable muxing.
|
sdmmc->regs->iospare |= 0x80000; // Enable muxing.
|
||||||
sdmmc->regs->veniotrimctl &= 0xFFFFFFFB; // Set Band Gap VREG to supply DLL.
|
sdmmc->regs->veniotrimctl &= 0xFFFFFFFB; // Set Band Gap VREG to supply DLL.
|
||||||
sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xE0FFFFFB) | (trim_values[sdmmc->id] << 24);
|
sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xE0FFFFFB) | (trim_values[sdmmc->id] << 24);
|
||||||
sdmmc->regs->sdmemcmppadctl =
|
sdmmc->regs->sdmemcmppadctl =
|
||||||
(sdmmc->regs->sdmemcmppadctl & TEGRA_MMC_SDMEMCOMPPADCTRL_COMP_VREF_SEL_MASK) | 7;
|
(sdmmc->regs->sdmemcmppadctl & TEGRA_MMC_SDMEMCOMPPADCTRL_COMP_VREF_SEL_MASK) | 7;
|
||||||
|
|
||||||
|
// Configure auto calibration values.
|
||||||
if (!_sdmmc_autocal_config_offset(sdmmc, power))
|
if (!_sdmmc_autocal_config_offset(sdmmc, power))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// Calibrate pads.
|
||||||
_sdmmc_autocal_execute(sdmmc, power);
|
_sdmmc_autocal_execute(sdmmc, power);
|
||||||
|
|
||||||
|
// Enable internal clock and power.
|
||||||
if (_sdmmc_enable_internal_clock(sdmmc))
|
if (_sdmmc_enable_internal_clock(sdmmc))
|
||||||
{
|
{
|
||||||
sdmmc_set_bus_width(sdmmc, bus_width);
|
sdmmc_set_bus_width(sdmmc, bus_width);
|
||||||
|
@ -1180,15 +1222,14 @@ int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int a
|
||||||
|
|
||||||
if (sdmmc_setup_clock(sdmmc, type))
|
if (sdmmc_setup_clock(sdmmc, type))
|
||||||
{
|
{
|
||||||
sdmmc_card_clock_ctrl(sdmmc, auto_cal_enable);
|
sdmmc_card_clock_powersave(sdmmc, powersave_enable);
|
||||||
_sdmmc_card_clock_enable(sdmmc);
|
_sdmmc_card_clock_enable(sdmmc);
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1213,7 +1254,7 @@ void sdmmc_end(sdmmc_t *sdmmc)
|
||||||
usleep(1000); // To power cycle, min 1ms without power is needed.
|
usleep(1000); // To power cycle, min 1ms without power is needed.
|
||||||
}
|
}
|
||||||
|
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
clock_sdmmc_disable(sdmmc->id);
|
clock_sdmmc_disable(sdmmc->id);
|
||||||
sdmmc->clock_stopped = 1;
|
sdmmc->clock_stopped = 1;
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1274,7 @@ int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *b
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Recalibrate periodically for SDMMC1.
|
// Recalibrate periodically for SDMMC1.
|
||||||
if (sdmmc->id == SDMMC_1 && sdmmc->auto_cal_enabled)
|
if (sdmmc->id == SDMMC_1 && sdmmc->powersave_enabled)
|
||||||
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
_sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
|
||||||
|
|
||||||
int should_disable_sd_clock = 0;
|
int should_disable_sd_clock = 0;
|
||||||
|
@ -1241,7 +1282,7 @@ int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *b
|
||||||
{
|
{
|
||||||
should_disable_sd_clock = 1;
|
should_disable_sd_clock = 1;
|
||||||
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
|
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,7 +1303,7 @@ int sdmmc_enable_low_voltage(sdmmc_t *sdmmc)
|
||||||
if (!sdmmc_setup_clock(sdmmc, SDHCI_TIMING_UHS_SDR12))
|
if (!sdmmc_setup_clock(sdmmc, SDHCI_TIMING_UHS_SDR12))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
|
|
||||||
// Switch to 1.8V and wait for regulator to stabilize. Assume max possible wait needed.
|
// Switch to 1.8V and wait for regulator to stabilize. Assume max possible wait needed.
|
||||||
max77620_regulator_set_voltage(REGULATOR_LDO2, 1800000);
|
max77620_regulator_set_voltage(REGULATOR_LDO2, 1800000);
|
||||||
|
@ -1272,24 +1313,19 @@ int sdmmc_enable_low_voltage(sdmmc_t *sdmmc)
|
||||||
PMC(APBDEV_PMC_PWR_DET_VAL) &= ~(PMC_PWR_DET_SDMMC1_IO_EN);
|
PMC(APBDEV_PMC_PWR_DET_VAL) &= ~(PMC_PWR_DET_SDMMC1_IO_EN);
|
||||||
|
|
||||||
// Enable schmitt trigger for better duty cycle and low jitter clock.
|
// Enable schmitt trigger for better duty cycle and low jitter clock.
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_CLK) |= PINMUX_SCHMT;
|
_sdmmc_config_sdmmc1_schmitt();
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_CMD) |= PINMUX_SCHMT;
|
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT3) |= PINMUX_SCHMT;
|
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT2) |= PINMUX_SCHMT;
|
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT1) |= PINMUX_SCHMT;
|
|
||||||
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT0) |= PINMUX_SCHMT;
|
|
||||||
|
|
||||||
_sdmmc_autocal_config_offset(sdmmc, SDMMC_POWER_1_8);
|
_sdmmc_autocal_config_offset(sdmmc, SDMMC_POWER_1_8);
|
||||||
_sdmmc_autocal_execute(sdmmc, SDMMC_POWER_1_8);
|
_sdmmc_autocal_execute(sdmmc, SDMMC_POWER_1_8);
|
||||||
_sdmmc_set_io_power(sdmmc, SDMMC_POWER_1_8);
|
_sdmmc_set_io_power(sdmmc, SDMMC_POWER_1_8);
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
msleep(5); // Wait minimum 5ms before turning on the card clock.
|
msleep(5); // Wait minimum 5ms before turning on the card clock.
|
||||||
|
|
||||||
// Turn on SDCLK.
|
// Turn on SDCLK.
|
||||||
if (sdmmc->regs->hostctl2 & SDHCI_CTRL_VDD_180)
|
if (sdmmc->regs->hostctl2 & SDHCI_CTRL_VDD_180)
|
||||||
{
|
{
|
||||||
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
|
||||||
_sdmmc_get_clkcon(sdmmc);
|
_sdmmc_commit_changes(sdmmc);
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
if ((sdmmc->regs->prnsts & SDHCI_DATA_LVL_MASK) == SDHCI_DATA_LVL_MASK)
|
if ((sdmmc->regs->prnsts & SDHCI_DATA_LVL_MASK) == SDHCI_DATA_LVL_MASK)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -200,8 +200,8 @@
|
||||||
#define SDHCI_CAN_64BIT 0x10000000
|
#define SDHCI_CAN_64BIT 0x10000000
|
||||||
|
|
||||||
/*! SDMMC Low power features. */
|
/*! SDMMC Low power features. */
|
||||||
#define SDMMC_AUTO_CAL_DISABLE 0
|
#define SDMMC_POWER_SAVE_DISABLE 0
|
||||||
#define SDMMC_AUTO_CAL_ENABLE 1
|
#define SDMMC_POWER_SAVE_ENABLE 1
|
||||||
|
|
||||||
/*! Helper for SWITCH command argument. */
|
/*! Helper for SWITCH command argument. */
|
||||||
#define SDMMC_SWITCH(mode, index, value) (((mode) << 24) | ((index) << 16) | ((value) << 8))
|
#define SDMMC_SWITCH(mode, index, value) (((mode) << 24) | ((index) << 16) | ((value) << 8))
|
||||||
|
@ -213,7 +213,7 @@ typedef struct _sdmmc_t
|
||||||
u32 id;
|
u32 id;
|
||||||
u32 divisor;
|
u32 divisor;
|
||||||
u32 clock_stopped;
|
u32 clock_stopped;
|
||||||
int auto_cal_enabled;
|
int powersave_enabled;
|
||||||
int card_clock_enabled;
|
int card_clock_enabled;
|
||||||
int venclkctl_set;
|
int venclkctl_set;
|
||||||
u32 venclkctl_tap;
|
u32 venclkctl_tap;
|
||||||
|
@ -246,14 +246,14 @@ typedef struct _sdmmc_req_t
|
||||||
int sdmmc_get_io_power(sdmmc_t *sdmmc);
|
int sdmmc_get_io_power(sdmmc_t *sdmmc);
|
||||||
u32 sdmmc_get_bus_width(sdmmc_t *sdmmc);
|
u32 sdmmc_get_bus_width(sdmmc_t *sdmmc);
|
||||||
void sdmmc_set_bus_width(sdmmc_t *sdmmc, u32 bus_width);
|
void sdmmc_set_bus_width(sdmmc_t *sdmmc, u32 bus_width);
|
||||||
void sdmmc_set_tap_value(sdmmc_t *sdmmc);
|
void sdmmc_save_tap_value(sdmmc_t *sdmmc);
|
||||||
int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type);
|
int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type);
|
||||||
void sdmmc_card_clock_ctrl(sdmmc_t *sdmmc, int auto_cal_enable);
|
void sdmmc_card_clock_powersave(sdmmc_t *sdmmc, int powersave_enable);
|
||||||
int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type);
|
int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type);
|
||||||
int sdmmc_tuning_execute(sdmmc_t *sdmmc, u32 type, u32 cmd);
|
int sdmmc_tuning_execute(sdmmc_t *sdmmc, u32 type, u32 cmd);
|
||||||
int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp);
|
int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp);
|
||||||
bool sdmmc_get_sd_inserted();
|
bool sdmmc_get_sd_inserted();
|
||||||
int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int auto_cal_enable);
|
int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int powersave_enable);
|
||||||
void sdmmc_end(sdmmc_t *sdmmc);
|
void sdmmc_end(sdmmc_t *sdmmc);
|
||||||
void sdmmc_init_cmd(sdmmc_cmd_t *cmdbuf, u16 cmd, u32 arg, u32 rsp_type, u32 check_busy);
|
void sdmmc_init_cmd(sdmmc_cmd_t *cmdbuf, u16 cmd, u32 arg, u32 rsp_type, u32 check_busy);
|
||||||
int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *blkcnt_out);
|
int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *blkcnt_out);
|
||||||
|
|
|
@ -103,6 +103,7 @@ typedef struct _t210_sdmmc_t
|
||||||
vu32 iospare;
|
vu32 iospare;
|
||||||
vu32 mcciffifoctl;
|
vu32 mcciffifoctl;
|
||||||
vu32 timeoutwcoal;
|
vu32 timeoutwcoal;
|
||||||
|
vu32 unk1;
|
||||||
} t210_sdmmc_t;
|
} t210_sdmmc_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue