Make existing field b_max field in struct mmc unconditional
and use it instead of CONFIG_SYS_MMC_MAX_BLK_COUNT in mmc_bread
and mmc_bwrite.

Initialize b_max to CONFIG_SYS_MMC_MAX_BLK_COUNT in mmc_register
if it has not been initialized by the hw driver.

Initialize b_max to 1 in omap_hsmmc.c for old rev silicon OMAP3
to disable multi block rw.

Signed-off-by: John Rigby <john.ri...@linaro.org>
---
 drivers/mmc/mmc.c        |    8 ++++----
 drivers/mmc/omap_hsmmc.c |    8 ++++++++
 include/mmc.h            |    2 --
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index f27b7c7..f6d31f5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -243,8 +243,7 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const 
void*src)
                return 0;
 
        do {
-               cur = (blocks_todo > CONFIG_SYS_MMC_MAX_BLK_COUNT) ?
-                      CONFIG_SYS_MMC_MAX_BLK_COUNT : blocks_todo;
+               cur = (blocks_todo > mmc->b_max) ?  mmc->b_max : blocks_todo;
                if(mmc_write_blocks(mmc, start, cur, src) != cur)
                        return 0;
                blocks_todo -= cur;
@@ -320,8 +319,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t 
blkcnt, void *dst)
                return 0;
 
        do {
-               cur = (blocks_todo > CONFIG_SYS_MMC_MAX_BLK_COUNT) ?
-                      CONFIG_SYS_MMC_MAX_BLK_COUNT : blocks_todo;
+               cur = (blocks_todo > mmc->b_max) ?  mmc->b_max : blocks_todo;
                if(mmc_read_blocks(mmc, dst, start, cur) != cur)
                        return 0;
                blocks_todo -= cur;
@@ -1029,6 +1027,8 @@ int mmc_register(struct mmc *mmc)
        mmc->block_dev.removable = 1;
        mmc->block_dev.block_read = mmc_bread;
        mmc->block_dev.block_write = mmc_bwrite;
+       if (!mmc->b_max)
+               mmc->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
        INIT_LIST_HEAD (&mmc->link);
 
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 6f2280a..1fab249 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -465,6 +465,14 @@ int omap_mmc_init(int dev_index)
        mmc->f_min = 400000;
        mmc->f_max = 52000000;
 
+#if defined(CONFIG_OMAP34XX)
+       /*
+        * Silicon revs 2.1 and older do not support multiblock transfers.
+        */
+       if (get_cpu_rev() <= CPU_3XX_ES21)
+               mmc->b_max = 1;
+#endif
+
        mmc_register(mmc);
 
        return 0;
diff --git a/include/mmc.h b/include/mmc.h
index e0a56d9..b4197a7 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -283,9 +283,7 @@ struct mmc {
                        struct mmc_cmd *cmd, struct mmc_data *data);
        void (*set_ios)(struct mmc *mmc);
        int (*init)(struct mmc *mmc);
-#ifdef CONFIG_MMC_MBLOCK
        uint b_max;
-#endif
 };
 
 int mmc_register(struct mmc *mmc);
-- 
1.7.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to