Bug#485192: SDHCI hacks used on OLPC

2008-06-27 Thread Andres Salomon
On Thu, 26 Jun 2008 09:51:52 +0200
Robert Millan [EMAIL PROTECTED] wrote:

 
 Hi!
 
 These are the patches Andres made  sent upstream:
 
   http://www.gossamer-threads.com/lists/linux/kernel/936294
 
   http://www.gossamer-threads.com/lists/linux/kernel/937056
 
 If they don't make it to 2.6.26, I'd suggest having them applied in
 the package (unless Andres has any objections, of course).
 


I just heard back from Pierre; it sounds like those patches will be
different from what goes upstream, but they're fine (for Debian's
purposes) for 2.6.26. The ones that go upstream need to be reworked for
changes that are in Pierre's -next tree.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#485192: SDHCI hacks used on OLPC

2008-06-26 Thread Robert Millan

Hi!

These are the patches Andres made  sent upstream:

  http://www.gossamer-threads.com/lists/linux/kernel/936294

  http://www.gossamer-threads.com/lists/linux/kernel/937056

If they don't make it to 2.6.26, I'd suggest having them applied in the
package (unless Andres has any objections, of course).

-- 
Robert Millan

GPLv2 I know my rights; I want my phone call!
DRM What good is a phone call… if you are unable to speak?
(as seen on /.)

http://www.gossamer-threads.com/lists/linux/kernel/936294

From 23a46157c15badacb23332abb8f489a515d7733f Mon Sep 17 00:00:00 2001
From: Andres Salomon [EMAIL PROTECTED]
Date: Sat, 21 Jun 2008 19:27:10 -0400
Subject: [PATCH] [OLPC] sdhci: add quirk for the Marvell CaFe's vdd/powerup issue

The Marvell CaFe chip's SD implementation chokes during card insertion
if one attempts to set the voltage and power up in the same
SDHCI_POWER_CONTROL register write.  This adds a quirk that does
that particular dance in two steps.

It also adds an entry to pci_ids.h for the CaFe chip's SD device.

Signed-off-by: Andres Salomon [EMAIL PROTECTED]
---
 drivers/mmc/host/sdhci.c |   18 ++
 include/linux/pci_ids.h  |1 +
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 07c2048..5b74c8c 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -55,6 +55,8 @@ static unsigned int debug_quirks = 0;
 #define SDHCI_QUIRK_32BIT_DMA_SIZE			(17)
 /* Controller needs to be reset after each request to stay stable */
 #define SDHCI_QUIRK_RESET_AFTER_REQUEST			(18)
