aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/magician.c
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2009-07-06 16:16:42 -0400
committerEric Miao <eric.y.miao@gmail.com>2009-09-10 06:49:30 -0400
commit7a648256b20c493c99757fe1d248daf7954647bc (patch)
tree82aa6566accc96ea07a89121cb9779090a6dab40 /arch/arm/mach-pxa/magician.c
parentb405db6c015fe8e4c9d8199a0355bb16d95d7049 (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/magician.c')
-rw-r--r--arch/arm/mach-pxa/magician.c49
1 files changed, 9 insertions, 40 deletions
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index ca39669cffc5..0daba43d7ca1 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -651,55 +651,24 @@ static struct platform_device bq24022 = {
651static int magician_mci_init(struct device *dev, 651static int magician_mci_init(struct device *dev,
652 irq_handler_t detect_irq, void *data) 652 irq_handler_t detect_irq, void *data)
653{ 653{
654 int err; 654 return request_irq(IRQ_MAGICIAN_SD, detect_irq,
655
656 err = request_irq(IRQ_MAGICIAN_SD, detect_irq,
657 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, 655 IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
658 "MMC card detect", data); 656 "mmc card detect", data);
659 if (err)
660 goto err_request_irq;
661 err = gpio_request(EGPIO_MAGICIAN_SD_POWER, "SD_POWER");
662 if (err)
663 goto err_request_power;
664 err = gpio_request(EGPIO_MAGICIAN_nSD_READONLY, "nSD_READONLY");
665 if (err)
666 goto err_request_readonly;
667
668 return 0;
669
670err_request_readonly:
671 gpio_free(EGPIO_MAGICIAN_SD_POWER);
672err_request_power:
673 free_irq(IRQ_MAGICIAN_SD, data);
674err_request_irq:
675 return err;
676}
677
678static void magician_mci_setpower(struct device *dev, unsigned int vdd)
679{
680 struct pxamci_platform_data *pdata = dev->platform_data;
681
682 gpio_set_value(EGPIO_MAGICIAN_SD_POWER, (1 << vdd) & pdata->ocr_mask);
683}
684
685static int magician_mci_get_ro(struct device *dev)
686{
687 return (!gpio_get_value(EGPIO_MAGICIAN_nSD_READONLY));
688} 657}
689 658
690static void magician_mci_exit(struct device *dev, void *data) 659static void magician_mci_exit(struct device *dev, void *data)
691{ 660{
692 gpio_free(EGPIO_MAGICIAN_nSD_READONLY);
693 gpio_free(EGPIO_MAGICIAN_SD_POWER);
694 free_irq(IRQ_MAGICIAN_SD, data); 661 free_irq(IRQ_MAGICIAN_SD, data);
695} 662}
696 663
697static struct pxamci_platform_data magician_mci_info = { 664static struct pxamci_platform_data magician_mci_info = {
698 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 665 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
699 .init = magician_mci_init, 666 .init = magician_mci_init,
700 .get_ro = magician_mci_get_ro, 667 .exit = magician_mci_exit,
701 .setpower = magician_mci_setpower, 668 .gpio_card_detect = -1,
702 .exit = magician_mci_exit, 669 .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY,
670 .gpio_card_ro_invert = 1,
671 .gpio_power = EGPIO_MAGICIAN_SD_POWER,
703}; 672};
704 673
705 674