summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2009-07-01 21:49:13 +0000
committerRafaël Carré <rafael.carre@gmail.com>2009-07-01 21:49:13 +0000
commitc0eb9aeb9e89ae33a9f084167147d8eacb9c7c60 (patch)
tree57e96460989d9cccc421486769befb5648601b8c /firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
parent93f6e3df246ff50c24524c9d329f27a06e1845db (diff)
downloadrockbox-c0eb9aeb9e89ae33a9f084167147d8eacb9c7c60.tar.gz
rockbox-c0eb9aeb9e89ae33a9f084167147d8eacb9c7c60.tar.bz2
rockbox-c0eb9aeb9e89ae33a9f084167147d8eacb9c7c60.zip
add firmware/driver/sd.c which contains common code between SD drivers
ingenic SD driver needs more cleanup so it still doesn't use the common code correct a comment in hotswap.c: card_extract_bits assume most significant word of register first (so, use this order) fix debug menu which used MMC specific commands / bits positions in csd/cid move the default block size of 512 into sd.h move the mantissa & exponent table into a single file (sd.c) to reduce binsize. we don't need to export it anymore anyway TODO : ingenic cleanup (will happen soon so building sd.c is not conditional) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21601 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 6e7f62a2e5..d14715c192 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -41,8 +41,6 @@ static long last_disk_activity = -1;
#define DEBUG(x...) logf(x)
-#define BLOCK_SIZE 512
-
#define MMC_INSERT_STATUS() __gpio_get_pin(MMC_CD_PIN)
#define MMC_RESET() __msc_reset()
@@ -1668,7 +1666,12 @@ tCardInfo* card_get_info_target(int card_no)
(void)card_no;
int i, temp;
static tCardInfo card;
-
+
+ static const unsigned char sd_mantissa[] = { /* *10 */
+ 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 };
+ static const unsigned int sd_exponent[] = { /* use varies */
+ 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000 };
+
card.initialized = true;
card.ocr = mmcinfo.ocr;
for(i=0; i<4; i++)
@@ -1707,22 +1710,22 @@ int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf
if (retval && (retval != MMC_ERROR_STATE_MISMATCH))
return retval;
- mmc_simple_cmd(&request, MMC_SET_BLOCKLEN, BLOCK_SIZE, RESPONSE_R1);
+ mmc_simple_cmd(&request, MMC_SET_BLOCKLEN, SD_BLOCK_SIZE, RESPONSE_R1);
if ((retval = mmc_unpack_r1(&request, &r1)))
return retval;
if (sd2_0)
{
mmc_send_cmd(&request, MMC_READ_MULTIPLE_BLOCK, start,
- count, BLOCK_SIZE, RESPONSE_R1, buf);
+ count, SD_BLOCK_SIZE, RESPONSE_R1, buf);
if ((retval = mmc_unpack_r1(&request, &r1)))
return retval;
}
else
{
mmc_send_cmd(&request, MMC_READ_MULTIPLE_BLOCK,
- start * BLOCK_SIZE, count,
- BLOCK_SIZE, RESPONSE_R1, buf);
+ start * SD_BLOCK_SIZE, count,
+ SD_BLOCK_SIZE, RESPONSE_R1, buf);
if ((retval = mmc_unpack_r1(&request, &r1)))
return retval;
}
@@ -1757,14 +1760,14 @@ int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const vo
if (retval && (retval != MMC_ERROR_STATE_MISMATCH))
return retval;
- mmc_simple_cmd(&request, MMC_SET_BLOCKLEN, BLOCK_SIZE, RESPONSE_R1);
+ mmc_simple_cmd(&request, MMC_SET_BLOCKLEN, SD_BLOCK_SIZE, RESPONSE_R1);
if ((retval = mmc_unpack_r1(&request, &r1)))
return retval;
if (sd2_0)
{
mmc_send_cmd(&request, MMC_WRITE_MULTIPLE_BLOCK, start,
- count, BLOCK_SIZE, RESPONSE_R1,
+ count, SD_BLOCK_SIZE, RESPONSE_R1,
(void*)buf);
if ((retval = mmc_unpack_r1(&request, &r1)))
return retval;
@@ -1772,8 +1775,8 @@ int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const vo
else
{
mmc_send_cmd(&request, MMC_WRITE_MULTIPLE_BLOCK,
- start * BLOCK_SIZE, count,
- BLOCK_SIZE, RESPONSE_R1, (void*)buf);
+ start * SD_BLOCK_SIZE, count,
+ SD_BLOCK_SIZE, RESPONSE_R1, (void*)buf);
if ((retval = mmc_unpack_r1(&request, &r1)))
return retval;
}