Skip to contentSkip to conversation

Intel MID SDHCI support (take two)

PATCH In review Alan Cox 3 participants 17 messages Sep 13, 2010 – Sep 14, 2010

Subsystems (3)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

cover Intel MID SDHCI support (take two)

Please ignore the original submission I found a nasty bug in it while I was submitting.

---

Alan Cox (6):
sdhci: Tidy up sdhci.c
sdhci_pci: Tidy this as well
sdhci: Tidy up spaces in sdhci_intel_mid
mmc: serialization support
sdhci: Allow the probe handler to override slots
sdhci: Rework some of the quirk behaviour

Xiaochen Shen (1):
sdhci: Intel Medfield support

 drivers/mmc/core/core.c            |   30 ++++++
 drivers/mmc/host/Kconfig           |   11 ++
 drivers/mmc/host/Makefile          |    1 
 drivers/mmc/host/sdhci-intel-mid.c |  170 ++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pci.c       |  153 ++++++++++++++++++++++++++++----
 drivers/mmc/host/sdhci.c           |  118 +++++++++++++++++--------
 drivers/mmc/host/sdhci.h           |   21 ++++
 include/linux/mmc/core.h           |    1 
 include/linux/mmc/host.h           |    3 +
 include/linux/pci_ids.h            |    7 +
 10 files changed, 452 insertions(+), 63 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-intel-mid.c
Signature · 3 lines
	"Standards committees don't like hashing.  It looks complicated and
         insufficiently deterministic on an overhead projector."
			-Vern Schryver
author
#1 lore raw

PATCH 1/7 sdhci: Rework some of the quirk behaviour

As the quirks go ever more complex it's getting harder and harder to integrate new drivers. The Intel MID devices add a whole further collection of new quirks so instead of quirks start moving some stuff to overridable functions.

We also introduce an sdhci_reset_all helper which is told if the reset is being done during init (which needs to be avoided by some hw) or on exit in which case it doesn't.

Arguably the driver wants to be lots of drivers and "libsdhci" but that would be a massive undertaking.

---

 drivers/mmc/host/Kconfig           |   11 ++
 drivers/mmc/host/Makefile          |    1 
 drivers/mmc/host/sdhci-intel-mid.c |  163 ++++++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pci.c       |   56 ++++++++++++
 drivers/mmc/host/sdhci.c           |   61 ++++++++++---
 drivers/mmc/host/sdhci.h           |   20 ++++
 include/linux/pci_ids.h            |    2 
 7 files changed, 296 insertions(+), 18 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-intel-mid.c
drivers/mmc/host/Kconfig +11 -0
index ce099c4..ffa40f1 100644
@@ -81,6 +81,17 @@ config MMC_RICOH_MMC
 
 	  If unsure, say Y.
 
+config MMC_SDHCI_INTEL_MID
+	tristate "SDHCI support on Intel MID platforms"
+	depends on MMC_SDHCI_PCI
+	help
+	  This includes support for the SDHCI controllers found on Intel
+	  MID platform systems.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_OF
 	tristate "SDHCI support on OpenFirmware platforms"
 	depends on MMC_SDHCI && PPC_OF
drivers/mmc/host/Makefile +1 -0
index 697bbfe..21c80f0 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)	+= sdhci-mv.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
+obj-$(CONFIG_MMC_SDHCI_INTEL_MID)	+= sdhci-intel-mid.o
 obj-$(CONFIG_MMC_SDHCI_S3C)	+= sdhci-s3c.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
drivers/mmc/host/sdhci-intel-mid.c new file +163 -0

163 lines not on this page · raw message

drivers/mmc/host/sdhci-pci.c +54 -2

92 lines not on this page · raw message

drivers/mmc/host/sdhci.c +45 -16

164 lines not on this page · raw message

drivers/mmc/host/sdhci.h +20 -0
index d316bc7..182fcc3 100644
@@ -323,6 +323,17 @@ struct sdhci_ops {
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
+
+	/* Interface hooks to allow drivers to override standard behaviour */
+	void	(*reset)(struct sdhci_host *host, u8 mask);
+	void	(*reset_all)(struct sdhci_host *host, int down);
+	void	(*init)(struct sdhci_host *host, int soft);
+	void 	(*write_command)(struct sdhci_host *host,
+				struct mmc_command *cmd, int flags);
+	void	(*set_ios)(struct sdhci_host *host,
+				struct mmc_ios *ios, u8 ctrl);
+	void	(*set_caps)(struct sdhci_host *host);
+	void	(*unexpected_cmd_irq)(struct sdhci_host *host, u32 intmask);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
@@ -427,4 +438,13 @@ extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state);
 extern int sdhci_resume_host(struct sdhci_host *host);
 #endif
 
+extern void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set);
+extern int sdhci_pci_enable_dma(struct sdhci_host *host);
+extern void sdhci_dumpregs(struct sdhci_host *host);
+extern void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
+
+/* Host function sets from driver support files */
+extern struct sdhci_ops sdhci_intel_mrst_hc;
+
+
 #endif /* __SDHCI_H */
include/linux/pci_ids.h +2 -0
index 9438660..674316e 100644
@@ -2410,6 +2410,8 @@
 #define PCI_DEVICE_ID_INTEL_82375	0x0482
 #define PCI_DEVICE_ID_INTEL_82424	0x0483
 #define PCI_DEVICE_ID_INTEL_82378	0x0484
+#define PCI_DEVICE_ID_INTEL_MRST_SD0	0x0807
+#define PCI_DEVICE_ID_INTEL_MRST_SD1	0x0808
 #define PCI_DEVICE_ID_INTEL_I960	0x0960
 #define PCI_DEVICE_ID_INTEL_I960RM	0x0962
 #define PCI_DEVICE_ID_INTEL_8257X_SOL	0x1062
#2 lore raw

Re: [PATCH 1/7] sdhci: Rework some of the quirk behaviour

Quoted 11 lines · Alan Cox

As the quirks go ever more complex it's getting harder and harder to integrate new drivers. The Intel MID devices add a whole further collection of new quirks so instead of quirks start moving some stuff to overridable functions.

We also introduce an sdhci_reset_all helper which is told if the reset is being done during init (which needs to be avoided by some hw) or on exit in which case it doesn't.

Arguably the driver wants to be lots of drivers and "libsdhci" but that would be a massive undertaking.

Quoted 6 lines

---

 drivers/mmc/host/Kconfig           |   11 ++
 drivers/mmc/host/Makefile          |    1 
 drivers/mmc/host/sdhci-intel-mid.c |  163 ++++++++++++++++++++++++++++++++++++

Why are those added here and not in patch 3/7?

Quoted 6 lines
 drivers/mmc/host/sdhci-pci.c       |   56 ++++++++++++
 drivers/mmc/host/sdhci.c           |   61 ++++++++++---
 drivers/mmc/host/sdhci.h           |   20 ++++
 include/linux/pci_ids.h            |    2 
 7 files changed, 296 insertions(+), 18 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-intel-mid.c

From having a glimpse, there is MID-specific stuff all over the patch. This makes finding the actual "quirk rework" harder.

Quoted 227 lines
drivers/mmc/host/Kconfig +11 -0
index ce099c4..ffa40f1 100644
@@ -81,6 +81,17 @@ config MMC_RICOH_MMC
 
 	  If unsure, say Y.
 
