| Russell King | fa0fe48 | 2006-01-13 21:30:48 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/arch/arm/common/vic.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 1999 - 2003 ARM Limited | 
|  | 5 | *  Copyright (C) 2000 Deep Blue Solutions Ltd | 
|  | 6 | * | 
|  | 7 | * This program is free software; you can redistribute it and/or modify | 
|  | 8 | * it under the terms of the GNU General Public License as published by | 
|  | 9 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 10 | * (at your option) any later version. | 
|  | 11 | * | 
|  | 12 | * This program is distributed in the hope that it will be useful, | 
|  | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 15 | * GNU General Public License for more details. | 
|  | 16 | * | 
|  | 17 | * You should have received a copy of the GNU General Public License | 
|  | 18 | * along with this program; if not, write to the Free Software | 
|  | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|  | 20 | */ | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 21 |  | 
| Russell King | fa0fe48 | 2006-01-13 21:30:48 +0000 | [diff] [blame] | 22 | #include <linux/init.h> | 
|  | 23 | #include <linux/list.h> | 
| Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 24 | #include <linux/io.h> | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 25 | #include <linux/syscore_ops.h> | 
| Linus Walleij | 59fcf48 | 2009-09-14 12:25:34 +0100 | [diff] [blame] | 26 | #include <linux/device.h> | 
| Linus Walleij | f17a1f0 | 2009-08-04 01:01:02 +0100 | [diff] [blame] | 27 | #include <linux/amba/bus.h> | 
| Russell King | fa0fe48 | 2006-01-13 21:30:48 +0000 | [diff] [blame] | 28 |  | 
| Russell King | fa0fe48 | 2006-01-13 21:30:48 +0000 | [diff] [blame] | 29 | #include <asm/mach/irq.h> | 
|  | 30 | #include <asm/hardware/vic.h> | 
|  | 31 |  | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 32 | #ifdef CONFIG_PM | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 33 | /** | 
|  | 34 | * struct vic_device - VIC PM device | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 35 | * @irq: The IRQ number for the base of the VIC. | 
|  | 36 | * @base: The register base for the VIC. | 
|  | 37 | * @resume_sources: A bitmask of interrupts for resume. | 
|  | 38 | * @resume_irqs: The IRQs enabled for resume. | 
|  | 39 | * @int_select: Save for VIC_INT_SELECT. | 
|  | 40 | * @int_enable: Save for VIC_INT_ENABLE. | 
|  | 41 | * @soft_int: Save for VIC_INT_SOFT. | 
|  | 42 | * @protect: Save for VIC_PROTECT. | 
|  | 43 | */ | 
|  | 44 | struct vic_device { | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 45 | void __iomem	*base; | 
|  | 46 | int		irq; | 
|  | 47 | u32		resume_sources; | 
|  | 48 | u32		resume_irqs; | 
|  | 49 | u32		int_select; | 
|  | 50 | u32		int_enable; | 
|  | 51 | u32		soft_int; | 
|  | 52 | u32		protect; | 
|  | 53 | }; | 
|  | 54 |  | 
|  | 55 | /* we cannot allocate memory when VICs are initially registered */ | 
|  | 56 | static struct vic_device vic_devices[CONFIG_ARM_VIC_NR]; | 
|  | 57 |  | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 58 | static int vic_id; | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 59 | #endif /* CONFIG_PM */ | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 60 |  | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 61 | /** | 
|  | 62 | * vic_init2 - common initialisation code | 
|  | 63 | * @base: Base of the VIC. | 
|  | 64 | * | 
| Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 65 | * Common initialisation code for registration | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 66 | * and resume. | 
|  | 67 | */ | 
|  | 68 | static void vic_init2(void __iomem *base) | 
|  | 69 | { | 
|  | 70 | int i; | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 71 |  | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 72 | for (i = 0; i < 16; i++) { | 
|  | 73 | void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4); | 
|  | 74 | writel(VIC_VECT_CNTL_ENABLE | i, reg); | 
|  | 75 | } | 
|  | 76 |  | 
|  | 77 | writel(32, base + VIC_PL190_DEF_VECT_ADDR); | 
|  | 78 | } | 
|  | 79 |  | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 80 | #ifdef CONFIG_PM | 
|  | 81 | static void resume_one_vic(struct vic_device *vic) | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 82 | { | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 83 | void __iomem *base = vic->base; | 
|  | 84 |  | 
|  | 85 | printk(KERN_DEBUG "%s: resuming vic at %p\n", __func__, base); | 
|  | 86 |  | 
|  | 87 | /* re-initialise static settings */ | 
|  | 88 | vic_init2(base); | 
|  | 89 |  | 
|  | 90 | writel(vic->int_select, base + VIC_INT_SELECT); | 
|  | 91 | writel(vic->protect, base + VIC_PROTECT); | 
|  | 92 |  | 
|  | 93 | /* set the enabled ints and then clear the non-enabled */ | 
|  | 94 | writel(vic->int_enable, base + VIC_INT_ENABLE); | 
|  | 95 | writel(~vic->int_enable, base + VIC_INT_ENABLE_CLEAR); | 
|  | 96 |  | 
|  | 97 | /* and the same for the soft-int register */ | 
|  | 98 |  | 
|  | 99 | writel(vic->soft_int, base + VIC_INT_SOFT); | 
|  | 100 | writel(~vic->soft_int, base + VIC_INT_SOFT_CLEAR); | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 101 | } | 
|  | 102 |  | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 103 | static void vic_resume(void) | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 104 | { | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 105 | int id; | 
|  | 106 |  | 
|  | 107 | for (id = vic_id - 1; id >= 0; id--) | 
|  | 108 | resume_one_vic(vic_devices + id); | 
|  | 109 | } | 
|  | 110 |  | 
|  | 111 | static void suspend_one_vic(struct vic_device *vic) | 
|  | 112 | { | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 113 | void __iomem *base = vic->base; | 
|  | 114 |  | 
|  | 115 | printk(KERN_DEBUG "%s: suspending vic at %p\n", __func__, base); | 
|  | 116 |  | 
|  | 117 | vic->int_select = readl(base + VIC_INT_SELECT); | 
|  | 118 | vic->int_enable = readl(base + VIC_INT_ENABLE); | 
|  | 119 | vic->soft_int = readl(base + VIC_INT_SOFT); | 
|  | 120 | vic->protect = readl(base + VIC_PROTECT); | 
|  | 121 |  | 
|  | 122 | /* set the interrupts (if any) that are used for | 
|  | 123 | * resuming the system */ | 
|  | 124 |  | 
|  | 125 | writel(vic->resume_irqs, base + VIC_INT_ENABLE); | 
|  | 126 | writel(~vic->resume_irqs, base + VIC_INT_ENABLE_CLEAR); | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 127 | } | 
|  | 128 |  | 
|  | 129 | static int vic_suspend(void) | 
|  | 130 | { | 
|  | 131 | int id; | 
|  | 132 |  | 
|  | 133 | for (id = 0; id < vic_id; id++) | 
|  | 134 | suspend_one_vic(vic_devices + id); | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 135 |  | 
|  | 136 | return 0; | 
|  | 137 | } | 
|  | 138 |  | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 139 | struct syscore_ops vic_syscore_ops = { | 
|  | 140 | .suspend	= vic_suspend, | 
|  | 141 | .resume		= vic_resume, | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 142 | }; | 
|  | 143 |  | 
|  | 144 | /** | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 145 | * vic_pm_init - initicall to register VIC pm | 
|  | 146 | * | 
|  | 147 | * This is called via late_initcall() to register | 
|  | 148 | * the resources for the VICs due to the early | 
|  | 149 | * nature of the VIC's registration. | 
|  | 150 | */ | 
|  | 151 | static int __init vic_pm_init(void) | 
|  | 152 | { | 
| Rafael J. Wysocki | 328f5cc | 2011-04-22 22:02:33 +0200 | [diff] [blame] | 153 | if (vic_id > 0) | 
|  | 154 | register_syscore_ops(&vic_syscore_ops); | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 155 |  | 
|  | 156 | return 0; | 
|  | 157 | } | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 158 | late_initcall(vic_pm_init); | 
|  | 159 |  | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 160 | /** | 
|  | 161 | * vic_pm_register - Register a VIC for later power management control | 
|  | 162 | * @base: The base address of the VIC. | 
|  | 163 | * @irq: The base IRQ for the VIC. | 
|  | 164 | * @resume_sources: bitmask of interrupts allowed for resume sources. | 
|  | 165 | * | 
|  | 166 | * Register the VIC with the system device tree so that it can be notified | 
|  | 167 | * of suspend and resume requests and ensure that the correct actions are | 
|  | 168 | * taken to re-instate the settings on resume. | 
|  | 169 | */ | 
|  | 170 | static void __init vic_pm_register(void __iomem *base, unsigned int irq, u32 resume_sources) | 
|  | 171 | { | 
|  | 172 | struct vic_device *v; | 
|  | 173 |  | 
|  | 174 | if (vic_id >= ARRAY_SIZE(vic_devices)) | 
|  | 175 | printk(KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n", __func__); | 
|  | 176 | else { | 
|  | 177 | v = &vic_devices[vic_id]; | 
|  | 178 | v->base = base; | 
|  | 179 | v->resume_sources = resume_sources; | 
|  | 180 | v->irq = irq; | 
|  | 181 | vic_id++; | 
|  | 182 | } | 
|  | 183 | } | 
|  | 184 | #else | 
|  | 185 | static inline void vic_pm_register(void __iomem *base, unsigned int irq, u32 arg1) { } | 
|  | 186 | #endif /* CONFIG_PM */ | 
|  | 187 |  | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 188 | static void vic_ack_irq(struct irq_data *d) | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 189 | { | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 190 | void __iomem *base = irq_data_get_irq_chip_data(d); | 
|  | 191 | unsigned int irq = d->irq & 31; | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 192 | writel(1 << irq, base + VIC_INT_ENABLE_CLEAR); | 
|  | 193 | /* moreover, clear the soft-triggered, in case it was the reason */ | 
|  | 194 | writel(1 << irq, base + VIC_INT_SOFT_CLEAR); | 
|  | 195 | } | 
|  | 196 |  | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 197 | static void vic_mask_irq(struct irq_data *d) | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 198 | { | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 199 | void __iomem *base = irq_data_get_irq_chip_data(d); | 
|  | 200 | unsigned int irq = d->irq & 31; | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 201 | writel(1 << irq, base + VIC_INT_ENABLE_CLEAR); | 
|  | 202 | } | 
|  | 203 |  | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 204 | static void vic_unmask_irq(struct irq_data *d) | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 205 | { | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 206 | void __iomem *base = irq_data_get_irq_chip_data(d); | 
|  | 207 | unsigned int irq = d->irq & 31; | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 208 | writel(1 << irq, base + VIC_INT_ENABLE); | 
|  | 209 | } | 
|  | 210 |  | 
|  | 211 | #if defined(CONFIG_PM) | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 212 | static struct vic_device *vic_from_irq(unsigned int irq) | 
|  | 213 | { | 
|  | 214 | struct vic_device *v = vic_devices; | 
|  | 215 | unsigned int base_irq = irq & ~31; | 
|  | 216 | int id; | 
|  | 217 |  | 
|  | 218 | for (id = 0; id < vic_id; id++, v++) { | 
|  | 219 | if (v->irq == base_irq) | 
|  | 220 | return v; | 
|  | 221 | } | 
|  | 222 |  | 
|  | 223 | return NULL; | 
|  | 224 | } | 
|  | 225 |  | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 226 | static int vic_set_wake(struct irq_data *d, unsigned int on) | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 227 | { | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 228 | struct vic_device *v = vic_from_irq(d->irq); | 
|  | 229 | unsigned int off = d->irq & 31; | 
| Ben Dooks | 3f1a567 | 2009-06-02 09:31:03 +0100 | [diff] [blame] | 230 | u32 bit = 1 << off; | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 231 |  | 
|  | 232 | if (!v) | 
|  | 233 | return -EINVAL; | 
|  | 234 |  | 
| Ben Dooks | 3f1a567 | 2009-06-02 09:31:03 +0100 | [diff] [blame] | 235 | if (!(bit & v->resume_sources)) | 
|  | 236 | return -EINVAL; | 
|  | 237 |  | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 238 | if (on) | 
| Ben Dooks | 3f1a567 | 2009-06-02 09:31:03 +0100 | [diff] [blame] | 239 | v->resume_irqs |= bit; | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 240 | else | 
| Ben Dooks | 3f1a567 | 2009-06-02 09:31:03 +0100 | [diff] [blame] | 241 | v->resume_irqs &= ~bit; | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 242 |  | 
|  | 243 | return 0; | 
|  | 244 | } | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 245 | #else | 
| Ben Dooks | c07f87f | 2009-03-24 15:30:07 +0000 | [diff] [blame] | 246 | #define vic_set_wake NULL | 
|  | 247 | #endif /* CONFIG_PM */ | 
|  | 248 |  | 
| David Brownell | 38c677c | 2006-08-01 22:26:25 +0100 | [diff] [blame] | 249 | static struct irq_chip vic_chip = { | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 250 | .name		= "VIC", | 
| Lennert Buytenhek | f013c98 | 2010-11-29 10:20:21 +0100 | [diff] [blame] | 251 | .irq_ack	= vic_ack_irq, | 
|  | 252 | .irq_mask	= vic_mask_irq, | 
|  | 253 | .irq_unmask	= vic_unmask_irq, | 
|  | 254 | .irq_set_wake	= vic_set_wake, | 
| Russell King | fa0fe48 | 2006-01-13 21:30:48 +0000 | [diff] [blame] | 255 | }; | 
|  | 256 |  | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 257 | static void __init vic_disable(void __iomem *base) | 
|  | 258 | { | 
|  | 259 | writel(0, base + VIC_INT_SELECT); | 
|  | 260 | writel(0, base + VIC_INT_ENABLE); | 
|  | 261 | writel(~0, base + VIC_INT_ENABLE_CLEAR); | 
|  | 262 | writel(0, base + VIC_IRQ_STATUS); | 
|  | 263 | writel(0, base + VIC_ITCR); | 
|  | 264 | writel(~0, base + VIC_INT_SOFT_CLEAR); | 
|  | 265 | } | 
|  | 266 |  | 
|  | 267 | static void __init vic_clear_interrupts(void __iomem *base) | 
|  | 268 | { | 
|  | 269 | unsigned int i; | 
|  | 270 |  | 
|  | 271 | writel(0, base + VIC_PL190_VECT_ADDR); | 
|  | 272 | for (i = 0; i < 19; i++) { | 
|  | 273 | unsigned int value; | 
|  | 274 |  | 
|  | 275 | value = readl(base + VIC_PL190_VECT_ADDR); | 
|  | 276 | writel(value, base + VIC_PL190_VECT_ADDR); | 
|  | 277 | } | 
|  | 278 | } | 
|  | 279 |  | 
|  | 280 | static void __init vic_set_irq_sources(void __iomem *base, | 
|  | 281 | unsigned int irq_start, u32 vic_sources) | 
|  | 282 | { | 
|  | 283 | unsigned int i; | 
|  | 284 |  | 
|  | 285 | for (i = 0; i < 32; i++) { | 
|  | 286 | if (vic_sources & (1 << i)) { | 
|  | 287 | unsigned int irq = irq_start + i; | 
|  | 288 |  | 
| Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 289 | irq_set_chip_and_handler(irq, &vic_chip, | 
|  | 290 | handle_level_irq); | 
| Thomas Gleixner | 9323f261 | 2011-03-24 13:29:39 +0100 | [diff] [blame] | 291 | irq_set_chip_data(irq, base); | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 292 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 
|  | 293 | } | 
|  | 294 | } | 
|  | 295 | } | 
|  | 296 |  | 
| Alessandro Rubini | 87e8824 | 2009-07-02 15:28:41 +0100 | [diff] [blame] | 297 | /* | 
|  | 298 | * The PL190 cell from ARM has been modified by ST to handle 64 interrupts. | 
|  | 299 | * The original cell has 32 interrupts, while the modified one has 64, | 
|  | 300 | * replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case | 
|  | 301 | * the probe function is called twice, with base set to offset 000 | 
|  | 302 | *  and 020 within the page. We call this "second block". | 
|  | 303 | */ | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 304 | static void __init vic_init_st(void __iomem *base, unsigned int irq_start, | 
| Alessandro Rubini | 87e8824 | 2009-07-02 15:28:41 +0100 | [diff] [blame] | 305 | u32 vic_sources) | 
|  | 306 | { | 
|  | 307 | unsigned int i; | 
|  | 308 | int vic_2nd_block = ((unsigned long)base & ~PAGE_MASK) != 0; | 
|  | 309 |  | 
|  | 310 | /* Disable all interrupts initially. */ | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 311 | vic_disable(base); | 
| Alessandro Rubini | 87e8824 | 2009-07-02 15:28:41 +0100 | [diff] [blame] | 312 |  | 
|  | 313 | /* | 
|  | 314 | * Make sure we clear all existing interrupts. The vector registers | 
|  | 315 | * in this cell are after the second block of general registers, | 
|  | 316 | * so we can address them using standard offsets, but only from | 
|  | 317 | * the second base address, which is 0x20 in the page | 
|  | 318 | */ | 
|  | 319 | if (vic_2nd_block) { | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 320 | vic_clear_interrupts(base); | 
| Alessandro Rubini | 87e8824 | 2009-07-02 15:28:41 +0100 | [diff] [blame] | 321 |  | 
| Alessandro Rubini | 87e8824 | 2009-07-02 15:28:41 +0100 | [diff] [blame] | 322 | /* ST has 16 vectors as well, but we don't enable them by now */ | 
|  | 323 | for (i = 0; i < 16; i++) { | 
|  | 324 | void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4); | 
|  | 325 | writel(0, reg); | 
|  | 326 | } | 
|  | 327 |  | 
|  | 328 | writel(32, base + VIC_PL190_DEF_VECT_ADDR); | 
|  | 329 | } | 
|  | 330 |  | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 331 | vic_set_irq_sources(base, irq_start, vic_sources); | 
| Alessandro Rubini | 87e8824 | 2009-07-02 15:28:41 +0100 | [diff] [blame] | 332 | } | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 333 |  | 
|  | 334 | /** | 
|  | 335 | * vic_init - initialise a vectored interrupt controller | 
|  | 336 | * @base: iomem base address | 
|  | 337 | * @irq_start: starting interrupt number, must be muliple of 32 | 
|  | 338 | * @vic_sources: bitmask of interrupt sources to allow | 
|  | 339 | * @resume_sources: bitmask of interrupt sources to allow for resume | 
|  | 340 | */ | 
|  | 341 | void __init vic_init(void __iomem *base, unsigned int irq_start, | 
|  | 342 | u32 vic_sources, u32 resume_sources) | 
|  | 343 | { | 
|  | 344 | unsigned int i; | 
|  | 345 | u32 cellid = 0; | 
|  | 346 | enum amba_vendor vendor; | 
|  | 347 |  | 
|  | 348 | /* Identify which VIC cell this one is, by reading the ID */ | 
|  | 349 | for (i = 0; i < 4; i++) { | 
|  | 350 | u32 addr = ((u32)base & PAGE_MASK) + 0xfe0 + (i * 4); | 
|  | 351 | cellid |= (readl(addr) & 0xff) << (8 * i); | 
|  | 352 | } | 
|  | 353 | vendor = (cellid >> 12) & 0xff; | 
|  | 354 | printk(KERN_INFO "VIC @%p: id 0x%08x, vendor 0x%02x\n", | 
|  | 355 | base, cellid, vendor); | 
|  | 356 |  | 
|  | 357 | switch(vendor) { | 
|  | 358 | case AMBA_VENDOR_ST: | 
|  | 359 | vic_init_st(base, irq_start, vic_sources); | 
|  | 360 | return; | 
|  | 361 | default: | 
|  | 362 | printk(KERN_WARNING "VIC: unknown vendor, continuing anyways\n"); | 
|  | 363 | /* fall through */ | 
|  | 364 | case AMBA_VENDOR_ARM: | 
|  | 365 | break; | 
|  | 366 | } | 
|  | 367 |  | 
|  | 368 | /* Disable all interrupts initially. */ | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 369 | vic_disable(base); | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 370 |  | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 371 | /* Make sure we clear all existing interrupts */ | 
|  | 372 | vic_clear_interrupts(base); | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 373 |  | 
|  | 374 | vic_init2(base); | 
|  | 375 |  | 
| Hartley Sweeten | b0c4c89 | 2010-04-02 18:04:47 +0100 | [diff] [blame] | 376 | vic_set_irq_sources(base, irq_start, vic_sources); | 
| Hartley Sweeten | bb06b73 | 2010-01-12 19:09:12 +0100 | [diff] [blame] | 377 |  | 
|  | 378 | vic_pm_register(base, irq_start, resume_sources); | 
|  | 379 | } |