Skip to content

Commit 32d1544

Browse files
linuswstorulf
authored andcommitted
ARM: pxa: Add gpio descriptor lookup tables for MMC CD/WP
This adds GPIO descriptor look-up tables for a whole bunch of PXA boards with MMC card detect (CD) and write protect (WP) GPIO lines, so we can move away from the hard-coded GPIO numberspace. In some cases the platforms were compulsively including the <linux/gpio.h> header even if they weren't actually using it, and in these cases I simply replaced that inclusion with the more appropriate <linux/gpio/machine.h> which is what board files should be including most of the time. Cc: Daniel Mack <daniel@zonque.org> Cc: Robert Jarzmik <robert.jarzmik@free.fr> Cc: Bartosz Golaszewski <brgl@bgdev.pl> Cc: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 5128f8d commit 32d1544

21 files changed

+322
-11
lines changed

arch/arm/mach-pxa/cm-x270.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/platform_device.h>
1313
#include <linux/irq.h>
1414
#include <linux/gpio.h>
15+
#include <linux/gpio/machine.h>
1516
#include <linux/delay.h>
1617

1718
#include <linux/platform_data/rtc-v3020.h>
@@ -294,8 +295,18 @@ static struct pxamci_platform_data cmx270_mci_platform_data = {
294295
.gpio_power_invert = 1,
295296
};
296297

298+
static struct gpiod_lookup_table cmx270_mci_gpio_table = {
299+
.dev_id = "pxa2xx-mci.0",
300+
.table = {
301+
/* Card detect on GPIO 83 */
302+
GPIO_LOOKUP("gpio-pxa", GPIO83_MMC_IRQ, "cd", GPIO_ACTIVE_LOW),
303+
{ },
304+
},
305+
};
306+
297307
static void __init cmx270_init_mmc(void)
298308
{
309+
gpiod_add_lookup_table(&cmx270_mci_gpio_table);
299310
pxa_set_mci_info(&cmx270_mci_platform_data);
300311
}
301312
#else

arch/arm/mach-pxa/cm-x300.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,17 @@ static struct pxamci_platform_data cm_x300_mci_platform_data = {
464464
.gpio_power = -1,
465465
};
466466