+config MMC_SDHCI_INTEL_MID
+	tristate "SDHCI support on Intel MID platforms"
+	depends on MMC_SDHCI_PCI
+	help
+	  This includes support for the SDHCI controllers found on Intel
+	  MID platform systems.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_OF
 	tristate "SDHCI support on OpenFirmware platforms"
 	depends on MMC_SDHCI && PPC_OF
drivers/mmc/host/Makefile +1 -0
index 697bbfe..21c80f0 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)	+= sdhci-mv.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
+obj-$(CONFIG_MMC_SDHCI_INTEL_MID)	+= sdhci-intel-mid.o
 obj-$(CONFIG_MMC_SDHCI_S3C)	+= sdhci-s3c.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
drivers/mmc/host/sdhci-intel-mid.c new file +163 -0
new file mode 100644
index 0000000..2828831
@@ -0,0 +1,163 @@
+#include <linux/delay.h>
+#include <linux/highmem.h>
+#include <linux/io.h>
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+#include <linux/scatterlist.h>
+#include <linux/regulator/consumer.h>
+
+#include <linux/leds.h>
+
+#include <linux/mmc/host.h>
+
+#include "sdhci.h"
+
+/*
+ *	Support code for SDHCI on Intel MID platforms. We have lots
+ * 	of quirks specific to these platforms so wrap them up in one place
+ *	that keeps them out of the main flow. We can't just make it a new
+ *	driver as the shdci core code isn't really a library.
+ */
+ 
+static void sdhci_broken_reset(struct sdhci_host *host, u8 mask)
+{
+	unsigned long timeout;
+	u32 uninitialized_var(ier);
+
+	if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
+		if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
+			SDHCI_CARD_PRESENT))
+			return;
+	}
+
+	if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)
+		ier = sdhci_readl(host, SDHCI_INT_ENABLE);
+
+	sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
+
+	if (mask & SDHCI_RESET_ALL)
+		host->clock = 0;
+
+	/* Wait max 100 ms */
+	timeout = 100;
+
+	/* hw clears the bit when it's done */
+	while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) {
+		if (timeout == 0) {
+			printk(KERN_ERR "%s: Reset 0x%x never completed.\n",
+				mmc_hostname(host->mmc), (int)mask);
+		}
+		timeout--;
+		mdelay(1);
+	}
+	if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)
+		sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier);
+}
+
+static void sdhci_mid_broken_resetall(struct sdhci_host *host, int down)
+{
+	if (down)
+		sdhci_broken_reset(host, SDHCI_RESET_ALL);
+}
+
+static void sdhci_mid_init_no_reset(struct sdhci_host *host, int soft)
+{
+	u32 intmask;
+
+	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+	sdhci_writel(host,
+		intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE),
+		SDHCI_INT_STATUS);
+
+        /* Ensure any IRQ left over from pre boot time (eg from Kboot) does
+           not turn up and cause chaos */
+	sdhci_writel(host, 0, SDHCI_INT_ENABLE);
+	sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
+
+	sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK,
+		SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
+		SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX |
+		SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
+		SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE);
+
+	if (soft) {
+		/* force clock reconfiguration */
+		host->clock = 0;
+		sdhci_set_ios(host->mmc, &host->mmc->ios);
+	}
+
+	/* disable wakeup signal during initialization */
+	sdhci_writeb(host, 0x0, SDHCI_WAKE_UP_CONTROL);
+}
+
+/*
+ * HW problem exists in LNW A3 so clock register has to be set
+ * for every command if both SDIO0 and SDIO1 are enabled.
+ */
+static void sdhci_clock_reset(struct sdhci_host *host)
+{
+	u16 clk;
+	unsigned long timeout;
+
+	clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
+
+	clk |= SDHCI_CLOCK_CARD_EN;
+	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
+
+	/* Wait max 10 ms */
+	timeout = 10;
+	while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
+		& SDHCI_CLOCK_INT_STABLE)) {
+		if (timeout == 0) {
+			printk(KERN_ERR "%s: Internal clock never "
+				"stabilised.\n",
+				mmc_hostname(host->mmc));
+			sdhci_dumpregs(host);
+			return;
+		}
+		timeout--;
+		mdelay(1);
+	}
+}
+
+static void sdhci_clockreset_wcmd(struct sdhci_host *host,
+				struct mmc_command *cmd, int flags)
+{
+	sdhci_clock_reset(host);
+ 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
+}
+
+static void sdhci_lnw_a3_set_ios(struct sdhci_host *host,
+					struct mmc_ios *ios, u8 ctrl)
+{
+	/*
+	 * For LNW A3, HISPD bit has to be cleared in order to
+	 * enable the 50MHz clock
+	 */
+	if (ios->timing == MMC_TIMING_SD_HS ||
+			ios->timing == MMC_TIMING_MMC_HS)
+		ctrl |= SDHCI_CTRL_HISPD;
+	else
+		ctrl &= ~SDHCI_CTRL_HISPD;
+	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+}
+
+/*
+ * HW problem exists in LNW A3 which leads to fake interrupt on SDIO1 if SDIO0
+ * and SDIO1 are both enabled.
+ */
+static void sdhci_lnw_a3_unexpected_cmd(struct sdhci_host *host, u32 intmask)
+{
+}
+
+struct sdhci_ops sdhci_intel_mrst_hc = {
+	.reset = sdhci_broken_reset,
+	.init = sdhci_mid_init_no_reset,
+	.set_ios = sdhci_lnw_a3_set_ios,
+	.reset_all = sdhci_mid_broken_resetall,
+	.write_command = sdhci_clockreset_wcmd,
+	.unexpected_cmd_irq = sdhci_lnw_a3_unexpected_cmd,
+};
+EXPORT_SYMBOL_GPL(sdhci_intel_mrst_hc);
+
+
drivers/mmc/host/sdhci-pci.c +7 -0
index e8aa99d..3e29e94 100644
@@ -54,6 +54,8 @@ struct sdhci_pci_fixes {
 	int			(*suspend)(struct sdhci_pci_chip*,
 					pm_message_t);
 	int			(*resume)(struct sdhci_pci_chip*);
+
+	struct sdhci_ops	*host_ops;
 };
 
 struct sdhci_pci_slot {
@@ -397,6 +399,35 @@ static const struct sdhci_pci_fixes sdhci_via = {
 	.probe		= via_probe,
 };
 
+#if defined(CONFIG_MMC_SDHCI_INTEL_MID) || defined(CONFIG_MMC_SDHCI_INTEL_MID_MODULE)
+
+/*
+ * ADMA operation is disabled for Moorestown platform due to
+ * hardware bugs.

drivers/mmc/host/sdhci-pci.c static const struct sdhci_pci_fixes sdhci_via = { · line 416

Quoted 10 lines
drivers/mmc/host/sdhci-pci.c +10 -0
+ */
+static int mrst_hc0_probe(struct sdhci_pci_chip *chip)
+{
+	/*
+	 * slots number is fixed here for MRST as SDIO3 is never used and has
+	 * hardware bugs.
+	 */
+	chip->num_slots = 1;
+	return 0;
+}

Why is this function here and not in sdhci-intel-mid.c?

Quoted 228 lines
drivers/mmc/host/sdhci-pci.c +37 -2
+
+static const struct sdhci_pci_fixes sdhci_intel_mrst_hc0 = {
+	.quirks		= SDHCI_QUIRK_BROKEN_ADMA,
+	.probe		= mrst_hc0_probe,
+	.host_ops	= &sdhci_intel_mrst_hc,
+};
+
+static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1 = {
+	.quirks		= SDHCI_QUIRK_BROKEN_ADMA,
+	.host_ops	= &sdhci_intel_mrst_hc,
+};
+
+#endif
+
 static const struct pci_device_id pci_ids[] __devinitdata = {
 	{
 		.vendor		= PCI_VENDOR_ID_RICOH,
@@ -494,6 +525,23 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
 		.driver_data	= (kernel_ulong_t)&sdhci_via,
 	},
 
+#if defined(CONFIG_MMC_SDHCI_INTEL_MID) || defined(CONFIG_MMC_SDHCI_INTEL_MID_MODULE)
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MRST_SD0,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mrst_hc0,
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MRST_SD1,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mrst_hc1,
+	},
+#endif
 	{	/* Generic SD host controller */
 		PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
 	},
@@ -509,7 +557,7 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
  *                                                                           *
 \*****************************************************************************/
 
-static int sdhci_pci_enable_dma(struct sdhci_host *host)
+int sdhci_pci_enable_dma(struct sdhci_host *host)
 {
 	struct sdhci_pci_slot *slot;
 	struct pci_dev *pdev;
@@ -533,6 +581,7 @@ static int sdhci_pci_enable_dma(struct sdhci_host *host)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(sdhci_pci_enable_dma);
 
 static struct sdhci_ops sdhci_pci_ops = {
 	.enable_dma	= sdhci_pci_enable_dma,
@@ -687,7 +736,10 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
 	slot->pci_bar = bar;
 
 	host->hw_name = "PCI";
-	host->ops = &sdhci_pci_ops;
+	if (chip->fixes->host_ops)
+		host->ops = chip->fixes->host_ops;
+	else
+		host->ops = &sdhci_pci_ops;
 	host->quirks = chip->quirks;
 
 	host->irq = pdev->irq;
drivers/mmc/host/sdhci.c +42 -13
index f608626..9d8091a 100644
@@ -45,7 +45,7 @@ static void sdhci_finish_data(struct sdhci_host *);
 static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
 static void sdhci_finish_command(struct sdhci_host *);
 
-static void sdhci_dumpregs(struct sdhci_host *host)
+void sdhci_dumpregs(struct sdhci_host *host)
 {
 	printk(KERN_DEBUG DRIVER_NAME ": ============== REGISTER DUMP ==============\n");
 
@@ -87,6 +87,7 @@ static void sdhci_dumpregs(struct sdhci_host *host)
 
 	printk(KERN_DEBUG DRIVER_NAME ": ===========================================\n");
 }
+EXPORT_SYMBOL_GPL(sdhci_dumpregs);
 
 /*****************************************************************************\
  *                                                                           *
@@ -94,7 +95,7 @@ static void sdhci_dumpregs(struct sdhci_host *host)
  *                                                                           *
 \*****************************************************************************/
 
-static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
+void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
 {
 	u32 ier;
 
@@ -104,6 +105,7 @@ static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
 	sdhci_writel(host, ier, SDHCI_INT_ENABLE);
 	sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE);
 }
+EXPORT_SYMBOL_GPL(sdhci_clear_set_irqs);
 
 static void sdhci_unmask_irqs(struct sdhci_host *host, u32 irqs)
 {
@@ -143,6 +145,11 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
 	unsigned long timeout;
 	u32 uninitialized_var(ier);
 
+	if (host->ops->reset) {
+		host->ops->reset(host, mask);
+		return;
+	}
+
 	if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
 		if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
 			SDHCI_CARD_PRESENT))
@@ -176,14 +183,21 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
 		sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier);
 }
 
