diff options
author | Robert Jarzmik <robert.jarzmik@free.fr> | 2009-07-06 16:16:42 -0400 |
---|---|---|
committer | Eric Miao <eric.y.miao@gmail.com> | 2009-09-10 06:49:30 -0400 |
commit | 7a648256b20c493c99757fe1d248daf7954647bc (patch) | |
tree | 82aa6566accc96ea07a89121cb9779090a6dab40 /arch/arm/mach-pxa/mioa701.c | |
parent | b405db6c015fe8e4c9d8199a0355bb16d95d7049 (diff) |
[ARM] pxa: factor pxamci gpio handling
Several boards use always the same pattern with pxamci :
request gpio, request irq for that gpio to detect MMC card
insertion, request gpio for read-only mode detection, etc
...
Now that pxamci provides platform_data to describe simple
gpio management of the MMC external controls, use it.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: rpurdie@rpsys.net
Cc: drwyrm@gmail.com
Cc: sakoman@gmail.com
Cc: marek.vasut@gmail.com
Cc: s.hauer@pengutronix.de
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'arch/arm/mach-pxa/mioa701.c')
-rw-r--r-- | arch/arm/mach-pxa/mioa701.c | 68 |
1 files changed, 6 insertions, 62 deletions
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index 2d28132c725b..a8122ecd2a3a 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c | |||
@@ -434,72 +434,15 @@ struct gpio_vbus_mach_info gpio_vbus_data = { | |||
434 | /* | 434 | /* |
435 | * SDIO/MMC Card controller | 435 | * SDIO/MMC Card controller |
436 | */ | 436 | */ |
437 | static void mci_setpower(struct device *dev, unsigned int vdd) | ||
438 | { | ||
439 | struct pxamci_platform_data *p_d = dev->platform_data; | ||
440 | |||
441 | if ((1 << vdd) & p_d->ocr_mask) | ||
442 | gpio_set_value(GPIO91_SDIO_EN, 1); /* enable SDIO power */ | ||
443 | else | ||
444 | gpio_set_value(GPIO91_SDIO_EN, 0); /* disable SDIO power */ | ||
445 | } | ||
446 | |||
447 | static int mci_get_ro(struct device *dev) | ||
448 | { | ||
449 | return gpio_get_value(GPIO78_SDIO_RO); | ||
450 | } | ||
451 | |||
452 | struct gpio_ress mci_gpios[] = { | ||
453 | MIO_GPIO_IN(GPIO78_SDIO_RO, "SDIO readonly detect"), | ||
454 | MIO_GPIO_IN(GPIO15_SDIO_INSERT, "SDIO insertion detect"), | ||
455 | MIO_GPIO_OUT(GPIO91_SDIO_EN, 0, "SDIO power enable") | ||
456 | }; | ||
457 | |||
458 | static void mci_exit(struct device *dev, void *data) | ||
459 | { | ||
460 | mio_gpio_free(ARRAY_AND_SIZE(mci_gpios)); | ||
461 | free_irq(gpio_to_irq(GPIO15_SDIO_INSERT), data); | ||
462 | } | ||
463 | |||
464 | static struct pxamci_platform_data mioa701_mci_info; | ||
465 | |||
466 | /** | 437 | /** |
467 | * The card detect interrupt isn't debounced so we delay it by 250ms | 438 | * The card detect interrupt isn't debounced so we delay it by 250ms |
468 | * to give the card a chance to fully insert/eject. | 439 | * to give the card a chance to fully insert/eject. |
469 | */ | 440 | */ |
470 | static int mci_init(struct device *dev, irq_handler_t detect_int, void *data) | ||
471 | { | ||
472 | int rc; | ||
473 | int irq = gpio_to_irq(GPIO15_SDIO_INSERT); | ||
474 | |||
475 | rc = mio_gpio_request(ARRAY_AND_SIZE(mci_gpios)); | ||
476 | if (rc) | ||
477 | goto err_gpio; | ||
478 | /* enable RE/FE interrupt on card insertion and removal */ | ||
479 | rc = request_irq(irq, detect_int, | ||
480 | IRQF_DISABLED | IRQF_TRIGGER_RISING | | ||
481 | IRQF_TRIGGER_FALLING, | ||
482 | "MMC card detect", data); | ||
483 | if (rc) | ||
484 | goto err_irq; | ||
485 | |||
486 | mioa701_mci_info.detect_delay = msecs_to_jiffies(250); | ||
487 | return 0; | ||
488 | |||
489 | err_irq: | ||
490 | dev_err(dev, "mioa701_mci_init: MMC/SD:" | ||
491 | " can't request MMC card detect IRQ\n"); | ||
492 | mio_gpio_free(ARRAY_AND_SIZE(mci_gpios)); | ||
493 | err_gpio: | ||
494 | return rc; | ||
495 | } | ||
496 | |||
497 | static struct pxamci_platform_data mioa701_mci_info = { | 441 | static struct pxamci_platform_data mioa701_mci_info = { |
498 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | 442 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
499 | .init = mci_init, | 443 | .gpio_card_detect = GPIO15_SDIO_INSERT, |
500 | .get_ro = mci_get_ro, | 444 | .gpio_card_ro = GPIO78_SDIO_RO, |
501 | .setpower = mci_setpower, | 445 | .gpio_power = GPIO91_SDIO_EN, |
502 | .exit = mci_exit, | ||
503 | }; | 446 | }; |
504 | 447 | ||
505 | /* FlashRAM */ | 448 | /* FlashRAM */ |
@@ -841,7 +784,7 @@ static void mioa701_restart(char c, const char *cmd) | |||
841 | static struct gpio_ress global_gpios[] = { | 784 | static struct gpio_ress global_gpios[] = { |
842 | MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"), | 785 | MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"), |
843 | MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"), | 786 | MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"), |
844 | MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power") | 787 | MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"), |
845 | }; | 788 | }; |
846 | 789 | ||
847 | static void __init mioa701_machine_init(void) | 790 | static void __init mioa701_machine_init(void) |
@@ -855,6 +798,7 @@ static void __init mioa701_machine_init(void) | |||
855 | mio_gpio_request(ARRAY_AND_SIZE(global_gpios)); | 798 | mio_gpio_request(ARRAY_AND_SIZE(global_gpios)); |
856 | bootstrap_init(); | 799 | bootstrap_init(); |
857 | set_pxa_fb_info(&mioa701_pxafb_info); | 800 | set_pxa_fb_info(&mioa701_pxafb_info); |
801 | mioa701_mci_info.detect_delay = msecs_to_jiffies(250); | ||
858 | pxa_set_mci_info(&mioa701_mci_info); | 802 | pxa_set_mci_info(&mioa701_mci_info); |
859 | pxa_set_keypad_info(&mioa701_keypad_info); | 803 | pxa_set_keypad_info(&mioa701_keypad_info); |
860 | wm97xx_bat_set_pdata(&mioa701_battery_data); | 804 | wm97xx_bat_set_pdata(&mioa701_battery_data); |