aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-12-02 03:43:20 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2018-12-17 02:26:24 -0500
commitd2951dfa070ddb3ae3c48ea8a5d7acb2fa8614bd (patch)
tree47a8b78838d507a1657f6c7cffa721b694720eb7
parentfaed9303067a0bd9d8ddb09c0de3bc742334773a (diff)
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>
-rw-r--r--arch/arm/mach-s3c24xx/mach-at2440evb.c14
-rw-r--r--arch/arm/mach-s3c24xx/mach-h1940.c15
-rw-r--r--arch/arm/mach-s3c24xx/mach-mini2440.c15
-rw-r--r--arch/arm/mach-s3c24xx/mach-n30.c15
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx1950.c15
-rw-r--r--drivers/mmc/host/s3cmci.c29
-rw-r--r--include/linux/platform_data/mmc-s3cmci.h4
7 files changed, 75 insertions, 32 deletions
diff --git a/arch/arm/mach-s3c24xx/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c
index 68a4fa94257a..58c5ef3cf1d7 100644
--- a/arch/arm/mach-s3c24xx/mach-at2440evb.c
+++ b/arch/arm/mach-s3c24xx/mach-at2440evb.c
@@ -9,7 +9,7 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/gpio.h> 12#include <linux/gpio/machine.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/timer.h> 15#include <linux/timer.h>
@@ -136,7 +136,16 @@ static struct platform_device at2440evb_device_eth = {
136}; 136};
137 137
138static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = { 138static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = {
139 .gpio_detect = S3C2410_GPG(10), 139 /* Intentionally left blank */
140};
141
142static 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/* 7" LCD panel */ 151/* 7" LCD panel */
@@ -200,6 +209,7 @@ static void __init at2440evb_init_time(void)
200static void __init at2440evb_init(void) 209static void __init at2440evb_init(void)
201{ 210{
202 s3c24xx_fb_set_platdata(&at2440evb_fb_info); 211 s3c24xx_fb_set_platdata(&at2440evb_fb_info);
212 gpiod_add_lookup_table(&at2440evb_mci_gpio_table);
203 s3c24xx_mci_set_platdata(&at2440evb_mci_pdata); 213 s3c24xx_mci_set_platdata(&at2440evb_mci_pdata);
204 s3c_nand_set_platdata(&at2440evb_nand_info); 214 s3c_nand_set_platdata(&at2440evb_nand_info);
205 s3c_i2c0_set_platdata(NULL); 215 s3c_i2c0_set_platdata(NULL);
diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c
index e064c73a57d3..74d6b68e91c7 100644
--- a/arch/arm/mach-s3c24xx/mach-h1940.c
+++ b/arch/arm/mach-s3c24xx/mach-h1940.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/gpio/machine.h>
21#include <linux/input.h> 22#include <linux/input.h>
22#include <linux/gpio_keys.h> 23#include <linux/gpio_keys.h>
23#include <linux/pwm.h> 24#include <linux/pwm.h>
@@ -459,12 +460,21 @@ static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
459} 460}
460 461
461static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = { 462static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
462 .gpio_detect = S3C2410_GPF(5),
463 .gpio_wprotect = S3C2410_GPH(8),
464 .set_power = h1940_set_mmc_power, 463 .set_power = h1940_set_mmc_power,
465 .ocr_avail = MMC_VDD_32_33, 464 .ocr_avail = MMC_VDD_32_33,
466}; 465};
467 466
467static 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
468static struct pwm_lookup h1940_pwm_lookup[] = { 478static struct pwm_lookup h1940_pwm_lookup[] = {
469 PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296, 479 PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296,
470 PWM_POLARITY_NORMAL), 480 PWM_POLARITY_NORMAL),
@@ -680,6 +690,7 @@ static void __init h1940_init(void)
680 u32 tmp; 690 u32 tmp;
681 691
682 s3c24xx_fb_set_platdata(&h1940_fb_info); 692 s3c24xx_fb_set_platdata(&h1940_fb_info);
693 gpiod_add_lookup_table(&h1940_mmc_gpio_table);
683 s3c24xx_mci_set_platdata(&h1940_mmc_cfg); 694 s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
684 s3c24xx_udc_set_platdata(&h1940_udc_cfg); 695 s3c24xx_udc_set_platdata(&h1940_udc_cfg);
685 s3c24xx_ts_set_platdata(&h1940_ts_cfg); 696 s3c24xx_ts_set_platdata(&h1940_ts_cfg);
diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
index 50d67d760efd..9035f868fb34 100644
--- a/arch/arm/mach-s3c24xx/mach-mini2440.c
+++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
@@ -15,6 +15,7 @@
15#include <linux/timer.h> 15#include <linux/timer.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/gpio/machine.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/io.h> 20#include <linux/io.h>
20#include <linux/serial_core.h> 21#include <linux/serial_core.h>
@@ -234,13 +235,22 @@ static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
234/* MMC/SD */ 235/* MMC/SD */
235 236
236static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { 237static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = {
237 .gpio_detect = S3C2410_GPG(8),
238 .gpio_wprotect = S3C2410_GPH(8),
239 .wprotect_invert = 1, 238 .wprotect_invert = 1,
240 .set_power = NULL, 239 .set_power = NULL,
241 .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, 240 .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
242}; 241};
243 242
243static 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
244/* NAND Flash on MINI2440 board */ 254/* NAND Flash on MINI2440 board */
245 255
246static struct mtd_partition mini2440_default_nand_part[] __initdata = { 256static struct mtd_partition mini2440_default_nand_part[] __initdata = {
@@ -696,6 +706,7 @@ static void __init mini2440_init(void)
696 } 706 }
697 707
698 s3c24xx_udc_set_platdata(&mini2440_udc_cfg); 708 s3c24xx_udc_set_platdata(&mini2440_udc_cfg);
709 gpiod_add_lookup_table(&mini2440_mmc_gpio_table);
699 s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); 710 s3c24xx_mci_set_platdata(&mini2440_mmc_cfg);
700 s3c_nand_set_platdata(&mini2440_nand_info); 711 s3c_nand_set_platdata(&mini2440_nand_info);
701 s3c_i2c0_set_platdata(NULL); 712 s3c_i2c0_set_platdata(NULL);
diff --git a/arch/arm/mach-s3c24xx/mach-n30.c b/arch/arm/mach-s3c24xx/mach-n30.c
index eec51fadb14a..d856f23939af 100644
--- a/arch/arm/mach-s3c24xx/mach-n30.c
+++ b/arch/arm/mach-s3c24xx/mach-n30.c
@@ -17,6 +17,7 @@
17#include <linux/gpio_keys.h> 17#include <linux/gpio_keys.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/gpio/machine.h>
20#include <linux/input.h> 21#include <linux/input.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
@@ -350,12 +351,21 @@ static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd)
350} 351}
351 352
352static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = { 353static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
353 .gpio_detect = S3C2410_GPF(1),
354 .gpio_wprotect = S3C2410_GPG(10),
355 .ocr_avail = MMC_VDD_32_33, 354 .ocr_avail = MMC_VDD_32_33,
356 .set_power = n30_sdi_set_power, 355 .set_power = n30_sdi_set_power,
357}; 356};
358 357
358static 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
359static struct platform_device *n30_devices[] __initdata = { 369static struct platform_device *n30_devices[] __initdata = {
360 &s3c_device_lcd, 370 &s3c_device_lcd,
361 &s3c_device_wdt, 371 &s3c_device_wdt,
@@ -549,6 +559,7 @@ static void __init n30_init(void)
549 559
550 s3c24xx_fb_set_platdata(&n30_fb_info); 560 s3c24xx_fb_set_platdata(&n30_fb_info);
551 s3c24xx_udc_set_platdata(&n30_udc_cfg); 561 s3c24xx_udc_set_platdata(&n30_udc_cfg);
562 gpiod_add_lookup_table(&n30_mci_gpio_table);
552 s3c24xx_mci_set_platdata(&n30_mci_cfg); 563 s3c24xx_mci_set_platdata(&n30_mci_cfg);
553 s3c_i2c0_set_platdata(&n30_i2ccfg); 564 s3c_i2c0_set_platdata(&n30_i2ccfg);
554 565
diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index 7f5a18fa305b..29f9b345a531 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -14,6 +14,7 @@
14#include <linux/timer.h> 14#include <linux/timer.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/gpio/machine.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/serial_core.h> 19#include <linux/serial_core.h>
19#include <linux/serial_s3c.h> 20#include <linux/serial_s3c.h>
@@ -558,12 +559,21 @@ static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
558} 559}
559 560
560static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = { 561static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
561 .gpio_detect = S3C2410_GPF(5),
562 .gpio_wprotect = S3C2410_GPH(8),
563 .set_power = rx1950_set_mmc_power, 562 .set_power = rx1950_set_mmc_power,
564 .ocr_avail = MMC_VDD_32_33, 563 .ocr_avail = MMC_VDD_32_33,
565}; 564};
566 565
566static 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
567static struct mtd_partition rx1950_nand_part[] = { 577static struct mtd_partition rx1950_nand_part[] = {
568 [0] = { 578 [0] = {
569 .name = "Boot0", 579 .name = "Boot0",
@@ -762,6 +772,7 @@ static void __init rx1950_init_machine(void)
762 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg); 772 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
763 s3c24xx_udc_set_platdata(&rx1950_udc_cfg); 773 s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
764 s3c24xx_ts_set_platdata(&rx1950_ts_cfg); 774 s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
775 gpiod_add_lookup_table(&rx1950_mmc_gpio_table);
765 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); 776 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
766 s3c_i2c0_set_platdata(NULL); 777 s3c_i2c0_set_platdata(NULL);
767 s3c_nand_set_platdata(&rx1950_nand_info); 778 s3c_nand_set_platdata(&rx1950_nand_info);
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index f77493604312..e1811ffd7b70 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -26,7 +26,6 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/of.h> 27#include <linux/of.h>
28#include <linux/of_device.h> 28#include <linux/of_device.h>
29#include <linux/of_gpio.h>
30#include <linux/mmc/slot-gpio.h> 29#include <linux/mmc/slot-gpio.h>
31 30
32#include <plat/gpio-cfg.h> 31#include <plat/gpio-cfg.h>
@@ -1545,25 +1544,19 @@ static int s3cmci_probe_pdata(struct s3cmci_host *host)
1545 if (pdata->wprotect_invert) 1544 if (pdata->wprotect_invert)
1546 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 1545 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
1547 1546
1548 if (pdata->detect_invert) 1547 /* If we get -ENOENT we have no card detect GPIO line */
1549 mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 1548 ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
1550 1549 if (ret != -ENOENT) {
1551 if (gpio_is_valid(pdata->gpio_detect)) { 1550 dev_err(&pdev->dev, "error requesting GPIO for CD %d\n",
1552 ret = mmc_gpio_request_cd(mmc, pdata->gpio_detect, 0); 1551 ret);
1553 if (ret) { 1552 return ret;
1554 dev_err(&pdev->dev, "error requesting GPIO for CD %d\n",
1555 ret);
1556 return ret;
1557 }
1558 } 1553 }
1559 1554
1560 if (gpio_is_valid(pdata->gpio_wprotect)) { 1555 ret = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL);
1561 ret = mmc_gpio_request_ro(mmc, pdata->gpio_wprotect); 1556 if (ret != -ENOENT) {
1562 if (ret) { 1557 dev_err(&pdev->dev, "error requesting GPIO for WP %d\n",
1563 dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", 1558 ret);
1564 ret); 1559 return ret;
1565 return ret;
1566 }
1567 } 1560 }
1568 1561
1569 return 0; 1562 return 0;
diff --git a/include/linux/platform_data/mmc-s3cmci.h b/include/linux/platform_data/mmc-s3cmci.h
index b68d9f0bdd9e..33310b11cbdd 100644
--- a/include/linux/platform_data/mmc-s3cmci.h
+++ b/include/linux/platform_data/mmc-s3cmci.h
@@ -7,7 +7,6 @@
7 * @no_wprotect: Set this to indicate there is no write-protect switch. 7 * @no_wprotect: Set this to indicate there is no write-protect switch.
8 * @no_detect: Set this if there is no detect switch. 8 * @no_detect: Set this if there is no detect switch.
9 * @wprotect_invert: Invert the default sense of the write protect switch. 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 * @use_dma: Set to allow the use of DMA. 10 * @use_dma: Set to allow the use of DMA.
12 * @gpio_detect: GPIO number for the card detect line. 11 * @gpio_detect: GPIO number for the card detect line.
13 * @gpio_wprotect: GPIO number for the write protect line. 12 * @gpio_wprotect: GPIO number for the write protect line.
@@ -31,11 +30,8 @@ struct s3c24xx_mci_pdata {
31 unsigned int no_wprotect:1; 30 unsigned int no_wprotect:1;
32 unsigned int no_detect:1; 31 unsigned int no_detect:1;
33 unsigned int wprotect_invert:1; 32 unsigned int wprotect_invert:1;
34 unsigned int detect_invert:1; /* set => detect active high */
35 unsigned int use_dma:1; 33 unsigned int use_dma:1;
36 34
37 unsigned int gpio_detect;
38 unsigned int gpio_wprotect;
39 unsigned long ocr_avail; 35 unsigned long ocr_avail;
40 void (*set_power)(unsigned char power_mode, 36 void (*set_power)(unsigned char power_mode,
41 unsigned short vdd); 37 unsigned short vdd);