[MINI2440] Updated defconfig to add (optional) packages
[openwrt/mini2440.git] / target / linux / pxa / patches-2.6.21 / 031-mmc-card-detect.patch
blob890f19578a033b6d9ad5eb4db94b574361251a2f
1 --- a/arch/arm/mach-pxa/gumstix.c
2 +++ b/arch/arm/mach-pxa/gumstix.c
3 @@ -29,19 +29,55 @@
5 #include "generic.h"
7 -static int gumstix_mci_init(struct device *dev, irqreturn_t (*lubbock_detect_int)(int, void *, struct pt_regs *), void *data)
8 +static struct pxamci_platform_data gumstix_mci_platform_data;
10 +static int gumstix_mci_init(struct device *dev, irqreturn_t (*gumstix_detect_int)(int, void *, struct pt_regs *), void *data)
12 - // Set up MMC controller
13 + int err;
15 pxa_gpio_mode(GPIO6_MMCCLK_MD);
16 pxa_gpio_mode(GPIO53_MMCCLK_MD);
17 pxa_gpio_mode(GPIO8_MMCCS0_MD);
19 + pxa_gpio_mode(GUMSTIX_GPIO_nSD_DETECT | GPIO_IN);
20 + set_irq_type(GUMSTIX_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
21 + pxa_gpio_mode(GUMSTIX_GPIO_nSD_WP | GPIO_IN);
23 + gumstix_mci_platform_data.detect_delay = msecs_to_jiffies(250);
25 + err = request_irq(GUMSTIX_IRQ_GPIO_nSD_DETECT, gumstix_detect_int, SA_INTERRUPT,
26 + "MMC card detect", data);
27 + if (err) {
28 + printk(KERN_ERR "gumstix_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
29 + return -1;
30 + }
32 + err = set_irq_type(GUMSTIX_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
34 return 0;
37 +static int gumstix_mci_get_ro(struct device *dev)
39 +#ifdef CONFIG_ARCH_GUMSTIX_VERDEX
40 + return 0; // microSD is always writable on verdex
41 +#else
42 + int ro;
43 + ro = GPLR(GUMSTIX_GPIO_nSD_WP) & GPIO_bit(GUMSTIX_GPIO_nSD_WP);
44 + return ro;
45 +#endif
48 +static void gumstix_mci_exit(struct device *dev, void *data)
50 + free_irq(GUMSTIX_IRQ_GPIO_nSD_DETECT, data);
53 static struct pxamci_platform_data gumstix_mci_platform_data = {
54 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
55 - .init = &gumstix_mci_init,
56 + .init = gumstix_mci_init,
57 + .get_ro = gumstix_mci_get_ro,
58 + .exit = gumstix_mci_exit,
61 static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
62 --- a/include/asm-arm/arch-pxa/gumstix.h
63 +++ b/include/asm-arm/arch-pxa/gumstix.h
64 @@ -36,6 +36,12 @@
65 #define GPIO_GUMSTIX_USB_GPIOx_CON_MD (GPIO_GUMSTIX_USB_GPIOx | GPIO_OUT)
66 #define GPIO_GUMSTIX_USB_GPIOx_DIS_MD (GPIO_GUMSTIX_USB_GPIOx | GPIO_IN)
68 +/*
69 + * SD/MMC definitions
70 + */
71 +#define GUMSTIX_GPIO_nSD_WP 22 /* SD Write Protect */
72 +#define GUMSTIX_GPIO_nSD_DETECT 11 /* MMC/SD Card Detect */
73 +#define GUMSTIX_IRQ_GPIO_nSD_DETECT IRQ_GPIO(GUMSTIX_GPIO_nSD_DETECT)
76 * SMC Ethernet definitions