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

mmc: s3cmci: Use the slot GPIO descriptor

Simplify things by making the S3CMCI driver just use
slot GPIO with descriptors instead of passing around the
global GPIO numbers that we want to get rid of.

Getting the names of the GPIO chips into the machine
descriptor tables was a bit of a challenge but I think
I have them right.

The platform data supports passing in inversion flags, but
no platform is using them, and it is highly unlikely
that we will add more, so drop them. The long term plan
is to let the inversion flags on the GPIO machine
descriptor do the job.

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().

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Sergio Prado <sergio.prado@e-labworks.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
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
d2951dfa faed9303

+75 -32
+12 -2
arch/arm/mach-s3c24xx/mach-at2440evb.c
··· 9 9 10 10 #include <linux/kernel.h> 11 11 #include <linux/types.h> 12 - #include <linux/gpio.h> 12 + #include <linux/gpio/machine.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/list.h> 15 15 #include <linux/timer.h> ··· 136 136 }; 137 137 138 138 static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = { 139 - .gpio_detect = S3C2410_GPG(10), 139 + /* Intentionally left blank */ 140 + }; 141 + 142 + static struct gpiod_lookup_table at2440evb_mci_gpio_table = { 143 + .dev_id = "s3c2410-sdi", 144 + .table = { 145 + /* Card detect S3C2410_GPG(10) */ 146 + GPIO_LOOKUP("GPG", 10, "cd", GPIO_ACTIVE_LOW), 147 + { }, 148 + }, 140 149 }; 141 150 142 151 /* 7" LCD panel */ ··· 209 200 static void __init at2440evb_init(void) 210 201 { 211 202 s3c24xx_fb_set_platdata(&at2440evb_fb_info); 203 + gpiod_add_lookup_table(&at2440evb_mci_gpio_table); 212 204 s3c24xx_mci_set_platdata(&at2440evb_mci_pdata); 213 205 s3c_nand_set_platdata(&at2440evb_nand_info); 214 206 s3c_i2c0_set_platdata(NULL);
+13 -2
arch/arm/mach-s3c24xx/mach-h1940.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/io.h> 20 20 #include <linux/gpio.h> 21 + #include <linux/gpio/machine.h> 21 22 #include <linux/input.h> 22 23 #include <linux/gpio_keys.h> 23 24 #include <linux/pwm.h> ··· 460 459 } 461 460 462 461 static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = { 463 - .gpio_detect = S3C2410_GPF(5), 464 - .gpio_wprotect = S3C2410_GPH(8), 465 462 .set_power = h1940_set_mmc_power, 466 463 .ocr_avail = MMC_VDD_32_33, 464 + }; 465 + 466 + static struct gpiod_lookup_table h1940_mmc_gpio_table = { 467 + .dev_id = "s3c2410-sdi", 468 + .table = { 469 + /* Card detect S3C2410_GPF(5) */ 470 + GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW), 471 + /* Write protect S3C2410_GPH(8) */ 472 + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW), 473 + { }, 474 + }, 467 475 }; 468 476 469 477 static struct pwm_lookup h1940_pwm_lookup[] = { ··· 690 680 u32 tmp; 691 681 692 682 s3c24xx_fb_set_platdata(&h1940_fb_info); 683 + gpiod_add_lookup_table(&h1940_mmc_gpio_table); 693 684 s3c24xx_mci_set_platdata(&h1940_mmc_cfg); 694 685 s3c24xx_udc_set_platdata(&h1940_udc_cfg); 695 686 s3c24xx_ts_set_platdata(&h1940_ts_cfg);
+13 -2
arch/arm/mach-s3c24xx/mach-mini2440.c
··· 15 15 #include <linux/timer.h> 16 16 #include <linux/init.h> 17 17 #include <linux/gpio.h> 18 + #include <linux/gpio/machine.h> 18 19 #include <linux/input.h> 19 20 #include <linux/io.h> 20 21 #include <linux/serial_core.h> ··· 235 234 /* MMC/SD */ 236 235 237 236 static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { 238 - .gpio_detect = S3C2410_GPG(8), 239 - .gpio_wprotect = S3C2410_GPH(8), 240 237 .wprotect_invert = 1, 241 238 .set_power = NULL, 242 239 .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, 240 + }; 241 + 242 + static struct gpiod_lookup_table mini2440_mmc_gpio_table = { 243 + .dev_id = "s3c2410-sdi", 244 + .table = { 245 + /* Card detect S3C2410_GPG(8) */ 246 + GPIO_LOOKUP("GPG", 8, "cd", GPIO_ACTIVE_LOW), 247 + /* Write protect S3C2410_GPH(8) */ 248 + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_HIGH), 249 + { }, 250 + }, 243 251 }; 244 252 245 253 /* NAND Flash on MINI2440 board */ ··· 706 696 } 707 697 708 698 s3c24xx_udc_set_platdata(&mini2440_udc_cfg); 699 + gpiod_add_lookup_table(&mini2440_mmc_gpio_table); 709 700 s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); 710 701 s3c_nand_set_platdata(&mini2440_nand_info); 711 702 s3c_i2c0_set_platdata(NULL);
+13 -2
arch/arm/mach-s3c24xx/mach-n30.c
··· 17 17 #include <linux/gpio_keys.h> 18 18 #include <linux/init.h> 19 19 #include <linux/gpio.h> 20 + #include <linux/gpio/machine.h> 20 21 #include <linux/input.h> 21 22 #include <linux/interrupt.h> 22 23 #include <linux/platform_device.h> ··· 351 350 } 352 351 353 352 static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = { 354 - .gpio_detect = S3C2410_GPF(1), 355 - .gpio_wprotect = S3C2410_GPG(10), 356 353 .ocr_avail = MMC_VDD_32_33, 357 354 .set_power = n30_sdi_set_power, 355 + }; 356 + 357 + static struct gpiod_lookup_table n30_mci_gpio_table = { 358 + .dev_id = "s3c2410-sdi", 359 + .table = { 360 + /* Card detect S3C2410_GPF(1) */ 361 + GPIO_LOOKUP("GPF", 1, "cd", GPIO_ACTIVE_LOW), 362 + /* Write protect S3C2410_GPG(10) */ 363 + GPIO_LOOKUP("GPG", 10, "wp", GPIO_ACTIVE_LOW), 364 + { }, 365 + }, 358 366 }; 359 367 360 368 static struct platform_device *n30_devices[] __initdata = { ··· 559 549 560 550 s3c24xx_fb_set_platdata(&n30_fb_info); 561 551 s3c24xx_udc_set_platdata(&n30_udc_cfg); 552 + gpiod_add_lookup_table(&n30_mci_gpio_table); 562 553 s3c24xx_mci_set_platdata(&n30_mci_cfg); 563 554 s3c_i2c0_set_platdata(&n30_i2ccfg); 564 555
+13 -2
arch/arm/mach-s3c24xx/mach-rx1950.c
··· 14 14 #include <linux/timer.h> 15 15 #include <linux/init.h> 16 16 #include <linux/gpio.h> 17 + #include <linux/gpio/machine.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/serial_core.h> 19 20 #include <linux/serial_s3c.h> ··· 559 558 } 560 559 561 560 static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = { 562 - .gpio_detect = S3C2410_GPF(5), 563 - .gpio_wprotect = S3C2410_GPH(8), 564 561 .set_power = rx1950_set_mmc_power, 565 562 .ocr_avail = MMC_VDD_32_33, 563 + }; 564 + 565 + static struct gpiod_lookup_table rx1950_mmc_gpio_table = { 566 + .dev_id = "s3c2410-sdi", 567 + .table = { 568 + /* Card detect S3C2410_GPF(5) */ 569 + GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW), 570 + /* Write protect S3C2410_GPH(8) */ 571 + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW), 572 + { }, 573 + }, 566 574 }; 567 575 568 576 static struct mtd_partition rx1950_nand_part[] = { ··· 772 762 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg); 773 763 s3c24xx_udc_set_platdata(&rx1950_udc_cfg); 774 764 s3c24xx_ts_set_platdata(&rx1950_ts_cfg); 765 + gpiod_add_lookup_table(&rx1950_mmc_gpio_table); 775 766 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); 776 767 s3c_i2c0_set_platdata(NULL); 777 768 s3c_nand_set_platdata(&rx1950_nand_info);
+11 -18
drivers/mmc/host/s3cmci.c
··· 26 26 #include <linux/io.h> 27 27 #include <linux/of.h> 28 28 #include <linux/of_device.h> 29 - #include <linux/of_gpio.h> 30 29 #include <linux/mmc/slot-gpio.h> 31 30 32 31 #include <plat/gpio-cfg.h> ··· 1544 1545 if (pdata->wprotect_invert) 1545 1546 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 1546 1547 1547 - if (pdata->detect_invert) 1548 - mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 1549 - 1550 - if (gpio_is_valid(pdata->gpio_detect)) { 1551 - ret = mmc_gpio_request_cd(mmc, pdata->gpio_detect, 0); 1552 - if (ret) { 1553 - dev_err(&pdev->dev, "error requesting GPIO for CD %d\n", 1554 - ret); 1555 - return ret; 1556 - } 1548 + /* If we get -ENOENT we have no card detect GPIO line */ 1549 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); 1550 + if (ret != -ENOENT) { 1551 + dev_err(&pdev->dev, "error requesting GPIO for CD %d\n", 1552 + ret); 1553 + return ret; 1557 1554 } 1558 1555 1559 - if (gpio_is_valid(pdata->gpio_wprotect)) { 1560 - ret = mmc_gpio_request_ro(mmc, pdata->gpio_wprotect); 1561 - if (ret) { 1562 - dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", 1563 - ret); 1564 - return ret; 1565 - } 1556 + ret = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL); 1557 + if (ret != -ENOENT) { 1558 + dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", 1559 + ret); 1560 + return ret; 1566 1561 } 1567 1562 1568 1563 return 0;
-4
include/linux/platform_data/mmc-s3cmci.h
··· 7 7 * @no_wprotect: Set this to indicate there is no write-protect switch. 8 8 * @no_detect: Set this if there is no detect switch. 9 9 * @wprotect_invert: Invert the default sense of the write protect switch. 10 - * @detect_invert: Invert the default sense of the write protect switch. 11 10 * @use_dma: Set to allow the use of DMA. 12 11 * @gpio_detect: GPIO number for the card detect line. 13 12 * @gpio_wprotect: GPIO number for the write protect line. ··· 30 31 unsigned int no_wprotect:1; 31 32 unsigned int no_detect:1; 32 33 unsigned int wprotect_invert:1; 33 - unsigned int detect_invert:1; /* set => detect active high */ 34 34 unsigned int use_dma:1; 35 35 36 - unsigned int gpio_detect; 37 - unsigned int gpio_wprotect; 38 36 unsigned long ocr_avail; 39 37 void (*set_power)(unsigned char power_mode, 40 38 unsigned short vdd);