Skip to content

Commit afa2c94

Browse files
Laurent Pinchartcjb
authored andcommitted
sh: ecovec24: Use MMC/SDHI CD and RO GPIO
Pass the CD and RO GPIO numbers to the MMC SPI and SDHI drivers and remove the custom .get_cd() and .get_ro() callback functions. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent 2a4f6b1 commit afa2c94

1 file changed

Lines changed: 8 additions & 34 deletions

File tree

  • arch/sh/boards/mach-ecovec24

‎arch/sh/boards/mach-ecovec24/setup.c‎

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,14 @@ static void sdhi0_set_pwr(struct platform_device *pdev, int state)
617617
gpio_set_value(GPIO_PTB6, state);
618618
}
619619

620-
static int sdhi0_get_cd(struct platform_device *pdev)
621-
{
622-
return !gpio_get_value(GPIO_PTY7);
623-
}
624-
625620
static struct sh_mobile_sdhi_info sdhi0_info = {
626621
.dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
627622
.dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
628623
.set_pwr = sdhi0_set_pwr,
629624
.tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
630625
MMC_CAP_NEEDS_POLL,
631-
.get_cd = sdhi0_get_cd,
626+
.tmio_flags = TMIO_MMC_USE_GPIO_CD,
627+
.cd_gpio = GPIO_PTY7,
632628
};
633629

634630
static struct resource sdhi0_resources[] = {
@@ -675,18 +671,14 @@ static void cn12_set_pwr(struct platform_device *pdev, int state)
675671

676672
#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
677673
/* SDHI1 */
678-
static int sdhi1_get_cd(struct platform_device *pdev)
679-
{
680-
return !gpio_get_value(GPIO_PTW7);
681-
}
682-
683674
static struct sh_mobile_sdhi_info sdhi1_info = {
684675
.dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
685676
.dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
686677
.tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
687678
MMC_CAP_NEEDS_POLL,
679+
.tmio_flags = TMIO_MMC_USE_GPIO_CD,
680+
.cd_gpio = GPIO_PTW7,
688681
.set_pwr = cn12_set_pwr,
689-
.get_cd = sdhi1_get_cd,
690682
};
691683

692684
static struct resource sdhi1_resources[] = {
@@ -716,27 +708,19 @@ static struct platform_device sdhi1_device = {
716708
#else
717709

718710
/* MMC SPI */
719-
static int mmc_spi_get_ro(struct device *dev)
720-
{
721-
return gpio_get_value(GPIO_PTY6);
722-
}
723-
724-
static int mmc_spi_get_cd(struct device *dev)
725-
{
726-
return !gpio_get_value(GPIO_PTY7);
727-
}
728-
729711
static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
730712
{
731713
gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
732714
}
733715

734716
static struct mmc_spi_platform_data mmc_spi_info = {
735-
.get_ro = mmc_spi_get_ro,
736-
.get_cd = mmc_spi_get_cd,
737717
.caps = MMC_CAP_NEEDS_POLL,
718+
.caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
738719
.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
739720
.setpower = mmc_spi_setpower,
721+
.flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO,
722+
.cd_gpio = GPIO_PTY7,
723+
.ro_gpio = GPIO_PTY6,
740724
};
741725

742726
static struct spi_board_info spi_bus[] = {
@@ -1339,10 +1323,6 @@ static int __init arch_setup(void)
13391323
gpio_direction_input(GPIO_PTR6);
13401324

13411325
/* SD-card slot CN11 */
1342-
/* Card-detect, used on CN11, either with SDHI0 or with SPI */
1343-
gpio_request(GPIO_PTY7, NULL);
1344-
gpio_direction_input(GPIO_PTY7);
1345-
13461326
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
13471327
/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
13481328
gpio_request(GPIO_FN_SDHI0WP, NULL);
@@ -1361,8 +1341,6 @@ static int __init arch_setup(void)
13611341
gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
13621342
gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
13631343
gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
1364-
gpio_request(GPIO_PTY6, NULL); /* write protect */
1365-
gpio_direction_input(GPIO_PTY6);
13661344

13671345
spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
13681346
#endif
@@ -1392,10 +1370,6 @@ static int __init arch_setup(void)
13921370
gpio_request(GPIO_FN_SDHI1D1, NULL);
13931371
gpio_request(GPIO_FN_SDHI1D0, NULL);
13941372

1395-
/* Card-detect, used on CN12 with SDHI1 */
1396-
gpio_request(GPIO_PTW7, NULL);
1397-
gpio_direction_input(GPIO_PTW7);
1398-
13991373
cn12_enabled = true;
14001374
#endif
14011375

0 commit comments

Comments
 (0)