Skip to contentSkip to conversation

sdhci-esdhc-imx: use gpio for write protection and card detection

PATCH Superseded Wolfram Sang 4 participants 15 messages Feb 23, 2011 – Feb 25, 2011

Subsystems (6)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

Regards,

Wolfram

Wolfram Sang (5):
mmc: sdhci-esdhc-imx: add support for write protect on custom GPIO
mmc: sdhci-esdhc: broken card detection is not a default quirk
mmc: sdhci-esdhc-imx: add card detect on custom GPIO
arm: mach-mx3: pcm043: add write-protect and card-detect for SD1
arm: mach-mx3: use IMX_GPIO_NR instead of hard-coded values

 arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c |    4 +-
 arch/arm/mach-mx3/mach-cpuimx35.c            |    2 +-
 arch/arm/mach-mx3/mach-pcm043.c              |   19 +++-
 arch/arm/plat-mxc/include/mach/esdhc.h       |   12 ++-
 drivers/mmc/host/sdhci-esdhc-imx.c           |  128 +++++++++++++++++++++++--
 drivers/mmc/host/sdhci-esdhc.h               |    1 -
 drivers/mmc/host/sdhci-of-esdhc.c            |    3 +-
 7 files changed, 148 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH v3 1/5 mmc: sdhci-esdhc-imx: add support for write protect on custom GPIO

---

change since last version:

* improve kerneldoc

 arch/arm/plat-mxc/include/mach/esdhc.h |   10 +++++-
 drivers/mmc/host/sdhci-esdhc-imx.c     |   52 +++++++++++++++++++++++++-------
 2 files changed, 50 insertions(+), 12 deletions(-)
arch/arm/plat-mxc/include/mach/esdhc.h +9 -1
index a48a9aa..47da109 100644
@@ -10,7 +10,15 @@
 #ifndef __ASM_ARCH_IMX_ESDHC_H
 #define __ASM_ARCH_IMX_ESDHC_H
 
+/**
+ * struct esdhc_platform_data - optional platform data for esdhc on i.MX
+ *
+ * strongly recommended for i.MX25/35, not needed for other variants
+ *
+ * @wp_gpio:	gpio for write_protect (-EINVAL if unused)
+ */
+
 struct esdhc_platform_data {
-	unsigned int wp_gpio;	/* write protect pin */
+	unsigned int wp_gpio;
 };
 #endif /* __ASM_ARCH_IMX_ESDHC_H */
drivers/mmc/host/sdhci-esdhc-imx.c +41 -11

89 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#2 lore raw

PATCH v3 2/5 mmc: sdhci-esdhc: broken card detection is not a default quirk

In reply to Wolfram Sang

It can be worked around using a GPIO which will be done for i.MX later.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |    3 ++-
 drivers/mmc/host/sdhci-esdhc.h     |    1 -
 drivers/mmc/host/sdhci-of-esdhc.c  |    3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -1
index 65df00b..49c9801 100644
@@ -171,7 +171,8 @@ static void esdhc_pltfm_exit(struct sdhci_host *host)
 }
 
 struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
-	.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA,
+	.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA
+			| SDHCI_QUIRK_BROKEN_CARD_DETECTION,
 	/* ADMA has issues. Might be fixable */
 	.ops = &sdhci_esdhc_ops,
 	.init = esdhc_pltfm_init,
drivers/mmc/host/sdhci-esdhc.h +0 -1
index afaf1bc..c55aae8 100644
@@ -19,7 +19,6 @@
  */
 
 #define ESDHC_DEFAULT_QUIRKS	(SDHCI_QUIRK_FORCE_BLK_SZ_2048 | \
-				SDHCI_QUIRK_BROKEN_CARD_DETECTION | \
 				SDHCI_QUIRK_NO_BUSY_IRQ | \
 				SDHCI_QUIRK_NONSTANDARD_CLOCK | \
 				SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | \
