summaryrefslogtreecommitdiffstats
path: root/firmware/target
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2009-07-17 22:28:49 +0000
committerFrank Gevaerts <frank@gevaerts.be>2009-07-17 22:28:49 +0000
commitc0a5a67387c4eec3db3bad4da77ba5126faf03c4 (patch)
treed7e61f6287c5fcdce903489b6b72d474225b98a7 /firmware/target
parentbb3b57f64594ba517e06add4cfeff72b2b06e65b (diff)
downloadrockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.tar.gz
rockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.tar.bz2
rockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.zip
Commit FS#9545, storage cleanup and multi-driver support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c58
-rw-r--r--firmware/target/arm/ata-nand-telechips.c51
-rw-r--r--firmware/target/arm/ata-sd-pp.c36
-rw-r--r--firmware/target/arm/s5l8700/ata-nand-s5l8700.c15
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c16
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-target.h4
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c25
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c35
8 files changed, 188 insertions, 52 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c
index 8a18a70826..bca52a09f1 100644
--- a/firmware/target/arm/as3525/ata_sd_as3525.c
+++ b/firmware/target/arm/as3525/ata_sd_as3525.c
@@ -24,7 +24,7 @@
/* TODO: Find the real capacity of >2GB models (will be useful for USB) */
-#include "config.h" /* for HAVE_MULTIVOLUME & AMS_OF_SIZE */
+#include "config.h" /* for HAVE_MULTIDRIVE & AMS_OF_SIZE */
#include "fat.h"
#include "thread.h"
#include "led.h"
@@ -88,9 +88,9 @@
#define INTERNAL_AS3525 0 /* embedded SD card */
#define SD_SLOT_AS3525 1 /* SD slot if present */
-static const int pl180_base[NUM_VOLUMES] = {
+static const int pl180_base[NUM_DRIVES] = {
NAND_FLASH_BASE
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
, SD_MCI_BASE
#endif
};
@@ -101,7 +101,7 @@ static void init_pl180_controller(const int drive);
#define SECTOR_SIZE 512 /* XXX: different sector sizes ? */
#define BLOCKS_PER_BANK 0x7a7800
-static tCardInfo card_info[NUM_VOLUMES];
+static tCardInfo card_info[NUM_DRIVES];
/* maximum timeouts recommanded in the SD Specification v2.00 */
#define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */
@@ -169,7 +169,7 @@ void INT_NAND(void)
MCI_CLEAR(INTERNAL_AS3525) = status;
}
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
void INT_MCI0(void)
{
const int status = MCI_STATUS(SD_SLOT_AS3525);
@@ -436,7 +436,7 @@ static void init_pl180_controller(const int drive)
MCI_MASK0(drive) = MCI_MASK1(drive) = MCI_ERROR | MCI_DATA_END;
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
VIC_INT_ENABLE |=
(drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0;
@@ -478,7 +478,7 @@ int sd_init(void)
CGU_PERI |= CGU_NAF_CLOCK_ENABLE;
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
CGU_PERI |= CGU_MCI_CLOCK_ENABLE;
CCU_IO &= ~(1<<3); /* bits 3:2 = 01, xpd is SD interface */
CCU_IO |= (1<<2);
@@ -490,7 +490,7 @@ int sd_init(void)
ret = sd_init_card(INTERNAL_AS3525);
if(ret < 0)
return ret;
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
init_pl180_controller(SD_SLOT_AS3525);
#endif
@@ -509,17 +509,17 @@ int sd_init(void)
}
#ifdef HAVE_HOTSWAP
-bool sd_removable(IF_MV_NONVOID(int drive))
+bool sd_removable(IF_MD_NONVOID(int drive))
{
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive=0;
#endif
return (drive==1);
}
-bool sd_present(IF_MV_NONVOID(int drive))
+bool sd_present(IF_MD_NONVOID(int drive))
{
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive=0;
#endif
return (card_info[drive].initialized && card_info[drive].numblocks > 0);
@@ -619,10 +619,10 @@ static int sd_select_bank(signed char bank)
return 0;
}
-static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
+static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
int count, void* buf, const bool write)
{
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive = 0;
#endif
int ret = 0;
@@ -774,18 +774,18 @@ sd_transfer_error:
return ret;
}
-int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count,
+int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
void* buf)
{
- return sd_transfer_sectors(IF_MV2(drive,) start, count, buf, false);
+ return sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false);
}
-int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
+int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
const void* buf)
{
#ifdef BOOTLOADER /* we don't need write support in bootloader */
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
(void) drive;
#endif
(void) start;
@@ -793,7 +793,7 @@ int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
(void) buf;
return -1;
#else
- return sd_transfer_sectors(IF_MV2(drive,) start, count, (void*)buf, true);
+ return sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true);
#endif
}
@@ -807,7 +807,7 @@ void sd_enable(bool on)
{
/* buttonlight AMSes need a bit of special handling for the buttonlight here,
* due to the dual mapping of GPIOD and XPD */
-#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIVOLUME)
+#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE)
extern int buttonlight_is_on;
#endif
if (sd_enabled == on)
@@ -815,7 +815,7 @@ void sd_enable(bool on)
if(on)
{
CGU_PERI |= CGU_NAF_CLOCK_ENABLE;
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
CGU_PERI |= CGU_MCI_CLOCK_ENABLE;
#ifdef HAVE_BUTTON_LIGHT
CCU_IO |= (1<<2);
@@ -832,7 +832,7 @@ void sd_enable(bool on)
else
{
CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE;
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
#ifdef HAVE_BUTTON_LIGHT
CCU_IO &= ~(1<<2);
if (buttonlight_is_on)
@@ -882,3 +882,17 @@ void card_enable_monitoring_target(bool on)
#endif
#endif /* BOOTLOADER */
+
+#ifdef CONFIG_STORAGE_MULTI
+int sd_num_drives(int first_drive)
+{
+ /* We don't care which logical drive number(s) we have been assigned */
+ (void)first_drive;
+
+#ifdef HAVE_MULTIDRIVE
+ return 2;
+#else
+ return 1;
+#endif
+}
+#endif
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index 8bef57ee21..ffe6de897e 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -696,10 +696,10 @@ static void read_inplace_writes_cache(int bank, int phys_segment)
}
-int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
+int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
void* inbuf)
{
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
(void)drive; /* unused for now */
#endif
@@ -753,11 +753,10 @@ nand_read_error:
return ret;
}
-
-int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
+int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
const void* outbuf)
{
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
(void)drive; /* unused for now */
#endif
@@ -770,8 +769,12 @@ int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
#ifdef STORAGE_GET_INFO
-void nand_get_info(struct storage_info *info)
+void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
{
+#ifdef HAVE_MULTIDRIVE
+ (void)drive; /* unused for now */
+#endif
+
/* firmware version */
info->revision="0.00";
@@ -913,3 +916,39 @@ void nand_spindown(int seconds)
{
(void)seconds;
}
+
+#ifdef CONFIG_STORAGE_MULTI
+
+int nand_num_drives(int first_drive)
+{
+ /* We don't care which logical drive number we have been assigned */
+ (void)first_drive;
+
+ return 1;
+}
+
+void nand_sleepnow(void)
+{
+}
+
+bool nand_disk_is_active(void)
+{
+ return false;
+}
+
+int nand_soft_reset(void)
+{
+ return 0;
+}
+
+int nand_spinup_time(void)
+{
+ return 0;
+}
+
+void nand_enable(bool onoff)
+{
+ (void)onoff;
+}
+
+#endif /* CONFIG_STORAGE_MULTI */
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c
index 1a76eeeba2..77d3c3dc31 100644
--- a/firmware/target/arm/ata-sd-pp.c
+++ b/firmware/target/arm/ata-sd-pp.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include "config.h" /* for HAVE_MULTIVOLUME */
+#include "config.h" /* for HAVE_MULTIDRIVE */
#include "fat.h"
#include "hotswap.h"
#ifdef HAVE_HOTSWAP
@@ -166,10 +166,10 @@ struct sd_card_status
int retry_max;
};
-static struct sd_card_status sd_status[NUM_VOLUMES] =
+static struct sd_card_status sd_status[NUM_DRIVES] =
{
{ 0, 1 },
-#ifdef HAVE_MULTIVOLUME
+#ifdef HAVE_MULTIDRIVE
{ 0, 10 }
#endif
};
@@ -839,10 +839,10 @@ static void sd_select_device(int card_no)
/* API Functions */
-int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
+int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
void* inbuf)
{
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive = 0;
#endif
int ret;
@@ -956,13 +956,13 @@ sd_read_error:
}
}
-int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
+int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
const void* outbuf)
{
/* Write support is not finished yet */
/* TODO: The standard suggests using ACMD23 prior to writing multiple blocks
to improve performance */
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive = 0;
#endif
int ret;
@@ -1330,19 +1330,33 @@ long sd_last_disk_activity(void)
}
#ifdef HAVE_HOTSWAP
-bool sd_removable(IF_MV_NONVOID(int drive))
+bool sd_removable(IF_MD_NONVOID(int drive))
{
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive=0;
#endif
return (drive==1);
}
-bool sd_present(IF_MV_NONVOID(int drive))
+bool sd_present(IF_MD_NONVOID(int drive))
{
-#ifndef HAVE_MULTIVOLUME
+#ifndef HAVE_MULTIDRIVE
const int drive=0;
#endif
return (card_info[drive].initialized && card_info[drive].numblocks > 0);
}
#endif
+
+#ifdef CONFIG_STORAGE_MULTI
+int sd_num_drives(int first_drive)
+{
+ /* We don't care which logical drive number(s) we have been assigned */
+ (void)first_drive;
+
+#ifdef HAVE_MULTIDRIVE
+ return 2;
+#else
+ return 1;
+#endif
+}
+#endif
diff --git a/firmware/target/arm/s5l8700/ata-nand-s5l8700.c b/firmware/target/arm/s5l8700/ata-nand-s5l8700.c
index 3fc3c0efea..f268558128 100644
--- a/firmware/target/arm/s5l8700/ata-nand-s5l8700.c
+++ b/firmware/target/arm/s5l8700/ata-nand-s5l8700.c
@@ -46,7 +46,7 @@ void nand_led(bool onoff)
led(onoff);
}
-int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
+int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
void* inbuf)
{
(void)start;
@@ -55,7 +55,7 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
return 0;
}
-int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
+int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
const void* outbuf)
{
(void)start;
@@ -82,7 +82,7 @@ void nand_enable(bool on)
(void)on;
}
-void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
+void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
{
(void)info;
}
@@ -98,3 +98,12 @@ int nand_init(void)
return 0;
}
+#ifdef CONFIG_STORAGE_MULTI
+int nand_num_drives(int first_drive)
+{
+ /* We don't care which logical drive number(s) we have been assigned */
+ (void)first_drive;
+
+ return 1;
+}
+#endif
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
index f9acdf5eb2..f84d904205 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
@@ -125,8 +125,8 @@ void GIO2(void)
#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */
-extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+extern int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+extern int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
struct main_header
{
@@ -378,14 +378,14 @@ static inline unsigned long map_sector(unsigned long sector)
return cfs_start+sectors[sector/64]*64+sector%64;
}
-int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
+int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf)
{
if(!cfs_inited)
cfs_init();
/* Check if count is lesser than or equal to 1 native CFS sector */
if(count <= 64)
- return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf);
+ return _ata_read_sectors(IF_MD2(drive,) map_sector(start), count, buf);
else
{
int i, ret;
@@ -394,7 +394,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* bu
/* Read sectors in parts of 0x8000 */
for(i=0; i<count; i+=64)
{
- ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
+ ret = _ata_read_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
if(ret != 0)
return ret;
@@ -405,7 +405,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* bu
}
}
-int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
+int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf)
{
if(!cfs_inited)
cfs_init();
@@ -413,7 +413,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v
#if 0 /* Disabled for now */
/* Check if count is lesser than or equal to 1 native CFS sector */
if(count <= 64)
- return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf);
+ return _ata_write_sectors(IF_MD2(drive,) map_sector(start), count, buf);
else
{
int i, ret;
@@ -422,7 +422,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v
/* Read sectors in parts of 0x8000 */
for(i=0; i<count; i+=64)
{
- ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
+ ret = _ata_write_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
if(ret != 0)
return ret;
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
index 64c49fe68e..a1d4a90cb8 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
@@ -38,8 +38,8 @@ void copy_write_sectors(const unsigned char* buf, int wordcount);
/* Nasty hack, but Creative is nasty... */
#define ata_read_sectors _ata_read_sectors
#define ata_write_sectors _ata_write_sectors
-extern int _ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-extern int _ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+extern int _ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+extern int _ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
/* General purpose memory region #1 */
#define ATA_IOBASE 0x50FEE000
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
index 8bd7d42e1f..a51dc5e882 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
@@ -707,6 +707,21 @@ void nand_enable(bool on)
(void)on;
}
+/* TODO */
+long nand_last_disk_activity(void)
+{
+ return 0;
+}
+
+int nand_spinup_time(void)
+{
+ return 0;
+}
+
+void nand_sleepnow(void)
+{
+}
+
#ifdef STORAGE_GET_INFO
void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
{
@@ -725,3 +740,13 @@ void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
info->sector_size = 512;
}
#endif
+
+#ifdef CONFIG_STORAGE_MULTI
+int nand_num_drives(int first_drive)
+{
+ /* We don't care which logical drive number(s) we have been assigned */
+ (void)first_drive;
+
+ return 1;
+}
+#endif
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 5de40c99dc..b1a9d599d9 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -1328,6 +1328,31 @@ long sd_last_disk_activity(void)
return last_disk_activity;
}
+int sd_spinup_time(void)
+{
+ return 0;
+}
+
+void sd_enable(bool on)
+{
+ (void)on;
+}
+
+void sd_sleepnow(void)
+{
+}
+
+/* TODO */
+bool sd_disk_is_active(void)
+{
+ return false;
+}
+
+int sd_soft_reset(void)
+{
+ return 0;
+}
+
#ifdef HAVE_HOTSWAP
bool sd_removable(IF_MV_NONVOID(int drive))
{
@@ -1346,3 +1371,13 @@ bool sd_present(IF_MV_NONVOID(int drive))
#endif
return (card.numblocks > 0 && card_detect_target());
}
+
+#ifdef CONFIG_STORAGE_MULTI
+int sd_num_drives(int first_drive)
+{
+ /* We don't care which logical drive number(s) we have been assigned */
+ (void)first_drive;
+
+ return 1;
+}
+#endif