Skip to contentSkip to conversation

mmc_spi: Add support for OpenFirmware bindings

PATCH In review Anton Vorontsov 2 participants 2 messages Dec 30, 2008 – Dec 31, 2008

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

PATCH 1/1 mmc_spi: Add support for OpenFirmware bindings

The support is implemented via platform data accessors, new module (of_mmc_spi) will be created automatically when the driver compiles on OpenFirmware platforms. Link-time dependency will load the module automatically.

---

Hello Pierre,

All the needed patches were merged into Linus' tree, so I believe it's time for the bindings.

Note that you need to pull Linus' tree into mmc.git's next branch before applying this patch, otherwise it will break bisect, since of_mmc_spi isn't buildable without some patches that are in Linus' tree, but not in the current mmc.git next.

Thanks,

 drivers/mmc/host/Makefile     |    3 +
 drivers/mmc/host/mmc_spi.c    |    4 +-
 drivers/mmc/host/of_mmc_spi.c |  149 +++++++++++++++++++++++++++++++++++++++++
 include/linux/spi/mmc_spi.h   |   15 ++++-
 4 files changed, 169 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mmc/host/of_mmc_spi.c
drivers/mmc/host/Makefile +3 -0
index c794cc5..f485328 100644
@@ -19,6 +19,9 @@ obj-$(CONFIG_MMC_AT91)		+= at91_mci.o
 obj-$(CONFIG_MMC_ATMELMCI)	+= atmel-mci.o
 obj-$(CONFIG_MMC_TIFM_SD)	+= tifm_sd.o
 obj-$(CONFIG_MMC_SPI)		+= mmc_spi.o
+ifeq ($(CONFIG_OF),y)
+obj-$(CONFIG_MMC_SPI)		+= of_mmc_spi.o
+endif
 obj-$(CONFIG_MMC_S3C)   	+= s3cmci.o
 obj-$(CONFIG_MMC_SDRICOH_CS)	+= sdricoh_cs.o
 obj-$(CONFIG_MMC_TMIO)		+= tmio_mmc.o
drivers/mmc/host/mmc_spi.c +3 -1
index ad00e16..87e211d 100644
@@ -1285,7 +1285,7 @@ static int mmc_spi_probe(struct spi_device *spi)
 	/* Platform data is used to hook up things like card sensing
 	 * and power switching gpios.
 	 */
-	host->pdata = spi->dev.platform_data;
+	host->pdata = mmc_spi_get_pdata(spi);
 	if (host->pdata)
 		mmc->ocr_avail = host->pdata->ocr_mask;
 	if (!mmc->ocr_avail) {
@@ -1368,6 +1368,7 @@ fail_glue_init:
 
 fail_nobuf1:
 	mmc_free_host(mmc);
+	mmc_spi_put_pdata(spi);
 	dev_set_drvdata(&spi->dev, NULL);
 
 nomem:
@@ -1402,6 +1403,7 @@ static int __devexit mmc_spi_remove(struct spi_device *spi)
 
 		spi->max_speed_hz = mmc->f_max;
 		mmc_free_host(mmc);
+		mmc_spi_put_pdata(spi);
 		dev_set_drvdata(&spi->dev, NULL);
 	}
 	return 0;
drivers/mmc/host/of_mmc_spi.c new file +149 -0

149 lines not on this page · raw message

include/linux/spi/mmc_spi.h +14 -1
index a3626ae..0f4eb16 100644
@@ -1,9 +1,10 @@
 #ifndef __LINUX_SPI_MMC_SPI_H
 #define __LINUX_SPI_MMC_SPI_H
 
+#include <linux/device.h>
+#include <linux/spi/spi.h>
 #include <linux/interrupt.h>
 
-struct device;
 struct mmc_host;
 
 /* Put this in platform_data of a device being used to manage an MMC/SD
@@ -41,4 +42,16 @@ struct mmc_spi_platform_data {
 	void (*setpower)(struct device *, unsigned int maskval);
 };
 
+#ifdef CONFIG_OF
+extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);
+extern void mmc_spi_put_pdata(struct spi_device *spi);
+#else
+static inline struct mmc_spi_platform_data *
+mmc_spi_get_pdata(struct spi_device *spi)
+{
+	return spi->dev.platform_data;
+}
+static inline void mmc_spi_put_pdata(struct spi_device *spi) {}
+#endif /* CONFIG_OF */
+
 #endif /* __LINUX_SPI_MMC_SPI_H */
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 7 lines · On Tue, 30 Dec 2008 18:15:28 +0300 Anton Vorontsov <[email protected]>…

The support is implemented via platform data accessors, new module (of_mmc_spi) will be created automatically when the driver compiles on OpenFirmware platforms. Link-time dependency will load the module automatically.

---

Queued up.

Quoted 11 lines

Hello Pierre,

All the needed patches were merged into Linus' tree, so I believe it's time for the bindings.

Note that you need to pull Linus' tree into mmc.git's next branch before applying this patch, otherwise it will break bisect, since of_mmc_spi isn't buildable without some patches that are in Linus' tree, but not in the current mmc.git next.

mmc.git#next gets rebased constantly to the current linus HEAD, so this isn't a problem. And since this doesn't really mess with the old SPI driver, I'm pushing this for .29.

Rgds

Signature · 9 lines
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.