summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c62
1 files changed, 46 insertions, 16 deletions
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index 8c18b284fd..b74c21c08c 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -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,21 +780,8 @@ 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;
+ return 0;
}
#if CONFIG_STORAGE & STORAGE_SD
@@ -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);
}