467+
static struct gpiod_lookup_table cm_x300_mci_gpio_table = {
468+
.dev_id = "pxa2xx-mci.0",
469+
.table = {
470+
/* Card detect on GPIO 82 */
471+
GPIO_LOOKUP("gpio-pxa", GPIO82_MMC_IRQ, "cd", GPIO_ACTIVE_LOW),
472+
/* Write protect on GPIO 85 */
473+
GPIO_LOOKUP("gpio-pxa", GPIO85_MMC_WP, "wp", GPIO_ACTIVE_LOW),
474+
{ },
475+
},
476+
};
477+
467478
/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
468479
no detection/ro pins */
469480
static int cm_x300_mci2_init(struct device *dev,
@@ -489,6 +500,7 @@ static struct pxamci_platform_data cm_x300_mci2_platform_data = {
489500

490501
static void __init cm_x300_init_mmc(void)
491502
{
503+
gpiod_add_lookup_table(&cm_x300_mci_gpio_table);
492504
pxa_set_mci_info(&cm_x300_mci_platform_data);
493505
pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
494506
}

arch/arm/mach-pxa/colibri-evalboard.c

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/kernel.h>
1515
#include <linux/platform_device.h>
1616
#include <linux/interrupt.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/machine.h>
1818
#include <asm/mach-types.h>
1919
#include <mach/hardware.h>
2020
#include <asm/mach/arch.h>
@@ -42,17 +42,50 @@ static struct pxamci_platform_data colibri_mci_platform_data = {
4242
.detect_delay_ms = 200,
4343
};
4444

45+
static struct gpiod_lookup_table colibri_pxa270_mci_gpio_table = {
46+
.dev_id = "pxa2xx-mci.0",
47+
.table = {
48+
GPIO_LOOKUP("gpio-pxa", GPIO0_COLIBRI_PXA270_SD_DETECT,
49+
"cd", GPIO_ACTIVE_LOW),
50+
{ },
51+
},
52+
};
53+
54+
static struct gpiod_lookup_table colibri_pxa300_mci_gpio_table = {
55+
.dev_id = "pxa2xx-mci.0",
56+
.table = {
57+
GPIO_LOOKUP("gpio-pxa", GPIO13_COLIBRI_PXA300_SD_DETECT,
58+
"cd", GPIO_ACTIVE_LOW),
59+
{ },
60+
},
61+
};
62+
63+
static struct gpiod_lookup_table colibri_pxa320_mci_gpio_table = {
64+
.dev_id = "pxa2xx-mci.0",
65+
.table = {
66+
GPIO_LOOKUP("gpio-pxa", GPIO28_COLIBRI_PXA320_SD_DETECT,
67+
"cd", GPIO_ACTIVE_LOW),
68+
{ },
69+
},
70+
};
71+
4572
static void __init colibri_mmc_init(void)
4673
{
47-
if (machine_is_colibri()) /* PXA270 Colibri */
74+
if (machine_is_colibri()) { /* PXA270 Colibri */
4875
colibri_mci_platform_data.gpio_card_detect =
4976
GPIO0_COLIBRI_PXA270_SD_DETECT;
50-
if (machine_is_colibri300()) /* PXA300 Colibri */
77+
gpiod_add_lookup_table(&colibri_pxa270_mci_gpio_table);
78+
}
79+
if (machine_is_colibri300()) { /* PXA300 Colibri */
5180
colibri_mci_platform_data.gpio_card_detect =
5281
GPIO13_COLIBRI_PXA300_SD_DETECT;
53-
else /* PXA320 Colibri */
82+
gpiod_add_lookup_table(&colibri_pxa300_mci_gpio_table);
83+
}
84+
else { /* PXA320 Colibri */
5485
colibri_mci_platform_data.gpio_card_detect =
5586
GPIO28_COLIBRI_PXA320_SD_DETECT;
87+
gpiod_add_lookup_table(&colibri_pxa320_mci_gpio_table);
88+
}
5689

5790
pxa_set_mci_info(&colibri_mci_platform_data);
5891
}

arch/arm/mach-pxa/colibri-pxa270-income.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <linux/bitops.h>
1616
#include <linux/delay.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/machine.h>
1818
#include <linux/init.h>
1919
#include <linux/interrupt.h>
2020
#include <linux/leds.h>
@@ -57,8 +57,22 @@ static struct pxamci_platform_data income_mci_platform_data = {
5757
.detect_delay_ms = 200,
5858
};
5959

60+
static struct gpiod_lookup_table income_mci_gpio_table = {
61+
.dev_id = "pxa2xx-mci.0",
62+
.table = {
63+
/* Card detect on GPIO 0 */
64+
GPIO_LOOKUP("gpio-pxa", GPIO0_INCOME_SD_DETECT,
65+
"cd", GPIO_ACTIVE_LOW),
66+
/* Write protect on GPIO 1 */
67+
GPIO_LOOKUP("gpio-pxa", GPIO0_INCOME_SD_RO,
68+
"wp", GPIO_ACTIVE_LOW),
69+
{ },
70+
},
71+
};
72+
6073
static void __init income_mmc_init(void)
6174
{
75+
gpiod_add_lookup_table(&income_mci_gpio_table);
6276
pxa_set_mci_info(&income_mci_platform_data);
6377
}
6478
#else

arch/arm/mach-pxa/corgi.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/mtd/physmap.h>
2525
#include <linux/pm.h>
2626
#include <linux/gpio.h>
27+
#include <linux/gpio/machine.h>
2728
#include <linux/backlight.h>
2829
#include <linux/i2c.h>
2930
#include <linux/platform_data/i2c-pxa.h>
@@ -498,6 +499,18 @@ static struct pxamci_platform_data corgi_mci_platform_data = {
498499
.gpio_power = CORGI_GPIO_SD_PWR,
499500
};
500501

502+
static struct gpiod_lookup_table corgi_mci_gpio_table = {
503+
.dev_id = "pxa2xx-mci.0",
504+
.table = {
505+
/* Card detect on GPIO 9 */
506+
GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_DETECT,
507+
"cd", GPIO_ACTIVE_LOW),
508+
/* Write protect on GPIO 7 */
509+
GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_WP,
510+
"wp", GPIO_ACTIVE_LOW),
511+
{ },
512+
},
513+
};
501514

