Hello,
I have to suspend for a while my investigations on the MMC driver of the GIT
kernel; however I've managed to make it work at least with the LSP kernel
shipped with DVEVM 1.1 (the davinci_mmc driver shipped with LSP crashed as
well). If someone has the same problem, I've attached the patch that fixes it;
I repeat that this is a patch for the LSP kernel, not the GIT kernel. I don't
know if it works with the LSP shipped with DVEVM 1.0, but since someone claimed
that MMC worked under that kernel, I suppose you don't need it anyway.
The MMC driver seems to be very picky; of three SD cards I have here (one 128MB from
Panasonic and two 64MB from "no name"), only one out of three works, and for
that one I have to create the partitions starting from cylinder 50 or I get data
corruption. Probably there is some timing that isn't calculated in the correct way.
Cheers, Lorenzo
diff -u -r davinci-lsp-orig/drivers/mmc/davinci_mmc.c
davinci-lsp/drivers/mmc/davinci_mmc.c
--- davinci-lsp-orig/drivers/mmc/davinci_mmc.c 2006-07-07 15:44:53.000000000
+0200
+++ davinci-lsp/drivers/mmc/davinci_mmc.c 2006-10-23 10:44:39.000000000
+0200
@@ -38,12 +38,14 @@
#include <linux/console.h>
#include <linux/blkdev.h>
#include <linux/device.h>
+#include <linux/dma-mapping.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
#include <linux/mmc/protocol.h>
+#include <asm/scatterlist.h>
#include <asm/arch/irqs.h>
#include <asm/arch/hardware.h>
#include <asm/hardware/clock.h>
@@ -413,7 +421,15 @@
temp_ccnt = ccnt;
}
- src_port = (unsigned int)virt_to_phys(req->data->req->buffer);
+/* src_port = (unsigned int)virt_to_phys(req->data->req->buffer);*/
+ r = dma_map_sg( &mmc_dev, req->data->sg, req->data->sg_len,
+ DMA_FROM_DEVICE);
+ if( r<0) {
+ printk( KERN_NOTICE
+ "MMC: dma_map_sg() failed with %d\n", r);
+ return r;
+ }
+ src_port = sg_dma_address( req->data->sg);
mode_src = INCR;
fifo_width_src = W8BIT; /* It's not cared as modeDsr is INCR */
src_bidx = 4;
@@ -443,7 +459,16 @@
fifo_width_src = W8BIT;
src_bidx = 0;
src_cidx = 0;
- dst_port = (unsigned int)virt_to_phys(req->data->req->buffer);
+/* dst_port = (unsigned int)virt_to_phys(req->data->req->buffer);*/
+ r = dma_map_sg( &mmc_dev, req->data->sg, req->data->sg_len,
+ DMA_TO_DEVICE);
+ if( r<0) {
+ printk( KERN_NOTICE
+ "MMC: dma_map_sg() failed with %d\n", r);
+ return r;
+ }
+ dst_port = sg_dma_address( req->data->sg);
+
mode_dst = INCR;
fifo_width_dst = W8BIT; /* It's not cared as modeDsr is INCR */
dst_bidx = 4;
@@ -545,6 +570,8 @@
struct mmc_request *req)
{
int timeout;
+ int r;
+
host->data = req->data;
if (req->data == NULL) {
host->data_dir = DAVINCI_MMC_DATADIR_NONE;
@@ -597,8 +624,21 @@
host->buffer = NULL;
host->bytes_left = 0;
} else {
+ r = dma_map_sg( &mmc_dev, req->data->sg, req->data->sg_len,
+ (req->data->flags & MMC_DATA_WRITE) ?
+ DMA_FROM_DEVICE : DMA_TO_DEVICE);
+ if( r<0) {
+ printk( KERN_NOTICE
+ "MMC: dma_map_sg() failed with %d\n", r);
+ return;
+ }
+ printk( KERN_NOTICE "DAVINCIMMC dma PIO write=%d size=%d
bytes_left=%d\n",
+ (req->data->flags & MMC_DATA_WRITE) ? 1 : 0,
+ sg_dma_len(req->data->sg),
+ req->data->blocks * (1 << req->data->blksz_bits));
+
/* Revert to CPU Copy */
- host->buffer = (u32 *) (req->data->req->buffer);
+ host->buffer = (u32*)sg_dma_address( req->data->sg);
host->bytes_left =
req->data->blocks * (1 << req->data->blksz_bits);
host->use_dma = 0;
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source