blob: da3a44a4249a520c23e8c264802a1435c19497dc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-pxa/irq.c
3 *
eric miaoe3630db2008-03-04 11:42:26 +08004 * Generic PXA IRQ handling
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * Author: Nicolas Pitre
7 * Created: Jun 15, 2001
8 * Copyright: MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/init.h>
16#include <linux/module.h>
17#include <linux/interrupt.h>
eric miaoc01655042008-01-28 23:00:02 +000018#include <linux/sysdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#include <asm/hardware.h>
21#include <asm/irq.h>
22#include <asm/mach/irq.h>
23#include <asm/arch/pxa-regs.h>
24
25#include "generic.h"
26
27
28/*
29 * This is for peripheral IRQs internal to the PXA chip.
30 */
31
32static void pxa_mask_low_irq(unsigned int irq)
33{
Eric Miao486c9552007-06-06 06:22:20 +010034 ICMR &= ~(1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035}
36
37static void pxa_unmask_low_irq(unsigned int irq)
38{
Eric Miao486c9552007-06-06 06:22:20 +010039 ICMR |= (1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
David Brownell38c677c2006-08-01 22:26:25 +010042static struct irq_chip pxa_internal_chip_low = {
43 .name = "SC",
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 .ack = pxa_mask_low_irq,
45 .mask = pxa_mask_low_irq,
46 .unmask = pxa_unmask_low_irq,
47};
48
Eric Miao53665a52007-06-06 06:36:04 +010049void __init pxa_init_irq_low(void)
50{
51 int irq;
52
53 /* disable all IRQs */
54 ICMR = 0;
55
56 /* all IRQs are IRQ, not FIQ */
57 ICLR = 0;
58
59 /* only unmasked interrupts kick us out of idle */
60 ICCR = 1;
61
62 for (irq = PXA_IRQ(0); irq <= PXA_IRQ(31); irq++) {
63 set_irq_chip(irq, &pxa_internal_chip_low);
64 set_irq_handler(irq, handle_level_irq);
65 set_irq_flags(irq, IRQF_VALID);
66 }
67}
68
eric miao2c8086a2007-09-11 19:13:17 -070069#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71/*
72 * This is for the second set of internal IRQs as found on the PXA27x.
73 */
74
75static void pxa_mask_high_irq(unsigned int irq)
76{
Eric Miao486c9552007-06-06 06:22:20 +010077 ICMR2 &= ~(1 << (irq - 32));
Linus Torvalds1da177e2005-04-16 15:20:36 -070078}
79
80static void pxa_unmask_high_irq(unsigned int irq)
81{
Eric Miao486c9552007-06-06 06:22:20 +010082 ICMR2 |= (1 << (irq - 32));
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
David Brownell38c677c2006-08-01 22:26:25 +010085static struct irq_chip pxa_internal_chip_high = {
86 .name = "SC-hi",
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 .ack = pxa_mask_high_irq,
88 .mask = pxa_mask_high_irq,
89 .unmask = pxa_unmask_high_irq,
90};
91
Eric Miaoc08b7b32007-06-06 06:32:38 +010092void __init pxa_init_irq_high(void)
93{
94 int irq;
95
96 ICMR2 = 0;
97 ICLR2 = 0;
98
99 for (irq = PXA_IRQ(32); irq < PXA_IRQ(64); irq++) {
100 set_irq_chip(irq, &pxa_internal_chip_high);
101 set_irq_handler(irq, handle_level_irq);
102 set_irq_flags(irq, IRQF_VALID);
103 }
104}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#endif
106
eric miaoc95530c2007-08-29 10:22:17 +0100107void __init pxa_init_irq_set_wake(int (*set_wake)(unsigned int, unsigned int))
108{
109 pxa_internal_chip_low.set_wake = set_wake;
110#ifdef CONFIG_PXA27x
111 pxa_internal_chip_high.set_wake = set_wake;
112#endif
eric miaoa7bf4db2008-03-04 11:12:14 +0800113 pxa_init_gpio_set_wake(set_wake);
eric miaoc95530c2007-08-29 10:22:17 +0100114}
eric miaoc01655042008-01-28 23:00:02 +0000115
116#ifdef CONFIG_PM
117static unsigned long saved_icmr[2];
118
119static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state)
120{
121 switch (dev->id) {
122 case 0:
123 saved_icmr[0] = ICMR;
124 ICMR = 0;
125 break;
126#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
127 case 1:
128 saved_icmr[1] = ICMR2;
129 ICMR2 = 0;
130 break;
131#endif
132 default:
133 return -EINVAL;
134 }
135
136 return 0;
137}
138
139static int pxa_irq_resume(struct sys_device *dev)
140{
141 switch (dev->id) {
142 case 0:
143 ICMR = saved_icmr[0];
144 ICLR = 0;
145 ICCR = 1;
146 break;
147#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
148 case 1:
149 ICMR2 = saved_icmr[1];
150 ICLR2 = 0;
151 break;
152#endif
153 default:
154 return -EINVAL;
155 }
156
157 return 0;
158}
159#else
160#define pxa_irq_suspend NULL
161#define pxa_irq_resume NULL
162#endif
163
164struct sysdev_class pxa_irq_sysclass = {
165 .name = "irq",
166 .suspend = pxa_irq_suspend,
167 .resume = pxa_irq_resume,
168};
169
170static int __init pxa_irq_init(void)
171{
172 return sysdev_class_register(&pxa_irq_sysclass);
173}
174
175core_initcall(pxa_irq_init);