summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas at>2010-08-11 15:56:03 -0700
committerSandeep Paulraj <s-paulraj@ti.com>2010-08-12 13:50:25 -0400
commitdc41b8bf3df2b2c3bd833f871d88ff5ef40a19f3 (patch)
treedc4543c634a4011cec588676e51cd1fc3fd13d03 /drivers
parent8bbf4307c7a44ecf6a1cff905913a630ac949f18 (diff)
downloadu-boot-imx-dc41b8bf3df2b2c3bd833f871d88ff5ef40a19f3.zip
u-boot-imx-dc41b8bf3df2b2c3bd833f871d88ff5ef40a19f3.tar.gz
u-boot-imx-dc41b8bf3df2b2c3bd833f871d88ff5ef40a19f3.tar.bz2
mmc: omap3: fix block read function
The OMAP3 block read function is not following API and always returning 1 instead of read block count, fix it. Also to simplify code, merge it with with a helper function, which was only called from the block read function. After this patch ext2 filesystem can be used properly. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Tested-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/omap3_mmc.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/mmc/omap3_mmc.c b/drivers/mmc/omap3_mmc.c
index 238f537..15d41e5 100644
--- a/drivers/mmc/omap3_mmc.c
+++ b/drivers/mmc/omap3_mmc.c
@@ -434,42 +434,45 @@ static unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
return 1;
}
-static unsigned char omap_mmc_read_sect(unsigned int start_sec,
- unsigned int num_bytes, mmc_card_data *mmc_c,
- unsigned long *output_buf)
+static unsigned long mmc_bread(int dev_num, unsigned long blknr,
+ lbaint_t blkcnt, void *dst)
{
unsigned char err;
unsigned int argument;
unsigned int resp[4];
- unsigned int num_sec_val =
- (num_bytes + (MMCSD_SECTOR_SIZE - 1)) / MMCSD_SECTOR_SIZE;
+ unsigned int *output_buf = dst;
unsigned int sec_inc_val;
+ lbaint_t i;
- if (num_sec_val == 0)
- return 1;
+ if (blkcnt == 0)
+ return 0;
- if (mmc_c->mode == SECTOR_MODE) {
- argument = start_sec;
+ if (cur_card_data.mode == SECTOR_MODE) {
+ argument = blknr;
sec_inc_val = 1;
} else {
- argument = start_sec * MMCSD_SECTOR_SIZE;
+ argument = blknr * MMCSD_SECTOR_SIZE;
sec_inc_val = MMCSD_SECTOR_SIZE;
}
- while (num_sec_val) {
+ for (i = 0; i < blkcnt; i++) {
err = mmc_send_cmd(MMC_CMD17, argument, resp);
- if (err != 1)
- return err;
+ if (err != 1) {
+ printf("mmc: CMD17 failed, status = %08x\n", err);
+ break;
+ }
- err = mmc_read_data((unsigned int *) output_buf);
- if (err != 1)
- return err;
+ err = mmc_read_data(output_buf);
+ if (err != 1) {
+ printf("mmc: read failed, status = %08x\n", err);
+ break;
+ }
output_buf += (MMCSD_SECTOR_SIZE / 4);
argument += sec_inc_val;
- num_sec_val--;
}
- return 1;
+
+ return i;
}
static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
@@ -542,14 +545,6 @@ static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
return 1;
}
-static unsigned long mmc_bread(int dev_num, unsigned long blknr,
- lbaint_t blkcnt, void *dst)
-{
- omap_mmc_read_sect(blknr, (blkcnt * MMCSD_SECTOR_SIZE), &cur_card_data,
- (unsigned long *) dst);
- return 1;
-}
-
int mmc_legacy_init(int dev)
{
if (mmc_set_dev(dev) != 0)