imx233: various sdmmc fixes
Change-Id: I261d0bdea1e7c5bc9139b10bf42e7ce7ce6b6dd8
This commit is contained in:
parent
fbee03e0f0
commit
8ed8a79f5c
1 changed files with 46 additions and 16 deletions
|
@ -181,6 +181,19 @@ static int init_drive(int drive);
|
|||
* refer to sd/mmc drive indexes. We keep two maps sd->sdmmc and mmc->sdmmc
|
||||
* to find the sdmmc index from the sd or mmc one */
|
||||
|
||||
static int sdmmc_present(int drive)
|
||||
{
|
||||
if(SDMMC_FLAGS(drive) & REMOVABLE)
|
||||
return imx233_ssp_sdmmc_detect(SDMMC_SSP(drive));
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline int sdmmc_removable(int drive)
|
||||
{
|
||||
return SDMMC_FLAGS(drive) & REMOVABLE;
|
||||
}
|
||||
|
||||
static void sdmmc_detect_callback(int ssp)
|
||||
{
|
||||
/* This is called only if the state was stable for 300ms - check state
|
||||
|
@ -291,7 +304,6 @@ static int init_sd_card(int drive)
|
|||
/* SSPCLK @ 96MHz
|
||||
* gives bitrate of 96000 / 240 / 1 = 400kHz */
|
||||
imx233_ssp_set_timings(ssp, 240, 0, 0xffff);
|
||||
|
||||
imx233_ssp_sd_mmc_power_up_sequence(ssp);
|
||||
imx233_ssp_set_bus_width(ssp, 1);
|
||||
imx233_ssp_set_block_size(ssp, 9);
|
||||
|
@ -671,7 +683,9 @@ static void sdmmc_thread(void)
|
|||
* prevent deadlocking via disk_mount that
|
||||
* would cause a reverse-order attempt with
|
||||
* another thread */
|
||||
#ifdef HAVE_HOTSWAP
|
||||
fat_lock();
|
||||
#endif
|
||||
|
||||
/* We now have exclusive control of fat cache and sd.
|
||||
* Release "by force", ensure file
|
||||
|
@ -681,7 +695,7 @@ static void sdmmc_thread(void)
|
|||
{
|
||||
int drive = sd_map[sd_drive];
|
||||
/* Skip non-removable drivers */
|
||||
if(!sd_removable(sd_drive))
|
||||
if(!sdmmc_removable(drive))
|
||||
continue;
|
||||
/* lock-out card activity - direct calls
|
||||
* into driver that bypass the fat cache */
|
||||
|
@ -709,7 +723,9 @@ static void sdmmc_thread(void)
|
|||
mutex_unlock(&mutex[drive]);
|
||||
}
|
||||
/* Access is now safe */
|
||||
#ifdef HAVE_HOTSWAP
|
||||
fat_unlock();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -764,23 +780,10 @@ static int sdmmc_init(void)
|
|||
imx233_ssp_sdmmc_setup_detect(SDMMC_SSP(drive), true, sdmmc_detect_callback,
|
||||
false, SDMMC_FLAGS(drive) & DETECT_INVERTED);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sdmmc_present(int drive)
|
||||
{
|
||||
if(SDMMC_FLAGS(drive) & REMOVABLE)
|
||||
return imx233_ssp_sdmmc_detect(SDMMC_SSP(drive));
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline int sdmmc_removable(int drive)
|
||||
{
|
||||
return SDMMC_FLAGS(drive) & REMOVABLE;
|
||||
}
|
||||
|
||||
#if CONFIG_STORAGE & STORAGE_SD
|
||||
int sd_init(void)
|
||||
{
|
||||
|
@ -807,11 +810,17 @@ int sd_num_drives(int first_drive)
|
|||
|
||||
bool sd_present(IF_MV_NONVOID(int sd_drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
int sd_drive = 0;
|
||||
#endif
|
||||
return sdmmc_present(sd_map[sd_drive]);
|
||||
}
|
||||
|
||||
bool sd_removable(IF_MV_NONVOID(int sd_drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
int sd_drive = 0;
|
||||
#endif
|
||||
return sdmmc_removable(sd_map[sd_drive]);
|
||||
}
|
||||
|
||||
|
@ -830,11 +839,17 @@ void sd_enable(bool on)
|
|||
|
||||
int sd_read_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, void *buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int sd_drive = 0;
|
||||
#endif
|
||||
return transfer_sectors(sd_map[sd_drive], start, count, buf, true);
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MD2(int sd_drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int sd_drive = 0;
|
||||
#endif
|
||||
return transfer_sectors(sd_map[sd_drive], start, count, (void *)buf, false);
|
||||
}
|
||||
#endif
|
||||
|
@ -857,6 +872,9 @@ int mmc_init(void)
|
|||
|
||||
void mmc_get_info(IF_MD2(int mmc_drive,) struct storage_info *info)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int mmc_drive = 0;
|
||||
#endif
|
||||
int drive = mmc_map[mmc_drive];
|
||||
info->sector_size = 512;
|
||||
info->num_sectors = window_end[drive] - window_start[drive];
|
||||
|
@ -873,11 +891,17 @@ int mmc_num_drives(int first_drive)
|
|||
|
||||
bool mmc_present(IF_MV_NONVOID(int mmc_drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
int mmc_drive = 0;
|
||||
#endif
|
||||
return sdmmc_present(mmc_map[mmc_drive]);
|
||||
}
|
||||
|
||||
bool mmc_removable(IF_MV_NONVOID(int mmc_drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
int mmc_drive = 0;
|
||||
#endif
|
||||
return sdmmc_removable(mmc_map[mmc_drive]);
|
||||
}
|
||||
|
||||
|
@ -938,11 +962,17 @@ int mmc_spinup_time(void)
|
|||
|
||||
int mmc_read_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, void *buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int mmc_drive = 0;
|
||||
#endif
|
||||
return transfer_sectors(mmc_map[mmc_drive], start, count, buf, true);
|
||||
}
|
||||
|
||||
int mmc_write_sectors(IF_MD2(int mmc_drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int mmc_drive = 0;
|
||||
#endif
|
||||
return transfer_sectors(mmc_map[mmc_drive], start, count, (void *)buf, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue