Fusee: Deployed new SDMMC driver in fusee-secondary. All stages boot now.

Fusee: Fixed wrong argument in se.c function.
Fusee: Improved timers.
This commit is contained in:
hexkyz
2018-07-19 21:07:53 +01:00
parent 49ba91a8f3
commit 3db9ce32fa
44 changed files with 5247 additions and 4802 deletions

View File

@@ -189,7 +189,7 @@ static int sdmmc_device_rw(sdmmc_device_t *device, uint32_t sector, uint32_t num
sdmmc_device_send_status(device);
/* Wait for a while. */
udelay(100000);
mdelay(100);
}
else
break;
@@ -504,8 +504,8 @@ static int sdmmc_sd_send_op_cond(sdmmc_device_t *device, bool is_sd_ver2, bool i
/* Keep checking if timeout expired. */
is_timeout = (get_time_since(timebase) > 2000000);
/* Delay for an appropriate period. */
udelay(10000);
/* Delay for a minimum of 10 milliseconds. */
mdelay(10);
}
return 0;
@@ -1161,8 +1161,8 @@ static int sdmmc_mmc_send_op_cond(sdmmc_device_t *device, SdmmcBusVoltage bus_vo
/* Keep checking if timeout expired. */
is_timeout = (get_time_since(timebase) > 2000000);
/* Delay for an appropriate period. */
udelay(10000);
/* Delay for a minimum of 10 milliseconds. */
mdelay(10);
}
return 0;
@@ -1357,11 +1357,23 @@ static int sdmmc_mmc_select_bkops(sdmmc_device_t *device)
return sdmmc_device_send_status(device);
}
int sdmmc_mmc_select_partition(sdmmc_device_t *device, SdmmcPartitionNum partition)
{
uint32_t arg = (((MMC_SWITCH_MODE_WRITE_BYTE) << 24) | ((EXT_CSD_PART_CONFIG) << 16) | ((partition) << 8));
/* Try to change the active partition. */
if (!sdmmc_mmc_switch(device, arg))
return 0;
/* Peek the current status. */
return sdmmc_device_send_status(device);
}
int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth bus_width, SdmmcBusSpeed bus_speed)
{
uint32_t cid[4] = {0};
uint32_t csd[4] = {0};
uint8_t ext_csd[512] = {0};
uint8_t *ext_csd = (uint8_t *)SDMMC_BOUNCE_BUFFER_ADDRESS; // TODO: Better way to do this.
/* Initialize our device's struct. */
memset(device, 0, sizeof(sdmmc_device_t));
@@ -1376,6 +1388,9 @@ int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth
/* Bind the underlying driver. */
device->sdmmc = sdmmc;
/* Set RCA. */
device->rca = 0x01;
sdmmc_info(sdmmc, "SDMMC driver was successfully initialized for eMMC!");
/* Apply at least 74 clock cycles. eMMC should be ready afterwards. */
@@ -1408,14 +1423,14 @@ int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth
sdmmc_info(sdmmc, "Got CID from eMMC!");
/* Get the eMMC's RCA. */
/* Set the eMMC's RCA. */
if (!sdmmc_mmc_set_relative_addr(device))
{
sdmmc_error(sdmmc, "Failed to get RCA!");
sdmmc_error(sdmmc, "Failed to set RCA!");
return 0;
}
sdmmc_info(sdmmc, "Got RCA (0x%08x) from eMMC!", device->rca);
sdmmc_info(sdmmc, "RCA is now set in eMMC!");
/* Get the eMMC card's CSD. */
if (!sdmmc_device_send_csd(device, csd))
@@ -1484,7 +1499,7 @@ int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth
/* Decode and save the CID. */
sdmmc_mmc_decode_cid(device, cid);
/* TODO: Handle automatic BKOPS properly. Leave it disabled for now. */
if (false && device->ext_csd.bkops && !(device->ext_csd.auto_bkops_en & EXT_CSD_AUTO_BKOPS_MASK))
{
@@ -1507,4 +1522,4 @@ int sdmmc_device_mmc_init(sdmmc_device_t *device, sdmmc_t *sdmmc, SdmmcBusWidth
sdmmc_adjust_sd_clock(sdmmc);
return 1;
}
}