+/* Controller needs voltage and power writes to happen separately */
+#define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER		(19)
 
 static const struct pci_device_id pci_ids[] __devinitdata = {
 	{
@@ -128,6 +130,14 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
 	},
 
 	{
+		.vendor = PCI_VENDOR_ID_MARVELL,
+		.device = PCI_DEVICE_ID_MARVELL_CAFE_SD,
+		.subvendor  = PCI_ANY_ID,
+		.subdevice  = PCI_ANY_ID,
+		.driver_data= SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER,
+	},
+
+	{
 		.vendor = PCI_VENDOR_ID_JMICRON,
 		.device = PCI_DEVICE_ID_JMICRON_JMB38X_SD,
 		.subvendor  = PCI_ANY_ID,
@@ -774,6 +784,14 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
 		BUG();
 	}
 
+	/*
+	 * At least the CaFe chip gets confused if we set the voltage
+	 * and set turn on power at the same time, so set the voltage first.
+	 */
+	if ((host-chip-quirks  SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER))
+		writeb(pwr  ~SDHCI_POWER_ON,
+host-ioaddr + SDHCI_POWER_CONTROL);
+
 	writeb(pwr, host-ioaddr + SDHCI_POWER_CONTROL);
 
 out:
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index eafc9d6..6595382 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1520,6 +1520,7 @@
 #define PCI_DEVICE_ID_MARVELL_GT64260	0x6430
 #define PCI_DEVICE_ID_MARVELL_MV64360	0x6460
 #define PCI_DEVICE_ID_MARVELL_MV64460	0x6480
+#define PCI_DEVICE_ID_MARVELL_CAFE_SD	0x4101
 
 #define PCI_VENDOR_ID_V3		0x11b0
 #define PCI_DEVICE_ID_V3_V960		0x0001
-- 
1.5.5.3


http://www.gossamer-threads.com/lists/linux/kernel/937056

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 5b74c8c..2b3f06a 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -57,6 +57,8 @@ static unsigned int debug_quirks = 0;
 #define SDHCI_QUIRK_RESET_AFTER_REQUEST			(18)
 /* Controller needs voltage and power writes to happen separately */
 #define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER		(19)
+/* Controller has an off-by-one issue with timeout value */
+#define SDHCI_QUIRK_INCR_TIMEOUT_CONTROL		(110)
 
 static const struct pci_device_id pci_ids[] __devinitdata = {
 	{
@@ -134,7 +136,8 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
 		.device = PCI_DEVICE_ID_MARVELL_CAFE_SD,
 		.subvendor  = PCI_ANY_ID,
 		.subdevice  = PCI_ANY_ID,
-		.driver_data= SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER,
+		.driver_data= SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
+  SDHCI_QUIRK_INCR_TIMEOUT_CONTROL,
 	},
 
 	{
@@ -479,6 +482,13 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
 			break;
 	}
 
+	/*
+	 * Compensate for an off-by-one error in the CaFe hardware; otherwise,
+	 * a too-small count gives us interrupt timeouts.
+	 */
+	if ((host-chip-quirks  SDHCI_QUIRK_INCR_TIMEOUT_CONTROL))
+		count++;
+
 	if (count = 0xF) {
 		printk(KERN_WARNING %s: Too large timeout requested!\n,
 			mmc_hostname(host-mmc));


Bug#485192: SDHCI hacks used on OLPC

2008-06-08 Thread Robert Millan
Package: linux-2.6
Version: 2.6.26~rc4-1~experimental.1
Severity: normal

This diff was extracted from OLPC branch.  Without it, MMC cards are not
detected.

I'm not setting the patch tag since the last hunks look like a kludge
(specially the off-by-one thing).

Putting Andres Salomon on CC, as he probably knows about the reasons this
was added.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i586)

Kernel: Linux 2.6.26-rc4-486
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 91ded3e..43a6c2b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -237,6 +237,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 		if (brq.data.blocks  card-host-max_blk_count)
 			brq.data.blocks = card-host-max_blk_count;
 
+		if (mmc_card_sd(card)  !card-host-ios.clock) {
+			printk(KERN_ERR %s: I/O to stopped card\n,
+			   req-rq_disk-disk_name);
+			goto cmd_err;
+		}
+
 		/*
 		 * If the host doesn't support multiple block writes, force
 		 * block writes to single block. SD cards are excepted from
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 07c2048..9ac2c2b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -469,6 +469,12 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
 			break;
 	}
 
+	/*
+	 * There's an off-by-one error in the hw that we need to
+	 * compensate for.
+	 */
+	count++;
+
 	if (count = 0xF) {
 		printk(KERN_WARNING %s: Too large timeout requested!\n,
 			mmc_hostname(host-mmc));
@@ -756,19 +762,17 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
 	if (!(host-chip-quirks  SDHCI_QUIRK_SINGLE_POWER_WRITE))
 		writeb(0, host-ioaddr + SDHCI_POWER_CONTROL);
 
-	pwr = SDHCI_POWER_ON;
-
 	switch (1  power) {
 	case MMC_VDD_165_195:
-		pwr |= SDHCI_POWER_180;
+		pwr = SDHCI_POWER_180;
 		break;
 	case MMC_VDD_29_30:
 	case MMC_VDD_30_31:
-		pwr |= SDHCI_POWER_300;
+		pwr = SDHCI_POWER_300;
 		break;
 	case MMC_VDD_32_33:
 	case MMC_VDD_33_34:
-		pwr |= SDHCI_POWER_330;
+		pwr = SDHCI_POWER_330;
 		break;
 	default:
 		BUG();
@@ -776,6 +780,10 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
 
 	writeb(pwr, host-ioaddr + SDHCI_POWER_CONTROL);
 
+	pwr |= SDHCI_POWER_ON;
+
+	writeb(pwr, host-ioaddr + SDHCI_POWER_CONTROL);
+
 out:
 	host-power = power;
 }


Bug#485192: SDHCI hacks used on OLPC

2008-06-08 Thread Andres Salomon
On Mon, 09 Jun 2008 01:28:10 +
Robert Millan [EMAIL PROTECTED] wrote:

 Package: linux-2.6
 Version: 2.6.26~rc4-1~experimental.1
 Severity: normal
 
 This diff was extracted from OLPC branch.  Without it, MMC cards are
 not detected.
 
 I'm not setting the patch tag since the last hunks look like a kludge
 (specially the off-by-one thing).
 
 Putting Andres Salomon on CC, as he probably knows about the reasons
 this was added.

These are hardware workarounds; I would highly suggest waiting for this
stuff to go upstream first..



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]