History

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

Linus Walleij committed 7 years ago

Commit d2951df1 parent faed9307 files · +75 −32Browse files

Unified · Split

7 files
  1. arch/arm/mach-s3c24xx/mach-at2440evb.c +12 −2
  2. arch/arm/mach-s3c24xx/mach-h1940.c +13 −2
  3. arch/arm/mach-s3c24xx/mach-mini2440.c +13 −2
  4. arch/arm/mach-s3c24xx/mach-n30.c +13 −2
  5. arch/arm/mach-s3c24xx/mach-rx1950.c +13 −2
  6. drivers/mmc/host/s3cmci.c +11 −18
  7. include/linux/platform_data/mmc-s3cmci.h +0 −4
arch/arm/mach-s3c24xx/mach-at2440evb.c+12−2
@@ -9,7 +9,7 @@ · 8 unmodified lines
99
1010 #include <linux/kernel.h>
1111 #include <linux/types.h>
12−#include <linux/gpio.h>
12+#include <linux/gpio/machine.h>
1313 #include <linux/interrupt.h>
1414 #include <linux/list.h>
1515 #include <linux/timer.h>
@@ -136,7 +136,16 @@ static struct platform_device at2440evb_device_eth = { · 120 unmodified lines
136136 };
137137
138138 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+ },
140149 };
141150
142151 /* 7" LCD panel */
@@ -200,6 +209,7 @@ static void __init at2440evb_init_time(void) · 57 unmodified lines
200209 static void __init at2440evb_init(void)
201210 {
202211 s3c24xx_fb_set_platdata(&at2440evb_fb_info);
212+ gpiod_add_lookup_table(&at2440evb_mci_gpio_table);
203213 s3c24xx_mci_set_platdata(&at2440evb_mci_pdata);
204214 s3c_nand_set_platdata(&at2440evb_nand_info);
205215 s3c_i2c0_set_platdata(NULL);
arch/arm/mach-s3c24xx/mach-h1940.c+13−2
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/platform_device.h>
1919 #include <linux/io.h>
2020 #include <linux/gpio.h>
21+#include <linux/gpio/machine.h>
2122 #include <linux/input.h>
2223 #include <linux/gpio_keys.h>
2324 #include <linux/pwm.h>
@@ -459,12 +460,21 @@ static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd) · 435 unmodified lines
459460 }
460461
461462 static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
462− .gpio_detect = S3C2410_GPF(5),
463− .gpio_wprotect = S3C2410_GPH(8),
464463 .set_power = h1940_set_mmc_power,
465464 .ocr_avail = MMC_VDD_32_33,
466465 };
467466
467+static struct gpiod_lookup_table h1940_mmc_gpio_table = {
468+ .dev_id = "s3c2410-sdi",
469+ .table = {
470+ /* Card detect S3C2410_GPF(5) */
471+ GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW),
472+ /* Write protect S3C2410_GPH(8) */
473+ GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW),
474+ { },
475+ },
476+};
477+
468478 static struct pwm_lookup h1940_pwm_lookup[] = {
469479 PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296,
470480 PWM_POLARITY_NORMAL),
@@ -680,6 +690,7 @@ static void __init h1940_init(void) · 209 unmodified lines
680690 u32 tmp;
681691
682692 s3c24xx_fb_set_platdata(&h1940_fb_info);
693+ gpiod_add_lookup_table(&h1940_mmc_gpio_table);
683694 s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
684695 s3c24xx_udc_set_platdata(&h1940_udc_cfg);
685696 s3c24xx_ts_set_platdata(&h1940_ts_cfg);
arch/arm/mach-s3c24xx/mach-mini2440.c+13−2
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/timer.h>
1616 #include <linux/init.h>
1717 #include <linux/gpio.h>
18+#include <linux/gpio/machine.h>
1819 #include <linux/input.h>
1920 #include <linux/io.h>
2021 #include <linux/serial_core.h>
@@ -234,13 +235,22 @@ static struct s3c2410fb_mach_info mini2440_fb_info __initdata = { · 213 unmodified lines
234235 /* MMC/SD */
235236
236237 static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = {
237− .gpio_detect = S3C2410_GPG(8),
238− .gpio_wprotect = S3C2410_GPH(8),
239238 .wprotect_invert = 1,
240239 .set_power = NULL,
241240 .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
242241 };
243242
243+static struct gpiod_lookup_table mini2440_mmc_gpio_table = {
244+ .dev_id = "s3c2410-sdi",
245+ .table = {
246+ /* Card detect S3C2410_GPG(8) */
247+ GPIO_LOOKUP("GPG", 8, "cd", GPIO_ACTIVE_LOW),
248+ /* Write protect S3C2410_GPH(8) */
249+ GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_HIGH),
250+ { },
251+ },
252+};
253+
244254 /* NAND Flash on MINI2440 board */
245255
246256 static struct mtd_partition mini2440_default_nand_part[] __initdata = {
@@ -696,6 +706,7 @@ static void __init mini2440_init(void) · 449 unmodified lines
696706 }
697707
698708 s3c24xx_udc_set_platdata(&mini2440_udc_cfg);
709+ gpiod_add_lookup_table(&mini2440_mmc_gpio_table);
699710 s3c24xx_mci_set_platdata(&mini2440_mmc_cfg);
700711 s3c_nand_set_platdata(&mini2440_nand_info);
701712 s3c_i2c0_set_platdata(NULL);
arch/arm/mach-s3c24xx/mach-n30.c+13−2
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 #include <linux/gpio_keys.h>
1818 #include <linux/init.h>
1919 #include <linux/gpio.h>
20+#include <linux/gpio/machine.h>
2021 #include <linux/input.h>
2122 #include <linux/interrupt.h>
2223 #include <linux/platform_device.h>
@@ -350,12 +351,21 @@ static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd) · 327 unmodified lines
350351 }
351352
352353 static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
353− .gpio_detect = S3C2410_GPF(1),
354− .gpio_wprotect = S3C2410_GPG(10),
355354 .ocr_avail = MMC_VDD_32_33,
356355 .set_power = n30_sdi_set_power,
357356 };
358357
358+static struct gpiod_lookup_table n30_mci_gpio_table = {
359+ .dev_id = "s3c2410-sdi",
360+ .table = {
361+ /* Card detect S3C2410_GPF(1) */
362+ GPIO_LOOKUP("GPF", 1, "cd", GPIO_ACTIVE_LOW),
363+ /* Write protect S3C2410_GPG(10) */
364+ GPIO_LOOKUP("GPG", 10, "wp", GPIO_ACTIVE_LOW),
365+ { },
366+ },
367+};
368+
359369 static struct platform_device *n30_devices[] __initdata = {
360370 &s3c_device_lcd,
361371 &s3c_device_wdt,
@@ -549,6 +559,7 @@ static void __init n30_init(void) · 187 unmodified lines
549559
550560 s3c24xx_fb_set_platdata(&n30_fb_info);
551561 s3c24xx_udc_set_platdata(&n30_udc_cfg);
562+ gpiod_add_lookup_table(&n30_mci_gpio_table);
552563 s3c24xx_mci_set_platdata(&n30_mci_cfg);
553564 s3c_i2c0_set_platdata(&n30_i2ccfg);
554565
arch/arm/mach-s3c24xx/mach-rx1950.c+13−2
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/timer.h>
1515 #include <linux/init.h>
1616 #include <linux/gpio.h>
17+#include <linux/gpio/machine.h>
1718 #include <linux/platform_device.h>
1819 #include <linux/serial_core.h>
1920 #include <linux/serial_s3c.h>
@@ -558,12 +559,21 @@ static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd) · 538 unmodified lines
558559 }
559560
560561 static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
561− .gpio_detect = S3C2410_GPF(5),
562− .gpio_wprotect = S3C2410_GPH(8),
563562 .set_power = rx1950_set_mmc_power,
564563 .ocr_avail = MMC_VDD_32_33,
565564 };
566565
566+static struct gpiod_lookup_table rx1950_mmc_gpio_table = {
567+ .dev_id = "s3c2410-sdi",
568+ .table = {
569+ /* Card detect S3C2410_GPF(5) */
570+ GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW),
571+ /* Write protect S3C2410_GPH(8) */
572+ GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW),
573+ { },
574+ },
575+};
576+
567577 static struct mtd_partition rx1950_nand_part[] = {
568578 [0] = {
569579 .name = "Boot0",
@@ -762,6 +772,7 @@ static void __init rx1950_init_machine(void) · 192 unmodified lines
762772 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
763773 s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
764774 s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
775+ gpiod_add_lookup_table(&rx1950_mmc_gpio_table);
765776 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
766777 s3c_i2c0_set_platdata(NULL);
767778 s3c_nand_set_platdata(&rx1950_nand_info);
drivers/mmc/host/s3cmci.c+11−18
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 #include <linux/io.h>
2727 #include <linux/of.h>
2828 #include <linux/of_device.h>
29−#include <linux/of_gpio.h>
3029 #include <linux/mmc/slot-gpio.h>
3130
3231 #include <plat/gpio-cfg.h>
@@ -1545,25 +1544,19 @@ static int s3cmci_probe_pdata(struct s3cmci_host *host) · 1512 unmodified lines
15451544 if (pdata->wprotect_invert)
15461545 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
15471546
1548− if (pdata->detect_invert)
1549− mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
1550−
1551− if (gpio_is_valid(pdata->gpio_detect)) {
1552− ret = mmc_gpio_request_cd(mmc, pdata->gpio_detect, 0);
1553− if (ret) {
1554− dev_err(&pdev->dev, "error requesting GPIO for CD %d\n",
1555− ret);
1556− return ret;
1557− }
1547+ /* If we get -ENOENT we have no card detect GPIO line */
1548+ ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
1549+ if (ret != -ENOENT) {
1550+ dev_err(&pdev->dev, "error requesting GPIO for CD %d\n",
1551+ ret);
1552+ return ret;
15581553 }
15591554
1560− if (gpio_is_valid(pdata->gpio_wprotect)) {
1561− ret = mmc_gpio_request_ro(mmc, pdata->gpio_wprotect);
1562− if (ret) {
1563− dev_err(&pdev->dev, "error requesting GPIO for WP %d\n",
1564− ret);
1565− return ret;
1566− }
1555+ ret = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL);
1556+ if (ret != -ENOENT) {
1557+ dev_err(&pdev->dev, "error requesting GPIO for WP %d\n",
1558+ ret);
1559+ return ret;
15671560 }
15681561
15691562 return 0;
include/linux/platform_data/mmc-s3cmci.h+0−4
@@ -7,7 +7,6 @@ · 6 unmodified lines
77 * @no_wprotect: Set this to indicate there is no write-protect switch.
88 * @no_detect: Set this if there is no detect switch.
99 * @wprotect_invert: Invert the default sense of the write protect switch.
10− * @detect_invert: Invert the default sense of the write protect switch.
1110 * @use_dma: Set to allow the use of DMA.
1211 * @gpio_detect: GPIO number for the card detect line.
1312 * @gpio_wprotect: GPIO number for the write protect line.
@@ -31,11 +30,8 @@ struct s3c24xx_mci_pdata { · 17 unmodified lines
3130 unsigned int no_wprotect:1;
3231 unsigned int no_detect:1;
3332 unsigned int wprotect_invert:1;
34− unsigned int detect_invert:1; /* set => detect active high */
3533 unsigned int use_dma:1;
3634
37− unsigned int gpio_detect;
38− unsigned int gpio_wprotect;
3935 unsigned long ocr_avail;
4036 void (*set_power)(unsigned char power_mode,
4137 unsigned short vdd);