-static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
+/* Down is true if we are shutting down the port */
+static void sdhci_reset_all(struct sdhci_host *host, int down)
+{
+	if (host->ops->reset_all)
+		host->ops->reset_all(host, down);
+	else
+		sdhci_reset(host, SDHCI_RESET_ALL);
+}
 
 static void sdhci_init(struct sdhci_host *host, int soft)
 {
 	if (soft)
 		sdhci_reset(host, SDHCI_RESET_CMD|SDHCI_RESET_DATA);
 	else
-		sdhci_reset(host, SDHCI_RESET_ALL);
+		sdhci_reset_all(host, 0);
 
 	sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK,
 		SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
@@ -945,7 +959,11 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 	if (cmd->data)
 		flags |= SDHCI_CMD_DATA;
 
-	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
+	if (host->ops->write_command)
+		host->ops->write_command(host, cmd, flags);
+	else
+		sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags),
+						SDHCI_COMMAND);
 }
 
 static void sdhci_finish_command(struct sdhci_host *host)
@@ -1139,7 +1157,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	spin_unlock_irqrestore(&host->lock, flags);
 }
 
-static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct sdhci_host *host;
 	unsigned long flags;
@@ -1186,9 +1204,13 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	else
 		ctrl &= ~SDHCI_CTRL_HISPD;
 
-	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+	if (host->ops->set_ios)
+		host->ops->set_ios(host, ios, ctrl);
+	else
+		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
-	/*
+	/*	FIXME: This can also be moved to ops->set_ios
+	 *
 	 * Some (ENE) controllers go apeshit on some ios operation,
 	 * signalling timeout and CRC errors even on CMD0. Resetting
 	 * it on each ios seems to solve the problem.
@@ -1200,6 +1222,7 @@ out:
 	mmiowb();
 	spin_unlock_irqrestore(&host->lock, flags);
 }
+EXPORT_SYMBOL_GPL(sdhci_set_ios);
 
 static int sdhci_get_ro(struct mmc_host *mmc)
 {
@@ -1383,10 +1406,13 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
 	BUG_ON(intmask == 0);
 
 	if (!host->cmd) {
-		printk(KERN_ERR "%s: Got command interrupt 0x%08x even "
-			"though no command operation was in progress.\n",
-			mmc_hostname(host->mmc), (unsigned)intmask);
-		sdhci_dumpregs(host);
+		if (host->ops->unexpected_cmd_irq)
+			host->ops->unexpected_cmd_irq(host, intmask);
+		else {
+			printk(KERN_ERR "%s: Got command interrupt 0x%08x even though no command operation was in progress.\n",
+				mmc_hostname(host->mmc), (unsigned)intmask);
+			sdhci_dumpregs(host);
+		}
 		return;
 	}
 
@@ -1703,7 +1729,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (debug_quirks)
 		host->quirks = debug_quirks;
 
-	sdhci_reset(host, SDHCI_RESET_ALL);
+	sdhci_reset_all(host, 0);
 
 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
 	host->version = (host->version & SDHCI_SPEC_VER_MASK)
@@ -1829,6 +1855,9 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
 		mmc->caps |= MMC_CAP_NEEDS_POLL;
 
+	if (host->ops->set_caps)
+		host->ops->set_caps(host);
+
 	mmc->ocr_avail = 0;
 	if (caps & SDHCI_CAN_VDD_330)
 		mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34;

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 1913

Quoted 5 lines
drivers/mmc/host/sdhci.c +1 -1
@@ -1881,7 +1910,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	} else {
 		mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >>
 				SDHCI_MAX_BLOCK_SHIFT;
-		if (mmc->max_blk_size >= 3) {
+		if (mmc->max_blk_size > 3) {

Why this change? Not mentioned in the changelog. And wrong according to the simplified standard v2. Is it V3 material?

Quoted 30 lines
drivers/mmc/host/sdhci.c +2 -2
 			printk(KERN_WARNING "%s: Invalid maximum block size, "
 				"assuming 512 bytes\n", mmc_hostname(mmc));
 			mmc->max_blk_size = 0;
@@ -1952,7 +1981,7 @@ int sdhci_add_host(struct sdhci_host *host)
 
 #ifdef SDHCI_USE_LEDS_CLASS
 reset:
-	sdhci_reset(host, SDHCI_RESET_ALL);
+	sdhci_reset_all(host, 1);
 	free_irq(host->irq, host);
 #endif
 untasklet:
@@ -1993,7 +2022,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 #endif
 
 	if (!dead)
-		sdhci_reset(host, SDHCI_RESET_ALL);
+		sdhci_reset_all(host, 1);
 
 	free_irq(host->irq, host);
 
drivers/mmc/host/sdhci.h +1 -0
index d316bc7..182fcc3 100644
@@ -323,6 +323,17 @@ struct sdhci_ops {
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
+

drivers/mmc/host/sdhci.h struct sdhci_ops { · line 336

Quoted 10 lines
drivers/mmc/host/sdhci.h +10 -0
+	/* Interface hooks to allow drivers to override standard behaviour */
+	void	(*reset)(struct sdhci_host *host, u8 mask);
+	void	(*reset_all)(struct sdhci_host *host, int down);
+	void	(*init)(struct sdhci_host *host, int soft);
+	void 	(*write_command)(struct sdhci_host *host,
+				struct mmc_command *cmd, int flags);
+	void	(*set_ios)(struct sdhci_host *host,
+				struct mmc_ios *ios, u8 ctrl);
+	void	(*set_caps)(struct sdhci_host *host);
+	void	(*unexpected_cmd_irq)(struct sdhci_host *host, u32 intmask);

