Commit 9b79dbd2019d2ef86dae4fab49b0c57360b8b61f

Authored by Jean-Jacques Hiblot
Committed by Jaehoon Chung
1 parent d0e443786c

mmc: atmel: when sending a data command, use the provided block size

struct mmc_data contains the block size to use for the data transfer.
Use this information instead of using the default value or the block length
information stored in struct mmc.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

Showing 1 changed file with 20 additions and 22 deletions Side-by-side Diff

drivers/mmc/gen_atmel_mci.c
... ... @@ -74,6 +74,20 @@
74 74 cmdr, cmdr & 0x3F, arg, status, msg);
75 75 }
76 76  
  77 +static inline void mci_set_blklen(atmel_mci_t *mci, int blklen)
  78 +{
  79 + unsigned int version = atmel_mci_get_version(mci);
  80 +
  81 + blklen &= 0xfffc;
  82 +
  83 + /* MCI IP version >= 0x200 has blkr */
  84 + if (version >= 0x200)
  85 + writel(MMCI_BFINS(BLKLEN, blklen, readl(&mci->blkr)),
  86 + &mci->blkr);
  87 + else
  88 + writel(MMCI_BFINS(BLKLEN, blklen, readl(&mci->mr)), &mci->mr);
  89 +}
  90 +
77 91 /* Setup for MCI Clock and Block Size */
78 92 #ifdef CONFIG_DM_MMC
79 93 static void mci_set_mode(struct udevice *dev, u32 hz, u32 blklen)
... ... @@ -124,7 +138,6 @@
124 138 priv->curr_clk = bus_hz / (clkdiv * 2 + clkodd + 2);
125 139 else
126 140 priv->curr_clk = (bus_hz / (clkdiv + 1)) / 2;
127   - blklen &= 0xfffc;
128 141  
129 142 mr = MMCI_BF(CLKDIV, clkdiv);
130 143  
131 144  
... ... @@ -138,14 +151,10 @@
138 151 */
139 152 if (version >= 0x500)
140 153 mr |= MMCI_BF(CLKODD, clkodd);
141   - else
142   - mr |= MMCI_BF(BLKLEN, blklen);
143 154  
144 155 writel(mr, &mci->mr);
145 156  
146   - /* MCI IP version >= 0x200 has blkr */
147   - if (version >= 0x200)
148   - writel(MMCI_BF(BLKLEN, blklen), &mci->blkr);
  157 + mci_set_blklen(mci, blklen);
149 158  
150 159 if (mmc->card_caps & mmc->cfg->host_caps & MMC_MODE_HS)
151 160 writel(MMCI_BIT(HSMODE), &mci->cfg);
... ... @@ -236,7 +245,6 @@
236 245 {
237 246 struct atmel_mci_plat *plat = dev_get_platdata(dev);
238 247 struct atmel_mci_priv *priv = dev_get_priv(dev);
239   - struct mmc *mmc = mmc_get_mmc_dev(dev);
240 248 atmel_mci_t *mci = plat->mci;
241 249 #else
242 250 static int
243 251  
... ... @@ -257,11 +265,13 @@
257 265 /* Figure out the transfer arguments */
258 266 cmdr = mci_encode_cmd(cmd, data, &error_flags);
259 267  
  268 + mci_set_blklen(mci, data->blocksize);
  269 +
260 270 /* For multi blocks read/write, set the block register */
261 271 if ((cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK)
262 272 || (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK))
263   - writel(data->blocks | MMCI_BF(BLKLEN, mmc->read_bl_len),
264   - &mci->blkr);
  273 + writel(data->blocks | MMCI_BF(BLKLEN, data->blocksize),
  274 + &mci->blkr);
265 275  
266 276 /* Send the command */
267 277 writel(cmd->cmdarg, &mci->argr);
268 278  
269 279  
... ... @@ -295,17 +305,15 @@
295 305 if (data) {
296 306 u32 word_count, block_count;
297 307 u32* ioptr;
298   - u32 sys_blocksize, dummy, i;
  308 + u32 i;
299 309 u32 (*mci_data_op)
300 310 (atmel_mci_t *mci, u32* data, u32 error_flags);
301 311  
302 312 if (data->flags & MMC_DATA_READ) {
303 313 mci_data_op = mci_data_read;
304   - sys_blocksize = mmc->read_bl_len;
305 314 ioptr = (u32*)data->dest;
306 315 } else {
307 316 mci_data_op = mci_data_write;
308   - sys_blocksize = mmc->write_bl_len;
309 317 ioptr = (u32*)data->src;
310 318 }
311 319  
... ... @@ -328,16 +336,6 @@
328 336 1, cnt, 0);
329 337 }
330 338 #endif
331   -#ifdef DEBUG
332   - if (!status && word_count < (sys_blocksize / 4))
333   - printf("filling rest of block...\n");
334   -#endif
335   - /* fill the rest of a full block */
336   - while (!status && word_count < (sys_blocksize / 4)) {
337   - status = mci_data_op(mci, &dummy,
338   - error_flags);
339   - word_count++;
340   - }
341 339 if (status) {
342 340 dump_cmd(cmdr, cmd->cmdarg, status,
343 341 "Data Transfer Failed");