Skip to content

Commit ef5332c

Browse files
Wolfram Sangstorulf
authored andcommitted
mmc: renesas_sdhi: really fix WP logic regressions
This reverts commit e060d37 ("mmc: renesas_sdhi: fix WP detection") and adds some code to really fix the regressions. It was missed so far that Renesas R-Car instantiations of SDHI chose to disable internal WP and used the existence of "wp-gpios" to en/disable WP at all. With the first refactoring by Yamada-san with commit 2ad1db0 ("mmc: renesas_sdhi: use MMC_CAP2_NO_WRITE_PROTECT instead of TMIO own flag"), WP was always disabled even when GPIOs were present. With Wolfram's first fix which gets now reverted, GPIOs were honored. But when not available, the fallback was to internal WP and not to disabled WP. This caused wrong WP status on uSD card slots. Restore the old behaviour now. By default, WP is disabled. When a GPIO is found, the GPIO re-enables WP. We will think about possible better ways to handle this in the future. Tested on a previously regressing Renesas Lager board (H2) and a still working Renesas Salvator-X board (M3-W). Reported-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: Wolfram Sang <[email protected]> Cc: [email protected] # v4.17+ Signed-off-by: Ulf Hansson <[email protected]>
1 parent 77252da commit ef5332c

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

drivers/mmc/host/renesas_sdhi_core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/of_device.h>
2929
#include <linux/platform_device.h>
3030
#include <linux/mmc/host.h>
31+
#include <linux/mmc/slot-gpio.h>
3132
#include <linux/mfd/tmio.h>
3233
#include <linux/sh_dma.h>
3334
#include <linux/delay.h>
@@ -534,6 +535,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
534535
host->multi_io_quirk = renesas_sdhi_multi_io_quirk;
535536
host->dma_ops = dma_ops;
536537

538+
/* For some SoC, we disable internal WP. GPIO may override this */
539+
if (mmc_can_gpio_ro(host->mmc))
540+
mmc_data->capabilities2 &= ~MMC_CAP2_NO_WRITE_PROTECT;
541+
537542
/* SDR speeds are only available on Gen2+ */
538543
if (mmc_data->flags & TMIO_MMC_MIN_RCAR2) {
539544
/* card_busy caused issues on r8a73a4 (pre-Gen2) CD-less SDHI */

drivers/mmc/host/renesas_sdhi_internal_dmac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
8787
TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
8888
.capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
8989
MMC_CAP_CMD23,
90+
.capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
9091
.bus_shift = 2,
9192
.scc_offset = 0x1000,
9293
.taps = rcar_gen3_scc_taps,

drivers/mmc/host/renesas_sdhi_sys_dmac.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const struct renesas_sdhi_of_data of_rz_compatible = {
4242
static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = {
4343
.tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL,
4444
.capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
45+
.capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
4546
};
4647

4748
/* Definitions for sampling clocks */
@@ -61,6 +62,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = {
6162
TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
6263
.capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
6364
MMC_CAP_CMD23,
65+
.capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
6466
.dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES,
6567
.dma_rx_offset = 0x2000,
6668
.scc_offset = 0x0300,
@@ -81,6 +83,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
8183
TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
8284
.capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
8385
MMC_CAP_CMD23,
86+
.capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
8487
.bus_shift = 2,
8588
.scc_offset = 0x1000,
8689
.taps = rcar_gen3_scc_taps,

0 commit comments

Comments
 (0)