502515
/*
503516
* Irda
@@ -731,6 +744,7 @@ static void __init corgi_init(void)
731744
corgi_init_spi();
732745

733746
pxa_set_udc_info(&udc_info);
747+
gpiod_add_lookup_table(&corgi_mci_gpio_table);
734748
pxa_set_mci_info(&corgi_mci_platform_data);
735749
pxa_set_ficp_info(&corgi_ficp_platform_data);
736750
pxa_set_i2c_info(NULL);

arch/arm/mach-pxa/csb726.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/kernel.h>
1212
#include <linux/init.h>
1313
#include <linux/io.h>
14-
#include <linux/gpio.h>
14+
#include <linux/gpio/machine.h>
1515
#include <linux/platform_device.h>
1616
#include <linux/mtd/physmap.h>
1717
#include <linux/mtd/partitions.h>
@@ -134,6 +134,19 @@ static struct pxamci_platform_data csb726_mci = {
134134
.gpio_power = -1,
135135
};
136136

137+
static struct gpiod_lookup_table csb726_mci_gpio_table = {
138+
.dev_id = "pxa2xx-mci.0",
139+
.table = {
140+
/* Card detect on GPIO 100 */
141+
GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_DETECT,
142+
"cd", GPIO_ACTIVE_LOW),
143+
/* Write protect on GPIO 101 */
144+
GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_RO,
145+
"wp", GPIO_ACTIVE_LOW),
146+
{ },
147+
},
148+
};
149+
137150
static struct pxaohci_platform_data csb726_ohci_platform_data = {
138151
.port_mode = PMM_NPS_MODE,
139152
.flags = ENABLE_PORT1 | NO_OC_PROTECTION,
@@ -264,6 +277,7 @@ static void __init csb726_init(void)
264277
pxa_set_stuart_info(NULL);
265278
pxa_set_i2c_info(NULL);
266279
pxa27x_set_i2c_power_info(NULL);
280+
gpiod_add_lookup_table(&csb726_mci_gpio_table);
267281
pxa_set_mci_info(&csb726_mci);
268282
pxa_set_ohci_info(&csb726_ohci_platform_data);
269283
pxa_set_ac97_info(NULL);

arch/arm/mach-pxa/em-x270.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/input.h>
2121
#include <linux/gpio_keys.h>
2222
#include <linux/gpio.h>
23+
#include <linux/gpio/machine.h>
2324
#include <linux/mfd/da903x.h>
2425
#include <linux/regulator/machine.h>
2526
#include <linux/regulator/fixed.h>
@@ -546,6 +547,15 @@ static inline void em_x270_init_ohci(void) {}
546547
#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
547548
static struct regulator *em_x270_sdio_ldo;
548549

550+
static struct gpiod_lookup_table em_x270_mci_wp_gpio_table = {
551+
.dev_id = "pxa2xx-mci.0",
552+
.table = {
553+
/* Write protect on GPIO 95 */
554+
GPIO_LOOKUP("gpio-pxa", GPIO95_MMC_WP, "wp", GPIO_ACTIVE_LOW),
555+
{ },
556+
},
557+
};
558+
549559
static int em_x270_mci_init(struct device *dev,
550560
irq_handler_t em_x270_detect_int,
551561
void *data)
@@ -642,8 +652,10 @@ static struct pxamci_platform_data em_x270_mci_platform_data = {
642652

643653
static void __init em_x270_init_mmc(void)
644654
{
645-
if (machine_is_em_x270())
655+
if (machine_is_em_x270()) {
646656
em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
657+
gpiod_add_lookup_table(&em_x270_mci_wp_gpio_table);
658+
}
647659

648660
pxa_set_mci_info(&em_x270_mci_platform_data);
649661
}

arch/arm/mach-pxa/littleton.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <linux/delay.h>
2121
#include <linux/platform_device.h>
2222
#include <linux/clk.h>
23-
#include <linux/gpio.h>
23+
#include <linux/gpio/machine.h>
2424
#include <linux/spi/spi.h>
2525
#include <linux/spi/pxa2xx_spi.h>
2626
#include <linux/smc91x.h>
@@ -283,8 +283,19 @@ static struct pxamci_platform_data littleton_mci_platform_data = {
283283
.gpio_power = -1,
284284
};
285285

286+
static struct gpiod_lookup_table littleton_mci_gpio_table = {
287+
.dev_id = "pxa2xx-mci.0",
288+
.table = {
289+
/* Card detect on MFP (gpio-pxa) GPIO 15 */
290+
GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO15,
291+
"cd", GPIO_ACTIVE_LOW),
292+
{ },
293+
},
294+
};
295+
286296
static void __init littleton_init_mmc(void)
287297
{
298+
gpiod_add_lookup_table(&littleton_mci_gpio_table);
288299
pxa_set_mci_info(&littleton_mci_platform_data);
289300
}
290301
#else

arch/arm/mach-pxa/magician.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,21 @@ static struct pxamci_platform_data magician_mci_info = {
781781
.gpio_power = EGPIO_MAGICIAN_SD_POWER,
782782
};
783783

784+
/*
785+
* Write protect on EGPIO register 5 index 4, this is on the second HTC
786+
* EGPIO chip which starts at register 4, so we need offset 8+4=12 on that
787+
* particular chip.
788+
*/
789+
#define EGPIO_MAGICIAN_nSD_READONLY_OFFSET 12
790+
791+
static struct gpiod_lookup_table magician_mci_gpio_table = {
792+
.dev_id = "pxa2xx-mci.0",
793+
.table = {
794+
GPIO_LOOKUP("htc-egpio-1", EGPIO_MAGICIAN_nSD_READONLY_OFFSET,
795+
"wp", GPIO_ACTIVE_HIGH),
796+
{ },
797+
},
798+
};
784799

785800
/*
786801
* USB OHCI
@@ -979,6 +994,7 @@ static void __init magician_init(void)
979994
i2c_register_board_info(1,
980995
ARRAY_AND_SIZE(magician_pwr_i2c_board_info));
981996

997+
gpiod_add_lookup_table(&magician_mci_gpio_table);
982998
pxa_set_mci_info(&magician_mci_info);
983999
pxa_set_ohci_info(&magician_ohci_info);
9841000
pxa_set_udc_info(&magician_udc_info);

arch/arm/mach-pxa/mioa701.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/rtc.h>
3232
#include <linux/leds.h>
3333
#include <linux/gpio.h>
34+
#include <linux/gpio/machine.h>
3435
#include <linux/interrupt.h>
3536
#include <linux/irq.h>
3637
#include <linux/pda_power.h>
@@ -402,6 +403,19 @@ static struct pxamci_platform_data mioa701_mci_info = {
402403
.gpio_power = GPIO91_SDIO_EN,
403404
};
404405

406+
static struct gpiod_lookup_table mioa701_mci_gpio_table = {
407+
.dev_id = "pxa2xx-mci.0",
408+
.table = {
409+
/* Card detect on GPIO 15 */
410+
GPIO_LOOKUP("gpio-pxa", GPIO15_SDIO_INSERT,
411+
"cd", GPIO_ACTIVE_LOW),
412+
/* Write protect on GPIO 78 */
413+
GPIO_LOOKUP("gpio-pxa", GPIO78_SDIO_RO,
414+
"wp", GPIO_ACTIVE_LOW),
415+
{ },
416+
},
417+
};
418+
405419
/* FlashRAM */
406420
static struct resource docg3_resource = {
407421
.start = PXA_CS0_PHYS,
@@ -743,6 +757,7 @@ static void __init mioa701_machine_init(void)
743757
pr_err("MioA701: Failed to request GPIOs: %d", rc);
744758
bootstrap_init();
745759
pxa_set_fb_info(NULL, &mioa701_pxafb_info);
760+
gpiod_add_lookup_table(&mioa701_mci_gpio_table);
746761
pxa_set_mci_info(&mioa701_mci_info);
747762
pxa_set_keypad_info(&mioa701_keypad_info);
748763
pxa_set_udc_info(&mioa701_udc_info);

arch/arm/mach-pxa/mxm8x10.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <linux/serial_8250.h>
2323
#include <linux/dm9000.h>
24-
#include <linux/gpio.h>
24+
#include <linux/gpio/machine.h>
2525
#include <linux/platform_data/i2c-pxa.h>
2626

2727
#include <linux/platform_data/mtd-nand-pxa3xx.h>
@@ -331,8 +331,22 @@ static struct pxamci_platform_data mxm_8x10_mci_platform_data = {
331331
.gpio_power = -1
332332
};
333333

334+
static struct gpiod_lookup_table mxm_8x10_mci_gpio_table = {
335+
.dev_id = "pxa2xx-mci.0",
336+
.table = {
337+
/* Card detect on GPIO 72 */
338+
GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_nCD,
339+
"cd", GPIO_ACTIVE_LOW),
340+
/* Write protect on GPIO 84 */
341+
GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_WP,
342+
"wp", GPIO_ACTIVE_LOW),
343+
{ },
344+
},
345+
};
346+
334347
void __init mxm_8x10_mmc_init(void)
335348
{
349+
gpiod_add_lookup_table(&mxm_8x10_mci_gpio_table);
336350
pxa_set_mci_info(&mxm_8x10_mci_platform_data);
337351
}
338352
#endif

0 commit comments

Comments
 (0)