USB: EHCI: Support controllers with big endian capability regs
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-tegra / legacy_irq.c
blob38eb719a4f53517688871d00e613486367231302
1 /*
2 * arch/arm/mach-tegra/legacy_irq.c
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Colin Cross <ccross@android.com>
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/io.h>
19 #include <linux/kernel.h>
20 #include <mach/iomap.h>
21 #include <mach/irqs.h>
22 #include <mach/legacy_irq.h>
24 #define INT_SYS_NR (INT_GPIO_BASE - INT_PRI_BASE)
25 #define INT_SYS_SZ (INT_SEC_BASE - INT_PRI_BASE)
26 #define PPI_NR ((INT_SYS_NR+INT_SYS_SZ-1)/INT_SYS_SZ)
28 #define ICTLR_CPU_IEP_VFIQ 0x08
29 #define ICTLR_CPU_IEP_FIR 0x14
30 #define ICTLR_CPU_IEP_FIR_SET 0x18
31 #define ICTLR_CPU_IEP_FIR_CLR 0x1c
33 #define ICTLR_CPU_IER 0x20
34 #define ICTLR_CPU_IER_SET 0x24
35 #define ICTLR_CPU_IER_CLR 0x28
36 #define ICTLR_CPU_IEP_CLASS 0x2C
38 #define ICTLR_COP_IER 0x30
39 #define ICTLR_COP_IER_SET 0x34
40 #define ICTLR_COP_IER_CLR 0x38
41 #define ICTLR_COP_IEP_CLASS 0x3c
43 #define NUM_ICTLRS 4
45 static void __iomem *ictlr_reg_base[] = {
46 IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE),
47 IO_ADDRESS(TEGRA_SECONDARY_ICTLR_BASE),
48 IO_ADDRESS(TEGRA_TERTIARY_ICTLR_BASE),
49 IO_ADDRESS(TEGRA_QUATERNARY_ICTLR_BASE),
52 static u32 tegra_legacy_wake_mask[4];
53 static u32 tegra_legacy_saved_mask[4];
55 /* When going into deep sleep, the CPU is powered down, taking the GIC with it
56 In order to wake, the wake interrupts need to be enabled in the legacy
57 interrupt controller. */
58 void tegra_legacy_unmask_irq(unsigned int irq)
60 void __iomem *base;
61 pr_debug("%s: %d\n", __func__, irq);
63 irq -= 32;
64 base = ictlr_reg_base[irq>>5];
65 writel(1 << (irq & 31), base + ICTLR_CPU_IER_SET);
68 void tegra_legacy_mask_irq(unsigned int irq)
70 void __iomem *base;
71 pr_debug("%s: %d\n", __func__, irq);
73 irq -= 32;
74 base = ictlr_reg_base[irq>>5];
75 writel(1 << (irq & 31), base + ICTLR_CPU_IER_CLR);
78 void tegra_legacy_force_irq_set(unsigned int irq)
80 void __iomem *base;
81 pr_debug("%s: %d\n", __func__, irq);
83 irq -= 32;
84 base = ictlr_reg_base[irq>>5];
85 writel(1 << (irq & 31), base + ICTLR_CPU_IEP_FIR_SET);
88 void tegra_legacy_force_irq_clr(unsigned int irq)
90 void __iomem *base;
91 pr_debug("%s: %d\n", __func__, irq);
93 irq -= 32;
94 base = ictlr_reg_base[irq>>5];
95 writel(1 << (irq & 31), base + ICTLR_CPU_IEP_FIR_CLR);
98 int tegra_legacy_force_irq_status(unsigned int irq)
100 void __iomem *base;
101 pr_debug("%s: %d\n", __func__, irq);
103 irq -= 32;
104 base = ictlr_reg_base[irq>>5];
105 return !!(readl(base + ICTLR_CPU_IEP_FIR) & (1 << (irq & 31)));
108 void tegra_legacy_select_fiq(unsigned int irq, bool fiq)
110 void __iomem *base;
111 pr_debug("%s: %d\n", __func__, irq);
113 irq -= 32;
114 base = ictlr_reg_base[irq>>5];
115 writel(fiq << (irq & 31), base + ICTLR_CPU_IEP_CLASS);
118 unsigned long tegra_legacy_vfiq(int nr)
120 void __iomem *base;
121 base = ictlr_reg_base[nr];
122 return readl(base + ICTLR_CPU_IEP_VFIQ);
125 unsigned long tegra_legacy_class(int nr)
127 void __iomem *base;
128 base = ictlr_reg_base[nr];
129 return readl(base + ICTLR_CPU_IEP_CLASS);
132 int tegra_legacy_irq_set_wake(int irq, int enable)
134 irq -= 32;
135 if (enable)
136 tegra_legacy_wake_mask[irq >> 5] |= 1 << (irq & 31);
137 else
138 tegra_legacy_wake_mask[irq >> 5] &= ~(1 << (irq & 31));
140 return 0;
143 void tegra_legacy_irq_set_lp1_wake_mask(void)
145 void __iomem *base;
146 int i;
148 for (i = 0; i < NUM_ICTLRS; i++) {
149 base = ictlr_reg_base[i];
150 tegra_legacy_saved_mask[i] = readl(base + ICTLR_CPU_IER);
151 writel(tegra_legacy_wake_mask[i], base + ICTLR_CPU_IER);
155 void tegra_legacy_irq_restore_mask(void)
157 void __iomem *base;
158 int i;
160 for (i = 0; i < NUM_ICTLRS; i++) {
161 base = ictlr_reg_base[i];
162 writel(tegra_legacy_saved_mask[i], base + ICTLR_CPU_IER);
166 void tegra_init_legacy_irq(void)
168 int i;
170 for (i = 0; i < NUM_ICTLRS; i++) {
171 void __iomem *ictlr = ictlr_reg_base[i];
172 writel(~0, ictlr + ICTLR_CPU_IER_CLR);
173 writel(0, ictlr + ICTLR_CPU_IEP_CLASS);
177 #ifdef CONFIG_PM
178 static u32 cop_ier[NUM_ICTLRS];
179 static u32 cpu_ier[NUM_ICTLRS];
180 static u32 cpu_iep[NUM_ICTLRS];
182 void tegra_irq_suspend(void)
184 unsigned long flags;
185 int i;
187 local_irq_save(flags);
188 for (i = 0; i < NUM_ICTLRS; i++) {
189 void __iomem *ictlr = ictlr_reg_base[i];
190 cpu_ier[i] = readl(ictlr + ICTLR_CPU_IER);
191 cpu_iep[i] = readl(ictlr + ICTLR_CPU_IEP_CLASS);
192 cop_ier[i] = readl(ictlr + ICTLR_COP_IER);
193 writel(~0, ictlr + ICTLR_COP_IER_CLR);
195 local_irq_restore(flags);
198 void tegra_irq_resume(void)
200 unsigned long flags;
201 int i;
203 local_irq_save(flags);
204 for (i = 0; i < NUM_ICTLRS; i++) {
205 void __iomem *ictlr = ictlr_reg_base[i];
206 writel(cpu_iep[i], ictlr + ICTLR_CPU_IEP_CLASS);
207 writel(~0ul, ictlr + ICTLR_CPU_IER_CLR);
208 writel(cpu_ier[i], ictlr + ICTLR_CPU_IER_SET);
209 writel(0, ictlr + ICTLR_COP_IEP_CLASS);
210 writel(~0ul, ictlr + ICTLR_COP_IER_CLR);
211 writel(cop_ier[i], ictlr + ICTLR_COP_IER_SET);
213 local_irq_restore(flags);
215 #endif