That looks quite much on a first view. Might need to dig in deeper...

Quoted 35 lines
drivers/mmc/host/sdhci.h +9 -0
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
@@ -427,4 +438,13 @@ extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state);
 extern int sdhci_resume_host(struct sdhci_host *host);
 #endif
 
+extern void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set);
+extern int sdhci_pci_enable_dma(struct sdhci_host *host);
+extern void sdhci_dumpregs(struct sdhci_host *host);
+extern void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
+
+/* Host function sets from driver support files */
+extern struct sdhci_ops sdhci_intel_mrst_hc;
+
+
 #endif /* __SDHCI_H */
include/linux/pci_ids.h +2 -1
index 9438660..674316e 100644
@@ -2410,6 +2410,8 @@
 #define PCI_DEVICE_ID_INTEL_82375	0x0482
 #define PCI_DEVICE_ID_INTEL_82424	0x0483
 #define PCI_DEVICE_ID_INTEL_82378	0x0484
+#define PCI_DEVICE_ID_INTEL_MRST_SD0	0x0807
+#define PCI_DEVICE_ID_INTEL_MRST_SD1	0x0808
 #define PCI_DEVICE_ID_INTEL_I960	0x0960
 #define PCI_DEVICE_ID_INTEL_I960RM	0x0962
 #define PCI_DEVICE_ID_INTEL_8257X_SOL	0x1062
 
--

To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#3 lore raw

Re: [PATCH 1/7] sdhci: Rework some of the quirk behaviour

Quoted 6 lines
Quoted 4 lines
 drivers/mmc/host/Kconfig           |   11 ++
 drivers/mmc/host/Makefile          |    1 
 drivers/mmc/host/sdhci-intel-mid.c |  163

++++++++++++++++++++++++++++++++++++

Why are those added here and not in patch 3/7?

I thought it would be useful to add the hooks and show how they are used in one - I can split that easily enough.

Quoted 7 lines
Quoted 7 lines

+ * ADMA operation is disabled for Moorestown platform due to
+ * hardware bugs.
+ */

drivers/mmc/host/sdhci-pci.c +4 -0
+static int mrst_hc0_probe(struct sdhci_pci_chip *chip)
+{
+	/*
+	 * slots number is fixed here for MRST as SDIO3 is never
Quoted 8 lines

drivers/mmc/host/sdhci-pci.c static const struct sdhci_pci_fixes sdhci_via = { · line 416

Quoted 6 lines

used and has

drivers/mmc/host/sdhci-pci.c +5 -0
+	 * hardware bugs.
+	 */
+	chip->num_slots = 1;
+	return 0;
+}

Why is this function here and not in sdhci-intel-mid.c?

So it follows the pattern of the other drivers, so it doesn't need an extra exported symbol (at about ten times the size of the function).

We could move probe into host_ops I guess but that means tweaking all the other drivers which I cannot test.

I guess the other way to do it would be not to have a separate file but to stick it all in sdhci-pci ?

Quoted 7 lines

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 1913

Quoted 4 lines

mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK)

Quoted 1 line
Quoted 1 line

SDHCI_MAX_BLOCK_SHIFT;

