Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ARM] 4236/2: basic {enable,disable}_irq_wake() support for PXA

pxa_set_gpio_wake handles GPIOs > 1, so IRQ_TO_GPIO has to be used
instead of just substracting IRQ_GPIO0 from the irq number.

authored by

Philipp Zabel and committed by
Russell King
4fe4a2bf 235b185c

+70 -2
+70 -2
arch/arm/mach-pxa/irq.c
··· 38 38 ICMR |= (1 << (irq + PXA_IRQ_SKIP)); 39 39 } 40 40 41 + static int pxa_set_wake(unsigned int irq, unsigned int on) 42 + { 43 + u32 mask; 44 + 45 + switch (irq) { 46 + case IRQ_RTCAlrm: 47 + mask = PWER_RTC; 48 + break; 49 + #ifdef CONFIG_PXA27x 50 + /* REVISIT can handle USBH1, USBH2, USB, MSL, USIM, ... */ 51 + #endif 52 + default: 53 + return -EINVAL; 54 + } 55 + if (on) 56 + PWER |= mask; 57 + else 58 + PWER &= ~mask; 59 + return 0; 60 + } 61 + 41 62 static struct irq_chip pxa_internal_chip_low = { 42 63 .name = "SC", 43 64 .ack = pxa_mask_low_irq, 44 65 .mask = pxa_mask_low_irq, 45 66 .unmask = pxa_unmask_low_irq, 67 + .set_wake = pxa_set_wake, 46 68 }; 47 69 48 70 #if PXA_INTERNAL_IRQS > 32 ··· 92 70 93 71 #endif 94 72 73 + /* Note that if an input/irq line ever gets changed to an output during 74 + * suspend, the relevant PWER, PRER, and PFER bits should be cleared. 75 + */ 76 + #ifdef CONFIG_PXA27x 77 + 78 + /* PXA27x: Various gpios can issue wakeup events. This logic only 79 + * handles the simple cases, not the WEMUX2 and WEMUX3 options 80 + */ 81 + #define PXA27x_GPIO_NOWAKE_MASK \ 82 + ((1 << 8) | (1 << 7) | (1 << 6) | (1 << 5) | (1 << 2)) 83 + #define WAKEMASK(gpio) \ 84 + (((gpio) <= 15) \ 85 + ? ((1 << (gpio)) & ~PXA27x_GPIO_NOWAKE_MASK) \ 86 + : ((gpio == 35) ? (1 << 24) : 0)) 87 + #else 88 + 89 + /* pxa 210, 250, 255, 26x: gpios 0..15 can issue wakeups */ 90 + #define WAKEMASK(gpio) (((gpio) <= 15) ? (1 << (gpio)) : 0) 91 + #endif 92 + 95 93 /* 96 94 * PXA GPIO edge detection for IRQs: 97 95 * IRQs are generated on Falling-Edge, Rising-Edge, or both. ··· 125 83 static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) 126 84 { 127 85 int gpio, idx; 86 + u32 mask; 128 87 129 88 gpio = IRQ_TO_GPIO(irq); 130 89 idx = gpio >> 5; 90 + mask = WAKEMASK(gpio); 131 91 132 92 if (type == IRQT_PROBE) { 133 93 /* Don't mess with enabled GPIOs using preconfigured edges or ··· 149 105 if (type & __IRQT_RISEDGE) { 150 106 /* printk("rising "); */ 151 107 __set_bit (gpio, GPIO_IRQ_rising_edge); 152 - } else 108 + PRER |= mask; 109 + } else { 153 110 __clear_bit (gpio, GPIO_IRQ_rising_edge); 111 + PRER &= ~mask; 112 + } 154 113 155 114 if (type & __IRQT_FALEDGE) { 156 115 /* printk("falling "); */ 157 116 __set_bit (gpio, GPIO_IRQ_falling_edge); 158 - } else 117 + PFER |= mask; 118 + } else { 159 119 __clear_bit (gpio, GPIO_IRQ_falling_edge); 120 + PFER &= ~mask; 121 + } 160 122 161 123 /* printk("edges\n"); */ 162 124 ··· 180 130 GEDR0 = (1 << (irq - IRQ_GPIO0)); 181 131 } 182 132 133 + static int pxa_set_gpio_wake(unsigned int irq, unsigned int on) 134 + { 135 + int gpio = IRQ_TO_GPIO(irq); 136 + u32 mask = WAKEMASK(gpio); 137 + 138 + if (!mask) 139 + return -EINVAL; 140 + 141 + if (on) 142 + PWER |= mask; 143 + else 144 + PWER &= ~mask; 145 + return 0; 146 + } 147 + 148 + 183 149 static struct irq_chip pxa_low_gpio_chip = { 184 150 .name = "GPIO-l", 185 151 .ack = pxa_ack_low_gpio, 186 152 .mask = pxa_mask_low_irq, 187 153 .unmask = pxa_unmask_low_irq, 188 154 .set_type = pxa_gpio_irq_type, 155 + .set_wake = pxa_set_gpio_wake, 189 156 }; 190 157 191 158 /* ··· 311 244 .mask = pxa_mask_muxed_gpio, 312 245 .unmask = pxa_unmask_muxed_gpio, 313 246 .set_type = pxa_gpio_irq_type, 247 + .set_wake = pxa_set_gpio_wake, 314 248 }; 315 249 316 250