Skip to contentSkip to conversation

sdhci-esdhc-imx: fix bus-width for 1-bit operation.

PATCH In review Leonardo G. Veiga 4 participants 5 messages Nov 1, 2016 – Nov 17, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sdhci-esdhc-imx: fix bus-width for 1-bit operation.

From: Leonardo Graboski Veiga <[email protected]>

The 1-bit operation mode, enabled by seeting the 'bus-width' property of the device tree 'esdhc' node to <1>, not work while using SD card.

The behavior is only noticed when only the data pin 0 is connected to the hardware. A series of kernel errors are printed to the console, all of them returning the following error message followed by some explanation:
mmcblk0: error -84 transferring data

If four data lines are connected, it ignores the device-tree property and works in 4-bit mode of operation without errors. The hardware used for testing does not support 8-bit mode.

Check the 'bus-width' property and if set to <1>, enable the SDHCI_QUIRK_FORCE_1_BIT_DATA quirk.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-esdhc-imx.c +4 -0
index c9fbc4c3..88d7d22 100644
@@ -1003,6 +1003,10 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 		host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
 	}
 
+	if (!of_property_read_u32(np, "bus-width", &boarddata->max_bus_width)
+		&& boarddata->max_bus_width == 1)
+		host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
+
 	/* call to generic mmc_of_parse to support additional capabilities */
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
Signature · 1 line
2.7.4
#1 lore raw

Hi Leonardo,

Quoted 27 lines · Leonardo G. Veiga

From: Leonardo Graboski Veiga <[email protected]>

The 1-bit operation mode, enabled by seeting the 'bus-width' property of the device tree 'esdhc' node to <1>, not work while using SD card.

The behavior is only noticed when only the data pin 0 is connected to the hardware. A series of kernel errors are printed to the console, all of them returning the following error message followed by some explanation:
mmcblk0: error -84 transferring data

If four data lines are connected, it ignores the device-tree property and works in 4-bit mode of operation without errors. The hardware used for testing does not support 8-bit mode.

Check the 'bus-width' property and if set to <1>, enable the SDHCI_QUIRK_FORCE_1_BIT_DATA quirk.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index c9fbc4c3..88d7d22 100644

drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · line 1009

Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4 -0
@@ -1003,6 +1003,10 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
                host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
        }
 
+       if (!of_property_read_u32(np, "bus-width", &boarddata->max_bus_width)
+               && boarddata->max_bus_width == 1)
+               host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
+

This looks like a common SDHCI driver issue that it assumes the default bus-width as 4 bit if no SDHCI_QUIRK_FORCE_1_BIT_DATA specified.

        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;

And I'm not sure Andrian or Ulf would like to see people keep using this quirk. IMHO we probably could totally remove it since bus-width already tells what the driver needs.

Andrian & Ulf,
Comments?

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
        /* call to generic mmc_of_parse to support additional capabilities */
        ret = mmc_of_parse(host->mmc);
        if (ret)
--

2.7.4

Regards
Dong Aisheng

maintainer
#4 lore raw
In reply to Leonardo G. Veiga

+Aisheng.

Best Regards
Haibo Chen

Quoted 56 lines

-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Leonardo G. Veiga
Sent: Tuesday, November 01, 2016 11:58 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] sdhci-esdhc-imx: fix bus-width for 1-bit operation.

From: Leonardo Graboski Veiga <[email protected]>

The 1-bit operation mode, enabled by seeting the 'bus-width' property of the device tree 'esdhc' node to <1>, not work while using SD card.

The behavior is only noticed when only the data pin 0 is connected to the hardware. A series of kernel errors are printed to the console, all of them returning the following error message followed by some explanation:
mmcblk0: error -84 transferring data

If four data lines are connected, it ignores the device-tree property and works in 4-bit mode of operation without errors. The hardware used for testing does not support 8-bit mode.

Check the 'bus-width' property and if set to <1>, enable the SDHCI_QUIRK_FORCE_1_BIT_DATA quirk.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci- renamed from drivers/mmc/host/sdhci-esdhc-imx.c +0 -0

esdhc-imx.c
index c9fbc4c3..88d7d22 100644

drivers/mmc/host/sdhci-esdhc-imx.c +4 -0
@@ -1003,6 +1003,10 @@ sdhci_esdhc_imx_probe_dt(struct platform_device
 *pdev,
 		host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
 	}
 
+	if (!of_property_read_u32(np, "bus-width", &boarddata-
 >max_bus_width)
+		&& boarddata->max_bus_width == 1)
+		host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
+
 	/* call to generic mmc_of_parse to support additional capabilities */
drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
--

2.7.4

--
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

