1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 14:14:38 +02:00

qi-glamo-mmc-multiblock-read.patch

Improve glamo-mmc so that it uses MMC_READ_MULTIPLE_BLOCK and copes with
64 blocks in one command (and STOP sent after each set), instead of sending
a new command per-block

Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
Andy Green 2008-11-28 10:16:41 +00:00 committed by Andy Green
parent f46dc9e4ab
commit cff19a41ce
2 changed files with 27 additions and 10 deletions

View File

@ -400,7 +400,7 @@ const struct board_api board_api_gta02 = {
"rootfstype=ext3 " \ "rootfstype=ext3 " \
"root=/dev/mmcblk0p1 " \ "root=/dev/mmcblk0p1 " \
"console=ttySAC2,115200 " \ "console=ttySAC2,115200 " \
"loglevel=8 " \ "loglevel=4 " \
"init=/sbin/init "\ "init=/sbin/init "\
"ro" "ro"
}, },
@ -420,7 +420,7 @@ const struct board_api board_api_gta02 = {
"rootfstype=jffs2 " \ "rootfstype=jffs2 " \
"root=/dev/mtdblock6 " \ "root=/dev/mtdblock6 " \
"console=ttySAC2,115200 " \ "console=ttySAC2,115200 " \
"loglevel=3 " \ "loglevel=8 " \
"init=/sbin/init "\ "init=/sbin/init "\
"ro" "ro"
}, },

View File

@ -47,6 +47,9 @@ static int mmc_ready = 0;
//static int wide = 0; //static int wide = 0;
static enum card_type card_type = CARDTYPE_NONE; static enum card_type card_type = CARDTYPE_NONE;
#define MULTI_READ_BLOCKS_PER_COMMAND 64
int mmc_read(unsigned long src, u8 *dst, int size); int mmc_read(unsigned long src, u8 *dst, int size);
#define UNSTUFF_BITS(resp,start,size) \ #define UNSTUFF_BITS(resp,start,size) \
@ -422,6 +425,7 @@ int mmc_read(unsigned long src, u8 *dst, int size)
int resp; int resp;
u8 response[16]; u8 response[16];
int size_original = size; int size_original = size;
int lump;
if (((int)dst) & 1) { if (((int)dst) & 1) {
puts("Bad align on dst\n"); puts("Bad align on dst\n");
@ -435,18 +439,23 @@ int mmc_read(unsigned long src, u8 *dst, int size)
return resp; return resp;
while (size) { while (size) {
/* glamo mmc times out as this increases too much */
lump = MULTI_READ_BLOCKS_PER_COMMAND;
if (lump > size)
lump = size;
switch (card_type) { switch (card_type) {
case CARDTYPE_SDHC: /* block addressing */ case CARDTYPE_SDHC: /* block addressing */
resp = mmc_cmd(MMC_READ_SINGLE_BLOCK, resp = mmc_cmd(MMC_READ_MULTIPLE_BLOCK,
src, src,
MMC_CMD_ADTC | MMC_RSP_R1 | MMC_CMD_ADTC | MMC_RSP_R1 |
MMC_DATA_READ, MMC_BLOCK_SIZE, 1, 0, MMC_DATA_READ, MMC_BLOCK_SIZE, lump, 1,
(u16 *)&response[0]); (u16 *)&response[0]);
break; break;
default: /* byte addressing */ default: /* byte addressing */
resp = mmc_cmd(MMC_READ_SINGLE_BLOCK, src * MMC_BLOCK_SIZE, resp = mmc_cmd(MMC_READ_MULTIPLE_BLOCK, src * MMC_BLOCK_SIZE,
MMC_CMD_ADTC | MMC_RSP_R1 | MMC_DATA_READ, MMC_CMD_ADTC | MMC_RSP_R1 | MMC_DATA_READ,
MMC_BLOCK_SIZE, 1, 0, MMC_BLOCK_SIZE, lump, 1,
(u16 *)&response[0]); (u16 *)&response[0]);
break; break;
} }
@ -459,14 +468,22 @@ int mmc_read(unsigned long src, u8 *dst, int size)
0xff00) | 2, GLAMO_REG_CLOCK_GEN8); 0xff00) | 2, GLAMO_REG_CLOCK_GEN8);
do_pio_read((u16 *)dst, MMC_BLOCK_SIZE >> 1); do_pio_read((u16 *)dst, lump * MMC_BLOCK_SIZE >> 1);
if (size) if (size)
size--; size -= lump;
dst += lump * MMC_BLOCK_SIZE;
src += lump;
resp = mmc_cmd(MMC_STOP_TRANSMISSION, 0,
MMC_CMD_AC | MMC_RSP_R1B, 0, 0, 0,
(u16 *)&response[0]);
if (resp)
return resp;
dst += MMC_BLOCK_SIZE;
src++;
} }
return size_original; return size_original;
} }