From: Lei Wen <leiwen@marvell.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2] mmc: seperate block number into small parts for multi-write cmd
Date: Mon, 11 Oct 2010 11:42:06 +0800 [thread overview]
Message-ID: <1286768526-14298-1-git-send-email-leiwen@marvell.com> (raw)
In-Reply-To: <4CB1886B.8090209@emk-elektronik.de>
As suggested by Reinhard, I add two additional member in mmc structure,
so that we could specify its value in each driver. If that value is 0, then
the behavior would be the same as original, as no seperation.
Signed-off-by: Lei Wen <leiwen@marvell.com>
Cc: Reinhard Meyer <u-boot@emk-elektronik.de>
---
V2: add additional members in mmc structure
drivers/mmc/bfin_sdh.c | 1 +
drivers/mmc/fsl_esdhc.c | 1 +
drivers/mmc/gen_atmel_mci.c | 1 +
drivers/mmc/mmc.c | 62 +++++++++++++++++++++++++++----------------
drivers/mmc/mxcmmc.c | 1 +
include/mmc.h | 2 +
6 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/drivers/mmc/bfin_sdh.c b/drivers/mmc/bfin_sdh.c
index 27d9bf6..6803322 100644
--- a/drivers/mmc/bfin_sdh.c
+++ b/drivers/mmc/bfin_sdh.c
@@ -246,6 +246,7 @@ int bfin_mmc_init(bd_t *bis)
if (!mmc)
return -ENOMEM;
sprintf(mmc->name, "Blackfin SDH");
+ mmc->host_maxblk = mmc->host_maxdmalen = 0;
mmc->send_cmd = bfin_sdh_request;
mmc->set_ios = bfin_sdh_set_ios;
mmc->init = bfin_sdh_init;
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index a368fe6..ba98de0 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -457,6 +457,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
/* First reset the eSDHC controller */
esdhc_reset(regs);
+ mmc->host_maxblk = mmc->host_maxdmalen = 0;
mmc->priv = cfg;
mmc->send_cmd = esdhc_send_cmd;
mmc->set_ios = esdhc_set_ios;
diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
index fa4df99..054f62d 100644
--- a/drivers/mmc/gen_atmel_mci.c
+++ b/drivers/mmc/gen_atmel_mci.c
@@ -332,6 +332,7 @@ int atmel_mci_init(void *regs)
if (!mmc)
return -1;
strcpy(mmc->name, "mci");
+ mmc->host_maxblk = mmc->host_maxdmalen = 0;
mmc->priv = regs;
mmc->send_cmd = mci_send_cmd;
mmc->set_ios = mci_set_ios;
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 80cd9bf..b7bd2f9 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -77,33 +77,13 @@ struct mmc *find_mmc_device(int dev_num)
return NULL;
}
-static ulong
-mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
+int mmc_write_block(struct mmc *mmc, ulong *src, ulong start, uint blkcnt)
{
struct mmc_cmd cmd;
struct mmc_data data;
- int err;
- int stoperr = 0;
- struct mmc *mmc = find_mmc_device(dev_num);
- int blklen;
-
- if (!mmc)
- return -1;
+ int blklen, err;
blklen = mmc->write_bl_len;
-
- if ((start + blkcnt) > mmc->block_dev.lba) {
- printf("MMC: block number 0x%lx exceeds max(0x%lx)",
- start + blkcnt, mmc->block_dev.lba);
- return 0;
- }
- err = mmc_set_blocklen(mmc, mmc->write_bl_len);
-
- if (err) {
- printf("set write bl len failed\n\r");
- return err;
- }
-
if (blkcnt > 1)
cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
else
@@ -134,12 +114,48 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
cmd.cmdarg = 0;
cmd.resp_type = MMC_RSP_R1b;
cmd.flags = 0;
- stoperr = mmc_send_cmd(mmc, &cmd, NULL);
+ mmc_send_cmd(mmc, &cmd, NULL);
}
return blkcnt;
}
+static ulong
+mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
+{
+ int err;
+ struct mmc *mmc = find_mmc_device(dev_num);
+ unsigned int max;
+ lbaint_t tmp = blkcnt, cur;
+
+ if (!mmc)
+ return -1;
+
+ if ((start + blkcnt ) > mmc->block_dev.lba) {
+ printf("MMC: block number 0x%lx exceeds max(0x%lx)",
+ start + blkcnt, mmc->block_dev.lba);
+ return 0;
+ }
+ err = mmc_set_blocklen(mmc, mmc->write_bl_len);
+ if (err) {
+ printf("set write bl len failed\n\r");
+ return err;
+ }
+
+ max = ((mmc->host_maxdmalen / mmc->write_bl_len) > mmc->host_maxblk)
+ ? mmc->host_maxblk :(mmc->host_maxdmalen / mmc->write_bl_len);
+ max = (!max) ? tmp : max;
+ do {
+ cur = (tmp > max) ? max : tmp;
+ if(mmc_write_block(mmc, src, start, cur) != cur)
+ return -1;
+ tmp -= cur;
+ start += cur;
+ src += cur * mmc->write_bl_len;
+ } while (tmp > 0);
+ return blkcnt;
+}
+
int mmc_read_block(struct mmc *mmc, void *dst, uint blocknum)
{
struct mmc_cmd cmd;
diff --git a/drivers/mmc/mxcmmc.c b/drivers/mmc/mxcmmc.c
index 5963953..76501ed 100644
--- a/drivers/mmc/mxcmmc.c
+++ b/drivers/mmc/mxcmmc.c
@@ -497,6 +497,7 @@ static int mxcmci_initialize(bd_t *bis)
return -ENOMEM;
sprintf(mmc->name, "MXC MCI");
+ mmc->host_maxblk = mmc->host_maxdmalen = 0;
mmc->send_cmd = mxcmci_request;
mmc->set_ios = mxcmci_set_ios;
mmc->init = mxcmci_init;
diff --git a/include/mmc.h b/include/mmc.h
index 9f94f42..ad28ad2 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -260,6 +260,8 @@ struct mmc {
uint clock;
uint card_caps;
uint host_caps;
+ uint host_maxblk;
+ uint host_maxdmalen;
uint ocr;
uint scr[2];
uint csd[4];
--
1.7.0.4
next prev parent reply other threads:[~2010-10-11 3:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 7:19 [U-Boot] [PATCH] mmc: seperate block number into small parts for multi-write cmd Lei Wen
2010-09-06 8:28 ` Wolfgang Denk
2010-09-06 8:40 ` Lei Wen
2010-09-06 9:23 ` Reinhard Meyer
2010-09-06 9:31 ` Lei Wen
2010-09-06 10:16 ` Reinhard Meyer
2010-09-06 10:48 ` Lei Wen
2010-09-06 11:50 ` Reinhard Meyer
2010-10-10 4:20 ` Lei Wen
2010-10-10 6:48 ` Wolfgang Denk
2010-10-10 8:49 ` Lei Wen
2010-10-10 9:22 ` Wolfgang Denk
2010-10-10 9:27 ` Lei Wen
2010-10-10 9:39 ` Reinhard Meyer
2010-10-10 9:44 ` Lei Wen
2010-10-10 9:33 ` Reinhard Meyer
2010-10-10 9:42 ` Lei Wen
2010-10-11 3:42 ` Lei Wen [this message]
2010-10-11 9:00 ` [U-Boot] [PATCH V2] " Reinhard Meyer
2010-10-11 9:22 ` Wolfgang Denk
2010-10-11 9:27 ` Lei Wen
2010-10-11 10:44 ` [U-Boot] [PATCH] " Reinhard Meyer
2010-10-11 11:35 ` Wolfgang Denk
2010-10-11 15:39 ` [U-Boot] [PATCH V3] " Lei Wen
2010-10-13 19:57 ` Wolfgang Denk
2010-10-14 5:38 ` [U-Boot] [PATCH V4] " Lei Wen
2010-10-25 18:46 ` Steve Sakoman
2010-10-27 18:39 ` Wolfgang Denk
2010-10-27 19:59 ` Steve Sakoman
2010-10-27 6:04 ` [U-Boot] [PATCH V3] " Lei Wen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286768526-14298-1-git-send-email-leiwen@marvell.com \
--to=leiwen@marvell.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.