#2 lore raw
In reply to Dong Aisheng
Quoted 40 lines · Dong Aisheng

Hi Leonardo,

Quoted 27 lines · Leonardo G. Veiga

From: Leonardo Graboski Veiga <[email protected]>

The 1-bit operation mode, enabled by seeting the 'bus-width' property of the device tree 'esdhc' node to <1>, not work while using SD card.

The behavior is only noticed when only the data pin 0 is connected to the hardware. A series of kernel errors are printed to the console, all of them returning the following error message followed by some explanation:
mmcblk0: error -84 transferring data

If four data lines are connected, it ignores the device-tree property and works in 4-bit mode of operation without errors. The hardware used for testing does not support 8-bit mode.

Check the 'bus-width' property and if set to <1>, enable the SDHCI_QUIRK_FORCE_1_BIT_DATA quirk.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index c9fbc4c3..88d7d22 100644

drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · line 1009

Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4 -0
@@ -1003,6 +1003,10 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
                host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
        }
 
+       if (!of_property_read_u32(np, "bus-width", &boarddata->max_bus_width)
+               && boarddata->max_bus_width == 1)
+               host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
+

This looks like a common SDHCI driver issue that it assumes the default bus-width as 4 bit if no SDHCI_QUIRK_FORCE_1_BIT_DATA specified.

Quoted 6 lines
        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;

And I'm not sure Andrian or Ulf would like to see people keep using this quirk. IMHO we probably could totally remove it since bus-width already tells what the driver needs.

Hm, I see what you are saying, the problem is that the core (sdhci_setup_host) falls back to 4-bit if SDHCI_QUIRK_FORCE_1_BIT_DATA is not set... Removing that should be fine for DT enabled SDHC drivers, since mmc_of_parse sets MMC_CAP_4_BIT_DATA. But not sure about drivers which parse dt on their own or still support platform data.... Those might rely on MMC_CAP_4_BIT_DATA being set by default...

--
Stefan

Quoted 13 lines

Andrian & Ulf,
Comments?

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
        /* call to generic mmc_of_parse to support additional capabilities */
        ret = mmc_of_parse(host->mmc);
        if (ret)
--

2.7.4

Regards
Dong Aisheng

#3 lore raw
Quoted 48 lines · Stefan Agner
Quoted 40 lines · Dong Aisheng

Hi Leonardo,

Quoted 27 lines · Leonardo G. Veiga

From: Leonardo Graboski Veiga <[email protected]>

The 1-bit operation mode, enabled by seeting the 'bus-width' property of the device tree 'esdhc' node to <1>, not work while using SD card.

The behavior is only noticed when only the data pin 0 is connected to the hardware. A series of kernel errors are printed to the console, all of them returning the following error message followed by some explanation:
mmcblk0: error -84 transferring data

If four data lines are connected, it ignores the device-tree property and works in 4-bit mode of operation without errors. The hardware used for testing does not support 8-bit mode.

Check the 'bus-width' property and if set to <1>, enable the SDHCI_QUIRK_FORCE_1_BIT_DATA quirk.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index c9fbc4c3..88d7d22 100644

drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · line 1009

Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4 -0
@@ -1003,6 +1003,10 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
                host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
        }
 
+       if (!of_property_read_u32(np, "bus-width", &boarddata->max_bus_width)
+               && boarddata->max_bus_width == 1)
+               host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
+

This looks like a common SDHCI driver issue that it assumes the default bus-width as 4 bit if no SDHCI_QUIRK_FORCE_1_BIT_DATA specified.

Quoted 6 lines
        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;

And I'm not sure Andrian or Ulf would like to see people keep using this quirk. IMHO we probably could totally remove it since bus-width already tells what the driver needs.

Quoted 6 lines

Hm, I see what you are saying, the problem is that the core (sdhci_setup_host) falls back to 4-bit if SDHCI_QUIRK_FORCE_1_BIT_DATA is not set... Removing that should be fine for DT enabled SDHC drivers, since mmc_of_parse sets MMC_CAP_4_BIT_DATA. But not sure about drivers which parse dt on their own or still support platform data.... Those might rely on MMC_CAP_4_BIT_DATA being set by default...

Any thoughts on this?

Btw, I just realized that this used to work in 4.1 because back then the device tree properties got parsed into struct esdhc_platform_data, which does set the 1-bit quirk.. So this can be seen as a regression...

--
Stefan

Quoted 19 lines

--
Stefan

Quoted 13 lines

Andrian & Ulf,
Comments?

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
        /* call to generic mmc_of_parse to support additional capabilities */
        ret = mmc_of_parse(host->mmc);
        if (ret)
--

2.7.4

Regards
Dong Aisheng