drivers/mmc/host/sdhci-of-esdhc.c +2 -1
index fcd0e1f..08161f6 100644
@@ -73,7 +73,8 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host)
 }
 
 struct sdhci_of_data sdhci_esdhc = {
-	.quirks = ESDHC_DEFAULT_QUIRKS,
+	/* card detection could be handled via GPIO */
+	.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION,
 	.ops = {
 		.read_l = sdhci_be32bs_readl,
 		.read_w = esdhc_readw,
Signature · 1 line
1.7.2.3
#3 lore raw

PATCH v3 3/5 mmc: sdhci-esdhc-imx: add card detect on custom GPIO

In reply to Wolfram Sang

---
change since last version:

* improve kerneldoc
* intercept SDHCI_SIGNAL_ENABLE, too (mx25)
* remove BROKEN_CARD_DETECTION as default quirk

 arch/arm/plat-mxc/include/mach/esdhc.h |    2 +
 drivers/mmc/host/sdhci-esdhc-imx.c     |   79 +++++++++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 2 deletions(-)
arch/arm/plat-mxc/include/mach/esdhc.h +2 -0
index 47da109..86003f4 100644
@@ -16,9 +16,11 @@
  * strongly recommended for i.MX25/35, not needed for other variants
  *
  * @wp_gpio:	gpio for write_protect (-EINVAL if unused)
+ * @cd_gpio:	gpio for card_detect interrupt (-EINVAL if unused)
  */
 
 struct esdhc_platform_data {
 	unsigned int wp_gpio;
+	unsigned int cd_gpio;
 };
 #endif /* __ASM_ARCH_IMX_ESDHC_H */
drivers/mmc/host/sdhci-esdhc-imx.c +77 -2

117 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#4 lore raw

PATCH v3 4/5 arm: mach-mx3: pcm043: add write-protect and card-detect for SD1

In reply to Wolfram Sang
---
 arch/arm/mach-mx3/mach-pcm043.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
arch/arm/mach-mx3/mach-pcm043.c +12 -1
index bcf83fc..26b686c 100644
@@ -40,6 +40,7 @@
 #include <mach/mx3fb.h>
 #include <mach/ulpi.h>
 #include <mach/audmux.h>
+#include <mach/esdhc.h>
 
 #include "devices-imx35.h"
 #include "devices.h"
@@ -219,12 +220,17 @@ static iomux_v3_cfg_t pcm043_pads[] = {
 	MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
 	MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
 	MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
+	MX35_PAD_ATA_DATA10__GPIO2_23, /* WriteProtect */
+	MX35_PAD_ATA_DATA11__GPIO2_24, /* CardDetect */
 };
 
 #define AC97_GPIO_TXFS	(1 * 32 + 31)
 #define AC97_GPIO_TXD	(1 * 32 + 28)
 #define AC97_GPIO_RESET	(1 * 32 + 0)
 
+#define SD1_GPIO_WP	(1 * 32 + 23)
+#define SD1_GPIO_CD	(1 * 32 + 24)
+
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
 	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
@@ -307,6 +313,11 @@ pcm037_nand_board_info __initconst = {
 	.hw_ecc = 1,
 };
 
+static struct esdhc_platform_data sd1_pdata = {
+	.wp_gpio = SD1_GPIO_WP,
+	.cd_gpio = SD1_GPIO_CD,
+};
+
 #if defined(CONFIG_USB_ULPI)
 static struct mxc_usbh_platform_data otg_pdata __initdata = {
 	.portsc	= MXC_EHCI_MODE_UTMI,
@@ -393,7 +404,7 @@ static void __init mxc_board_init(void)
 		imx35_add_fsl_usb2_udc(&otg_device_pdata);
 
 	imx35_add_flexcan1(NULL);
-	imx35_add_sdhci_esdhc_imx(0, NULL);
+	imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
 }
 
 static void __init pcm043_timer_init(void)
Signature · 1 line
1.7.2.3
#5 lore raw

PATCH v3 5/5 arm: mach-mx3: use IMX_GPIO_NR instead of hard-coded values

In reply to Wolfram Sang

The latter are error-prone because the bank number is one less than one would read in the documentation.

---
 arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c |    4 ++--
 arch/arm/mach-mx3/mach-cpuimx35.c            |    2 +-
 arch/arm/mach-mx3/mach-pcm043.c              |   10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c +2 -2
index 14a5ffc..8076147 100644
@@ -165,8 +165,8 @@ static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
 };
 
-#define GPIO_LED1	(2 * 32 + 29)
-#define GPIO_SWITCH1	(2 * 32 + 25)
+#define GPIO_LED1	IMX_GPIO_NR(3, 29)
+#define GPIO_SWITCH1	IMX_GPIO_NR(3, 25)
 #define GPIO_LCDPWR	(4)
 
 static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
arch/arm/mach-mx3/mach-cpuimx35.c +1 -1
index 26ae90f..892c3a9 100644
@@ -60,7 +60,7 @@ static struct tsc2007_platform_data tsc2007_info = {
 	.x_plate_ohms		= 180,
 };
 
-#define TSC2007_IRQGPIO		(2 * 32 + 2)
+#define TSC2007_IRQGPIO		IMX_GPIO_NR(3, 2)
 static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("pcf8563", 0x51),
arch/arm/mach-mx3/mach-pcm043.c +5 -5
index 26b686c..51542f7 100644
@@ -224,12 +224,12 @@ static iomux_v3_cfg_t pcm043_pads[] = {
 	MX35_PAD_ATA_DATA11__GPIO2_24, /* CardDetect */
 };
 
-#define AC97_GPIO_TXFS	(1 * 32 + 31)
-#define AC97_GPIO_TXD	(1 * 32 + 28)
-#define AC97_GPIO_RESET	(1 * 32 + 0)
+#define AC97_GPIO_TXFS	IMX_GPIO_NR(2, 31)
+#define AC97_GPIO_TXD	IMX_GPIO_NR(2, 28)
+#define AC97_GPIO_RESET	IMX_GPIO_NR(2, 0)
 
-#define SD1_GPIO_WP	(1 * 32 + 23)
-#define SD1_GPIO_CD	(1 * 32 + 24)
+#define SD1_GPIO_WP	IMX_GPIO_NR(2, 23)
+#define SD1_GPIO_CD	IMX_GPIO_NR(2, 24)
 
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
Signature · 1 line
1.7.2.3
#6 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

In reply to Wolfram Sang

Hi Wolfram,

Quoted 10 lines · Wolfram Sang

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

I'm testing it on mx25 3ds and mx51 babbage. Both card-detect and write-protect are working on mx25 3ds, but write-protect has some problem on babbage, and I need some time to figure it out.

Also it's not testable on mx35 3ds board, as these two "gpio" pins are routed to a MCU which needs the I2C access. Do we have this support on mainline?

Signature · 2 lines
Regards,
Shawn
#7 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Quoted 10 lines · Shawn Guo

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Quoted 7 lines
Quoted 3 lines

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

I'm testing it on mx25 3ds and mx51 babbage. Both card-detect and write-protect are working on mx25 3ds, but write-protect has some problem on babbage, and I need some time to figure it out.

I just figured out why wp_gpio does not work on mx51.

+ if (cpu_is_mx25() || cpu_is_mx35()) {
+ /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */

                host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK;

+ /* write_protect can't be routed to controller, use gpio */
+ sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro;
+ }

Would it make sense to do the same for mx51? On babbage board, SD1_WP is routed to controller, but SD2_WP is not, so we have to use gpio for SD2 write_protect.

Signature · 2 lines
Regards,
Shawn
#8 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Quoted 27 lines · Shawn Guo
Quoted 10 lines · Shawn Guo

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Quoted 7 lines
Quoted 3 lines

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

I'm testing it on mx25 3ds and mx51 babbage. Both card-detect and write-protect are working on mx25 3ds, but write-protect has some problem on babbage, and I need some time to figure it out.

I just figured out why wp_gpio does not work on mx51.

(quoted diff) +5 -0
+       if (cpu_is_mx25() || cpu_is_mx35()) {
+               /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
                host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK;
+               /* write_protect can't be routed to controller, use gpio */
+               sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro;
+       }
Quoted 4 lines

Would it make sense to do the same for mx51? On babbage board, SD1_WP is routed to controller, but SD2_WP is not, so we have to use gpio for SD2 write_protect.

We should probably have esdhc_pltfm_get_ro whenever platform provides a wp_gpio, and fall on controller SD_WP only when platform does not provide the wp_gpio.

Signature · 2 lines
Regards,
Shawn
#9 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Quoted 28 lines · Shawn Guo
Quoted 27 lines · Shawn Guo
Quoted 10 lines · Shawn Guo

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Quoted 7 lines
Quoted 3 lines

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

I'm testing it on mx25 3ds and mx51 babbage. Both card-detect and write-protect are working on mx25 3ds, but write-protect has some problem on babbage, and I need some time to figure it out.

I just figured out why wp_gpio does not work on mx51.

(quoted diff) +5 -0
+       if (cpu_is_mx25() || cpu_is_mx35()) {
+               /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
                host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK;
+               /* write_protect can't be routed to controller, use gpio */
+               sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro;
+       }
Quoted 7 lines
Quoted 4 lines

Would it make sense to do the same for mx51? On babbage board, SD1_WP is routed to controller, but SD2_WP is not, so we have to use gpio for SD2 write_protect.

We should probably have esdhc_pltfm_get_ro whenever platform provides a wp_gpio, and fall on controller SD_WP only when platform does not provide the wp_gpio.

OK, will think about it. Thanks for testing!

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110224/1e00e5e7/attachment.sig>
#10 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

In reply to Wolfram Sang

Wolfram Sang <[email protected]> writes:

Hi,

Quoted 9 lines

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

I'm getting a hard freeze on my efika sb and mx once I remove the unconditional BROKEN_CARD_DETECTION flag. I'm still investigating the issue. I'll keep you informed if I find something.

Arnaud

#11 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Quoted 3 lines

I'm getting a hard freeze on my efika sb and mx once I remove the unconditional BROKEN_CARD_DETECTION flag. I'm still investigating the issue. I'll keep you informed if I find something.

Hmm, this is probably an unhandled interrupt. Will see if I can get the efika here...

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110224/8852c4d8/attachment.sig>
#12 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

In reply to Arnaud Patard (Rtp)

Hi Arnaud,

Quoted 11 lines · Arnaud Patard (Rtp)

Wolfram Sang<[email protected]> writes:

Hi,

Quoted 7 lines

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Quoted 7 lines
Quoted 2 lines

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

I'm getting a hard freeze on my efika sb and mx once I remove the unconditional BROKEN_CARD_DETECTION flag. I'm still investigating the issue. I'll keep you informed if I find something.

may you please test the attached patch. It may give someone with a better knowledge of sdhci than me an idea of what is wrong.

Here are the workaround this patch add :
- we can't let enable or disable irq enabled when the card is present/not present, else the irq triger again which explains why you get the freeze -> so we must rely on the card presence bit to enable the right interrupt,
- we can't turn the clock off if we want the card detect to work when the card is removed -> as a quick workaround this patch prevents sdhci_set_clock from turning off the clocks when the SDHCI_INT_CARD_INSERT interrupt is enabled.

Also, I had to change the MX51_PAD_GPIO1_0__SD1_CD pad setting as follows to enable the internal pull up :
_MX51_PAD_GPIO1_0__SD1_CD | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |
PAD_CTL_PKE | PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),

Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mx51_sdhci_cd_fix.patch
Type: text/x-patch
Size: 2488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110224/e118ff7a/attachment-0001.bin>

#13 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Quoted 1 line · Eric Benard

Hi Arnaud,

Salut !

Quoted 16 lines · Arnaud Patard (Rtp)
Quoted 14 lines

Wolfram Sang<[email protected]> writes:

Hi,

Quoted 9 lines

Take #3, changes:

* also intercept calls to SDHCI_SIGNAL_ENABLE (needed on mx25)
* remove unconditional BROKEN_CARD_DETECTION (leftover)
* improved kernel-doc about unused GPIO
* added tags from Eric

Tested now by me and Marc on mx35, Eric on mx25/35/51. Arnaud, did you have a chance to retest on mx51? What about the FSL guys? :)

Quoted 6 lines
Quoted 4 lines

I'm getting a hard freeze on my efika sb and mx once I remove the unconditional BROKEN_CARD_DETECTION flag. I'm still investigating the issue. I'll keep you informed if I find something.

may you please test the attached patch. It may give someone with a better knowledge of sdhci than me an idea of what is wrong.

I've tested this patch on my efikamx and this patch does solve the issue. I didn't test on the efika smartbook but I guess it'll be fine here too. Thanks.

Quoted 6 lines

Here are the workaround this patch add :
- we can't let enable or disable irq enabled when the card is present/not present, else the irq triger again which explains why you get the freeze -> so we must rely on the card presence bit to enable the right interrupt,