drivers/mmc/host/sdhci.c +1 -1
-		if (mmc->max_blk_size >= 3) {
+		if (mmc->max_blk_size > 3) {

Why this change? Not mentioned in the changelog. And wrong according to the simplified standard v2. Is it V3 material?

That's got in by mistake. I thought I'd got all the spec related bits stripped out.

I actually suspect for the more general case of cleaning up some of the other driver quirks we need a couple more callbacks but its hard to sure.

author
#4 lore raw

PATCH 2/7 sdhci: Allow the probe handler to override slots

In reply to Alan Cox

Currently we write it to the chip data, but if the probe handler overrides it we ignore the new value and keep using our cached one. Fix this so that a probe handler can adjust the slot count

---

 drivers/mmc/host/sdhci-pci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-pci.c +2 -0
index 3e29e94..9b0a348 100644
@@ -870,6 +870,8 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
 			goto free;
 	}
 
+	slots = chip->num_slots;	/* Quirk may have changed this */
+
 	for (i = 0;i < slots;i++) {
 		slot = sdhci_pci_probe_slot(pdev, chip, first_bar + i);
 		if (IS_ERR(slot)) {
author
#5 lore raw

PATCH 3/7 sdhci: Intel Medfield support

In reply to Alan Cox

From: Xiaochen Shen <[email protected]>

Basic support for the Intel Medfield devices

---

 drivers/mmc/host/sdhci-pci.c |   49 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/pci_ids.h      |    5 ++++
 2 files changed, 54 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-pci.c +49 -0
index 9b0a348..1324369 100644
@@ -426,6 +426,15 @@ static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1 = {
 	.host_ops	= &sdhci_intel_mrst_hc,
 };
 
+static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = {
+	.quirks		= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
+};
+
+static const struct sdhci_pci_fixes sdhci_intel_mfd_emmc_sdio = {
+	.quirks		= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
+};
+
+
 #endif
 
 static const struct pci_device_id pci_ids[] __devinitdata = {
@@ -541,6 +550,46 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
 		.subdevice	= PCI_ANY_ID,
 		.driver_data	= (kernel_ulong_t)&sdhci_intel_mrst_hc1,
 	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MFD_SD,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mfd_sd,
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MFD_SDIO1,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mfd_emmc_sdio,
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MFD_SDIO2,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mfd_emmc_sdio,
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MFD_EMMC0,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mfd_emmc_sdio,
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_INTEL,
+		.device		= PCI_DEVICE_ID_INTEL_MFD_EMMC1,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (kernel_ulong_t)&sdhci_intel_mfd_emmc_sdio,
+	},
 #endif
 	{	/* Generic SD host controller */
 		PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
include/linux/pci_ids.h +5 -0
index 674316e..fd619e8 100644
@@ -2412,6 +2412,11 @@
 #define PCI_DEVICE_ID_INTEL_82378	0x0484
 #define PCI_DEVICE_ID_INTEL_MRST_SD0	0x0807
 #define PCI_DEVICE_ID_INTEL_MRST_SD1	0x0808
+#define PCI_DEVICE_ID_INTEL_MFD_SD	0x0820
+#define PCI_DEVICE_ID_INTEL_MFD_SDIO1	0x0821
+#define PCI_DEVICE_ID_INTEL_MFD_SDIO2	0x0822
+#define PCI_DEVICE_ID_INTEL_MFD_EMMC0	0x0823
+#define PCI_DEVICE_ID_INTEL_MFD_EMMC1	0x0824
 #define PCI_DEVICE_ID_INTEL_I960	0x0960
 #define PCI_DEVICE_ID_INTEL_I960RM	0x0962
 #define PCI_DEVICE_ID_INTEL_8257X_SOL	0x1062
author
#6 lore raw

PATCH 4/7 mmc: serialization support

In reply to Alan Cox

Some hardware has restrictions that require only one command is outstanding per controller or some other similar restriction.

Provide optional serialization support and enable it for the Intel MID platform devices with this restriction. Split up from some existing patches by JiebingLi.

---

 drivers/mmc/core/core.c            |   30 ++++++++++++++++++++++++++----
 drivers/mmc/host/sdhci-intel-mid.c |   33 ++++++++++++++++++++-------------
 drivers/mmc/host/sdhci-pci.c       |    2 ++
 drivers/mmc/host/sdhci.c           |   18 ++++++++++++++++++
 drivers/mmc/host/sdhci.h           |    1 +
 include/linux/mmc/core.h           |    1 +
 include/linux/mmc/host.h           |    3 +++
 7 files changed, 71 insertions(+), 17 deletions(-)
drivers/mmc/core/core.c +26 -4
index 5db49b1..b2abb68 100644
@@ -202,11 +202,14 @@ static void mmc_wait_done(struct mmc_request *mrq)
  *	@host: MMC host to start command
  *	@mrq: MMC request to start
  *
- *	Start a new MMC custom command request for a host, and wait
- *	for the command to complete. Does not attempt to parse the
- *	response.
+ *	Implementation hander for starting a new MMC custom command request
+ *	for a host, and wait for the command to complete. Does not attempt to
+ *	parse the response.
+ *
+ *	We provide this separately and export it so that it can be wrapped
+ *	by callers who need serialization or have other issue constraints
  */
-void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
+void mmc_do_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
 {
 	DECLARE_COMPLETION_ONSTACK(complete);
 
@@ -218,6 +221,25 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
 	wait_for_completion(&complete);
 }
 
+EXPORT_SYMBOL(mmc_do_wait_for_req);
+
+/**
+ *	mmc_wait_for_req - start a request and wait for completion
+ *	@host: MMC host to start command
+ *	@mrq: MMC request to start
+ *
+ *	Start a new MMC custom command request for a host, and wait
+ *	for the command to complete. Does not attempt to parse the
+ *	response.
+ */
+void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
+{
+	if (host->ops->wait_for_req)
+		host->ops->wait_for_req(host, mrq);
+	else
+		return mmc_do_wait_for_req(host, mrq);
+}
+
 EXPORT_SYMBOL(mmc_wait_for_req);
 
 /**
drivers/mmc/host/sdhci-intel-mid.c +20 -13
index 2828831..436ee46 100644
@@ -18,20 +18,27 @@
  *	that keeps them out of the main flow. We can't just make it a new
  *	driver as the shdci core code isn't really a library.
  */
- 
+
+/*
+ *	Support serialization
+ */
+
+static DEFINE_MUTEX(port_mutex);
+
+static void sdhci_intel_wait_req(struct sdhci_host *host,
+                                                struct mmc_request *mrq)
+{
+        mutex_lock(&port_mutex);
+        mmc_do_wait_for_req(host->mmc, mrq);
+        mutex_unlock(&port_mutex);
+}
+
+/*
+ *	Handle the Moorestown reset
+ */ 
 static void sdhci_broken_reset(struct sdhci_host *host, u8 mask)
 {
 	unsigned long timeout;
-	u32 uninitialized_var(ier);
-
-	if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
-		if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
-			SDHCI_CARD_PRESENT))
-			return;
-	}
-
-	if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)
-		ier = sdhci_readl(host, SDHCI_INT_ENABLE);
 
 	sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
 
@@ -46,12 +53,11 @@ static void sdhci_broken_reset(struct sdhci_host *host, u8 mask)
 		if (timeout == 0) {
 			printk(KERN_ERR "%s: Reset 0x%x never completed.\n",
 				mmc_hostname(host->mmc), (int)mask);
+			return;
 		}
 		timeout--;
 		mdelay(1);
 	}
-	if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)
-		sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier);
 }
 
 static void sdhci_mid_broken_resetall(struct sdhci_host *host, int down)
@@ -156,6 +162,7 @@ struct sdhci_ops sdhci_intel_mrst_hc = {
 	.set_ios = sdhci_lnw_a3_set_ios,
 	.reset_all = sdhci_mid_broken_resetall,
 	.write_command = sdhci_clockreset_wcmd,
+	.wait_for_req = sdhci_intel_wait_req,
 	.unexpected_cmd_irq = sdhci_lnw_a3_unexpected_cmd,
 };
 EXPORT_SYMBOL_GPL(sdhci_intel_mrst_hc);
drivers/mmc/host/sdhci-pci.c +2 -0
index 1324369..bb14047 100644
@@ -55,6 +55,8 @@ struct sdhci_pci_fixes {
 					pm_message_t);
 	int			(*resume)(struct sdhci_pci_chip*);
 
+	/* Allow the driver to override some operations for particularly
+	   quirky chips */
 	struct sdhci_ops	*host_ops;
 };
 
drivers/mmc/host/sdhci.c +18 -0
index 9d8091a..9d8047c 100644
@@ -1268,6 +1268,12 @@ out:
 	spin_unlock_irqrestore(&host->lock, flags);
 }
 
+static void sdhci_wait_for_req(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	host->ops->wait_for_req(host, mrq);
+}
+
 static const struct mmc_host_ops sdhci_ops = {
 	.request	= sdhci_request,
 	.set_ios	= sdhci_set_ios,
@@ -1275,6 +1281,16 @@ static const struct mmc_host_ops sdhci_ops = {
 	.enable_sdio_irq = sdhci_enable_sdio_irq,
 };
 
+/* Operations struct we use if the controller has an sdhci level
+   ops->wait_for_req */
+static const struct mmc_host_ops sdhci_ops_wait = {
+	.request	= sdhci_request,
+	.set_ios	= sdhci_set_ios,
+	.get_ro		= sdhci_get_ro,
+	.enable_sdio_irq = sdhci_enable_sdio_irq,
+	.wait_for_req	= sdhci_wait_for_req,
+};
+
 /*****************************************************************************\
  *                                                                           *
  * Tasklets                                                                  *
@@ -1839,6 +1855,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	 * Set host parameters.
 	 */
 	mmc->ops = &sdhci_ops;
+	if (host->ops->wait_for_req)
+		mmc->ops = &sdhci_ops_wait;
 	if (host->ops->get_min_clock)
 		mmc->f_min = host->ops->get_min_clock(host);
 	else
drivers/mmc/host/sdhci.h +1 -0
index 182fcc3..7c934bd 100644
@@ -334,6 +334,7 @@ struct sdhci_ops {
 				struct mmc_ios *ios, u8 ctrl);
 	void	(*set_caps)(struct sdhci_host *host);
 	void	(*unexpected_cmd_irq)(struct sdhci_host *host, u32 intmask);
+	void	(*wait_for_req)(struct sdhci_host *host, struct mmc_request *mrq);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
include/linux/mmc/core.h +1 -0
index 7429033..6eaf5dd 100644
@@ -132,6 +132,7 @@ struct mmc_host;
 struct mmc_card;
 
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
+extern void mmc_do_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
 extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
 	struct mmc_command *, int);
include/linux/mmc/host.h +3 -0
index ded4017..1b0e162 100644
@@ -111,6 +111,9 @@ struct mmc_host_ops {
 
 	/* optional callback for HC quirks */
 	void	(*init_card)(struct mmc_host *host, struct mmc_card *card);
+	/* optional callback for serialization */
+	void	(*wait_for_req)(struct mmc_host *host,
+						struct mmc_request *mrq);
 };
 
 struct mmc_card;
author
#7 lore raw

PATCH 5/7 sdhci: Tidy up spaces in sdhci_intel_mid

In reply to Alan Cox

Coding style fixes

---

 drivers/mmc/host/sdhci-intel-mid.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci-intel-mid.c +9 -9
index 436ee46..5057133 100644
@@ -14,7 +14,7 @@
 
 /*
  *	Support code for SDHCI on Intel MID platforms. We have lots
- * 	of quirks specific to these platforms so wrap them up in one place
+ *	of quirks specific to these platforms so wrap them up in one place
  *	that keeps them out of the main flow. We can't just make it a new
  *	driver as the shdci core code isn't really a library.
  */
@@ -26,16 +26,16 @@
 static DEFINE_MUTEX(port_mutex);
 
 static void sdhci_intel_wait_req(struct sdhci_host *host,
-                                                struct mmc_request *mrq)
+						struct mmc_request *mrq)
 {
-        mutex_lock(&port_mutex);
-        mmc_do_wait_for_req(host->mmc, mrq);
-        mutex_unlock(&port_mutex);
+	mutex_lock(&port_mutex);
+	mmc_do_wait_for_req(host->mmc, mrq);
+	mutex_unlock(&port_mutex);
 }
 
 /*
  *	Handle the Moorestown reset
- */ 
+ */
 static void sdhci_broken_reset(struct sdhci_host *host, u8 mask)
 {
 	unsigned long timeout;
@@ -75,8 +75,8 @@ static void sdhci_mid_init_no_reset(struct sdhci_host *host, int soft)
 		intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE),
 		SDHCI_INT_STATUS);
 
-        /* Ensure any IRQ left over from pre boot time (eg from Kboot) does
-           not turn up and cause chaos */
+	/* Ensure any IRQ left over from pre boot time (eg from Kboot) does
+	   not turn up and cause chaos */
 	sdhci_writel(host, 0, SDHCI_INT_ENABLE);
 	sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
 
