Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * arch/arm/mach-pxa/colibri-pxa3xx.c |
| 3 | * |
| 4 | * Common functions for all Toradex PXA3xx modules |
| 5 | * |
| 6 | * Daniel Mack <daniel@caiaq.de> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/gpio.h> |
| 17 | #include <asm/mach-types.h> |
| 18 | #include <mach/hardware.h> |
| 19 | #include <asm/sizes.h> |
| 20 | #include <asm/mach/arch.h> |
| 21 | #include <asm/mach/irq.h> |
| 22 | #include <mach/pxa3xx-regs.h> |
| 23 | #include <mach/mfp-pxa300.h> |
| 24 | #include <mach/colibri.h> |
| 25 | #include <mach/mmc.h> |
| 26 | |
| 27 | #include "generic.h" |
| 28 | #include "devices.h" |
| 29 | |
| 30 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 31 | static int mmc_detect_pin; |
| 32 | |
| 33 | static int colibri_pxa3xx_mci_init(struct device *dev, |
| 34 | irq_handler_t colibri_mmc_detect_int, |
| 35 | void *data) |
| 36 | { |
| 37 | int ret; |
| 38 | |
| 39 | ret = gpio_request(mmc_detect_pin, "mmc card detect"); |
| 40 | if (ret) |
| 41 | return ret; |
| 42 | |
| 43 | gpio_direction_input(mmc_detect_pin); |
| 44 | ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int, |
| 45 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 46 | "MMC card detect", data); |
| 47 | if (ret) { |
| 48 | gpio_free(mmc_detect_pin); |
| 49 | return ret; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static void colibri_pxa3xx_mci_exit(struct device *dev, void *data) |
| 56 | { |
| 57 | free_irq(mmc_detect_pin, data); |
| 58 | gpio_free(gpio_to_irq(mmc_detect_pin)); |
| 59 | } |
| 60 | |
| 61 | static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = { |
| 62 | .detect_delay = 20, |
| 63 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 64 | .init = colibri_pxa3xx_mci_init, |
| 65 | .exit = colibri_pxa3xx_mci_exit, |
| 66 | }; |
| 67 | |
| 68 | void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin) |
| 69 | { |
| 70 | pxa3xx_mfp_config(pins, len); |
| 71 | mmc_detect_pin = detect_pin; |
| 72 | pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data); |
| 73 | } |
| 74 | #endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */ |
| 75 | |