so, we're getting an interrupt storm, right ? can't it be fixed by setting a different irq type ?

Quoted 10 lines

- we can't turn the clock off if we want the card detect to work when the card is removed -> as a quick workaround this patch prevents sdhci_set_clock from turning off the clocks when the SDHCI_INT_CARD_INSERT interrupt is enabled.

Also, I had to change the MX51_PAD_GPIO1_0__SD1_CD pad setting as follows to enable the internal pull up :
_MX51_PAD_GPIO1_0__SD1_CD | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |
PAD_CTL_PKE | PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),

It worked without changing this.

Arnaud

#14 lore raw

v3 cover sdhci-esdhc-imx: use gpio for write protection and card detection

Hi,

Quoted 8 lines · Arnaud Patard (Rtp)
Quoted 2 lines · Eric Benard

may you please test the attached patch. It may give someone with a better knowledge of sdhci than me an idea of what is wrong.

I've tested this patch on my efikamx and this patch does solve the issue. I didn't test on the efika smartbook but I guess it'll be fine here too. Thanks.

good. Now we have to find can how this code be integrated properly in the sdhci driver.

Quoted 10 lines
Quoted 6 lines

Here are the workaround this patch add :
- we can't let enable or disable irq enabled when the card is present/not present, else the irq triger again which explains why you get the freeze -> so we must rely on the card presence bit to enable the right interrupt,

so, we're getting an interrupt storm, right ? can't it be fixed by setting a different irq type ?

no this seems to be the way the SDHCI works, at least the i.MX51 ref manual says :
- When the CRM bit is cleared, if no card is inserted it is immediately set
again: this can be prevented by clearing the card removal status enable bit in interrupt status enable register.
- When the CIN bit is cleared, if a card is inserted it is immediately set
again: this can be prevented by clearing the card inserted status enable bit in interrupt status enable register.

As, unless I'm mistaken, sdhci host actually consider card detect as broken by default, I think this code in not actually used so it may not be really tested.

Quoted 5 lines
Quoted 5 lines

- we can't turn the clock off if we want the card detect to work when the card is removed -> as a quick workaround this patch prevents sdhci_set_clock from turning off the clocks when the SDHCI_INT_CARD_INSERT interrupt is enabled.

Quoted 8 lines
Quoted 5 lines

Also, I had to change the MX51_PAD_GPIO1_0__SD1_CD pad setting as follows to enable the internal pull up :
_MX51_PAD_GPIO1_0__SD1_CD | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |
PAD_CTL_PKE | PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),

It worked without changing this.

this could mean you have an external pull up resistor on the board which was not the case on the prototype I was working on which is partially mounted ;-)

Eric