Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: host: tmio: Use GPIO descriptors

The TMIO MMC driver was passing global GPIO numbers around for
card detect. It turns out only one single board in the kernel
was actually making use of this feature so it is pretty easy
to convert the driver to use only GPIO descriptors.

The lines are flagged as GPIO_ACTIVE_[LOW|HIGH] as that is
what they are, and since we can now rely on the descriptors
to have the right polarity, we set the
"override_active_level" to false in mmc_gpiod_request_cd()
and mmc_gpiod_request_ro().

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Linus Walleij and committed by
Ulf Hansson
faed9303 5716fb9b

+31 -16
+22 -4
arch/sh/boards/mach-ecovec24/setup.c
··· 696 696 }, 697 697 }; 698 698 699 + static struct gpiod_lookup_table sdhi0_gpio_table = { 700 + .dev_id = "sh_mobile_sdhi.0", 701 + .table = { 702 + /* Card detect */ 703 + GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW), 704 + { }, 705 + }, 706 + }; 707 + 699 708 static struct tmio_mmc_data sdhi0_info = { 700 709 .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, 701 710 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, 702 711 .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 703 712 MMC_CAP_NEEDS_POLL, 704 - .flags = TMIO_MMC_USE_GPIO_CD, 705 - .cd_gpio = GPIO_PTY7, 706 713 }; 707 714 708 715 static struct resource sdhi0_resources[] = { ··· 742 735 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX, 743 736 .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 744 737 MMC_CAP_NEEDS_POLL, 745 - .flags = TMIO_MMC_USE_GPIO_CD, 746 - .cd_gpio = GPIO_PTW7, 738 + }; 739 + 740 + static struct gpiod_lookup_table sdhi1_gpio_table = { 741 + .dev_id = "sh_mobile_sdhi.1", 742 + .table = { 743 + /* Card detect */ 744 + GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW), 745 + { }, 746 + }, 747 747 }; 748 748 749 749 static struct resource sdhi1_resources[] = { ··· 1459 1445 gpiod_add_lookup_table(&cn12_power_gpiod_table); 1460 1446 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1461 1447 gpiod_add_lookup_table(&sdhi0_power_gpiod_table); 1448 + gpiod_add_lookup_table(&sdhi0_gpio_table); 1449 + #endif 1450 + #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1451 + gpiod_add_lookup_table(&sdhi1_gpio_table); 1462 1452 #endif 1463 1453 1464 1454 return platform_add_devices(ecovec_devices,
+7 -5
drivers/mmc/host/tmio_mmc_core.c
··· 1168 1168 if (ret < 0) 1169 1169 return ret; 1170 1170 1171 - if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { 1172 - ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); 1173 - if (ret) 1174 - return ret; 1175 - } 1171 + /* 1172 + * Look for a card detect GPIO, if it fails with anything 1173 + * else than a probe deferral, just live without it. 1174 + */ 1175 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); 1176 + if (ret == -EPROBE_DEFER) 1177 + return ret; 1176 1178 1177 1179 mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; 1178 1180 mmc->caps2 |= pdata->capabilities2;
+2 -7
include/linux/mfd/tmio.h
··· 54 54 * idle before writing to some registers. 55 55 */ 56 56 #define TMIO_MMC_HAS_IDLE_WAIT BIT(4) 57 - /* 58 - * A GPIO is used for card hotplug detection. We need an extra flag for this, 59 - * because 0 is a valid GPIO number too, and requiring users to specify 60 - * cd_gpio < 0 to disable GPIO hotplug would break backwards compatibility. 61 - */ 62 - #define TMIO_MMC_USE_GPIO_CD BIT(5) 57 + 58 + /* BIT(5) is unused */ 63 59 64 60 /* 65 61 * Some controllers have CMD12 automatically ··· 100 104 unsigned long capabilities2; 101 105 unsigned long flags; 102 106 u32 ocr_mask; /* available voltages */ 103 - unsigned int cd_gpio; 104 107 int alignment_shift; 105 108 dma_addr_t dma_rx_offset; 106 109 unsigned int max_blk_count;