[patch 4/4] sdio: disable CD resistor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-- 
David Vrabel, Software Engineer, Drivers group  Tel: +44 (0)1223 692562
CSR plc, Churchill House, Cambridge Business Park, Cowley Road, CB4 0WZ


.
sdio: disable CD resistor

Disable the card detect resistor to ensure all data lines are equally loaded.
Not doing this can have a negative impact on buses with marginal signal
quality.

Signed-off-by: David Vrabel <[email protected]
---
Index: mmc/drivers/mmc/core/sdio.c
===================================================================
--- mmc.orig/drivers/mmc/core/sdio.c	2007-08-07 07:27:31.000000000 +0100
+++ mmc/drivers/mmc/core/sdio.c	2007-08-07 07:30:58.000000000 +0100
@@ -148,10 +148,25 @@
 	return ret;
 }
 
+static int sdio_modify_cccr(struct mmc_card *card, unsigned reg,
+	u8 val, u8 mask)
+{
+	u8 old;
+	int ret;
+
+	ret = mmc_io_rw_direct(card, 0, 0, reg, 0, &old);
+	if (ret)
+		return ret;
+
+	val = (old & ~mask) | val;
+
+	ret = mmc_io_rw_direct(card, 1, 0, reg, val, NULL);
+	return ret;
+}
+
 static int sdio_enable_wide(struct mmc_card *card)
 {
 	int ret;
-	u8 ctrl;
 
 	if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
 		return 0;
@@ -159,13 +174,8 @@
 	if (card->cccr.low_speed && !card->cccr.wide_bus)
 		return 0;
 
-	ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl);
-	if (ret)
-		return ret;
-
-	ctrl |= SDIO_BUS_WIDTH_4BIT;
-
-	ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL);
+	ret = sdio_modify_cccr(card, SDIO_CCCR_IF, SDIO_BUS_WIDTH_4BIT,
+		SDIO_BUS_WIDTH_MASK);
 	if (ret)
 		return ret;
 
@@ -334,6 +344,15 @@
 	mmc_set_clock(host, card->cis.max_dtr);
 
 	/*
+	 * Disable Card Detect resistor on DAT3 so all data lines are
+	 * loaded the same.
+	 */
+	err = sdio_modify_cccr(card, SDIO_CCCR_IF, SDIO_BUS_CD_DISABLE,
+		SDIO_BUS_CD_DISABLE);
+	if (err)
+		goto remove;
+
+	/*
 	 * Switch to wider bus (if supported).
 	 */
 	err = sdio_enable_wide(card);
Index: mmc/include/linux/mmc/sdio.h
===================================================================
--- mmc.orig/include/linux/mmc/sdio.h	2007-08-07 07:27:30.000000000 +0100
+++ mmc/include/linux/mmc/sdio.h	2007-08-07 07:27:31.000000000 +0100
@@ -94,6 +94,7 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_WIDTH_MASK	0x03
 
 #define  SDIO_BUS_CD_DISABLE     0x80	/* disable pull-up on DAT3 (pin 1) */
 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux