Skip to contentSkip to conversation

Block request processing for MMC/SD over SPI bus

DISCUSSION Hans Eklund 2 participants 3 messages Aug 1, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi David.

First, my original post on LKML on the subject of MMC/SD over SPI framwork:

http://lkml.org/lkml/2006/8/1/71

I began developing a driver for MMC access over SPI on the Analog Devices Blackfin DSPs, running uClinux this spring. However, since then the blackfin uClinux has moved from kernel version 2.6.12 to 2.6.16 with the unified SPI framework. Also, a platform spi driver for the ADI Blackfin was recently written. I released my driver to the Blackfin uClinux community a few weeks ago and my plans was to move over to the SPI framwork using the platform driver instead of low level blackfin SPI related code.

As you can see om my LKML post, my driver covers(at first stage) everything from low level SPI commands and block device insertion to the request processing(since i at first could not connect to the MMC subsystem). Now, Russel King believes that you may have written a SPI to MMC subsytem driver. Correct? If so, whats the status on your driver?

My current goal was to make my driver platform independent and then(if possible) connect to the MMC subsystem which i, at this point is not too familiar with.

regards

Hans Eklund
Rubico AB - http://www.rubico.se
Sweden.

#1 lore raw
Quoted 5 lines · Hans Eklund

As you can see om my LKML post, my driver covers (at first stage) everything from low level SPI commands and block device insertion to the request processing(since i at first could not connect to the MMC subsystem). Now, Russel King believes that you may have written a SPI to MMC subsytem driver. Correct? If so, whats the status on your driver?

Not entirely "my" driver, I just updated it and got it to partially enumerate on some hardware that's a bit too weak for "real work":

http://sourceforge.net/mailarchive/forum.php?thread_id=13335072&forum_id=45866

... and there's the separate issue of the spi_claim()/spi_release() API to take over an entire bus. Such an API could be used by other SPI based interfaces; some in-system-programmers (including JTAG) need that same kind of protocol tweaking hook for SPI.

- Dave

#2 lore raw
Quoted 1 line · David Brownell

http://sourceforge.net/mailarchive/forum.php?thread_id=13335072&forum_id=45866

Whoops, that's a stupid archive, one that doesn't record entire patches. Here's the relevant patch.

- Dave

This is an experimental MMC-to-SPI adapter, updated for 2.6.17 and generalized from the original by Mike Lavender. It would be used with MMC/SD card slots hooked up to SPI controllers, as is common with systems that don't have parallel MMC/SD controllers.

This version gets part way through MMC and SD card enumeration, given a driver for the spi controller hooked up to the card. There are some annoying hardware states it doesn't seem to detect, avoid or recover from; but those could very easily be SPI controller driver issues.

All MMC, SD, and SDIO cards have two options for connection hardware, ignoring things like bridges to USB:

- The "native" option using dedicated "MCI" controllers that may support parallel as well as serial signaling. Linux already supports a number of these; many Linux-capable SOCs include one.

- The simpler option uses SPI controllers, which are multipurpose but serial-only. SPI is more widely supported on microcontrollers, so this option is probably most interesting with uClinux.

The protocol messages used to talk to such cards over the two types of connection have small differences in both content and encoding, which are not currently known to the Linux MMC core. Such knowledge sits in this driver for now, but some of it might be better in the MMC core.

This requires a new SPI primitive somewhat like the mmc_host_claim() calls; that SPI primitive is still in the prototype stage.

REVISIT: tweak transfer limits to avoid being a bus + cpu hog

drivers/mmc/Kconfig +11 -0
Index: at91/drivers/mmc/Kconfig
===================================================================
@@ -109,4 +109,15 @@ config MMC_AT91RM9200
 
 	  If unsure, say N.
 
+config MMC_SPI
+	tristate "MMC/SD over SPI"
+	depends on MMC && SPI && EXPERIMENTAL
+	help
+	  Some systems accss MMC/SD cards using the SPI protocol instead of
+	  using an MMC/SD controller.  The disadvantage of using SPI is that
+	  it's often not as fast; its compensating advantage is that SPI is
+	  available on many systems without MMC/SD controllers.
+
+	  If unsure, or if your system has no SPI controller driver, say N.
+
 endmenu
include/linux/spi/mmc_spi.h new file +34 -0
Index: at91/include/linux/spi/mmc_spi.h
===================================================================
@@ -0,0 +1,34 @@
+#ifndef __LINUX_SPI_MMC_SPI_H
+#define __LINUX_SPI_MMC_SPI_H
+
+#include <linux/mmc/protocol.h>
+#include <linux/interrupt.h>
+
+struct device;
+struct mmc_host;
+
+/* something to put in platform_data of a device being used
+ * to manage an MMC/SD card slot
+ *
+ * REVISIT this isn't spi-specific, any card slot should be
+ * able to handle it
+ */
+struct mmc_spi_platform_data {
+	/* driver activation and (optional) card detect irq */
+	int (*init)(struct device *,
+		irqreturn_t (*)(int, void *, struct pt_regs *),
+		void *);
+	void (*exit)(struct device *, void *);
+
+	/* how long to debounce card detect, in jiffies */
+	unsigned long detect_delay;
+
+	/* sense switch on sd cards */
+	int (*get_ro)(struct device *);
+
+	/* power management */
+	unsigned int ocr_mask;			/* available voltages */
+	void (*setpower)(struct device *, unsigned int);
+};
+
+#endif /* __LINUX_SPI_MMC_SPI_H */
drivers/mmc/Makefile +1 -0
Index: at91/drivers/mmc/Makefile
===================================================================
@@ -23,6 +23,7 @@ obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
 obj-$(CONFIG_MMC_AU1X)		+= au1xmmc.o
 obj-$(CONFIG_MMC_OMAP)		+= omap.o
 obj-$(CONFIG_MMC_AT91RM9200)	+= at91_mci.o
+obj-$(CONFIG_MMC_SPI)		+= mmc_spi.o
 
 mmc_core-y := mmc.o mmc_queue.o mmc_sysfs.o
 
drivers/mmc/mmc_spi.c new file +1222 -0

1,222 lines not on this page · raw message