Skip to contentSkip to conversation

mmc: add Toshiba PCI SD controller driver

RFC PATCH In review Ondrej Zary 2 participants 2 messages Jan 14, 2014 – Jan 15, 2014 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 mmc: add Toshiba PCI SD controller driver

Hello,
this patch resurrects an old never-finished driver for Toshiba PCI SD controllers found in some older Toshiba laptops (such as Portege R100):

02:0d.0 System peripheral [0880]: Toshiba America Info Systems SD TypA Controller [1179:0805] (rev 05)

The hardware is slow (around 2 MB/s - same in Windows) because it does not support bus mastering (busmaster enable bit cannot be set in PCI control reg). Also the card clock is limited to 16MHz (33MHz PCI clock divided by 2).

The driver seems to work fine except for error handling, which requires some more work - I need to figure out how to properly (i.e. when) clear error bits of the buffer status register.

SD, SDHC and MMC cards work. (MMC cards don't work in Windows) SDIO is not supported (don't have any SDIO card).

drivers/mmc/host/Kconfig +5 -0
index 7fc5099..29dc4ef 100644
@@ -665,3 +665,8 @@ config MMC_REALTEK_PCI
 	help
 	  Say Y here to include driver code to support SD/MMC card interface
 	  of Realtek PCI-E card reader
+
+config MMC_TOSHIBA_PCI
+	tristate "Toshiba Type A SD/MMC Card Interface Driver"
+	depends on PCI
+	help
drivers/mmc/host/Makefile +1 -0
index c41d0c3..2dd1617 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_MMC_USHC)		+= ushc.o
 obj-$(CONFIG_MMC_WMT)		+= wmt-sdmmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)	+= rtsx_pci_sdmmc.o
+obj-$(CONFIG_MMC_TOSHIBA_PCI)	+= toshsd.o
 
 obj-$(CONFIG_MMC_SDHCI_PLTFM)		+= sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_CNS3XXX)		+= sdhci-cns3xxx.o
drivers/mmc/host/toshsd.c new file +740 -0

740 lines not on this page · raw message

drivers/mmc/host/toshsd.h new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
Ondrej Zary
#1 lore raw

drivers/mmc/host/toshsd.c line 190

Quoted 3 lines
drivers/mmc/host/toshsd.c new file +2 -0
+	pr_debug("Command IRQ complete %d %d %x\n", cmd->opcode, cmd->error,
+	    cmd->flags);

dev_dbg... (and a few other places)

drivers/mmc/host/toshsd.c line 447

Quoted 6 lines
drivers/mmc/host/toshsd.c new file +6 -0
+/* Set MMC clock / power.
+ * Note: This controller uses a simple divider scheme therefore it cannot run
+ * SD/MMC cards at full speed (24/20MHz). HCLK (=33MHz PCI clock?) is too high
+ * and the next slowest is 16MHz (div=2).
+ */
+static void toshsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)

This has some very long delays with interrupts off from the spin_lock_irqsave. I guess thats hardly #1 priority though nor a killer.

drivers/mmc/host/toshsd.c line 545

Quoted 5 lines
drivers/mmc/host/toshsd.c new file +5 -0
+	/* reset */
+	toshsd_writew(host, SD_SOFTWARERESET, 0); /* assert */
+	mdelay(2);
+	toshsd_writew(host, SD_SOFTWARERESET, 1); /* deassert */
+	mdelay(2);

This doesn't do quite what you might think - if the device is mmio mapped then the write can be posted so the mdelay(2) may not be 2mS. I guess if the old driver didn't do it then it was already plenty long enough...

drivers/mmc/host/toshsd.c line 684

Quoted 2 lines
drivers/mmc/host/toshsd.c new file +2 -0
+	base = pci_resource_start(pdev, 0);
+	dev_info(&pdev->dev, "MMIO %pa, IRQ %d\n", &base, pdev->irq);

dbg