atmel-mci: Initialize BLKR before sending data transfer command
authorHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
Mon, 6 Oct 2008 18:09:53 +0000 (20:09 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 6 Oct 2008 21:26:24 +0000 (14:26 -0700)
commite683b423007b9befec30c672c695d0e6abf87493
tree5486cdf01cd6e8f23978170fe8505a5e4b5413c9
parente84956f92a846246b09b34f2a728329c386d250f
atmel-mci: Initialize BLKR before sending data transfer command

The atmel-mci driver sometimes fails data transfers like this:

   mmcblk0: error -5 transferring data
   end_request: I/O error, dev mmcblk0, sector 2749769
   end_request: I/O error, dev mmcblk0, sector 2749777

It turns out that this might be caused by the BLKR register (which
contains the block size and the number of blocks being transfered) being
initialized too late. This patch moves the initialization of BLKR so
that it contains the correct value before the block transfer command is
sent.

This error is difficult to reproduce, but if you insert a long delay
(mdelay(10) or thereabouts) between the calls to atmci_start_command()
and atmci_submit_data(), all transfers seem to fail without this patch,
while I haven't seen any failures with this patch.

Reported-by: Hein_Tibosch <hein_tibosch@yahoo.es>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/mmc/host/atmel-mci.c