summaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc.c
diff options
context:
space:
mode:
authorMatt Waddel <matt.waddel@linaro.org>2011-02-24 16:35:23 +0000
committerAndy Fleming <afleming@freescale.com>2011-04-13 06:35:22 -0500
commitce0fbcd2e1bd8c7b0975589b9853f3e8914aa406 (patch)
tree3e21648aaaee68b050ea9f5f6bafa16a86a82e7a /drivers/mmc/mmc.c
parentb44c70837a87bcd92b76a94e49b85d7656cb2a11 (diff)
downloadu-boot-imx-ce0fbcd2e1bd8c7b0975589b9853f3e8914aa406.zip
u-boot-imx-ce0fbcd2e1bd8c7b0975589b9853f3e8914aa406.tar.gz
u-boot-imx-ce0fbcd2e1bd8c7b0975589b9853f3e8914aa406.tar.bz2
MMC: Max blocks value adjustable
The maximum blocks value was hardcoded to 65535 due to a 16 bit register length. The value can change for different platforms. This patch makes the default the current value of 65535, but it is configurable for other platforms. Signed-off-by: Matt Waddel <matt.waddel@linaro.org> Signed-off-by: Andy Fleming <afleming@freescale.com>
Diffstat (limited to 'drivers/mmc/mmc.c')
-rw-r--r--drivers/mmc/mmc.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 9988cb1..1355735 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -33,6 +33,11 @@
#include <mmc.h>
#include <div64.h>
+/* Set block count limit because of 16 bit register limit on some hardware*/
+#ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535
+#endif
+
static struct list_head mmc_devices;
static int cur_dev_num = -1;
@@ -139,11 +144,8 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
return 0;
do {
- /*
- * The 65535 constraint comes from some hardware has
- * only 16 bit width block number counter
- */
- cur = (blocks_todo > 65535) ? 65535 : blocks_todo;
+ cur = (blocks_todo > CONFIG_SYS_MMC_MAX_BLK_COUNT) ?
+ CONFIG_SYS_MMC_MAX_BLK_COUNT : blocks_todo;
if(mmc_write_blocks(mmc, start, cur, src) != cur)
return 0;
blocks_todo -= cur;
@@ -215,11 +217,8 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
return 0;
do {
- /*
- * The 65535 constraint comes from some hardware has
- * only 16 bit width block number counter
- */
- cur = (blocks_todo > 65535) ? 65535 : blocks_todo;
+ cur = (blocks_todo > CONFIG_SYS_MMC_MAX_BLK_COUNT) ?
+ CONFIG_SYS_MMC_MAX_BLK_COUNT : blocks_todo;
if(mmc_read_blocks(mmc, dst, start, cur) != cur)
return 0;
blocks_todo -= cur;