MMC: P2020 SDHC: Fix bug when writing to SDHCI_HOST_CONTROL register
PATCH 2/2 MMC: P2020 SDHC: Fix bug when writing to SDHCI_HOST_CONTROL register
The P2020 has a non-standard implementation of the SDHCI_HOST_CONTROL register. This patch adds a QUIRK in the SDHCI header to signal that a host controller has a non-standard SDHCI_HOST_CONTROL register. The patch adds a check to the function esdhc_writeb in file sdhci-of-esdhc.c, where it checks if the write is done to the SDHCI_HOST_CONTROL register and th host has the above mentioned QUIRK, then the function simply returns instead of writing to the register. The patch also detects if the processor is P2020 (by looking in dev tree) and if so, adds the QUIRK to the host->quirk2
This patch depends on the first patch of this set (total of 2 patches)
--- drivers/mmc/host/sdhci-of-esdhc.c | 14 ++++++++++++++ include/linux/mmc/sdhci.h | 2 ++ 2 files changed, 16 insertions(+)
drivers/mmc/host/sdhci-of-esdhc.c +14 -0
@@ -121,6 +121,11 @@ static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg)if (reg ==SDHCI_HOST_CONTROL ) {u32 dma_bits; +/* If host control register is not standard, exit +* this function */ +if (host->quirks2 &SDHCI_QUIRK2_BROKEN_HOST_CONTROL ) +return ; +/* DMA select is 22,23 bits in Protocol Control Register */ dma_bits = (val &SDHCI_CTRL_DMA_MASK ) <<5 ; clrsetbits_be32(host->ioaddr + reg , SDHCI_CTRL_DMA_MASK << 5,
@@ -289,6 +294,7 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {static int sdhci_esdhc_probe (struct platform_device *pdev) {struct sdhci_host *host; +struct device_node *np;int ret =0 ; host =sdhci_pltfm_init (pdev, &sdhci_esdhc_pdata);
@@ -297,6 +303,14 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)sdhci_get_of_property (pdev); + np = pdev->dev.of_node; +if (of_device_is_compatible (np,"fsl,p2020-esdhc" )) { +/* Freescale messed up with P2020 as it has a non-standard +* host control register +*/ + host->quirks2 |=SDHCI_QUIRK2_BROKEN_HOST_CONTROL ; + } +/* call to generic mmc_of_parse to support additional capabilities */ mmc_of_parse (host->mmc);
include/linux/mmc/sdhci.h +2 -0
@@ -95,6 +95,8 @@ struct sdhci_host {/* The system physically doesn't support 1.8v, even if the host does */ #define SDHCI_QUIRK2_NO_1_8_V (1<<2)#define SDHCI_QUIRK2_PRESET_VALUE_BROKEN (1<<3) +/* Controller has a non-standard host control register */ +#define SDHCI_QUIRK2_BROKEN_HOST_CONTROL (1<<4)int irq;/* Device IRQ */ void __iomem *ioaddr;/* Mapped address */
Signature · 1 line
1.8.3.1
Quoted 23 lines · Oded Gabbay
The P2020 has a non-standard implementation of the
SDHCI_HOST_CONTROLregister. This patch adds a QUIRK in the SDHCI header to signal that a host controller has a non-standardSDHCI_HOST_CONTROLregister. The patch adds a check to the functionesdhc_writebin filesdhci-of-esdhc.c, where it checks if the write is done to theSDHCI_HOST_CONTROLregister and th host has the above mentioned QUIRK, then the function simply returns instead of writing to the register. The patch also detects if the processor is P2020 (by looking in dev tree) and if so, adds the QUIRK to thehost->quirk2This patch depends on the first patch of this set (total of 2 patches)
Signed-off-by Oded Gabbay <[email protected]>--- drivers/mmc/host/sdhci-of-esdhc.c | 14 ++++++++++++++ include/linux/mmc/sdhci.h | 2 ++ 2 files changed, 16 insertions(+)drivers/mmc/host/sdhci-of-esdhc.c +0
-0
drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg) · line 125
Quoted 5 lines
drivers/mmc/host/sdhci-of-esdhc.c +2
-0@@ -121,6 +121,11 @@ static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg)if (reg ==SDHCI_HOST_CONTROL ) {u32 dma_bits; +/* If host control register is not standard, exit +* this function */
Broken comments.
Quoted 15 lines
drivers/mmc/host/sdhci-of-esdhc.c +4
-0+if (host->quirks2 &SDHCI_QUIRK2_BROKEN_HOST_CONTROL ) +return ; +/* DMA select is 22,23 bits in Protocol Control Register */ dma_bits = (val &SDHCI_CTRL_DMA_MASK ) <<5 ; clrsetbits_be32(host->ioaddr + reg , SDHCI_CTRL_DMA_MASK << 5,@@ -289,6 +294,7 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {static int sdhci_esdhc_probe (struct platform_device *pdev) {struct sdhci_host *host; +struct device_node *np;int ret =0 ; host =sdhci_pltfm_init (pdev, &sdhci_esdhc_pdata);
drivers/mmc/host/sdhci-of-esdhc.c static int sdhci_esdhc_probe(struct platform_device *pdev) · line 310
Quoted 8 lines
drivers/mmc/host/sdhci-of-esdhc.c +5
-0@@ -297,6 +303,14 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)sdhci_get_of_property (pdev); + np = pdev->dev.of_node; +if (of_device_is_compatible (np,"fsl,p2020-esdhc" )) { +/* Freescale messed up with P2020 as it has a non-standard +* host control register +*/
Ditto.
Otherwise, it looks good. Thanks!
Quoted 21 lines
drivers/mmc/host/sdhci-of-esdhc.c +3
-0+ host->quirks2 |=SDHCI_QUIRK2_BROKEN_HOST_CONTROL ; + } +/* call to generic mmc_of_parse to support additional capabilities */ mmc_of_parse (host->mmc);include/linux/mmc/sdhci.h +2
-0@@ -95,6 +95,8 @@ struct sdhci_host {/* The system physically doesn't support 1.8v, even if the host does */ #define SDHCI_QUIRK2_NO_1_8_V (1<<2)#define SDHCI_QUIRK2_PRESET_VALUE_BROKEN (1<<3) +/* Controller has a non-standard host control register */ +#define SDHCI_QUIRK2_BROKEN_HOST_CONTROL (1<<4)int irq;/* Device IRQ */ void __iomem *ioaddr;/* Mapped address */ Signature · 1 line
1.8.3.1