@@ -130,7 +130,7 @@ static void sdhci_clockreset_wcmd(struct sdhci_host *host,
 				struct mmc_command *cmd, int flags)
 {
 	sdhci_clock_reset(host);
- 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
+	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
 }
 
 static void sdhci_lnw_a3_set_ios(struct sdhci_host *host,
#8 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

Quoted 3 lines · Alan Cox

Coding style fixes

Shouldn't this be folded into the patch which initially creates sdhci-intel-mid.c?

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#9 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

Quoted 7 lines · On Tue, 14 Sep 2010 16:21:29 +0200 Wolfram Sang <[email protected]> wrote:
Quoted 3 lines · Alan Cox

Coding style fixes

Shouldn't this be folded into the patch which initially creates sdhci-intel-mid.c?

The work was done later and the signoffs are not the same. In the ideal world - yes of course. I can redo them this way if you want but it'll probably be about a month.

Alan

#10 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

Quoted 6 lines · Alan Cox
Quoted 3 lines · On Tue, 14 Sep 2010 16:21:29 +0200 Wolfram Sang <[email protected]> wrote:
Quoted 2 lines · Alan Cox

Coding style fixes

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Shouldn't this be folded into the patch which initially creates sdhci-intel-mid.c?

The work was done later and the signoffs are not the same. In the ideal world - yes of course. I can redo them this way if you want but it'll probably be about a month.

I would indeed prefer to first have minimal changes to the mmc/sdhci-core and then have the final version of sdhci-intel-mid.c put on top of that (also applies to patch 4/7). Less error prone and easier to review. Yet, I am not the one who is picking up the patches.

(BTW can't you just combine SoB if you fold patches?)

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#11 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

Quoted 16 lines · On Tue, 14 Sep 2010 16:45:12 +0200 Wolfram Sang <[email protected]> wrote:
Quoted 6 lines · Alan Cox
Quoted 3 lines · On Tue, 14 Sep 2010 16:21:29 +0200 Wolfram Sang <[email protected]> wrote:
Quoted 2 lines · Alan Cox

Coding style fixes

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Shouldn't this be folded into the patch which initially creates sdhci-intel-mid.c?

The work was done later and the signoffs are not the same. In the ideal world - yes of course. I can redo them this way if you want but it'll probably be about a month.

Quoted 6 lines

I would indeed prefer to first have minimal changes to the mmc/sdhci-core and then have the final version of sdhci-intel-mid.c put on top of that (also applies to patch 4/7). Less error prone and easier to review. Yet, I am not the one who is picking up the patches.

(BTW can't you just combine SoB if you fold patches?)

Ok will have a look at that next month and will also split the host ops patches into a patch to add them and a patch to use them.

Alan

#12 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

In reply to Wolfram Sang

Hi,

Quoted 6 lines · Wolfram Sang

I would indeed prefer to first have minimal changes to the mmc/sdhci-core and then have the final version of sdhci-intel-mid.c put on top of that (also applies to patch 4/7). Less error prone and easier to review. Yet, I am not the one who is picking up the patches.

(BTW can't you just combine SoB if you fold patches?)

I'm willing to help split up/fold patches if it'll help, especially if it would make a difference to whether or not we get MID support into 2.6.37, which is worth trying for. I like Wolfram's suggested patchset format. Alan, do you feel comfortable re-doing this in time for some testing before the merge window opens, or should I help?

I think we should postpone style cleanups outside of sdhci-intel-mid.c until .38, when there'll be less of an outstanding patch backlog.

The big question seems to be whether the approach the patchset takes -- moving from quirks to hooks, extending sdhci.c without creating a full driver, and the initial choice of overridable hooks -- makes sense. I'd be happy to hear everyone's thoughts on that.

Thanks for the review so far, Wolfram!

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
author
#13 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

Quoted 3 lines

into 2.6.37, which is worth trying for. I like Wolfram's suggested patchset format. Alan, do you feel comfortable re-doing this in time for some testing before the merge window opens, or should I help?

Redoing it shouldn't be a problem, getting testing of the MID bits will slow it down a fair bit. I'm not in a huge rush - I need to get the SFI device patches merged before an upstream kernel will actually be useful on a MID device.

Quoted 4 lines

The big question seems to be whether the approach the patchset takes -- moving from quirks to hooks, extending sdhci.c without creating a full driver, and the initial choice of overridable hooks -- makes sense. I'd be happy to hear everyone's thoughts on that.

I'd rather see that discussion happen and then redo the MID patches to match whatever turns out to suit a more generalised set of driver tidyups this way than push it in ASAP.

That also fits my timetable better as I've got an exam coming up early October and other stuff to push before I run off and hide revising.

#14 lore raw

Re: [PATCH 5/7] sdhci: Tidy up spaces in sdhci_intel_mid

Quoted 9 lines
Quoted 5 lines

The big question seems to be whether the approach the patchset takes -- moving from quirks to hooks, extending sdhci.c without creating a full driver, and the initial choice of overridable hooks -- makes sense. I'd be happy to hear everyone's thoughts on that.

I'd rather see that discussion happen and then redo the MID patches to match whatever turns out to suit a more generalised set of driver tidyups this way than push it in ASAP.

+1 The cleanup may force the drivers to adapt, but not the other way around ;)

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#15 lore raw

PATCH 6/7 sdhci_pci: Tidy this as well

In reply to Alan Cox

While doing the tidy up of the new stuff might as well tidy the old
---

 drivers/mmc/host/sdhci-pci.c |   48 ++++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 23 deletions(-)
drivers/mmc/host/sdhci-pci.c +25 -23
index bb14047..9692eab 100644
@@ -21,8 +21,8 @@
 
 #include <linux/mmc/host.h>
 
-#include <asm/scatterlist.h>
-#include <asm/io.h>
+#include <linux/scatterlist.h>
+#include <linux/io.h>
 
 #include "sdhci.h"
 
@@ -46,14 +46,14 @@ struct sdhci_pci_slot;
 struct sdhci_pci_fixes {
 	unsigned int		quirks;
 
-	int			(*probe)(struct sdhci_pci_chip*);
+	int			(*probe)(struct sdhci_pci_chip *);
 
-	int			(*probe_slot)(struct sdhci_pci_slot*);
-	void			(*remove_slot)(struct sdhci_pci_slot*, int);
+	int			(*probe_slot)(struct sdhci_pci_slot *);
+	void			(*remove_slot)(struct sdhci_pci_slot *, int);
 
-	int			(*suspend)(struct sdhci_pci_chip*,
+	int			(*suspend)(struct sdhci_pci_chip *,
 					pm_message_t);
-	int			(*resume)(struct sdhci_pci_chip*);
+	int			(*resume)(struct sdhci_pci_chip *);
 
 	/* Allow the driver to override some operations for particularly
 	   quirky chips */
@@ -287,7 +287,7 @@ static int jmicron_suspend(struct sdhci_pci_chip *chip, pm_message_t state)
 	int i;
 
 	if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC) {
-		for (i = 0;i < chip->num_slots;i++)
+		for (i = 0; i < chip->num_slots; i++)
 			jmicron_enable_mmc(chip->slots[i]->host, 0);
 	}
 
@@ -299,7 +299,7 @@ static int jmicron_resume(struct sdhci_pci_chip *chip)
 	int ret, i;
 
 	if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC) {
-		for (i = 0;i < chip->num_slots;i++)
+		for (i = 0; i < chip->num_slots; i++)
 			jmicron_enable_mmc(chip->slots[i]->host, 1);
 	}
 
@@ -401,7 +401,8 @@ static const struct sdhci_pci_fixes sdhci_via = {
 	.probe		= via_probe,
 };
 
-#if defined(CONFIG_MMC_SDHCI_INTEL_MID) || defined(CONFIG_MMC_SDHCI_INTEL_MID_MODULE)
+#if defined(CONFIG_MMC_SDHCI_INTEL_MID) || \
+		defined(CONFIG_MMC_SDHCI_INTEL_MID_MODULE)
 
 /*
  * ADMA operation is disabled for Moorestown platform due to
@@ -536,7 +537,8 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
 		.driver_data	= (kernel_ulong_t)&sdhci_via,
 	},
 
-#if defined(CONFIG_MMC_SDHCI_INTEL_MID) || defined(CONFIG_MMC_SDHCI_INTEL_MID_MODULE)
+#if defined(CONFIG_MMC_SDHCI_INTEL_MID) || \
+			defined(CONFIG_MMC_SDHCI_INTEL_MID_MODULE)
 	{
 		.vendor		= PCI_VENDOR_ID_INTEL,
 		.device		= PCI_DEVICE_ID_INTEL_MRST_SD0,
@@ -646,7 +648,7 @@ static struct sdhci_ops sdhci_pci_ops = {
 
 #ifdef CONFIG_PM
 
-static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
+static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
@@ -657,7 +659,7 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
 	if (!chip)
 		return 0;
 
-	for (i = 0;i < chip->num_slots;i++) {
+	for (i = 0; i < chip->num_slots; i++) {
 		slot = chip->slots[i];
 		if (!slot)
 			continue;
@@ -665,7 +667,7 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
 		ret = sdhci_suspend_host(slot->host, state);
 
 		if (ret) {
-			for (i--;i >= 0;i--)
+			for (i--; i >= 0; i--)
 				sdhci_resume_host(chip->slots[i]->host);
 			return ret;
 		}
@@ -676,7 +678,7 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
 	if (chip->fixes && chip->fixes->suspend) {
 		ret = chip->fixes->suspend(chip, state);
 		if (ret) {
-			for (i = chip->num_slots - 1;i >= 0;i--)
+			for (i = chip->num_slots - 1; i >= 0; i--)
 				sdhci_resume_host(chip->slots[i]->host);
 			return ret;
 		}
@@ -696,7 +698,7 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
 	return 0;
 }
 
-static int sdhci_pci_resume (struct pci_dev *pdev)
+static int sdhci_pci_resume(struct pci_dev *pdev)
 {
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
@@ -718,7 +720,7 @@ static int sdhci_pci_resume (struct pci_dev *pdev)
 			return ret;
 	}
 
-	for (i = 0;i < chip->num_slots;i++) {
+	for (i = 0; i < chip->num_slots; i++) {
 		slot = chip->slots[i];
 		if (!slot)
 			continue;
@@ -908,7 +910,7 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
 	}
 
 	chip->pdev = pdev;
-	chip->fixes = (const struct sdhci_pci_fixes*)ent->driver_data;
+	chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data;
 	if (chip->fixes)
 		chip->quirks = chip->fixes->quirks;
 	chip->num_slots = slots;
@@ -923,10 +925,10 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
 
 	slots = chip->num_slots;	/* Quirk may have changed this */
 
-	for (i = 0;i < slots;i++) {
+	for (i = 0; i < slots; i++) {
 		slot = sdhci_pci_probe_slot(pdev, chip, first_bar + i);
 		if (IS_ERR(slot)) {
-			for (i--;i >= 0;i--)
+			for (i--; i >= 0; i--)
 				sdhci_pci_remove_slot(chip->slots[i]);
 			ret = PTR_ERR(slot);
 			goto free;
@@ -954,7 +956,7 @@ static void __devexit sdhci_pci_remove(struct pci_dev *pdev)
 	chip = pci_get_drvdata(pdev);
 
 	if (chip) {
-		for (i = 0;i < chip->num_slots; i++)
+		for (i = 0; i < chip->num_slots; i++)
 			sdhci_pci_remove_slot(chip->slots[i]);
 
 		pci_set_drvdata(pdev, NULL);
@@ -965,9 +967,9 @@ static void __devexit sdhci_pci_remove(struct pci_dev *pdev)
 }
 
 static struct pci_driver sdhci_driver = {
-	.name = 	"sdhci-pci",
+	.name =		"sdhci-pci",
 	.id_table =	pci_ids,
-	.probe = 	sdhci_pci_probe,
+	.probe =	sdhci_pci_probe,
 	.remove =	__devexit_p(sdhci_pci_remove),
 	.suspend =	sdhci_pci_suspend,
 	.resume	=	sdhci_pci_resume,
author
#16 lore raw

PATCH 7/7 sdhci: Tidy up sdhci.c

In reply to Alan Cox

While we are passing through..

---

 drivers/mmc/host/sdhci.c |   39 +++++++++++++++++++--------------------
 1 files changed, 19 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci.c +19 -20
index 9d8047c..dcafe13 100644
@@ -1,5 +1,6 @@
 /*
- *  linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface driver
+ *  linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface
+ *				     driver
  *
  *  Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
  *
@@ -30,14 +31,14 @@
 #define DRIVER_NAME "sdhci"
 
 #define DBG(f, x...) \
-	pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
+	pr_debug(DRIVER_NAME " [%s()]: " f, __func__, ## x)
 
 #if defined(CONFIG_LEDS_CLASS) || (defined(CONFIG_LEDS_CLASS_MODULE) && \
 	defined(CONFIG_MMC_SDHCI_MODULE))
 #define SDHCI_USE_LEDS_CLASS
 #endif
 
-static unsigned int debug_quirks = 0;
+static unsigned int debug_quirks;
 
 static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
 static void sdhci_finish_data(struct sdhci_host *);
@@ -479,7 +480,8 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
 		if (offset) {
 			if (data->flags & MMC_DATA_WRITE) {
 				buffer = sdhci_kmap_atomic(sg, &flags);
-				WARN_ON(((long)buffer & PAGE_MASK) > (PAGE_SIZE - 3));
+				WARN_ON(((long)buffer & PAGE_MASK)
+							> (PAGE_SIZE - 3));
 				memcpy(align, buffer, offset);
 				sdhci_kunmap_atomic(buffer, &flags);
 			}
@@ -587,7 +589,8 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
 				size = 4 - (sg_dma_address(sg) & 0x3);
 
 				buffer = sdhci_kmap_atomic(sg, &flags);
-				WARN_ON(((long)buffer & PAGE_MASK) > (PAGE_SIZE - 3));
+				WARN_ON(((long)buffer & PAGE_MASK)
+							> (PAGE_SIZE - 3));
 				memcpy(buffer, align, size);
 				sdhci_kunmap_atomic(buffer, &flags);
 
@@ -975,7 +978,7 @@ static void sdhci_finish_command(struct sdhci_host *host)
 	if (host->cmd->flags & MMC_RSP_PRESENT) {
 		if (host->cmd->flags & MMC_RSP_136) {
 			/* CRC is stripped so we need to do some shifting. */
-			for (i = 0;i < 4;i++) {
+			for (i = 0; i < 4; i++) {
 				host->cmd->resp[i] = sdhci_readl(host,
 					SDHCI_RESPONSE + (3-i)*4) << 8;
 				if (i != 3)
@@ -1019,7 +1022,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 	if (clock == 0)
 		goto out;
 
-	for (div = 1;div < 256;div *= 2) {
+	for (div = 1; div < 256; div *= 2) {
 		if ((host->max_clk / div) <= clock)
 			break;
 	}
@@ -1215,7 +1218,7 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	 * signalling timeout and CRC errors even on CMD0. Resetting
 	 * it on each ios seems to solve the problem.
 	 */
-	if(host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
+	if (host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
 		sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
 
 out:
@@ -1302,7 +1305,7 @@ static void sdhci_tasklet_card(unsigned long param)
 	struct sdhci_host *host;
 	unsigned long flags;
 
-	host = (struct sdhci_host*)param;
+	host = (struct sdhci_host *)param;
 
 	spin_lock_irqsave(&host->lock, flags);
 
@@ -1332,7 +1335,7 @@ static void sdhci_tasklet_finish(unsigned long param)
 	unsigned long flags;
 	struct mmc_request *mrq;
 
-	host = (struct sdhci_host*)param;
+	host = (struct sdhci_host *)param;
 
 	spin_lock_irqsave(&host->lock, flags);
 
@@ -1385,7 +1388,7 @@ static void sdhci_timeout_timer(unsigned long data)
 	struct sdhci_host *host;
 	unsigned long flags;
 
-	host = (struct sdhci_host*)data;
+	host = (struct sdhci_host *)data;
 
 	spin_lock_irqsave(&host->lock, flags);
 
@@ -1566,7 +1569,7 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
 static irqreturn_t sdhci_irq(int irq, void *dev_id)
 {
 	irqreturn_t result;
-	struct sdhci_host* host = dev_id;
+	struct sdhci_host *host = dev_id;
 	u32 intmask;
 	int cardint = 0;
 
@@ -1667,7 +1670,6 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
 
 	return ret;
 }
-
 EXPORT_SYMBOL_GPL(sdhci_suspend_host);
 
 int sdhci_resume_host(struct sdhci_host *host)
@@ -1699,7 +1701,6 @@ int sdhci_resume_host(struct sdhci_host *host)
 
 	return ret;
 }
-
 EXPORT_SYMBOL_GPL(sdhci_resume_host);
 
 #endif /* CONFIG_PM */
@@ -1727,7 +1728,6 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 
 	return host;
 }
-
 EXPORT_SYMBOL_GPL(sdhci_alloc_host);
 
 int sdhci_add_host(struct sdhci_host *host)
@@ -1940,7 +1940,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	/*
 	 * Maximum block count.
 	 */
-	mmc->max_blk_count = (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535;
+	mmc->max_blk_count = (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK)
+								? 1 : 65535;
 
 	/*
 	 * Init tasklets.
@@ -1959,7 +1960,8 @@ int sdhci_add_host(struct sdhci_host *host)
 
 	host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
 	if (IS_ERR(host->vmmc)) {
-		printk(KERN_INFO "%s: no vmmc regulator found\n", mmc_hostname(mmc));
+		printk(KERN_INFO "%s: no vmmc regulator found\n",
+							mmc_hostname(mmc));
 		host->vmmc = NULL;
 	} else {
 		regulator_enable(host->vmmc);
@@ -2008,7 +2010,6 @@ untasklet:
 
 	return ret;
 }
-
 EXPORT_SYMBOL_GPL(sdhci_add_host);
 
 void sdhci_remove_host(struct sdhci_host *host, int dead)
@@ -2060,14 +2061,12 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 	host->adma_desc = NULL;
 	host->align_buffer = NULL;
 }
-
 EXPORT_SYMBOL_GPL(sdhci_remove_host);
 
 void sdhci_free_host(struct sdhci_host *host)
 {
 	mmc_free_host(host->mmc);
 }
-
 EXPORT_SYMBOL_GPL(sdhci_free_host);
 
 /*****************************************************************************\