diff mbox

[Resend,v5,00/16] spi/spi-atmel: add dmaengine support for atmel spi controller and to test the device tree support

Message ID 51472F81.9060803@interlog.com (mailing list archive)
State New, archived
Headers show

Commit Message

Douglas Gilbert March 18, 2013, 3:15 p.m. UTC
On Tue, Feb 26, 2013 at 6:34 PM, Wenyou Yang <wenyou.yang@atmel.com>
wrote:
> Hi All,
>
> This set of patches is to add dmaengine support for atmel spi and to test
> device tree support.
>
> The work is based on Nicolas and Richard's work.
>
> Because the Atmel DMA device tree support hasn't on mainline, to
> at91sam9x5ek and at91sam9n12ek
> with dma support, it doesn't work on the dmaengine mode, only on PIO mode
> so far.
>
> It has been tested as below:
>   1./tested on v3.8, by using mtd utils, "mount", "umount" and "cp"
> commands.
>   2./tested on "spi/next" git tree after removing commit "spi: make sure all
> transfer has proper speed set".
>   3./tested by using Documentation/spi/spidev_test.c on "/dev/spidev".
>   4./tested on on at91sam9x5ek, at91sam9m10g45ek, at91sam9263ek and
> at91sam9g20ek boards

I took a different approach to testing this patch. Try
the world's most common SPI device, namely a (micro)SD
card. There are a few issues.

The mmc_spi driver isn't very DT friendly. I added some
DT SPI attributes, patch attached. In my case cd-inverted
was needed.

Also I ran into a boot sequence problem since my hardware
boots of a microSD card using the MCI interface. I was
using a second microSD for SPI testing. at91bootstrap
and u-boot (plus the kernel image) are on my MCI microSD
card and they got the kernel booting. However since the
kernel probes SPI before MCI, then by the time of the rootfs
remount, my SPI microSD card had overtaken the /dev/mmcblk0
device node leading to some confusion.

There are several ways of coping with this problem and I
took an easy one: making mmc_spi a module. Just wondering
if there are any DT mechanisms to cope with these "order
of probing" type problems?

And data transfers to and from that microSD card using SPI
were slow, as in 200 kB/sec (should be closer to 1 MB/sec).
So Atmel, when are we getting DMA working for the AT91SAM9x5
family?

Doug Gilbert
diff mbox

Patch

diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index d720b5e..c06abb2 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -64,6 +64,11 @@  static int of_mmc_spi_get_cd(struct device *dev)
 	return of_mmc_spi_read_gpio(dev, CD_GPIO);
 }
 
+static int of_mmc_spi_get_cd_inv(struct device *dev)
+{
+	return ! of_mmc_spi_read_gpio(dev, CD_GPIO);
+}
+
 static int of_mmc_spi_get_ro(struct device *dev)
 {
 	return of_mmc_spi_read_gpio(dev, WP_GPIO);
@@ -140,17 +145,26 @@  struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
 			oms->alow_gpios[i] = true;
 	}
 
-	if (gpio_is_valid(oms->gpios[CD_GPIO]))
-		oms->pdata.get_cd = of_mmc_spi_get_cd;
+	if (gpio_is_valid(oms->gpios[CD_GPIO])) {
+		if (of_get_property(np, "cd-inverted", NULL))
+			oms->pdata.get_cd = of_mmc_spi_get_cd_inv;
+		else
+			oms->pdata.get_cd = of_mmc_spi_get_cd;
+	}
 	if (gpio_is_valid(oms->gpios[WP_GPIO]))
 		oms->pdata.get_ro = of_mmc_spi_get_ro;
 
-	oms->detect_irq = irq_of_parse_and_map(np, 0);
-	if (oms->detect_irq != 0) {
-		oms->pdata.init = of_mmc_spi_init;
-		oms->pdata.exit = of_mmc_spi_exit;
-	} else {
+	if (of_get_property(np, "np-removable", NULL))
+		oms->pdata.caps |= MMC_CAP_NONREMOVABLE;
+	else if (of_get_property(np, "broken-cd", NULL))
 		oms->pdata.caps |= MMC_CAP_NEEDS_POLL;
+	else {
+		oms->detect_irq = irq_of_parse_and_map(np, 0);
+		if (oms->detect_irq != 0) {
+			oms->pdata.init = of_mmc_spi_init;
+			oms->pdata.exit = of_mmc_spi_exit;
+		} else
+			oms->pdata.caps |= MMC_CAP_NEEDS_POLL;
 	}
 
 	dev->platform_data = &oms->pdata;
-- 
1.7.10.4