13 #include <linux/module.h>
14 #include <linux/signal.h>
18 #include <linux/random.h>
22 #include <linux/errno.h>
23 #include <linux/list.h>
29 #include <mach/hardware.h>
38 static int GPIO_IRQ_rising_edge;
39 static int GPIO_IRQ_falling_edge;
40 static int GPIO_IRQ_mask = 0;
42 #define GPIO_MASK(irq) (1 << (irq - IRQ_GPIO0))
44 static int puv3_gpio_type(
struct irq_data *
d,
unsigned int type)
54 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
60 GPIO_IRQ_rising_edge |=
mask;
62 GPIO_IRQ_rising_edge &= ~mask;
64 GPIO_IRQ_falling_edge |=
mask;
66 GPIO_IRQ_falling_edge &= ~mask;
77 static void puv3_low_gpio_ack(
struct irq_data *
d)
82 static void puv3_low_gpio_mask(
struct irq_data *d)
87 static void puv3_low_gpio_unmask(
struct irq_data *d)
92 static int puv3_low_gpio_wake(
struct irq_data *d,
unsigned int on)
101 static struct irq_chip puv3_low_gpio_chip = {
103 .irq_ack = puv3_low_gpio_ack,
104 .irq_mask = puv3_low_gpio_mask,
105 .irq_unmask = puv3_low_gpio_unmask,
106 .irq_set_type = puv3_gpio_type,
107 .irq_set_wake = puv3_low_gpio_wake,
116 puv3_gpio_handler(
unsigned int irq,
struct irq_desc *
desc)
144 static void puv3_high_gpio_ack(
struct irq_data *d)
151 static void puv3_high_gpio_mask(
struct irq_data *d)
155 GPIO_IRQ_mask &= ~mask;
161 static void puv3_high_gpio_unmask(
struct irq_data *d)
165 GPIO_IRQ_mask |=
mask;
171 static int puv3_high_gpio_wake(
struct irq_data *d,
unsigned int on)
180 static struct irq_chip puv3_high_gpio_chip = {
182 .irq_ack = puv3_high_gpio_ack,
183 .irq_mask = puv3_high_gpio_mask,
184 .irq_unmask = puv3_high_gpio_unmask,
185 .irq_set_type = puv3_gpio_type,
186 .irq_set_wake = puv3_high_gpio_wake,
193 static void puv3_mask_irq(
struct irq_data *d)
198 static void puv3_unmask_irq(
struct irq_data *d)
206 static int puv3_set_wake(
struct irq_data *d,
unsigned int on)
218 static struct irq_chip puv3_normal_chip = {
219 .name =
"PKUnity-v3",
220 .irq_ack = puv3_mask_irq,
221 .irq_mask = puv3_mask_irq,
222 .irq_unmask = puv3_unmask_irq,
223 .irq_set_wake = puv3_set_wake,
226 static struct resource irq_resource = {
232 static struct puv3_irq_state {
239 static int puv3_irq_suspend(
void)
241 struct puv3_irq_state *
st = &puv3_irq_state;
267 static void puv3_irq_resume(
void)
269 struct puv3_irq_state *st = &puv3_irq_state;
283 .suspend = puv3_irq_suspend,
284 .resume = puv3_irq_resume,
287 static int __init puv3_irq_init_syscore(
void)
323 for (irq = IRQ_GPIOHIGH + 1; irq <
IRQ_GPIO0; irq++) {
331 for (irq = IRQ_GPIO0; irq <=
IRQ_GPIO27; irq++) {
343 irq_set_chained_handler(IRQ_GPIOHIGH, puv3_gpio_handler);
345 #ifdef CONFIG_PUV3_GPIO
357 struct pt_regs *old_regs = set_irq_regs(regs);
366 if (printk_ratelimit())
374 set_irq_regs(old_regs);