diff options
Diffstat (limited to 'arch/powerpc/kernel')
| -rw-r--r-- | arch/powerpc/kernel/btext.c | 20 | ||||
| -rw-r--r-- | arch/powerpc/kernel/ibmebus.c | 9 | ||||
| -rw-r--r-- | arch/powerpc/kernel/irq.c | 656 | ||||
| -rw-r--r-- | arch/powerpc/kernel/legacy_serial.c | 57 | ||||
| -rw-r--r-- | arch/powerpc/kernel/misc_64.S | 10 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci_32.c | 37 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci_64.c | 33 | ||||
| -rw-r--r-- | arch/powerpc/kernel/prom.c | 454 | ||||
| -rw-r--r-- | arch/powerpc/kernel/prom_init.c | 20 | ||||
| -rw-r--r-- | arch/powerpc/kernel/prom_parse.c | 443 | ||||
| -rw-r--r-- | arch/powerpc/kernel/rtas_pci.c | 17 | ||||
| -rw-r--r-- | arch/powerpc/kernel/setup_32.c | 2 | ||||
| -rw-r--r-- | arch/powerpc/kernel/setup_64.c | 17 | ||||
| -rw-r--r-- | arch/powerpc/kernel/vio.c | 12 |
14 files changed, 1067 insertions, 720 deletions
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c index a6920919d68e..f4e5e14ee2b6 100644 --- a/arch/powerpc/kernel/btext.c +++ b/arch/powerpc/kernel/btext.c | |||
| @@ -111,7 +111,7 @@ void __init btext_setup_display(int width, int height, int depth, int pitch, | |||
| 111 | logicalDisplayBase = (unsigned char *)address; | 111 | logicalDisplayBase = (unsigned char *)address; |
| 112 | dispDeviceBase = (unsigned char *)address; | 112 | dispDeviceBase = (unsigned char *)address; |
| 113 | dispDeviceRowBytes = pitch; | 113 | dispDeviceRowBytes = pitch; |
| 114 | dispDeviceDepth = depth; | 114 | dispDeviceDepth = depth == 15 ? 16 : depth; |
| 115 | dispDeviceRect[0] = dispDeviceRect[1] = 0; | 115 | dispDeviceRect[0] = dispDeviceRect[1] = 0; |
| 116 | dispDeviceRect[2] = width; | 116 | dispDeviceRect[2] = width; |
| 117 | dispDeviceRect[3] = height; | 117 | dispDeviceRect[3] = height; |
| @@ -160,20 +160,28 @@ int btext_initialize(struct device_node *np) | |||
| 160 | unsigned long address = 0; | 160 | unsigned long address = 0; |
| 161 | u32 *prop; | 161 | u32 *prop; |
| 162 | 162 | ||
| 163 | prop = (u32 *)get_property(np, "width", NULL); | 163 | prop = (u32 *)get_property(np, "linux,bootx-width", NULL); |
| 164 | if (prop == NULL) | ||
| 165 | prop = (u32 *)get_property(np, "width", NULL); | ||
| 164 | if (prop == NULL) | 166 | if (prop == NULL) |
| 165 | return -EINVAL; | 167 | return -EINVAL; |
| 166 | width = *prop; | 168 | width = *prop; |
| 167 | prop = (u32 *)get_property(np, "height", NULL); | 169 | prop = (u32 *)get_property(np, "linux,bootx-height", NULL); |
| 170 | if (prop == NULL) | ||
| 171 | prop = (u32 *)get_property(np, "height", NULL); | ||
| 168 | if (prop == NULL) | 172 | if (prop == NULL) |
| 169 | return -EINVAL; | 173 | return -EINVAL; |
| 170 | height = *prop; | 174 | height = *prop; |
| 171 | prop = (u32 *)get_property(np, "depth", NULL); | 175 | prop = (u32 *)get_property(np, "linux,bootx-depth", NULL); |
| 176 | if (prop == NULL) | ||
| 177 | prop = (u32 *)get_property(np, "depth", NULL); | ||
| 172 | if (prop == NULL) | 178 | if (prop == NULL) |
| 173 | return -EINVAL; | 179 | return -EINVAL; |
| 174 | depth = *prop; | 180 | depth = *prop; |
| 175 | pitch = width * ((depth + 7) / 8); | 181 | pitch = width * ((depth + 7) / 8); |
| 176 | prop = (u32 *)get_property(np, "linebytes", NULL); | 182 | prop = (u32 *)get_property(np, "linux,bootx-linebytes", NULL); |
| 183 | if (prop == NULL) | ||
| 184 | prop = (u32 *)get_property(np, "linebytes", NULL); | ||
| 177 | if (prop) | 185 | if (prop) |
| 178 | pitch = *prop; | 186 | pitch = *prop; |
| 179 | if (pitch == 1) | 187 | if (pitch == 1) |
| @@ -194,7 +202,7 @@ int btext_initialize(struct device_node *np) | |||
| 194 | g_max_loc_Y = height / 16; | 202 | g_max_loc_Y = height / 16; |
| 195 | dispDeviceBase = (unsigned char *)address; | 203 | dispDeviceBase = (unsigned char *)address; |
| 196 | dispDeviceRowBytes = pitch; | 204 | dispDeviceRowBytes = pitch; |
| 197 | dispDeviceDepth = depth; | 205 | dispDeviceDepth = depth == 15 ? 16 : depth; |
| 198 | dispDeviceRect[0] = dispDeviceRect[1] = 0; | 206 | dispDeviceRect[0] = dispDeviceRect[1] = 0; |
| 199 | dispDeviceRect[2] = width; | 207 | dispDeviceRect[2] = width; |
| 200 | dispDeviceRect[3] = height; | 208 | dispDeviceRect[3] = height; |
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c index e47d40ac6f39..97ddc02a3d42 100644 --- a/arch/powerpc/kernel/ibmebus.c +++ b/arch/powerpc/kernel/ibmebus.c | |||
| @@ -323,13 +323,11 @@ int ibmebus_request_irq(struct ibmebus_dev *dev, | |||
| 323 | unsigned long irq_flags, const char * devname, | 323 | unsigned long irq_flags, const char * devname, |
| 324 | void *dev_id) | 324 | void *dev_id) |
| 325 | { | 325 | { |
| 326 | unsigned int irq = virt_irq_create_mapping(ist); | 326 | unsigned int irq = irq_create_mapping(NULL, ist, 0); |
| 327 | 327 | ||
| 328 | if (irq == NO_IRQ) | 328 | if (irq == NO_IRQ) |
| 329 | return -EINVAL; | 329 | return -EINVAL; |
| 330 | 330 | ||
| 331 | irq = irq_offset_up(irq); | ||
| 332 | |||
| 333 | return request_irq(irq, handler, | 331 | return request_irq(irq, handler, |
| 334 | irq_flags, devname, dev_id); | 332 | irq_flags, devname, dev_id); |
| 335 | } | 333 | } |
| @@ -337,12 +335,9 @@ EXPORT_SYMBOL(ibmebus_request_irq); | |||
| 337 | 335 | ||
| 338 | void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id) | 336 | void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id) |
| 339 | { | 337 | { |
| 340 | unsigned int irq = virt_irq_create_mapping(ist); | 338 | unsigned int irq = irq_find_mapping(NULL, ist); |
| 341 | 339 | ||
| 342 | irq = irq_offset_up(irq); | ||
| 343 | free_irq(irq, dev_id); | 340 | free_irq(irq, dev_id); |
| 344 | |||
| 345 | return; | ||
| 346 | } | 341 | } |
| 347 | EXPORT_SYMBOL(ibmebus_free_irq); | 342 | EXPORT_SYMBOL(ibmebus_free_irq); |
| 348 | 343 | ||
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 525baab45d2d..8cf987809c66 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | * to reduce code space and undefined function references. | 29 | * to reduce code space and undefined function references. |
| 30 | */ | 30 | */ |
| 31 | 31 | ||
| 32 | #undef DEBUG | ||
| 33 | |||
| 32 | #include <linux/module.h> | 34 | #include <linux/module.h> |
| 33 | #include <linux/threads.h> | 35 | #include <linux/threads.h> |
| 34 | #include <linux/kernel_stat.h> | 36 | #include <linux/kernel_stat.h> |
| @@ -46,7 +48,10 @@ | |||
| 46 | #include <linux/cpumask.h> | 48 | #include <linux/cpumask.h> |
| 47 | #include <linux/profile.h> | 49 | #include <linux/profile.h> |
| 48 | #include <linux/bitops.h> | 50 | #include <linux/bitops.h> |
| 49 | #include <linux/pci.h> | 51 | #include <linux/list.h> |
| 52 | #include <linux/radix-tree.h> | ||
| 53 | #include <linux/mutex.h> | ||
| 54 | #include <linux/bootmem.h> | ||
| 50 | 55 | ||
| 51 | #include <asm/uaccess.h> | 56 | #include <asm/uaccess.h> |
| 52 | #include <asm/system.h> | 57 | #include <asm/system.h> |
| @@ -57,39 +62,38 @@ | |||
| 57 | #include <asm/prom.h> | 62 | #include <asm/prom.h> |
| 58 | #include <asm/ptrace.h> | 63 | #include <asm/ptrace.h> |
| 59 | #include <asm/machdep.h> | 64 | #include <asm/machdep.h> |
| 65 | #include <asm/udbg.h> | ||
| 60 | #ifdef CONFIG_PPC_ISERIES | 66 | #ifdef CONFIG_PPC_ISERIES |
| 61 | #include <asm/paca.h> | 67 | #include <asm/paca.h> |
| 62 | #endif | 68 | #endif |
| 63 | 69 | ||
| 64 | int __irq_offset_value; | 70 | int __irq_offset_value; |
| 65 | #ifdef CONFIG_PPC32 | ||
| 66 | EXPORT_SYMBOL(__irq_offset_value); | ||
| 67 | #endif | ||
| 68 | |||
| 69 | static int ppc_spurious_interrupts; | 71 | static int ppc_spurious_interrupts; |
| 70 | 72 | ||
| 71 | #ifdef CONFIG_PPC32 | 73 | #ifdef CONFIG_PPC32 |
| 72 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | 74 | EXPORT_SYMBOL(__irq_offset_value); |
| 75 | atomic_t ppc_n_lost_interrupts; | ||
| 73 | 76 | ||
| 77 | #ifndef CONFIG_PPC_MERGE | ||
| 78 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | ||
| 74 | unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; | 79 | unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; |
| 75 | atomic_t ppc_n_lost_interrupts; | 80 | #endif |
| 76 | 81 | ||
| 77 | #ifdef CONFIG_TAU_INT | 82 | #ifdef CONFIG_TAU_INT |
| 78 | extern int tau_initialized; | 83 | extern int tau_initialized; |
| 79 | extern int tau_interrupts(int); | 84 | extern int tau_interrupts(int); |
| 80 | #endif | 85 | #endif |
| 86 | #endif /* CONFIG_PPC32 */ | ||
| 81 | 87 | ||
| 82 | #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE) | 88 | #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE) |
| 83 | extern atomic_t ipi_recv; | 89 | extern atomic_t ipi_recv; |
| 84 | extern atomic_t ipi_sent; | 90 | extern atomic_t ipi_sent; |
| 85 | #endif | 91 | #endif |
| 86 | #endif /* CONFIG_PPC32 */ | ||
| 87 | 92 | ||
| 88 | #ifdef CONFIG_PPC64 | 93 | #ifdef CONFIG_PPC64 |
| 89 | EXPORT_SYMBOL(irq_desc); | 94 | EXPORT_SYMBOL(irq_desc); |
| 90 | 95 | ||
| 91 | int distribute_irqs = 1; | 96 | int distribute_irqs = 1; |
| 92 | u64 ppc64_interrupt_controller; | ||
| 93 | #endif /* CONFIG_PPC64 */ | 97 | #endif /* CONFIG_PPC64 */ |
| 94 | 98 | ||
| 95 | int show_interrupts(struct seq_file *p, void *v) | 99 | int show_interrupts(struct seq_file *p, void *v) |
| @@ -182,7 +186,7 @@ void fixup_irqs(cpumask_t map) | |||
| 182 | 186 | ||
| 183 | void do_IRQ(struct pt_regs *regs) | 187 | void do_IRQ(struct pt_regs *regs) |
| 184 | { | 188 | { |
| 185 | int irq; | 189 | unsigned int irq; |
| 186 | #ifdef CONFIG_IRQSTACKS | 190 | #ifdef CONFIG_IRQSTACKS |
| 187 | struct thread_info *curtp, *irqtp; | 191 | struct thread_info *curtp, *irqtp; |
| 188 | #endif | 192 | #endif |
| @@ -213,22 +217,26 @@ void do_IRQ(struct pt_regs *regs) | |||
| 213 | */ | 217 | */ |
| 214 | irq = ppc_md.get_irq(regs); | 218 | irq = ppc_md.get_irq(regs); |
| 215 | 219 | ||
| 216 | if (irq >= 0) { | 220 | if (irq != NO_IRQ && irq != NO_IRQ_IGNORE) { |
| 217 | #ifdef CONFIG_IRQSTACKS | 221 | #ifdef CONFIG_IRQSTACKS |
| 218 | /* Switch to the irq stack to handle this */ | 222 | /* Switch to the irq stack to handle this */ |
| 219 | curtp = current_thread_info(); | 223 | curtp = current_thread_info(); |
| 220 | irqtp = hardirq_ctx[smp_processor_id()]; | 224 | irqtp = hardirq_ctx[smp_processor_id()]; |
| 221 | if (curtp != irqtp) { | 225 | if (curtp != irqtp) { |
| 226 | struct irq_desc *desc = irq_desc + irq; | ||
| 227 | void *handler = desc->handle_irq; | ||
| 228 | if (handler == NULL) | ||
| 229 | handler = &__do_IRQ; | ||
| 222 | irqtp->task = curtp->task; | 230 | irqtp->task = curtp->task; |
| 223 | irqtp->flags = 0; | 231 | irqtp->flags = 0; |
| 224 | call___do_IRQ(irq, regs, irqtp); | 232 | call_handle_irq(irq, desc, regs, irqtp, handler); |
| 225 | irqtp->task = NULL; | 233 | irqtp->task = NULL; |
| 226 | if (irqtp->flags) | 234 | if (irqtp->flags) |
| 227 | set_bits(irqtp->flags, &curtp->flags); | 235 | set_bits(irqtp->flags, &curtp->flags); |
| 228 | } else | 236 | } else |
| 229 | #endif | 237 | #endif |
| 230 | __do_IRQ(irq, regs); | 238 | generic_handle_irq(irq, regs); |
| 231 | } else if (irq != -2) | 239 | } else if (irq != NO_IRQ_IGNORE) |
| 232 | /* That's not SMP safe ... but who cares ? */ | 240 | /* That's not SMP safe ... but who cares ? */ |
| 233 | ppc_spurious_interrupts++; | 241 | ppc_spurious_interrupts++; |
| 234 | 242 | ||
| @@ -245,196 +253,562 @@ void do_IRQ(struct pt_regs *regs) | |||
| 245 | 253 | ||
| 246 | void __init init_IRQ(void) | 254 | void __init init_IRQ(void) |
| 247 | { | 255 | { |
| 256 | ppc_md.init_IRQ(); | ||
| 248 | #ifdef CONFIG_PPC64 | 257 | #ifdef CONFIG_PPC64 |
| 249 | static int once = 0; | 258 | irq_ctx_init(); |
| 259 | #endif | ||
| 260 | } | ||
| 261 | |||
| 262 | |||
| 263 | #ifdef CONFIG_IRQSTACKS | ||
| 264 | struct thread_info *softirq_ctx[NR_CPUS] __read_mostly; | ||
| 265 | struct thread_info *hardirq_ctx[NR_CPUS] __read_mostly; | ||
| 266 | |||
| 267 | void irq_ctx_init(void) | ||
| 268 | { | ||
| 269 | struct thread_info *tp; | ||
| 270 | int i; | ||
| 271 | |||
| 272 | for_each_possible_cpu(i) { | ||
| 273 | memset((void *)softirq_ctx[i], 0, THREAD_SIZE); | ||
| 274 | tp = softirq_ctx[i]; | ||
| 275 | tp->cpu = i; | ||
| 276 | tp->preempt_count = SOFTIRQ_OFFSET; | ||
| 277 | |||
| 278 | memset((void *)hardirq_ctx[i], 0, THREAD_SIZE); | ||
| 279 | tp = hardirq_ctx[i]; | ||
| 280 | tp->cpu = i; | ||
| 281 | tp->preempt_count = HARDIRQ_OFFSET; | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | static inline void do_softirq_onstack(void) | ||
| 286 | { | ||
| 287 | struct thread_info *curtp, *irqtp; | ||
| 288 | |||
| 289 | curtp = current_thread_info(); | ||
| 290 | irqtp = softirq_ctx[smp_processor_id()]; | ||
| 291 | irqtp->task = curtp->task; | ||
| 292 | call_do_softirq(irqtp); | ||
| 293 | irqtp->task = NULL; | ||
| 294 | } | ||
| 250 | 295 | ||
| 251 | if (once) | 296 | #else |
| 297 | #define do_softirq_onstack() __do_softirq() | ||
| 298 | #endif /* CONFIG_IRQSTACKS */ | ||
| 299 | |||
| 300 | void do_softirq(void) | ||
| 301 | { | ||
| 302 | unsigned long flags; | ||
| 303 | |||
| 304 | if (in_interrupt()) | ||
| 252 | return; | 305 | return; |
| 253 | 306 | ||
| 254 | once++; | 307 | local_irq_save(flags); |
| 255 | 308 | ||
| 256 | #endif | 309 | if (local_softirq_pending()) |
| 257 | ppc_md.init_IRQ(); | 310 | do_softirq_onstack(); |
| 258 | #ifdef CONFIG_PPC64 | 311 | |
| 259 | irq_ctx_init(); | 312 | local_irq_restore(flags); |
| 260 | #endif | ||
| 261 | } | 313 | } |
| 314 | EXPORT_SYMBOL(do_softirq); | ||
| 315 | |||
| 262 | 316 | ||
| 263 | #ifdef CONFIG_PPC64 | ||
| 264 | /* | 317 | /* |
| 265 | * Virtual IRQ mapping code, used on systems with XICS interrupt controllers. | 318 | * IRQ controller and virtual interrupts |
| 266 | */ | 319 | */ |
| 267 | 320 | ||
| 268 | #define UNDEFINED_IRQ 0xffffffff | 321 | #ifdef CONFIG_PPC_MERGE |
| 269 | unsigned int virt_irq_to_real_map[NR_IRQS]; | ||
| 270 | 322 | ||
| 271 | /* | 323 | static LIST_HEAD(irq_hosts); |
| 272 | * Don't use virtual irqs 0, 1, 2 for devices. | 324 | static spinlock_t irq_big_lock = SPIN_LOCK_UNLOCKED; |
| 273 | * The pcnet32 driver considers interrupt numbers < 2 to be invalid, | ||
| 274 | * and 2 is the XICS IPI interrupt. | ||
| 275 | * We limit virtual irqs to __irq_offet_value less than virt_irq_max so | ||
| 276 | * that when we offset them we don't end up with an interrupt | ||
| 277 | * number >= virt_irq_max. | ||
| 278 | */ | ||
| 279 | #define MIN_VIRT_IRQ 3 | ||
| 280 | 325 | ||
| 281 | unsigned int virt_irq_max; | 326 | struct irq_map_entry irq_map[NR_IRQS]; |
| 282 | static unsigned int max_virt_irq; | 327 | static unsigned int irq_virq_count = NR_IRQS; |
| 283 | static unsigned int nr_virt_irqs; | 328 | static struct irq_host *irq_default_host; |
| 284 | 329 | ||
| 285 | void | 330 | struct irq_host *irq_alloc_host(unsigned int revmap_type, |
| 286 | virt_irq_init(void) | 331 | unsigned int revmap_arg, |
| 332 | struct irq_host_ops *ops, | ||
| 333 | irq_hw_number_t inval_irq) | ||
| 287 | { | 334 | { |
| 288 | int i; | 335 | struct irq_host *host; |
| 336 | unsigned int size = sizeof(struct irq_host); | ||
| 337 | unsigned int i; | ||
| 338 | unsigned int *rmap; | ||
| 339 | unsigned long flags; | ||
| 289 | 340 | ||
| 290 | if ((virt_irq_max == 0) || (virt_irq_max > (NR_IRQS - 1))) | 341 | /* Allocate structure and revmap table if using linear mapping */ |
| 291 | virt_irq_max = NR_IRQS - 1; | 342 | if (revmap_type == IRQ_HOST_MAP_LINEAR) |
| 292 | max_virt_irq = virt_irq_max - __irq_offset_value; | 343 | size += revmap_arg * sizeof(unsigned int); |
| 293 | nr_virt_irqs = max_virt_irq - MIN_VIRT_IRQ + 1; | 344 | if (mem_init_done) |
| 345 | host = kzalloc(size, GFP_KERNEL); | ||
| 346 | else { | ||
| 347 | host = alloc_bootmem(size); | ||
| 348 | if (host) | ||
| 349 | memset(host, 0, size); | ||
| 350 | } | ||
| 351 | if (host == NULL) | ||
| 352 | return NULL; | ||
| 294 | 353 | ||
| 295 | for (i = 0; i < NR_IRQS; i++) | 354 | /* Fill structure */ |
| 296 | virt_irq_to_real_map[i] = UNDEFINED_IRQ; | 355 | host->revmap_type = revmap_type; |
| 356 | host->inval_irq = inval_irq; | ||
| 357 | host->ops = ops; | ||
| 358 | |||
| 359 | spin_lock_irqsave(&irq_big_lock, flags); | ||
| 360 | |||
| 361 | /* If it's a legacy controller, check for duplicates and | ||
| 362 | * mark it as allocated (we use irq 0 host pointer for that | ||
| 363 | */ | ||
| 364 | if (revmap_type == IRQ_HOST_MAP_LEGACY) { | ||
| 365 | if (irq_map[0].host != NULL) { | ||
| 366 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 367 | /* If we are early boot, we can't free the structure, | ||
| 368 | * too bad... | ||
| 369 | * this will be fixed once slab is made available early | ||
| 370 | * instead of the current cruft | ||
| 371 | */ | ||
| 372 | if (mem_init_done) | ||
| 373 | kfree(host); | ||
| 374 | return NULL; | ||
| 375 | } | ||
| 376 | irq_map[0].host = host; | ||
| 377 | } | ||
| 378 | |||
| 379 | list_add(&host->link, &irq_hosts); | ||
| 380 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 381 | |||
| 382 | /* Additional setups per revmap type */ | ||
| 383 | switch(revmap_type) { | ||
| 384 | case IRQ_HOST_MAP_LEGACY: | ||
| 385 | /* 0 is always the invalid number for legacy */ | ||
| 386 | host->inval_irq = 0; | ||
| 387 | /* setup us as the host for all legacy interrupts */ | ||
| 388 | for (i = 1; i < NUM_ISA_INTERRUPTS; i++) { | ||
| 389 | irq_map[i].hwirq = 0; | ||
| 390 | smp_wmb(); | ||
| 391 | irq_map[i].host = host; | ||
| 392 | smp_wmb(); | ||
| 393 | |||
| 394 | /* Clear some flags */ | ||
| 395 | get_irq_desc(i)->status | ||
| 396 | &= ~(IRQ_NOREQUEST | IRQ_LEVEL); | ||
| 397 | |||
| 398 | /* Legacy flags are left to default at this point, | ||
| 399 | * one can then use irq_create_mapping() to | ||
| 400 | * explicitely change them | ||
| 401 | */ | ||
| 402 | ops->map(host, i, i, 0); | ||
| 403 | } | ||
| 404 | break; | ||
| 405 | case IRQ_HOST_MAP_LINEAR: | ||
| 406 | rmap = (unsigned int *)(host + 1); | ||
| 407 | for (i = 0; i < revmap_arg; i++) | ||
| 408 | rmap[i] = IRQ_NONE; | ||
| 409 | host->revmap_data.linear.size = revmap_arg; | ||
| 410 | smp_wmb(); | ||
| 411 | host->revmap_data.linear.revmap = rmap; | ||
| 412 | break; | ||
| 413 | default: | ||
| 414 | break; | ||
| 415 | } | ||
| 416 | |||
| 417 | pr_debug("irq: Allocated host of type %d @0x%p\n", revmap_type, host); | ||
| 418 | |||
| 419 | return host; | ||
| 297 | } | 420 | } |
| 298 | 421 | ||
| 299 | /* Create a mapping for a real_irq if it doesn't already exist. | 422 | struct irq_host *irq_find_host(struct device_node *node) |
| 300 | * Return the virtual irq as a convenience. | ||
| 301 | */ | ||
| 302 | int virt_irq_create_mapping(unsigned int real_irq) | ||
| 303 | { | 423 | { |
| 304 | unsigned int virq, first_virq; | 424 | struct irq_host *h, *found = NULL; |
| 305 | static int warned; | 425 | unsigned long flags; |
| 426 | |||
| 427 | /* We might want to match the legacy controller last since | ||
| 428 | * it might potentially be set to match all interrupts in | ||
| 429 | * the absence of a device node. This isn't a problem so far | ||
| 430 | * yet though... | ||
| 431 | */ | ||
| 432 | spin_lock_irqsave(&irq_big_lock, flags); | ||
| 433 | list_for_each_entry(h, &irq_hosts, link) | ||
| 434 | if (h->ops->match == NULL || h->ops->match(h, node)) { | ||
| 435 | found = h; | ||
| 436 | break; | ||
| 437 | } | ||
| 438 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 439 | return found; | ||
| 440 | } | ||
| 441 | EXPORT_SYMBOL_GPL(irq_find_host); | ||
| 442 | |||
| 443 | void irq_set_default_host(struct irq_host *host) | ||
| 444 | { | ||
| 445 | pr_debug("irq: Default host set to @0x%p\n", host); | ||
| 446 | |||
| 447 | irq_default_host = host; | ||
| 448 | } | ||
| 306 | 449 | ||
| 307 | if (ppc64_interrupt_controller == IC_OPEN_PIC) | 450 | void irq_set_virq_count(unsigned int count) |
| 308 | return real_irq; /* no mapping for openpic (for now) */ | 451 | { |
| 452 | pr_debug("irq: Trying to set virq count to %d\n", count); | ||
| 309 | 453 | ||
| 310 | if (ppc64_interrupt_controller == IC_CELL_PIC) | 454 | BUG_ON(count < NUM_ISA_INTERRUPTS); |
| 311 | return real_irq; /* no mapping for iic either */ | 455 | if (count < NR_IRQS) |
| 456 | irq_virq_count = count; | ||
| 457 | } | ||
| 312 | 458 | ||
| 313 | /* don't map interrupts < MIN_VIRT_IRQ */ | 459 | unsigned int irq_create_mapping(struct irq_host *host, |
| 314 | if (real_irq < MIN_VIRT_IRQ) { | 460 | irq_hw_number_t hwirq, |
| 315 | virt_irq_to_real_map[real_irq] = real_irq; | 461 | unsigned int flags) |
| 316 | return real_irq; | 462 | { |
| 463 | unsigned int virq, hint; | ||
| 464 | |||
| 465 | pr_debug("irq: irq_create_mapping(0x%p, 0x%lx, 0x%x)\n", | ||
| 466 | host, hwirq, flags); | ||
| 467 | |||
| 468 | /* Look for default host if nececssary */ | ||
| 469 | if (host == NULL) | ||
| 470 | host = irq_default_host; | ||
| 471 | if (host == NULL) { | ||
| 472 | printk(KERN_WARNING "irq_create_mapping called for" | ||
| 473 | " NULL host, hwirq=%lx\n", hwirq); | ||
| 474 | WARN_ON(1); | ||
| 475 | return NO_IRQ; | ||
| 317 | } | 476 | } |
| 477 | pr_debug("irq: -> using host @%p\n", host); | ||
| 318 | 478 | ||
| 319 | /* map to a number between MIN_VIRT_IRQ and max_virt_irq */ | 479 | /* Check if mapping already exist, if it does, call |
| 320 | virq = real_irq; | 480 | * host->ops->map() to update the flags |
| 321 | if (virq > max_virt_irq) | 481 | */ |
| 322 | virq = (virq % nr_virt_irqs) + MIN_VIRT_IRQ; | 482 | virq = irq_find_mapping(host, hwirq); |
| 323 | 483 | if (virq != IRQ_NONE) { | |
| 324 | /* search for this number or a free slot */ | 484 | pr_debug("irq: -> existing mapping on virq %d\n", virq); |
| 325 | first_virq = virq; | 485 | host->ops->map(host, virq, hwirq, flags); |
| 326 | while (virt_irq_to_real_map[virq] != UNDEFINED_IRQ) { | 486 | return virq; |
| 327 | if (virt_irq_to_real_map[virq] == real_irq) | 487 | } |
| 328 | return virq; | 488 | |
| 329 | if (++virq > max_virt_irq) | 489 | /* Get a virtual interrupt number */ |
| 330 | virq = MIN_VIRT_IRQ; | 490 | if (host->revmap_type == IRQ_HOST_MAP_LEGACY) { |
| 331 | if (virq == first_virq) | 491 | /* Handle legacy */ |
| 332 | goto nospace; /* oops, no free slots */ | 492 | virq = (unsigned int)hwirq; |
| 493 | if (virq == 0 || virq >= NUM_ISA_INTERRUPTS) | ||
| 494 | return NO_IRQ; | ||
| 495 | return virq; | ||
| 496 | } else { | ||
| 497 | /* Allocate a virtual interrupt number */ | ||
| 498 | hint = hwirq % irq_virq_count; | ||
| 499 | virq = irq_alloc_virt(host, 1, hint); | ||
| 500 | if (virq == NO_IRQ) { | ||
| 501 | pr_debug("irq: -> virq allocation failed\n"); | ||
| 502 | return NO_IRQ; | ||
| 503 | } | ||
| 333 | } | 504 | } |
| 505 | pr_debug("irq: -> obtained virq %d\n", virq); | ||
| 334 | 506 | ||
| 335 | virt_irq_to_real_map[virq] = real_irq; | 507 | /* Clear some flags */ |
| 508 | get_irq_desc(virq)->status &= ~(IRQ_NOREQUEST | IRQ_LEVEL); | ||
| 509 | |||
| 510 | /* map it */ | ||
| 511 | if (host->ops->map(host, virq, hwirq, flags)) { | ||
| 512 | pr_debug("irq: -> mapping failed, freeing\n"); | ||
| 513 | irq_free_virt(virq, 1); | ||
| 514 | return NO_IRQ; | ||
| 515 | } | ||
| 516 | smp_wmb(); | ||
| 517 | irq_map[virq].hwirq = hwirq; | ||
| 518 | smp_mb(); | ||
| 336 | return virq; | 519 | return virq; |
| 520 | } | ||
| 521 | EXPORT_SYMBOL_GPL(irq_create_mapping); | ||
| 337 | 522 | ||
| 338 | nospace: | 523 | extern unsigned int irq_create_of_mapping(struct device_node *controller, |
| 339 | if (!warned) { | 524 | u32 *intspec, unsigned int intsize) |
| 340 | printk(KERN_CRIT "Interrupt table is full\n"); | 525 | { |
| 341 | printk(KERN_CRIT "Increase virt_irq_max (currently %d) " | 526 | struct irq_host *host; |
| 342 | "in your kernel sources and rebuild.\n", virt_irq_max); | 527 | irq_hw_number_t hwirq; |
| 343 | warned = 1; | 528 | unsigned int flags = IRQ_TYPE_NONE; |
| 529 | |||
| 530 | if (controller == NULL) | ||
| 531 | host = irq_default_host; | ||
| 532 | else | ||
| 533 | host = irq_find_host(controller); | ||
| 534 | if (host == NULL) | ||
| 535 | return NO_IRQ; | ||
| 536 | |||
| 537 | /* If host has no translation, then we assume interrupt line */ | ||
| 538 | if (host->ops->xlate == NULL) | ||
| 539 | hwirq = intspec[0]; | ||
| 540 | else { | ||
| 541 | if (host->ops->xlate(host, controller, intspec, intsize, | ||
| 542 | &hwirq, &flags)) | ||
| 543 | return NO_IRQ; | ||
| 344 | } | 544 | } |
| 345 | return NO_IRQ; | 545 | |
| 546 | return irq_create_mapping(host, hwirq, flags); | ||
| 346 | } | 547 | } |
| 548 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | ||
| 347 | 549 | ||
| 348 | /* | 550 | unsigned int irq_of_parse_and_map(struct device_node *dev, int index) |
| 349 | * In most cases will get a hit on the very first slot checked in the | ||
| 350 | * virt_irq_to_real_map. Only when there are a large number of | ||
| 351 | * IRQs will this be expensive. | ||
| 352 | */ | ||
| 353 | unsigned int real_irq_to_virt_slowpath(unsigned int real_irq) | ||
| 354 | { | 551 | { |
| 355 | unsigned int virq; | 552 | struct of_irq oirq; |
| 356 | unsigned int first_virq; | ||
| 357 | 553 | ||
| 358 | virq = real_irq; | 554 | if (of_irq_map_one(dev, index, &oirq)) |
| 555 | return NO_IRQ; | ||
| 359 | 556 | ||
| 360 | if (virq > max_virt_irq) | 557 | return irq_create_of_mapping(oirq.controller, oirq.specifier, |
| 361 | virq = (virq % nr_virt_irqs) + MIN_VIRT_IRQ; | 558 | oirq.size); |
| 559 | } | ||
| 560 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | ||
| 362 | 561 | ||
| 363 | first_virq = virq; | 562 | void irq_dispose_mapping(unsigned int virq) |
| 563 | { | ||
| 564 | struct irq_host *host = irq_map[virq].host; | ||
| 565 | irq_hw_number_t hwirq; | ||
| 566 | unsigned long flags; | ||
| 364 | 567 | ||
| 365 | do { | 568 | WARN_ON (host == NULL); |
| 366 | if (virt_irq_to_real_map[virq] == real_irq) | 569 | if (host == NULL) |
| 367 | return virq; | 570 | return; |
| 368 | 571 | ||
| 369 | virq++; | 572 | /* Never unmap legacy interrupts */ |
| 573 | if (host->revmap_type == IRQ_HOST_MAP_LEGACY) | ||
| 574 | return; | ||
| 370 | 575 | ||
| 371 | if (virq >= max_virt_irq) | 576 | /* remove chip and handler */ |
| 372 | virq = 0; | 577 | set_irq_chip_and_handler(virq, NULL, NULL); |
| 578 | |||
| 579 | /* Make sure it's completed */ | ||
| 580 | synchronize_irq(virq); | ||
| 581 | |||
| 582 | /* Tell the PIC about it */ | ||
| 583 | if (host->ops->unmap) | ||
| 584 | host->ops->unmap(host, virq); | ||
| 585 | smp_mb(); | ||
| 586 | |||
| 587 | /* Clear reverse map */ | ||
| 588 | hwirq = irq_map[virq].hwirq; | ||
| 589 | switch(host->revmap_type) { | ||
| 590 | case IRQ_HOST_MAP_LINEAR: | ||
| 591 | if (hwirq < host->revmap_data.linear.size) | ||
| 592 | host->revmap_data.linear.revmap[hwirq] = IRQ_NONE; | ||
| 593 | break; | ||
| 594 | case IRQ_HOST_MAP_TREE: | ||
| 595 | /* Check if radix tree allocated yet */ | ||
| 596 | if (host->revmap_data.tree.gfp_mask == 0) | ||
| 597 | break; | ||
| 598 | /* XXX radix tree not safe ! remove lock whem it becomes safe | ||
| 599 | * and use some RCU sync to make sure everything is ok before we | ||
| 600 | * can re-use that map entry | ||
| 601 | */ | ||
| 602 | spin_lock_irqsave(&irq_big_lock, flags); | ||
| 603 | radix_tree_delete(&host->revmap_data.tree, hwirq); | ||
| 604 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 605 | break; | ||
| 606 | } | ||
| 373 | 607 | ||
| 374 | } while (first_virq != virq); | 608 | /* Destroy map */ |
| 609 | smp_mb(); | ||
| 610 | irq_map[virq].hwirq = host->inval_irq; | ||
| 375 | 611 | ||
| 376 | return NO_IRQ; | 612 | /* Set some flags */ |
| 613 | get_irq_desc(virq)->status |= IRQ_NOREQUEST; | ||
| 377 | 614 | ||
| 615 | /* Free it */ | ||
| 616 | irq_free_virt(virq, 1); | ||
| 378 | } | 617 | } |
| 379 | #endif /* CONFIG_PPC64 */ | 618 | EXPORT_SYMBOL_GPL(irq_dispose_mapping); |
| 380 | 619 | ||
| 381 | #ifdef CONFIG_IRQSTACKS | 620 | unsigned int irq_find_mapping(struct irq_host *host, |
| 382 | struct thread_info *softirq_ctx[NR_CPUS] __read_mostly; | 621 | irq_hw_number_t hwirq) |
| 383 | struct thread_info *hardirq_ctx[NR_CPUS] __read_mostly; | 622 | { |
| 623 | unsigned int i; | ||
| 624 | unsigned int hint = hwirq % irq_virq_count; | ||
| 625 | |||
| 626 | /* Look for default host if nececssary */ | ||
| 627 | if (host == NULL) | ||
| 628 | host = irq_default_host; | ||
| 629 | if (host == NULL) | ||
| 630 | return NO_IRQ; | ||
| 631 | |||
| 632 | /* legacy -> bail early */ | ||
| 633 | if (host->revmap_type == IRQ_HOST_MAP_LEGACY) | ||
| 634 | return hwirq; | ||
| 635 | |||
| 636 | /* Slow path does a linear search of the map */ | ||
| 637 | if (hint < NUM_ISA_INTERRUPTS) | ||
| 638 | hint = NUM_ISA_INTERRUPTS; | ||
| 639 | i = hint; | ||
| 640 | do { | ||
| 641 | if (irq_map[i].host == host && | ||
| 642 | irq_map[i].hwirq == hwirq) | ||
| 643 | return i; | ||
| 644 | i++; | ||
| 645 | if (i >= irq_virq_count) | ||
| 646 | i = NUM_ISA_INTERRUPTS; | ||
| 647 | } while(i != hint); | ||
| 648 | return NO_IRQ; | ||
| 649 | } | ||
| 650 | EXPORT_SYMBOL_GPL(irq_find_mapping); | ||
| 384 | 651 | ||
| 385 | void irq_ctx_init(void) | 652 | |
| 653 | unsigned int irq_radix_revmap(struct irq_host *host, | ||
| 654 | irq_hw_number_t hwirq) | ||
| 386 | { | 655 | { |
| 387 | struct thread_info *tp; | 656 | struct radix_tree_root *tree; |
| 388 | int i; | 657 | struct irq_map_entry *ptr; |
| 658 | unsigned int virq; | ||
| 659 | unsigned long flags; | ||
| 389 | 660 | ||
| 390 | for_each_possible_cpu(i) { | 661 | WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE); |
| 391 | memset((void *)softirq_ctx[i], 0, THREAD_SIZE); | ||
| 392 | tp = softirq_ctx[i]; | ||
| 393 | tp->cpu = i; | ||
| 394 | tp->preempt_count = SOFTIRQ_OFFSET; | ||
| 395 | 662 | ||
| 396 | memset((void *)hardirq_ctx[i], 0, THREAD_SIZE); | 663 | /* Check if the radix tree exist yet. We test the value of |
| 397 | tp = hardirq_ctx[i]; | 664 | * the gfp_mask for that. Sneaky but saves another int in the |
| 398 | tp->cpu = i; | 665 | * structure. If not, we fallback to slow mode |
| 399 | tp->preempt_count = HARDIRQ_OFFSET; | 666 | */ |
| 667 | tree = &host->revmap_data.tree; | ||
| 668 | if (tree->gfp_mask == 0) | ||
| 669 | return irq_find_mapping(host, hwirq); | ||
| 670 | |||
| 671 | /* XXX Current radix trees are NOT SMP safe !!! Remove that lock | ||
| 672 | * when that is fixed (when Nick's patch gets in | ||
| 673 | */ | ||
| 674 | spin_lock_irqsave(&irq_big_lock, flags); | ||
| 675 | |||
| 676 | /* Now try to resolve */ | ||
| 677 | ptr = radix_tree_lookup(tree, hwirq); | ||
| 678 | /* Found it, return */ | ||
| 679 | if (ptr) { | ||
| 680 | virq = ptr - irq_map; | ||
| 681 | goto bail; | ||
| 400 | } | 682 | } |
| 683 | |||
| 684 | /* If not there, try to insert it */ | ||
| 685 | virq = irq_find_mapping(host, hwirq); | ||
| 686 | if (virq != NO_IRQ) | ||
| 687 | radix_tree_insert(tree, virq, &irq_map[virq]); | ||
| 688 | bail: | ||
| 689 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 690 | return virq; | ||
| 401 | } | 691 | } |
| 402 | 692 | ||
| 403 | static inline void do_softirq_onstack(void) | 693 | unsigned int irq_linear_revmap(struct irq_host *host, |
| 694 | irq_hw_number_t hwirq) | ||
| 404 | { | 695 | { |
| 405 | struct thread_info *curtp, *irqtp; | 696 | unsigned int *revmap; |
| 406 | 697 | ||
| 407 | curtp = current_thread_info(); | 698 | WARN_ON(host->revmap_type != IRQ_HOST_MAP_LINEAR); |
| 408 | irqtp = softirq_ctx[smp_processor_id()]; | 699 | |
| 409 | irqtp->task = curtp->task; | 700 | /* Check revmap bounds */ |
| 410 | call_do_softirq(irqtp); | 701 | if (unlikely(hwirq >= host->revmap_data.linear.size)) |
| 411 | irqtp->task = NULL; | 702 | return irq_find_mapping(host, hwirq); |
| 703 | |||
| 704 | /* Check if revmap was allocated */ | ||
| 705 | revmap = host->revmap_data.linear.revmap; | ||
| 706 | if (unlikely(revmap == NULL)) | ||
| 707 | return irq_find_mapping(host, hwirq); | ||
| 708 | |||
| 709 | /* Fill up revmap with slow path if no mapping found */ | ||
| 710 | if (unlikely(revmap[hwirq] == NO_IRQ)) | ||
| 711 | revmap[hwirq] = irq_find_mapping(host, hwirq); | ||
| 712 | |||
| 713 | return revmap[hwirq]; | ||
| 412 | } | 714 | } |
| 413 | 715 | ||
| 414 | #else | 716 | unsigned int irq_alloc_virt(struct irq_host *host, |
| 415 | #define do_softirq_onstack() __do_softirq() | 717 | unsigned int count, |
| 416 | #endif /* CONFIG_IRQSTACKS */ | 718 | unsigned int hint) |
| 719 | { | ||
| 720 | unsigned long flags; | ||
| 721 | unsigned int i, j, found = NO_IRQ; | ||
| 722 | unsigned int limit = irq_virq_count - count; | ||
| 417 | 723 | ||
| 418 | void do_softirq(void) | 724 | if (count == 0 || count > (irq_virq_count - NUM_ISA_INTERRUPTS)) |
| 725 | return NO_IRQ; | ||
| 726 | |||
| 727 | spin_lock_irqsave(&irq_big_lock, flags); | ||
| 728 | |||
| 729 | /* Use hint for 1 interrupt if any */ | ||
| 730 | if (count == 1 && hint >= NUM_ISA_INTERRUPTS && | ||
| 731 | hint < irq_virq_count && irq_map[hint].host == NULL) { | ||
| 732 | found = hint; | ||
| 733 | goto hint_found; | ||
| 734 | } | ||
| 735 | |||
| 736 | /* Look for count consecutive numbers in the allocatable | ||
| 737 | * (non-legacy) space | ||
| 738 | */ | ||
| 739 | for (i = NUM_ISA_INTERRUPTS; i <= limit; ) { | ||
| 740 | for (j = i; j < (i + count); j++) | ||
| 741 | if (irq_map[j].host != NULL) { | ||
| 742 | i = j + 1; | ||
| 743 | continue; | ||
| 744 | } | ||
| 745 | found = i; | ||
| 746 | break; | ||
| 747 | } | ||
| 748 | if (found == NO_IRQ) { | ||
| 749 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 750 | return NO_IRQ; | ||
| 751 | } | ||
| 752 | hint_found: | ||
| 753 | for (i = found; i < (found + count); i++) { | ||
| 754 | irq_map[i].hwirq = host->inval_irq; | ||
| 755 | smp_wmb(); | ||
| 756 | irq_map[i].host = host; | ||
| 757 | } | ||
| 758 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 759 | return found; | ||
| 760 | } | ||
| 761 | |||
| 762 | void irq_free_virt(unsigned int virq, unsigned int count) | ||
| 419 | { | 763 | { |
| 420 | unsigned long flags; | 764 | unsigned long flags; |
| 765 | unsigned int i; | ||
| 421 | 766 | ||
| 422 | if (in_interrupt()) | 767 | WARN_ON (virq < NUM_ISA_INTERRUPTS); |
| 423 | return; | 768 | WARN_ON (count == 0 || (virq + count) > irq_virq_count); |
| 424 | 769 | ||
| 425 | local_irq_save(flags); | 770 | spin_lock_irqsave(&irq_big_lock, flags); |
| 771 | for (i = virq; i < (virq + count); i++) { | ||
| 772 | struct irq_host *host; | ||
| 426 | 773 | ||
| 427 | if (local_softirq_pending()) { | 774 | if (i < NUM_ISA_INTERRUPTS || |
| 428 | account_system_vtime(current); | 775 | (virq + count) > irq_virq_count) |
| 429 | local_bh_disable(); | 776 | continue; |
| 430 | do_softirq_onstack(); | 777 | |
| 431 | account_system_vtime(current); | 778 | host = irq_map[i].host; |
| 432 | __local_bh_enable(); | 779 | irq_map[i].hwirq = host->inval_irq; |
| 780 | smp_wmb(); | ||
| 781 | irq_map[i].host = NULL; | ||
| 433 | } | 782 | } |
| 783 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 784 | } | ||
| 434 | 785 | ||
| 435 | local_irq_restore(flags); | 786 | void irq_early_init(void) |
| 787 | { | ||
| 788 | unsigned int i; | ||
| 789 | |||
| 790 | for (i = 0; i < NR_IRQS; i++) | ||
| 791 | get_irq_desc(i)->status |= IRQ_NOREQUEST; | ||
| 436 | } | 792 | } |
| 437 | EXPORT_SYMBOL(do_softirq); | 793 | |
| 794 | /* We need to create the radix trees late */ | ||
| 795 | static int irq_late_init(void) | ||
| 796 | { | ||
| 797 | struct irq_host *h; | ||
| 798 | unsigned long flags; | ||
| 799 | |||
| 800 | spin_lock_irqsave(&irq_big_lock, flags); | ||
| 801 | list_for_each_entry(h, &irq_hosts, link) { | ||
| 802 | if (h->revmap_type == IRQ_HOST_MAP_TREE) | ||
| 803 | INIT_RADIX_TREE(&h->revmap_data.tree, GFP_ATOMIC); | ||
| 804 | } | ||
| 805 | spin_unlock_irqrestore(&irq_big_lock, flags); | ||
| 806 | |||
| 807 | return 0; | ||
| 808 | } | ||
| 809 | arch_initcall(irq_late_init); | ||
| 810 | |||
| 811 | #endif /* CONFIG_PPC_MERGE */ | ||
| 438 | 812 | ||
| 439 | #ifdef CONFIG_PCI_MSI | 813 | #ifdef CONFIG_PCI_MSI |
| 440 | int pci_enable_msi(struct pci_dev * pdev) | 814 | int pci_enable_msi(struct pci_dev * pdev) |
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c index 4cf0b971976b..7e98e778b52f 100644 --- a/arch/powerpc/kernel/legacy_serial.c +++ b/arch/powerpc/kernel/legacy_serial.c | |||
| @@ -28,6 +28,7 @@ static struct legacy_serial_info { | |||
| 28 | struct device_node *np; | 28 | struct device_node *np; |
| 29 | unsigned int speed; | 29 | unsigned int speed; |
| 30 | unsigned int clock; | 30 | unsigned int clock; |
| 31 | int irq_check_parent; | ||
| 31 | phys_addr_t taddr; | 32 | phys_addr_t taddr; |
| 32 | } legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS]; | 33 | } legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS]; |
| 33 | static unsigned int legacy_serial_count; | 34 | static unsigned int legacy_serial_count; |
| @@ -36,7 +37,7 @@ static int legacy_serial_console = -1; | |||
| 36 | static int __init add_legacy_port(struct device_node *np, int want_index, | 37 | static int __init add_legacy_port(struct device_node *np, int want_index, |
| 37 | int iotype, phys_addr_t base, | 38 | int iotype, phys_addr_t base, |
| 38 | phys_addr_t taddr, unsigned long irq, | 39 | phys_addr_t taddr, unsigned long irq, |
| 39 | upf_t flags) | 40 | upf_t flags, int irq_check_parent) |
| 40 | { | 41 | { |
| 41 | u32 *clk, *spd, clock = BASE_BAUD * 16; | 42 | u32 *clk, *spd, clock = BASE_BAUD * 16; |
| 42 | int index; | 43 | int index; |
| @@ -68,7 +69,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index, | |||
| 68 | if (legacy_serial_infos[index].np != 0) { | 69 | if (legacy_serial_infos[index].np != 0) { |
| 69 | /* if we still have some room, move it, else override */ | 70 | /* if we still have some room, move it, else override */ |
| 70 | if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) { | 71 | if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) { |
| 71 | printk(KERN_INFO "Moved legacy port %d -> %d\n", | 72 | printk(KERN_DEBUG "Moved legacy port %d -> %d\n", |
| 72 | index, legacy_serial_count); | 73 | index, legacy_serial_count); |
| 73 | legacy_serial_ports[legacy_serial_count] = | 74 | legacy_serial_ports[legacy_serial_count] = |
| 74 | legacy_serial_ports[index]; | 75 | legacy_serial_ports[index]; |
| @@ -76,7 +77,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index, | |||
| 76 | legacy_serial_infos[index]; | 77 | legacy_serial_infos[index]; |
| 77 | legacy_serial_count++; | 78 | legacy_serial_count++; |
| 78 | } else { | 79 | } else { |
| 79 | printk(KERN_INFO "Replacing legacy port %d\n", index); | 80 | printk(KERN_DEBUG "Replacing legacy port %d\n", index); |
| 80 | } | 81 | } |
| 81 | } | 82 | } |
| 82 | 83 | ||
| @@ -95,10 +96,11 @@ static int __init add_legacy_port(struct device_node *np, int want_index, | |||
| 95 | legacy_serial_infos[index].np = of_node_get(np); | 96 | legacy_serial_infos[index].np = of_node_get(np); |
| 96 | legacy_serial_infos[index].clock = clock; | 97 | legacy_serial_infos[index].clock = clock; |
| 97 | legacy_serial_infos[index].speed = spd ? *spd : 0; | 98 | legacy_serial_infos[index].speed = spd ? *spd : 0; |
| 99 | legacy_serial_infos[index].irq_check_parent = irq_check_parent; | ||
| 98 | 100 | ||
| 99 | printk(KERN_INFO "Found legacy serial port %d for %s\n", | 101 | printk(KERN_DEBUG "Found legacy serial port %d for %s\n", |
| 100 | index, np->full_name); | 102 | index, np->full_name); |
| 101 | printk(KERN_INFO " %s=%llx, taddr=%llx, irq=%lx, clk=%d, speed=%d\n", | 103 | printk(KERN_DEBUG " %s=%llx, taddr=%llx, irq=%lx, clk=%d, speed=%d\n", |
| 102 | (iotype == UPIO_PORT) ? "port" : "mem", | 104 | (iotype == UPIO_PORT) ? "port" : "mem", |
| 103 | (unsigned long long)base, (unsigned long long)taddr, irq, | 105 | (unsigned long long)base, (unsigned long long)taddr, irq, |
| 104 | legacy_serial_ports[index].uartclk, | 106 | legacy_serial_ports[index].uartclk, |
| @@ -126,11 +128,13 @@ static int __init add_legacy_soc_port(struct device_node *np, | |||
| 126 | return -1; | 128 | return -1; |
| 127 | 129 | ||
| 128 | addr = of_translate_address(soc_dev, addrp); | 130 | addr = of_translate_address(soc_dev, addrp); |
| 131 | if (addr == OF_BAD_ADDR) | ||
| 132 | return -1; | ||
| 129 | 133 | ||
| 130 | /* Add port, irq will be dealt with later. We passed a translated | 134 | /* Add port, irq will be dealt with later. We passed a translated |
| 131 | * IO port value. It will be fixed up later along with the irq | 135 | * IO port value. It will be fixed up later along with the irq |
| 132 | */ | 136 | */ |
| 133 | return add_legacy_port(np, -1, UPIO_MEM, addr, addr, NO_IRQ, flags); | 137 | return add_legacy_port(np, -1, UPIO_MEM, addr, addr, NO_IRQ, flags, 0); |
| 134 | } | 138 | } |
| 135 | 139 | ||
| 136 | static int __init add_legacy_isa_port(struct device_node *np, | 140 | static int __init add_legacy_isa_port(struct device_node *np, |
| @@ -141,6 +145,8 @@ static int __init add_legacy_isa_port(struct device_node *np, | |||
| 141 | int index = -1; | 145 | int index = -1; |
| 142 | phys_addr_t taddr; | 146 | phys_addr_t taddr; |
| 143 | 147 | ||
| 148 | DBG(" -> add_legacy_isa_port(%s)\n", np->full_name); | ||
| 149 | |||
| 144 | /* Get the ISA port number */ | 150 | /* Get the ISA port number */ |
| 145 | reg = (u32 *)get_property(np, "reg", NULL); | 151 | reg = (u32 *)get_property(np, "reg", NULL); |
| 146 | if (reg == NULL) | 152 | if (reg == NULL) |
| @@ -161,9 +167,12 @@ static int __init add_legacy_isa_port(struct device_node *np, | |||
| 161 | 167 | ||
| 162 | /* Translate ISA address */ | 168 | /* Translate ISA address */ |
| 163 | taddr = of_translate_address(np, reg); | 169 | taddr = of_translate_address(np, reg); |
| 170 | if (taddr == OF_BAD_ADDR) | ||
| 171 | return -1; | ||
| 164 | 172 | ||
| 165 | /* Add port, irq will be dealt with later */ | 173 | /* Add port, irq will be dealt with later */ |
| 166 | return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, NO_IRQ, UPF_BOOT_AUTOCONF); | 174 | return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, |
| 175 | NO_IRQ, UPF_BOOT_AUTOCONF, 0); | ||
| 167 | 176 | ||
| 168 | } | 177 | } |
| 169 | 178 | ||
| @@ -176,6 +185,8 @@ static int __init add_legacy_pci_port(struct device_node *np, | |||
| 176 | unsigned int flags; | 185 | unsigned int flags; |
| 177 | int iotype, index = -1, lindex = 0; | 186 | int iotype, index = -1, lindex = 0; |
| 178 | 187 | ||
| 188 | DBG(" -> add_legacy_pci_port(%s)\n", np->full_name); | ||
| 189 | |||
| 179 | /* We only support ports that have a clock frequency properly | 190 | /* We only support ports that have a clock frequency properly |
| 180 | * encoded in the device-tree (that is have an fcode). Anything | 191 | * encoded in the device-tree (that is have an fcode). Anything |
| 181 | * else can't be used that early and will be normally probed by | 192 | * else can't be used that early and will be normally probed by |
| @@ -194,6 +205,8 @@ static int __init add_legacy_pci_port(struct device_node *np, | |||
| 194 | /* We only support BAR 0 for now */ | 205 | /* We only support BAR 0 for now */ |
| 195 | iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT; | 206 | iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT; |
| 196 | addr = of_translate_address(pci_dev, addrp); | 207 | addr = of_translate_address(pci_dev, addrp); |
| 208 | if (addr == OF_BAD_ADDR) | ||
| 209 | return -1; | ||
| 197 | 210 | ||
| 198 | /* Set the IO base to the same as the translated address for MMIO, | 211 | /* Set the IO base to the same as the translated address for MMIO, |
| 199 | * or to the domain local IO base for PIO (it will be fixed up later) | 212 | * or to the domain local IO base for PIO (it will be fixed up later) |
| @@ -231,7 +244,8 @@ static int __init add_legacy_pci_port(struct device_node *np, | |||
| 231 | /* Add port, irq will be dealt with later. We passed a translated | 244 | /* Add port, irq will be dealt with later. We passed a translated |
| 232 | * IO port value. It will be fixed up later along with the irq | 245 | * IO port value. It will be fixed up later along with the irq |
| 233 | */ | 246 | */ |
| 234 | return add_legacy_port(np, index, iotype, base, addr, NO_IRQ, UPF_BOOT_AUTOCONF); | 247 | return add_legacy_port(np, index, iotype, base, addr, NO_IRQ, |
| 248 | UPF_BOOT_AUTOCONF, np != pci_dev); | ||
| 235 | } | 249 | } |
| 236 | #endif | 250 | #endif |
| 237 | 251 | ||
| @@ -362,27 +376,22 @@ static void __init fixup_port_irq(int index, | |||
| 362 | struct device_node *np, | 376 | struct device_node *np, |
| 363 | struct plat_serial8250_port *port) | 377 | struct plat_serial8250_port *port) |
| 364 | { | 378 | { |
| 379 | unsigned int virq; | ||
| 380 | |||
| 365 | DBG("fixup_port_irq(%d)\n", index); | 381 | DBG("fixup_port_irq(%d)\n", index); |
| 366 | 382 | ||
| 367 | /* Check for interrupts in that node */ | 383 | virq = irq_of_parse_and_map(np, 0); |
| 368 | if (np->n_intrs > 0) { | 384 | if (virq == NO_IRQ && legacy_serial_infos[index].irq_check_parent) { |
| 369 | port->irq = np->intrs[0].line; | 385 | np = of_get_parent(np); |
| 370 | DBG(" port %d (%s), irq=%d\n", | 386 | if (np == NULL) |
| 371 | index, np->full_name, port->irq); | 387 | return; |
| 372 | return; | 388 | virq = irq_of_parse_and_map(np, 0); |
| 389 | of_node_put(np); | ||
| 373 | } | 390 | } |
| 374 | 391 | if (virq == NO_IRQ) | |
| 375 | /* Check for interrupts in the parent */ | ||
| 376 | np = of_get_parent(np); | ||
| 377 | if (np == NULL) | ||
| 378 | return; | 392 | return; |
| 379 | 393 | ||
| 380 | if (np->n_intrs > 0) { | 394 | port->irq = virq; |
| 381 | port->irq = np->intrs[0].line; | ||
| 382 | DBG(" port %d (%s), irq=%d\n", | ||
| 383 | index, np->full_name, port->irq); | ||
| 384 | } | ||
| 385 | of_node_put(np); | ||
| 386 | } | 395 | } |
| 387 | 396 | ||
| 388 | static void __init fixup_port_pio(int index, | 397 | static void __init fixup_port_pio(int index, |
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S index 0c3c70d115c6..bfb407fc1aa1 100644 --- a/arch/powerpc/kernel/misc_64.S +++ b/arch/powerpc/kernel/misc_64.S | |||
| @@ -51,12 +51,14 @@ _GLOBAL(call_do_softirq) | |||
| 51 | mtlr r0 | 51 | mtlr r0 |
| 52 | blr | 52 | blr |
| 53 | 53 | ||
| 54 | _GLOBAL(call___do_IRQ) | 54 | _GLOBAL(call_handle_irq) |
| 55 | ld r8,0(r7) | ||
| 55 | mflr r0 | 56 | mflr r0 |
| 56 | std r0,16(r1) | 57 | std r0,16(r1) |
| 57 | stdu r1,THREAD_SIZE-112(r5) | 58 | mtctr r8 |
| 58 | mr r1,r5 | 59 | stdu r1,THREAD_SIZE-112(r6) |
| 59 | bl .__do_IRQ | 60 | mr r1,r6 |
| 61 | bctrl | ||
| 60 | ld r1,0(r1) | 62 | ld r1,0(r1) |
| 61 | ld r0,16(r1) | 63 | ld r0,16(r1) |
| 62 | mtlr r0 | 64 | mtlr r0 |
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 1333335c474e..898dae8ab6d9 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
| @@ -1404,6 +1404,43 @@ pcibios_update_irq(struct pci_dev *dev, int irq) | |||
| 1404 | /* XXX FIXME - update OF device tree node interrupt property */ | 1404 | /* XXX FIXME - update OF device tree node interrupt property */ |
| 1405 | } | 1405 | } |
| 1406 | 1406 | ||
| 1407 | #ifdef CONFIG_PPC_MERGE | ||
| 1408 | /* XXX This is a copy of the ppc64 version. This is temporary until we start | ||
| 1409 | * merging the 2 PCI layers | ||
| 1410 | */ | ||
| 1411 | /* | ||
| 1412 | * Reads the interrupt pin to determine if interrupt is use by card. | ||
| 1413 | * If the interrupt is used, then gets the interrupt line from the | ||
| 1414 | * openfirmware and sets it in the pci_dev and pci_config line. | ||
| 1415 | */ | ||
| 1416 | int pci_read_irq_line(struct pci_dev *pci_dev) | ||
| 1417 | { | ||
| 1418 | struct of_irq oirq; | ||
| 1419 | unsigned int virq; | ||
| 1420 | |||
| 1421 | DBG("Try to map irq for %s...\n", pci_name(pci_dev)); | ||
| 1422 | |||
| 1423 | if (of_irq_map_pci(pci_dev, &oirq)) { | ||
| 1424 | DBG(" -> failed !\n"); | ||
| 1425 | return -1; | ||
| 1426 | } | ||
| 1427 | |||
| 1428 | DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", | ||
| 1429 | oirq.size, oirq.specifier[0], oirq.controller->full_name); | ||
| 1430 | |||
| 1431 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); | ||
| 1432 | if(virq == NO_IRQ) { | ||
| 1433 | DBG(" -> failed to map !\n"); | ||
| 1434 | return -1; | ||
| 1435 | } | ||
| 1436 | pci_dev->irq = virq; | ||
| 1437 | pci_write_config_byte(pci_dev, PCI_INTERRUPT_LINE, virq); | ||
| 1438 | |||
| 1439 | return 0; | ||
| 1440 | } | ||
| 1441 | EXPORT_SYMBOL(pci_read_irq_line); | ||
| 1442 | #endif /* CONFIG_PPC_MERGE */ | ||
| 1443 | |||
| 1407 | int pcibios_enable_device(struct pci_dev *dev, int mask) | 1444 | int pcibios_enable_device(struct pci_dev *dev, int mask) |
| 1408 | { | 1445 | { |
| 1409 | u16 cmd, old_cmd; | 1446 | u16 cmd, old_cmd; |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index bea8451fb57b..efc0b5559ee0 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
| @@ -398,12 +398,8 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, | |||
| 398 | } else { | 398 | } else { |
| 399 | dev->hdr_type = PCI_HEADER_TYPE_NORMAL; | 399 | dev->hdr_type = PCI_HEADER_TYPE_NORMAL; |
| 400 | dev->rom_base_reg = PCI_ROM_ADDRESS; | 400 | dev->rom_base_reg = PCI_ROM_ADDRESS; |
| 401 | /* Maybe do a default OF mapping here */ | ||
| 401 | dev->irq = NO_IRQ; | 402 | dev->irq = NO_IRQ; |
| 402 | if (node->n_intrs > 0) { | ||
| 403 | dev->irq = node->intrs[0].line; | ||
| 404 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, | ||
| 405 | dev->irq); | ||
| 406 | } | ||
| 407 | } | 403 | } |
| 408 | 404 | ||
| 409 | pci_parse_of_addrs(node, dev); | 405 | pci_parse_of_addrs(node, dev); |
| @@ -1288,23 +1284,26 @@ EXPORT_SYMBOL(pcibios_fixup_bus); | |||
| 1288 | */ | 1284 | */ |
| 1289 | int pci_read_irq_line(struct pci_dev *pci_dev) | 1285 | int pci_read_irq_line(struct pci_dev *pci_dev) |
| 1290 | { | 1286 | { |
| 1291 | u8 intpin; | 1287 | struct of_irq oirq; |
| 1292 | struct device_node *node; | 1288 | unsigned int virq; |
| 1293 | |||
| 1294 | pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &intpin); | ||
| 1295 | if (intpin == 0) | ||
| 1296 | return 0; | ||
| 1297 | 1289 | ||
| 1298 | node = pci_device_to_OF_node(pci_dev); | 1290 | DBG("Try to map irq for %s...\n", pci_name(pci_dev)); |
| 1299 | if (node == NULL) | ||
| 1300 | return -1; | ||
| 1301 | 1291 | ||
| 1302 | if (node->n_intrs == 0) | 1292 | if (of_irq_map_pci(pci_dev, &oirq)) { |
| 1293 | DBG(" -> failed !\n"); | ||
| 1303 | return -1; | 1294 | return -1; |
| 1295 | } | ||
| 1304 | 1296 | ||
| 1305 | pci_dev->irq = node->intrs[0].line; | 1297 | DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", |
| 1298 | oirq.size, oirq.specifier[0], oirq.controller->full_name); | ||
| 1306 | 1299 | ||
| 1307 | pci_write_config_byte(pci_dev, PCI_INTERRUPT_LINE, pci_dev->irq); | 1300 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); |
| 1301 | if(virq == NO_IRQ) { | ||
| 1302 | DBG(" -> failed to map !\n"); | ||
| 1303 | return -1; | ||
| 1304 | } | ||
| 1305 | pci_dev->irq = virq; | ||
| 1306 | pci_write_config_byte(pci_dev, PCI_INTERRUPT_LINE, virq); | ||
| 1308 | 1307 | ||
| 1309 | return 0; | 1308 | return 0; |
| 1310 | } | 1309 | } |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 4c524cb52184..a1787ffb6319 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
| 31 | #include <linux/kexec.h> | 31 | #include <linux/kexec.h> |
| 32 | #include <linux/debugfs.h> | 32 | #include <linux/debugfs.h> |
| 33 | #include <linux/irq.h> | ||
| 33 | 34 | ||
| 34 | #include <asm/prom.h> | 35 | #include <asm/prom.h> |
| 35 | #include <asm/rtas.h> | 36 | #include <asm/rtas.h> |
| @@ -86,424 +87,6 @@ static DEFINE_RWLOCK(devtree_lock); | |||
| 86 | /* export that to outside world */ | 87 | /* export that to outside world */ |
| 87 | struct device_node *of_chosen; | 88 | struct device_node *of_chosen; |
| 88 | 89 | ||
| 89 | struct device_node *dflt_interrupt_controller; | ||
| 90 | int num_interrupt_controllers; | ||
| 91 | |||
| 92 | /* | ||
| 93 | * Wrapper for allocating memory for various data that needs to be | ||
| 94 | * attached to device nodes as they are processed at boot or when | ||
| 95 | * added to the device tree later (e.g. DLPAR). At boot there is | ||
| 96 | * already a region reserved so we just increment *mem_start by size; | ||
| 97 | * otherwise we call kmalloc. | ||
| 98 | */ | ||
| 99 | static void * prom_alloc(unsigned long size, unsigned long *mem_start) | ||
| 100 | { | ||
| 101 | unsigned long tmp; | ||
| 102 | |||
| 103 | if (!mem_start) | ||
| 104 | return kmalloc(size, GFP_KERNEL); | ||
| 105 | |||
| 106 | tmp = *mem_start; | ||
| 107 | *mem_start += size; | ||
| 108 | return (void *)tmp; | ||
| 109 | } | ||
| 110 | |||
| 111 | /* | ||
| 112 | * Find the device_node with a given phandle. | ||
| 113 | */ | ||
| 114 | static struct device_node * find_phandle(phandle ph) | ||
| 115 | { | ||
| 116 | struct device_node *np; | ||
| 117 | |||
| 118 | for (np = allnodes; np != 0; np = np->allnext) | ||
| 119 | if (np->linux_phandle == ph) | ||
| 120 | return np; | ||
| 121 | return NULL; | ||
| 122 | } | ||
| 123 | |||
| 124 | /* | ||
| 125 | * Find the interrupt parent of a node. | ||
| 126 | */ | ||
| 127 | static struct device_node * __devinit intr_parent(struct device_node *p) | ||
| 128 | { | ||
| 129 | phandle *parp; | ||
| 130 | |||
| 131 | parp = (phandle *) get_property(p, "interrupt-parent", NULL); | ||
| 132 | if (parp == NULL) | ||
| 133 | return p->parent; | ||
| 134 | p = find_phandle(*parp); | ||
| 135 | if (p != NULL) | ||
| 136 | return p; | ||
| 137 | /* | ||
| 138 | * On a powermac booted with BootX, we don't get to know the | ||
| 139 | * phandles for any nodes, so find_phandle will return NULL. | ||
| 140 | * Fortunately these machines only have one interrupt controller | ||
| 141 | * so there isn't in fact any ambiguity. -- paulus | ||
| 142 | */ | ||
| 143 | if (num_interrupt_controllers == 1) | ||
| 144 | p = dflt_interrupt_controller; | ||
| 145 | return p; | ||
| 146 | } | ||
| 147 | |||
| 148 | /* | ||
| 149 | * Find out the size of each entry of the interrupts property | ||
| 150 | * for a node. | ||
| 151 | */ | ||
| 152 | int __devinit prom_n_intr_cells(struct device_node *np) | ||
| 153 | { | ||
| 154 | struct device_node *p; | ||
| 155 | unsigned int *icp; | ||
| 156 | |||
| 157 | for (p = np; (p = intr_parent(p)) != NULL; ) { | ||
| 158 | icp = (unsigned int *) | ||
| 159 | get_property(p, "#interrupt-cells", NULL); | ||
| 160 | if (icp != NULL) | ||
| 161 | return *icp; | ||
| 162 | if (get_property(p, "interrupt-controller", NULL) != NULL | ||
| 163 | || get_property(p, "interrupt-map", NULL) != NULL) { | ||
| 164 | printk("oops, node %s doesn't have #interrupt-cells\n", | ||
| 165 | p->full_name); | ||
| 166 | return 1; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | #ifdef DEBUG_IRQ | ||
| 170 | printk("prom_n_intr_cells failed for %s\n", np->full_name); | ||
| 171 | #endif | ||
| 172 | return 1; | ||
| 173 | } | ||
| 174 | |||
| 175 | /* | ||
| 176 | * Map an interrupt from a device up to the platform interrupt | ||
| 177 | * descriptor. | ||
| 178 | */ | ||
| 179 | static int __devinit map_interrupt(unsigned int **irq, struct device_node **ictrler, | ||
| 180 | struct device_node *np, unsigned int *ints, | ||
| 181 | int nintrc) | ||
| 182 | { | ||
| 183 | struct device_node *p, *ipar; | ||
| 184 | unsigned int *imap, *imask, *ip; | ||
| 185 | int i, imaplen, match; | ||
| 186 | int newintrc = 0, newaddrc = 0; | ||
| 187 | unsigned int *reg; | ||
| 188 | int naddrc; | ||
| 189 | |||
| 190 | reg = (unsigned int *) get_property(np, "reg", NULL); | ||
| 191 | naddrc = prom_n_addr_cells(np); | ||
| 192 | p = intr_parent(np); | ||
| 193 | while (p != NULL) { | ||
| 194 | if (get_property(p, "interrupt-controller", NULL) != NULL) | ||
| 195 | /* this node is an interrupt controller, stop here */ | ||
| 196 | break; | ||
| 197 | imap = (unsigned int *) | ||
| 198 | get_property(p, "interrupt-map", &imaplen); | ||
| 199 | if (imap == NULL) { | ||
| 200 | p = intr_parent(p); | ||
| 201 | continue; | ||
| 202 | } | ||
| 203 | imask = (unsigned int *) | ||
| 204 | get_property(p, "interrupt-map-mask", NULL); | ||
| 205 | if (imask == NULL) { | ||
| 206 | printk("oops, %s has interrupt-map but no mask\n", | ||
| 207 | p->full_name); | ||
| 208 | return 0; | ||
| 209 | } | ||
| 210 | imaplen /= sizeof(unsigned int); | ||
| 211 | match = 0; | ||
| 212 | ipar = NULL; | ||
| 213 | while (imaplen > 0 && !match) { | ||
| 214 | /* check the child-interrupt field */ | ||
| 215 | match = 1; | ||
| 216 | for (i = 0; i < naddrc && match; ++i) | ||
| 217 | match = ((reg[i] ^ imap[i]) & imask[i]) == 0; | ||
| 218 | for (; i < naddrc + nintrc && match; ++i) | ||
| 219 | match = ((ints[i-naddrc] ^ imap[i]) & imask[i]) == 0; | ||
| 220 | imap += naddrc + nintrc; | ||
| 221 | imaplen -= naddrc + nintrc; | ||
| 222 | /* grab the interrupt parent */ | ||
| 223 | ipar = find_phandle((phandle) *imap++); | ||
| 224 | --imaplen; | ||
| 225 | if (ipar == NULL && num_interrupt_controllers == 1) | ||
| 226 | /* cope with BootX not giving us phandles */ | ||
| 227 | ipar = dflt_interrupt_controller; | ||
| 228 | if (ipar == NULL) { | ||
| 229 | printk("oops, no int parent %x in map of %s\n", | ||
| 230 | imap[-1], p->full_name); | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | /* find the parent's # addr and intr cells */ | ||
| 234 | ip = (unsigned int *) | ||
| 235 | get_property(ipar, "#interrupt-cells", NULL); | ||
| 236 | if (ip == NULL) { | ||
| 237 | printk("oops, no #interrupt-cells on %s\n", | ||
| 238 | ipar->full_name); | ||
| 239 | return 0; | ||
| 240 | } | ||
| 241 | newintrc = *ip; | ||
| 242 | ip = (unsigned int *) | ||
| 243 | get_property(ipar, "#address-cells", NULL); | ||
| 244 | newaddrc = (ip == NULL)? 0: *ip; | ||
| 245 | imap += newaddrc + newintrc; | ||
| 246 | imaplen -= newaddrc + newintrc; | ||
| 247 | } | ||
| 248 | if (imaplen < 0) { | ||
| 249 | printk("oops, error decoding int-map on %s, len=%d\n", | ||
| 250 | p->full_name, imaplen); | ||
| 251 | return 0; | ||
| 252 | } | ||
| 253 | if (!match) { | ||
| 254 | #ifdef DEBUG_IRQ | ||
| 255 | printk("oops, no match in %s int-map for %s\n", | ||
| 256 | p->full_name, np->full_name); | ||
| 257 | #endif | ||
| 258 | return 0; | ||
| 259 | } | ||
| 260 | p = ipar; | ||
| 261 | naddrc = newaddrc; | ||
| 262 | nintrc = newintrc; | ||
| 263 | ints = imap - nintrc; | ||
| 264 | reg = ints - naddrc; | ||
| 265 | } | ||
| 266 | if (p == NULL) { | ||
| 267 | #ifdef DEBUG_IRQ | ||
| 268 | printk("hmmm, int tree for %s doesn't have ctrler\n", | ||
| 269 | np->full_name); | ||
| 270 | #endif | ||
| 271 | return 0; | ||
| 272 | } | ||
| 273 | *irq = ints; | ||
| 274 | *ictrler = p; | ||
| 275 | return nintrc; | ||
| 276 | } | ||
| 277 | |||
| 278 | static unsigned char map_isa_senses[4] = { | ||
| 279 | IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE, | ||
| 280 | IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE, | ||
| 281 | IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE, | ||
| 282 | IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE | ||
| 283 | }; | ||
| 284 | |||
| 285 | static unsigned char map_mpic_senses[4] = { | ||
| 286 | IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE, | ||
| 287 | IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE, | ||
| 288 | /* 2 seems to be used for the 8259 cascade... */ | ||
| 289 | IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE, | ||
| 290 | IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE, | ||
| 291 | }; | ||
| 292 | |||
| 293 | static int __devinit finish_node_interrupts(struct device_node *np, | ||
| 294 | unsigned long *mem_start, | ||
| 295 | int measure_only) | ||
| 296 | { | ||
| 297 | unsigned int *ints; | ||
| 298 | int intlen, intrcells, intrcount; | ||
| 299 | int i, j, n, sense; | ||
| 300 | unsigned int *irq, virq; | ||
| 301 | struct device_node *ic; | ||
| 302 | int trace = 0; | ||
| 303 | |||
| 304 | //#define TRACE(fmt...) do { if (trace) { printk(fmt); mdelay(1000); } } while(0) | ||
| 305 | #define TRACE(fmt...) | ||
| 306 | |||
| 307 | if (!strcmp(np->name, "smu-doorbell")) | ||
| 308 | trace = 1; | ||
| 309 | |||
| 310 | TRACE("Finishing SMU doorbell ! num_interrupt_controllers = %d\n", | ||
| 311 | num_interrupt_controllers); | ||
| 312 | |||
| 313 | if (num_interrupt_controllers == 0) { | ||
| 314 | /* | ||
| 315 | * Old machines just have a list of interrupt numbers | ||
| 316 | * and no interrupt-controller nodes. | ||
| 317 | */ | ||
| 318 | ints = (unsigned int *) get_property(np, "AAPL,interrupts", | ||
| 319 | &intlen); | ||
| 320 | /* XXX old interpret_pci_props looked in parent too */ | ||
| 321 | /* XXX old interpret_macio_props looked for interrupts | ||
| 322 | before AAPL,interrupts */ | ||
| 323 | if (ints == NULL) | ||
| 324 | ints = (unsigned int *) get_property(np, "interrupts", | ||
| 325 | &intlen); | ||
| 326 | if (ints == NULL) | ||
| 327 | return 0; | ||
| 328 | |||
| 329 | np->n_intrs = intlen / sizeof(unsigned int); | ||
| 330 | np->intrs = prom_alloc(np->n_intrs * sizeof(np->intrs[0]), | ||
| 331 | mem_start); | ||
| 332 | if (!np->intrs) | ||
| 333 | return -ENOMEM; | ||
| 334 | if (measure_only) | ||
| 335 | return 0; | ||
| 336 | |||
| 337 | for (i = 0; i < np->n_intrs; ++i) { | ||
| 338 | np->intrs[i].line = *ints++; | ||
| 339 | np->intrs[i].sense = IRQ_SENSE_LEVEL | ||
| 340 | | IRQ_POLARITY_NEGATIVE; | ||
| 341 | } | ||
| 342 | return 0; | ||
| 343 | } | ||
| 344 | |||
| 345 | ints = (unsigned int *) get_property(np, "interrupts", &intlen); | ||
| 346 | TRACE("ints=%p, intlen=%d\n", ints, intlen); | ||
| 347 | if (ints == NULL) | ||
| 348 | return 0; | ||
| 349 | intrcells = prom_n_intr_cells(np); | ||
| 350 | intlen /= intrcells * sizeof(unsigned int); | ||
| 351 | TRACE("intrcells=%d, new intlen=%d\n", intrcells, intlen); | ||
| 352 | np->intrs = prom_alloc(intlen * sizeof(*(np->intrs)), mem_start); | ||
| 353 | if (!np->intrs) | ||
| 354 | return -ENOMEM; | ||
| 355 | |||
| 356 | if (measure_only) | ||
| 357 | return 0; | ||
| 358 | |||
| 359 | intrcount = 0; | ||
| 360 | for (i = 0; i < intlen; ++i, ints += intrcells) { | ||
| 361 | n = map_interrupt(&irq, &ic, np, ints, intrcells); | ||
| 362 | TRACE("map, irq=%d, ic=%p, n=%d\n", irq, ic, n); | ||
| 363 | if (n <= 0) | ||
| 364 | continue; | ||
| 365 | |||
| 366 | /* don't map IRQ numbers under a cascaded 8259 controller */ | ||
| 367 | if (ic && device_is_compatible(ic, "chrp,iic")) { | ||
| 368 | np->intrs[intrcount].line = irq[0]; | ||
| 369 | sense = (n > 1)? (irq[1] & 3): 3; | ||
| 370 | np->intrs[intrcount].sense = map_isa_senses[sense]; | ||
| 371 | } else { | ||
| 372 | virq = virt_irq_create_mapping(irq[0]); | ||
| 373 | TRACE("virq=%d\n", virq); | ||
| 374 | #ifdef CONFIG_PPC64 | ||
| 375 | if (virq == NO_IRQ) { | ||
| 376 | printk(KERN_CRIT "Could not allocate interrupt" | ||
| 377 | " number for %s\n", np->full_name); | ||
| 378 | continue; | ||
| 379 | } | ||
| 380 | #endif | ||
| 381 | np->intrs[intrcount].line = irq_offset_up(virq); | ||
| 382 | sense = (n > 1)? (irq[1] & 3): 1; | ||
| 383 | |||
| 384 | /* Apple uses bits in there in a different way, let's | ||
| 385 | * only keep the real sense bit on macs | ||
| 386 | */ | ||
| 387 | if (machine_is(powermac)) | ||
| 388 | sense &= 0x1; | ||
| 389 | np->intrs[intrcount].sense = map_mpic_senses[sense]; | ||
| 390 | } | ||
| 391 | |||
| 392 | #ifdef CONFIG_PPC64 | ||
| 393 | /* We offset irq numbers for the u3 MPIC by 128 in PowerMac */ | ||
| 394 | if (machine_is(powermac) && ic && ic->parent) { | ||
| 395 | char *name = get_property(ic->parent, "name", NULL); | ||
| 396 | if (name && !strcmp(name, "u3")) | ||
| 397 | np->intrs[intrcount].line += 128; | ||
| 398 | else if (!(name && (!strcmp(name, "mac-io") || | ||
| 399 | !strcmp(name, "u4")))) | ||
| 400 | /* ignore other cascaded controllers, such as | ||
| 401 | the k2-sata-root */ | ||
| 402 | break; | ||
| 403 | } | ||
| 404 | #endif /* CONFIG_PPC64 */ | ||
| 405 | if (n > 2) { | ||
| 406 | printk("hmmm, got %d intr cells for %s:", n, | ||
| 407 | np->full_name); | ||
| 408 | for (j = 0; j < n; ++j) | ||
| 409 | printk(" %d", irq[j]); | ||
| 410 | printk("\n"); | ||
| 411 | } | ||
| 412 | ++intrcount; | ||
| 413 | } | ||
| 414 | np->n_intrs = intrcount; | ||
| 415 | |||
| 416 | return 0; | ||
| 417 | } | ||
| 418 | |||
| 419 | static int __devinit finish_node(struct device_node *np, | ||
| 420 | unsigned long *mem_start, | ||
| 421 | int measure_only) | ||
| 422 | { | ||
| 423 | struct device_node *child; | ||
| 424 | int rc = 0; | ||
| 425 | |||
| 426 | rc = finish_node_interrupts(np, mem_start, measure_only); | ||
| 427 | if (rc) | ||
| 428 | goto out; | ||
| 429 | |||
| 430 | for (child = np->child; child != NULL; child = child->sibling) { | ||
| 431 | rc = finish_node(child, mem_start, measure_only); | ||
| 432 | if (rc) | ||
| 433 | goto out; | ||
| 434 | } | ||
| 435 | out: | ||
| 436 | return rc; | ||
| 437 | } | ||
| 438 | |||
| 439 | static void __init scan_interrupt_controllers(void) | ||
| 440 | { | ||
| 441 | struct device_node *np; | ||
| 442 | int n = 0; | ||
| 443 | char *name, *ic; | ||
| 444 | int iclen; | ||
| 445 | |||
| 446 | for (np = allnodes; np != NULL; np = np->allnext) { | ||
| 447 | ic = get_property(np, "interrupt-controller", &iclen); | ||
| 448 | name = get_property(np, "name", NULL); | ||
| 449 | /* checking iclen makes sure we don't get a false | ||
| 450 | match on /chosen.interrupt_controller */ | ||
| 451 | if ((name != NULL | ||
| 452 | && strcmp(name, "interrupt-controller") == 0) | ||
| 453 | || (ic != NULL && iclen == 0 | ||
| 454 | && strcmp(name, "AppleKiwi"))) { | ||
| 455 | if (n == 0) | ||
| 456 | dflt_interrupt_controller = np; | ||
| 457 | ++n; | ||
| 458 | } | ||
| 459 | } | ||
| 460 | num_interrupt_controllers = n; | ||
| 461 | } | ||
| 462 | |||
| 463 | /** | ||
| 464 | * finish_device_tree is called once things are running normally | ||
| 465 | * (i.e. with text and data mapped to the address they were linked at). | ||
| 466 | * It traverses the device tree and fills in some of the additional, | ||
| 467 | * fields in each node like {n_}addrs and {n_}intrs, the virt interrupt | ||
| 468 | * mapping is also initialized at this point. | ||
| 469 | */ | ||
| 470 | void __init finish_device_tree(void) | ||
| 471 | { | ||
| 472 | unsigned long start, end, size = 0; | ||
| 473 | |||
| 474 | DBG(" -> finish_device_tree\n"); | ||
| 475 | |||
| 476 | #ifdef CONFIG_PPC64 | ||
| 477 | /* Initialize virtual IRQ map */ | ||
| 478 | virt_irq_init(); | ||
| 479 | #endif | ||
| 480 | scan_interrupt_controllers(); | ||
| 481 | |||
| 482 | /* | ||
| 483 | * Finish device-tree (pre-parsing some properties etc...) | ||
| 484 | * We do this in 2 passes. One with "measure_only" set, which | ||
| 485 | * will only measure the amount of memory needed, then we can | ||
| 486 | * allocate that memory, and call finish_node again. However, | ||
| 487 | * we must be careful as most routines will fail nowadays when | ||
| 488 | * prom_alloc() returns 0, so we must make sure our first pass | ||
| 489 | * doesn't start at 0. We pre-initialize size to 16 for that | ||
| 490 | * reason and then remove those additional 16 bytes | ||
| 491 | */ | ||
| 492 | size = 16; | ||
| 493 | finish_node(allnodes, &size, 1); | ||
| 494 | size -= 16; | ||
| 495 | |||
| 496 | if (0 == size) | ||
| 497 | end = start = 0; | ||
| 498 | else | ||
| 499 | end = start = (unsigned long)__va(lmb_alloc(size, 128)); | ||
| 500 | |||
| 501 | finish_node(allnodes, &end, 0); | ||
| 502 | BUG_ON(end != start + size); | ||
| 503 | |||
| 504 | DBG(" <- finish_device_tree\n"); | ||
| 505 | } | ||
| 506 | |||
| 507 | static inline char *find_flat_dt_string(u32 offset) | 90 | static inline char *find_flat_dt_string(u32 offset) |
| 508 | { | 91 | { |
| 509 | return ((char *)initial_boot_params) + | 92 | return ((char *)initial_boot_params) + |
| @@ -1389,27 +972,6 @@ prom_n_size_cells(struct device_node* np) | |||
| 1389 | EXPORT_SYMBOL(prom_n_size_cells); | 972 | EXPORT_SYMBOL(prom_n_size_cells); |
| 1390 | 973 | ||
| 1391 | /** | 974 | /** |
| 1392 | * Work out the sense (active-low level / active-high edge) | ||
| 1393 | * of each interrupt from the device tree. | ||
| 1394 | */ | ||
| 1395 | void __init prom_get_irq_senses(unsigned char *senses, int off, int max) | ||
| 1396 | { | ||
| 1397 | struct device_node *np; | ||
| 1398 | int i, j; | ||
| 1399 | |||
| 1400 | /* default to level-triggered */ | ||
| 1401 | memset(senses, IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE, max - off); | ||
| 1402 | |||
| 1403 | for (np = allnodes; np != 0; np = np->allnext) { | ||
| 1404 | for (j = 0; j < np->n_intrs; j++) { | ||
| 1405 | i = np->intrs[j].line; | ||
| 1406 | if (i >= off && i < max) | ||
| 1407 | senses[i-off] = np->intrs[j].sense; | ||
| 1408 | } | ||
| 1409 | } | ||
| 1410 | } | ||
| 1411 | |||
| 1412 | /** | ||
| 1413 | * Construct and return a list of the device_nodes with a given name. | 975 | * Construct and return a list of the device_nodes with a given name. |
| 1414 | */ | 976 | */ |
| 1415 | struct device_node *find_devices(const char *name) | 977 | struct device_node *find_devices(const char *name) |
| @@ -1808,7 +1370,6 @@ static void of_node_release(struct kref *kref) | |||
| 1808 | node->deadprops = NULL; | 1370 | node->deadprops = NULL; |
| 1809 | } | 1371 | } |
| 1810 | } | 1372 | } |
| 1811 | kfree(node->intrs); | ||
| 1812 | kfree(node->full_name); | 1373 | kfree(node->full_name); |
| 1813 | kfree(node->data); | 1374 | kfree(node->data); |
| 1814 | kfree(node); | 1375 | kfree(node); |
| @@ -1881,13 +1442,7 @@ void of_detach_node(const struct device_node *np) | |||
| 1881 | #ifdef CONFIG_PPC_PSERIES | 1442 | #ifdef CONFIG_PPC_PSERIES |
| 1882 | /* | 1443 | /* |
| 1883 | * Fix up the uninitialized fields in a new device node: | 1444 | * Fix up the uninitialized fields in a new device node: |
| 1884 | * name, type, n_addrs, addrs, n_intrs, intrs, and pci-specific fields | 1445 | * name, type and pci-specific fields |
| 1885 | * | ||
| 1886 | * A lot of boot-time code is duplicated here, because functions such | ||
| 1887 | * as finish_node_interrupts, interpret_pci_props, etc. cannot use the | ||
| 1888 | * slab allocator. | ||
| 1889 | * | ||
| 1890 | * This should probably be split up into smaller chunks. | ||
| 1891 | */ | 1446 | */ |
| 1892 | 1447 | ||
| 1893 | static int of_finish_dynamic_node(struct device_node *node) | 1448 | static int of_finish_dynamic_node(struct device_node *node) |
| @@ -1928,8 +1483,6 @@ static int prom_reconfig_notifier(struct notifier_block *nb, | |||
| 1928 | switch (action) { | 1483 | switch (action) { |
| 1929 | case PSERIES_RECONFIG_ADD: | 1484 | case PSERIES_RECONFIG_ADD: |
| 1930 | err = of_finish_dynamic_node(node); | 1485 | err = of_finish_dynamic_node(node); |
| 1931 | if (!err) | ||
| 1932 | finish_node(node, NULL, 0); | ||
| 1933 | if (err < 0) { | 1486 | if (err < 0) { |
| 1934 | printk(KERN_ERR "finish_node returned %d\n", err); | 1487 | printk(KERN_ERR "finish_node returned %d\n", err); |
| 1935 | err = NOTIFY_BAD; | 1488 | err = NOTIFY_BAD; |
| @@ -1975,8 +1528,7 @@ struct property *of_find_property(struct device_node *np, const char *name, | |||
| 1975 | * Find a property with a given name for a given node | 1528 | * Find a property with a given name for a given node |
| 1976 | * and return the value. | 1529 | * and return the value. |
| 1977 | */ | 1530 | */ |
| 1978 | unsigned char *get_property(struct device_node *np, const char *name, | 1531 | void *get_property(struct device_node *np, const char *name, int *lenp) |
| 1979 | int *lenp) | ||
| 1980 | { | 1532 | { |
| 1981 | struct property *pp = of_find_property(np,name,lenp); | 1533 | struct property *pp = of_find_property(np,name,lenp); |
| 1982 | return pp ? pp->value : NULL; | 1534 | return pp ? pp->value : NULL; |
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 1e95a9f8cda1..ebd501a59abd 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c | |||
| @@ -1990,12 +1990,22 @@ static void __init flatten_device_tree(void) | |||
| 1990 | static void __init fixup_device_tree_maple(void) | 1990 | static void __init fixup_device_tree_maple(void) |
| 1991 | { | 1991 | { |
| 1992 | phandle isa; | 1992 | phandle isa; |
| 1993 | u32 rloc = 0x01002000; /* IO space; PCI device = 4 */ | ||
| 1993 | u32 isa_ranges[6]; | 1994 | u32 isa_ranges[6]; |
| 1994 | 1995 | char *name; | |
| 1995 | isa = call_prom("finddevice", 1, 1, ADDR("/ht@0/isa@4")); | 1996 | |
| 1997 | name = "/ht@0/isa@4"; | ||
| 1998 | isa = call_prom("finddevice", 1, 1, ADDR(name)); | ||
| 1999 | if (!PHANDLE_VALID(isa)) { | ||
| 2000 | name = "/ht@0/isa@6"; | ||
| 2001 | isa = call_prom("finddevice", 1, 1, ADDR(name)); | ||
| 2002 | rloc = 0x01003000; /* IO space; PCI device = 6 */ | ||
| 2003 | } | ||
| 1996 | if (!PHANDLE_VALID(isa)) | 2004 | if (!PHANDLE_VALID(isa)) |
| 1997 | return; | 2005 | return; |
| 1998 | 2006 | ||
| 2007 | if (prom_getproplen(isa, "ranges") != 12) | ||
| 2008 | return; | ||
| 1999 | if (prom_getprop(isa, "ranges", isa_ranges, sizeof(isa_ranges)) | 2009 | if (prom_getprop(isa, "ranges", isa_ranges, sizeof(isa_ranges)) |
| 2000 | == PROM_ERROR) | 2010 | == PROM_ERROR) |
| 2001 | return; | 2011 | return; |
| @@ -2005,15 +2015,15 @@ static void __init fixup_device_tree_maple(void) | |||
| 2005 | isa_ranges[2] != 0x00010000) | 2015 | isa_ranges[2] != 0x00010000) |
| 2006 | return; | 2016 | return; |
| 2007 | 2017 | ||
| 2008 | prom_printf("fixing up bogus ISA range on Maple...\n"); | 2018 | prom_printf("Fixing up bogus ISA range on Maple/Apache...\n"); |
| 2009 | 2019 | ||
| 2010 | isa_ranges[0] = 0x1; | 2020 | isa_ranges[0] = 0x1; |
| 2011 | isa_ranges[1] = 0x0; | 2021 | isa_ranges[1] = 0x0; |
| 2012 | isa_ranges[2] = 0x01002000; /* IO space; PCI device = 4 */ | 2022 | isa_ranges[2] = rloc; |
| 2013 | isa_ranges[3] = 0x0; | 2023 | isa_ranges[3] = 0x0; |
| 2014 | isa_ranges[4] = 0x0; | 2024 | isa_ranges[4] = 0x0; |
| 2015 | isa_ranges[5] = 0x00010000; | 2025 | isa_ranges[5] = 0x00010000; |
| 2016 | prom_setprop(isa, "/ht@0/isa@4", "ranges", | 2026 | prom_setprop(isa, name, "ranges", |
| 2017 | isa_ranges, sizeof(isa_ranges)); | 2027 | isa_ranges, sizeof(isa_ranges)); |
| 2018 | } | 2028 | } |
| 2019 | #else | 2029 | #else |
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c index 45df420383cc..21009b1f7869 100644 --- a/arch/powerpc/kernel/prom_parse.c +++ b/arch/powerpc/kernel/prom_parse.c | |||
| @@ -38,14 +38,6 @@ static void of_dump_addr(const char *s, u32 *addr, int na) | |||
| 38 | static void of_dump_addr(const char *s, u32 *addr, int na) { } | 38 | static void of_dump_addr(const char *s, u32 *addr, int na) { } |
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | /* Read a big address */ | ||
| 42 | static inline u64 of_read_addr(u32 *cell, int size) | ||
| 43 | { | ||
| 44 | u64 r = 0; | ||
| 45 | while (size--) | ||
| 46 | r = (r << 32) | *(cell++); | ||
| 47 | return r; | ||
| 48 | } | ||
| 49 | 41 | ||
| 50 | /* Callbacks for bus specific translators */ | 42 | /* Callbacks for bus specific translators */ |
| 51 | struct of_bus { | 43 | struct of_bus { |
| @@ -77,9 +69,9 @@ static u64 of_bus_default_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
| 77 | { | 69 | { |
| 78 | u64 cp, s, da; | 70 | u64 cp, s, da; |
| 79 | 71 | ||
| 80 | cp = of_read_addr(range, na); | 72 | cp = of_read_number(range, na); |
| 81 | s = of_read_addr(range + na + pna, ns); | 73 | s = of_read_number(range + na + pna, ns); |
| 82 | da = of_read_addr(addr, na); | 74 | da = of_read_number(addr, na); |
| 83 | 75 | ||
| 84 | DBG("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n", | 76 | DBG("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n", |
| 85 | cp, s, da); | 77 | cp, s, da); |
| @@ -91,7 +83,7 @@ static u64 of_bus_default_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
| 91 | 83 | ||
| 92 | static int of_bus_default_translate(u32 *addr, u64 offset, int na) | 84 | static int of_bus_default_translate(u32 *addr, u64 offset, int na) |
| 93 | { | 85 | { |
| 94 | u64 a = of_read_addr(addr, na); | 86 | u64 a = of_read_number(addr, na); |
| 95 | memset(addr, 0, na * 4); | 87 | memset(addr, 0, na * 4); |
| 96 | a += offset; | 88 | a += offset; |
| 97 | if (na > 1) | 89 | if (na > 1) |
| @@ -135,9 +127,9 @@ static u64 of_bus_pci_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
| 135 | return OF_BAD_ADDR; | 127 | return OF_BAD_ADDR; |
| 136 | 128 | ||
| 137 | /* Read address values, skipping high cell */ | 129 | /* Read address values, skipping high cell */ |
| 138 | cp = of_read_addr(range + 1, na - 1); | 130 | cp = of_read_number(range + 1, na - 1); |
| 139 | s = of_read_addr(range + na + pna, ns); | 131 | s = of_read_number(range + na + pna, ns); |
| 140 | da = of_read_addr(addr + 1, na - 1); | 132 | da = of_read_number(addr + 1, na - 1); |
| 141 | 133 | ||
| 142 | DBG("OF: PCI map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da); | 134 | DBG("OF: PCI map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da); |
| 143 | 135 | ||
| @@ -195,9 +187,9 @@ static u64 of_bus_isa_map(u32 *addr, u32 *range, int na, int ns, int pna) | |||
| 195 | return OF_BAD_ADDR; | 187 | return OF_BAD_ADDR; |
| 196 | 188 | ||
| 197 | /* Read address values, skipping high cell */ | 189 | /* Read address values, skipping high cell */ |
| 198 | cp = of_read_addr(range + 1, na - 1); | 190 | cp = of_read_number(range + 1, na - 1); |
| 199 | s = of_read_addr(range + na + pna, ns); | 191 | s = of_read_number(range + na + pna, ns); |
| 200 | da = of_read_addr(addr + 1, na - 1); | 192 | da = of_read_number(addr + 1, na - 1); |
| 201 | 193 | ||
| 202 | DBG("OF: ISA map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da); | 194 | DBG("OF: ISA map, cp="PRu64", s="PRu64", da="PRu64"\n", cp, s, da); |
| 203 | 195 | ||
| @@ -295,7 +287,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, | |||
| 295 | */ | 287 | */ |
| 296 | ranges = (u32 *)get_property(parent, "ranges", &rlen); | 288 | ranges = (u32 *)get_property(parent, "ranges", &rlen); |
| 297 | if (ranges == NULL || rlen == 0) { | 289 | if (ranges == NULL || rlen == 0) { |
| 298 | offset = of_read_addr(addr, na); | 290 | offset = of_read_number(addr, na); |
| 299 | memset(addr, 0, pna * 4); | 291 | memset(addr, 0, pna * 4); |
| 300 | DBG("OF: no ranges, 1:1 translation\n"); | 292 | DBG("OF: no ranges, 1:1 translation\n"); |
| 301 | goto finish; | 293 | goto finish; |
| @@ -378,7 +370,7 @@ u64 of_translate_address(struct device_node *dev, u32 *in_addr) | |||
| 378 | /* If root, we have finished */ | 370 | /* If root, we have finished */ |
| 379 | if (parent == NULL) { | 371 | if (parent == NULL) { |
| 380 | DBG("OF: reached root node\n"); | 372 | DBG("OF: reached root node\n"); |
| 381 | result = of_read_addr(addr, na); | 373 | result = of_read_number(addr, na); |
| 382 | break; | 374 | break; |
| 383 | } | 375 | } |
| 384 | 376 | ||
| @@ -442,7 +434,7 @@ u32 *of_get_address(struct device_node *dev, int index, u64 *size, | |||
| 442 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) | 434 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) |
| 443 | if (i == index) { | 435 | if (i == index) { |
| 444 | if (size) | 436 | if (size) |
| 445 | *size = of_read_addr(prop + na, ns); | 437 | *size = of_read_number(prop + na, ns); |
| 446 | if (flags) | 438 | if (flags) |
| 447 | *flags = bus->get_flags(prop); | 439 | *flags = bus->get_flags(prop); |
| 448 | return prop; | 440 | return prop; |
| @@ -484,7 +476,7 @@ u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, | |||
| 484 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) | 476 | for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) |
| 485 | if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { | 477 | if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { |
| 486 | if (size) | 478 | if (size) |
| 487 | *size = of_read_addr(prop + na, ns); | 479 | *size = of_read_number(prop + na, ns); |
| 488 | if (flags) | 480 | if (flags) |
| 489 | *flags = bus->get_flags(prop); | 481 | *flags = bus->get_flags(prop); |
| 490 | return prop; | 482 | return prop; |
| @@ -565,11 +557,414 @@ void of_parse_dma_window(struct device_node *dn, unsigned char *dma_window_prop, | |||
| 565 | prop = get_property(dn, "#address-cells", NULL); | 557 | prop = get_property(dn, "#address-cells", NULL); |
| 566 | 558 | ||
| 567 | cells = prop ? *(u32 *)prop : prom_n_addr_cells(dn); | 559 | cells = prop ? *(u32 *)prop : prom_n_addr_cells(dn); |
| 568 | *phys = of_read_addr(dma_window, cells); | 560 | *phys = of_read_number(dma_window, cells); |
| 569 | 561 | ||
| 570 | dma_window += cells; | 562 | dma_window += cells; |
| 571 | 563 | ||
| 572 | prop = get_property(dn, "ibm,#dma-size-cells", NULL); | 564 | prop = get_property(dn, "ibm,#dma-size-cells", NULL); |
| 573 | cells = prop ? *(u32 *)prop : prom_n_size_cells(dn); | 565 | cells = prop ? *(u32 *)prop : prom_n_size_cells(dn); |
| 574 | *size = of_read_addr(dma_window, cells); | 566 | *size = of_read_number(dma_window, cells); |
| 567 | } | ||
| 568 | |||
| 569 | /* | ||
| 570 | * Interrupt remapper | ||
| 571 | */ | ||
| 572 | |||
| 573 | static unsigned int of_irq_workarounds; | ||
| 574 | static struct device_node *of_irq_dflt_pic; | ||
| 575 | |||
| 576 | static struct device_node *of_irq_find_parent(struct device_node *child) | ||
| 577 | { | ||
| 578 | struct device_node *p; | ||
| 579 | phandle *parp; | ||
| 580 | |||
| 581 | if (!of_node_get(child)) | ||
| 582 | return NULL; | ||
| 583 | |||
| 584 | do { | ||
| 585 | parp = (phandle *)get_property(child, "interrupt-parent", NULL); | ||
| 586 | if (parp == NULL) | ||
| 587 | p = of_get_parent(child); | ||
| 588 | else { | ||
| 589 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
| 590 | p = of_node_get(of_irq_dflt_pic); | ||
| 591 | else | ||
| 592 | p = of_find_node_by_phandle(*parp); | ||
| 593 | } | ||
| 594 | of_node_put(child); | ||
| 595 | child = p; | ||
| 596 | } while (p && get_property(p, "#interrupt-cells", NULL) == NULL); | ||
| 597 | |||
| 598 | return p; | ||
| 599 | } | ||
| 600 | |||
| 601 | static u8 of_irq_pci_swizzle(u8 slot, u8 pin) | ||
| 602 | { | ||
| 603 | return (((pin - 1) + slot) % 4) + 1; | ||
| 575 | } | 604 | } |
| 605 | |||
| 606 | /* This doesn't need to be called if you don't have any special workaround | ||
| 607 | * flags to pass | ||
| 608 | */ | ||
| 609 | void of_irq_map_init(unsigned int flags) | ||
| 610 | { | ||
| 611 | of_irq_workarounds = flags; | ||
| 612 | |||
| 613 | /* OldWorld, don't bother looking at other things */ | ||
| 614 | if (flags & OF_IMAP_OLDWORLD_MAC) | ||
| 615 | return; | ||
| 616 | |||
| 617 | /* If we don't have phandles, let's try to locate a default interrupt | ||
| 618 | * controller (happens when booting with BootX). We do a first match | ||
| 619 | * here, hopefully, that only ever happens on machines with one | ||
| 620 | * controller. | ||
| 621 | */ | ||
| 622 | if (flags & OF_IMAP_NO_PHANDLE) { | ||
| 623 | struct device_node *np; | ||
| 624 | |||
| 625 | for(np = NULL; (np = of_find_all_nodes(np)) != NULL;) { | ||
| 626 | if (get_property(np, "interrupt-controller", NULL) | ||
| 627 | == NULL) | ||
| 628 | continue; | ||
| 629 | /* Skip /chosen/interrupt-controller */ | ||
| 630 | if (strcmp(np->name, "chosen") == 0) | ||
| 631 | continue; | ||
| 632 | /* It seems like at least one person on this planet wants | ||
| 633 | * to use BootX on a machine with an AppleKiwi controller | ||
| 634 | * which happens to pretend to be an interrupt | ||
| 635 | * controller too. | ||
| 636 | */ | ||
| 637 | if (strcmp(np->name, "AppleKiwi") == 0) | ||
| 638 | continue; | ||
| 639 | /* I think we found one ! */ | ||
| 640 | of_irq_dflt_pic = np; | ||
| 641 | break; | ||
| 642 | } | ||
| 643 | } | ||
| 644 | |||
| 645 | } | ||
| 646 | |||
| 647 | int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr, | ||
| 648 | struct of_irq *out_irq) | ||
| 649 | { | ||
| 650 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | ||
| 651 | u32 *tmp, *imap, *imask; | ||
| 652 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | ||
| 653 | int imaplen, match, i; | ||
| 654 | |||
| 655 | ipar = of_node_get(parent); | ||
| 656 | |||
| 657 | /* First get the #interrupt-cells property of the current cursor | ||
| 658 | * that tells us how to interpret the passed-in intspec. If there | ||
| 659 | * is none, we are nice and just walk up the tree | ||
| 660 | */ | ||
| 661 | do { | ||
| 662 | tmp = (u32 *)get_property(ipar, "#interrupt-cells", NULL); | ||
| 663 | if (tmp != NULL) { | ||
| 664 | intsize = *tmp; | ||
| 665 | break; | ||
| 666 | } | ||
| 667 | tnode = ipar; | ||
| 668 | ipar = of_irq_find_parent(ipar); | ||
| 669 | of_node_put(tnode); | ||
| 670 | } while (ipar); | ||
| 671 | if (ipar == NULL) { | ||
| 672 | DBG(" -> no parent found !\n"); | ||
| 673 | goto fail; | ||
| 674 | } | ||
| 675 | |||
| 676 | DBG("of_irq_map_raw: ipar=%s, size=%d\n", ipar->full_name, intsize); | ||
| 677 | |||
| 678 | /* Look for this #address-cells. We have to implement the old linux | ||
| 679 | * trick of looking for the parent here as some device-trees rely on it | ||
| 680 | */ | ||
| 681 | old = of_node_get(ipar); | ||
| 682 | do { | ||
| 683 | tmp = (u32 *)get_property(old, "#address-cells", NULL); | ||
| 684 | tnode = of_get_parent(old); | ||
| 685 | of_node_put(old); | ||
| 686 | old = tnode; | ||
| 687 | } while(old && tmp == NULL); | ||
| 688 | of_node_put(old); | ||
| 689 | old = NULL; | ||
| 690 | addrsize = (tmp == NULL) ? 2 : *tmp; | ||
| 691 | |||
| 692 | DBG(" -> addrsize=%d\n", addrsize); | ||
| 693 | |||
| 694 | /* Now start the actual "proper" walk of the interrupt tree */ | ||
| 695 | while (ipar != NULL) { | ||
| 696 | /* Now check if cursor is an interrupt-controller and if it is | ||
| 697 | * then we are done | ||
| 698 | */ | ||
| 699 | if (get_property(ipar, "interrupt-controller", NULL) != NULL) { | ||
| 700 | DBG(" -> got it !\n"); | ||
| 701 | memcpy(out_irq->specifier, intspec, | ||
| 702 | intsize * sizeof(u32)); | ||
| 703 | out_irq->size = intsize; | ||
| 704 | out_irq->controller = ipar; | ||
| 705 | of_node_put(old); | ||
| 706 | return 0; | ||
| 707 | } | ||
| 708 | |||
| 709 | /* Now look for an interrupt-map */ | ||
| 710 | imap = (u32 *)get_property(ipar, "interrupt-map", &imaplen); | ||
| 711 | /* No interrupt map, check for an interrupt parent */ | ||
| 712 | if (imap == NULL) { | ||
| 713 | DBG(" -> no map, getting parent\n"); | ||
| 714 | newpar = of_irq_find_parent(ipar); | ||
| 715 | goto skiplevel; | ||
| 716 | } | ||
| 717 | imaplen /= sizeof(u32); | ||
| 718 | |||
| 719 | /* Look for a mask */ | ||
| 720 | imask = (u32 *)get_property(ipar, "interrupt-map-mask", NULL); | ||
| 721 | |||
| 722 | /* If we were passed no "reg" property and we attempt to parse | ||
| 723 | * an interrupt-map, then #address-cells must be 0. | ||
| 724 | * Fail if it's not. | ||
| 725 | */ | ||
| 726 | if (addr == NULL && addrsize != 0) { | ||
| 727 | DBG(" -> no reg passed in when needed !\n"); | ||
| 728 | goto fail; | ||
| 729 | } | ||
| 730 | |||
| 731 | /* Parse interrupt-map */ | ||
| 732 | match = 0; | ||
| 733 | while (imaplen > (addrsize + intsize + 1) && !match) { | ||
| 734 | /* Compare specifiers */ | ||
| 735 | match = 1; | ||
| 736 | for (i = 0; i < addrsize && match; ++i) { | ||
| 737 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
| 738 | match = ((addr[i] ^ imap[i]) & mask) == 0; | ||
| 739 | } | ||
| 740 | for (; i < (addrsize + intsize) && match; ++i) { | ||
| 741 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
| 742 | match = | ||
| 743 | ((intspec[i-addrsize] ^ imap[i]) & mask) == 0; | ||
| 744 | } | ||
| 745 | imap += addrsize + intsize; | ||
| 746 | imaplen -= addrsize + intsize; | ||
| 747 | |||
| 748 | DBG(" -> match=%d (imaplen=%d)\n", match, imaplen); | ||
| 749 | |||
| 750 | /* Get the interrupt parent */ | ||
| 751 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
| 752 | newpar = of_node_get(of_irq_dflt_pic); | ||
| 753 | else | ||
| 754 | newpar = of_find_node_by_phandle((phandle)*imap); | ||
| 755 | imap++; | ||
| 756 | --imaplen; | ||
| 757 | |||
| 758 | /* Check if not found */ | ||
| 759 | if (newpar == NULL) { | ||
| 760 | DBG(" -> imap parent not found !\n"); | ||
| 761 | goto fail; | ||
| 762 | } | ||
| 763 | |||
| 764 | /* Get #interrupt-cells and #address-cells of new | ||
| 765 | * parent | ||
| 766 | */ | ||
| 767 | tmp = (u32 *)get_property(newpar, "#interrupt-cells", | ||
| 768 | NULL); | ||
| 769 | if (tmp == NULL) { | ||
| 770 | DBG(" -> parent lacks #interrupt-cells !\n"); | ||
| 771 | goto fail; | ||
| 772 | } | ||
| 773 | newintsize = *tmp; | ||
| 774 | tmp = (u32 *)get_property(newpar, "#address-cells", | ||
| 775 | NULL); | ||
| 776 | newaddrsize = (tmp == NULL) ? 0 : *tmp; | ||
| 777 | |||
| 778 | DBG(" -> newintsize=%d, newaddrsize=%d\n", | ||
| 779 | newintsize, newaddrsize); | ||
| 780 | |||
| 781 | /* Check for malformed properties */ | ||
| 782 | if (imaplen < (newaddrsize + newintsize)) | ||
| 783 | goto fail; | ||
| 784 | |||
| 785 | imap += newaddrsize + newintsize; | ||
| 786 | imaplen -= newaddrsize + newintsize; | ||
| 787 | |||
| 788 | DBG(" -> imaplen=%d\n", imaplen); | ||
| 789 | } | ||
| 790 | if (!match) | ||
| 791 | goto fail; | ||
| 792 | |||
| 793 | of_node_put(old); | ||
| 794 | old = of_node_get(newpar); | ||
| 795 | addrsize = newaddrsize; | ||
| 796 | intsize = newintsize; | ||
| 797 | intspec = imap - intsize; | ||
| 798 | addr = intspec - addrsize; | ||
| 799 | |||
| 800 | skiplevel: | ||
| 801 | /* Iterate again with new parent */ | ||
| 802 | DBG(" -> new parent: %s\n", newpar ? newpar->full_name : "<>"); | ||
| 803 | of_node_put(ipar); | ||
| 804 | ipar = newpar; | ||
| 805 | newpar = NULL; | ||
| 806 | } | ||
| 807 | fail: | ||
| 808 | of_node_put(ipar); | ||
| 809 | of_node_put(old); | ||
| 810 | of_node_put(newpar); | ||
| 811 | |||
| 812 | return -EINVAL; | ||
| 813 | } | ||
| 814 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
| 815 | |||
| 816 | #if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) | ||
| 817 | static int of_irq_map_oldworld(struct device_node *device, int index, | ||
| 818 | struct of_irq *out_irq) | ||
| 819 | { | ||
| 820 | u32 *ints; | ||
| 821 | int intlen; | ||
| 822 | |||
| 823 | /* | ||
| 824 | * Old machines just have a list of interrupt numbers | ||
| 825 | * and no interrupt-controller nodes. | ||
| 826 | */ | ||
| 827 | ints = (u32 *) get_property(device, "AAPL,interrupts", &intlen); | ||
| 828 | if (ints == NULL) | ||
| 829 | return -EINVAL; | ||
| 830 | intlen /= sizeof(u32); | ||
| 831 | |||
| 832 | if (index >= intlen) | ||
| 833 | return -EINVAL; | ||
| 834 | |||
| 835 | out_irq->controller = NULL; | ||
| 836 | out_irq->specifier[0] = ints[index]; | ||
| 837 | out_irq->size = 1; | ||
| 838 | |||
| 839 | return 0; | ||
| 840 | } | ||
| 841 | #else /* defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) */ | ||
| 842 | static int of_irq_map_oldworld(struct device_node *device, int index, | ||
| 843 | struct of_irq *out_irq) | ||
| 844 | { | ||
| 845 | return -EINVAL; | ||
| 846 | } | ||
| 847 | #endif /* !(defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)) */ | ||
| 848 | |||
| 849 | int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) | ||
| 850 | { | ||
| 851 | struct device_node *p; | ||
| 852 | u32 *intspec, *tmp, intsize, intlen, *addr; | ||
| 853 | int res; | ||
| 854 | |||
| 855 | DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index); | ||
| 856 | |||
| 857 | /* OldWorld mac stuff is "special", handle out of line */ | ||
| 858 | if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC) | ||
| 859 | return of_irq_map_oldworld(device, index, out_irq); | ||
| 860 | |||
| 861 | /* Get the interrupts property */ | ||
| 862 | intspec = (u32 *)get_property(device, "interrupts", &intlen); | ||
| 863 | if (intspec == NULL) | ||
| 864 | return -EINVAL; | ||
| 865 | intlen /= sizeof(u32); | ||
| 866 | |||
| 867 | /* Get the reg property (if any) */ | ||
| 868 | addr = (u32 *)get_property(device, "reg", NULL); | ||
| 869 | |||
| 870 | /* Look for the interrupt parent. */ | ||
| 871 | p = of_irq_find_parent(device); | ||
| 872 | if (p == NULL) | ||
| 873 | return -EINVAL; | ||
| 874 | |||
| 875 | /* Get size of interrupt specifier */ | ||
| 876 | tmp = (u32 *)get_property(p, "#interrupt-cells", NULL); | ||
| 877 | if (tmp == NULL) { | ||
| 878 | of_node_put(p); | ||
| 879 | return -EINVAL; | ||
| 880 | } | ||
| 881 | intsize = *tmp; | ||
| 882 | |||
| 883 | /* Check index */ | ||
| 884 | if (index * intsize >= intlen) | ||
| 885 | return -EINVAL; | ||
| 886 | |||
| 887 | /* Get new specifier and map it */ | ||
| 888 | res = of_irq_map_raw(p, intspec + index * intsize, addr, out_irq); | ||
| 889 | of_node_put(p); | ||
| 890 | return res; | ||
| 891 | } | ||
| 892 | EXPORT_SYMBOL_GPL(of_irq_map_one); | ||
| 893 | |||
| 894 | int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq) | ||
| 895 | { | ||
| 896 | struct device_node *dn, *ppnode; | ||
| 897 | struct pci_dev *ppdev; | ||
| 898 | u32 lspec; | ||
| 899 | u32 laddr[3]; | ||
| 900 | u8 pin; | ||
| 901 | int rc; | ||
| 902 | |||
| 903 | /* Check if we have a device node, if yes, fallback to standard OF | ||
| 904 | * parsing | ||
| 905 | */ | ||
| 906 | dn = pci_device_to_OF_node(pdev); | ||
| 907 | if (dn) | ||
| 908 | return of_irq_map_one(dn, 0, out_irq); | ||
| 909 | |||
| 910 | /* Ok, we don't, time to have fun. Let's start by building up an | ||
| 911 | * interrupt spec. we assume #interrupt-cells is 1, which is standard | ||
| 912 | * for PCI. If you do different, then don't use that routine. | ||
| 913 | */ | ||
| 914 | rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin); | ||
| 915 | if (rc != 0) | ||
| 916 | return rc; | ||
| 917 | /* No pin, exit */ | ||
| 918 | if (pin == 0) | ||
| 919 | return -ENODEV; | ||
| 920 | |||
| 921 | /* Now we walk up the PCI tree */ | ||
| 922 | lspec = pin; | ||
| 923 | for (;;) { | ||
| 924 | /* Get the pci_dev of our parent */ | ||
| 925 | ppdev = pdev->bus->self; | ||
| 926 | |||
| 927 | /* Ouch, it's a host bridge... */ | ||
| 928 | if (ppdev == NULL) { | ||
| 929 | #ifdef CONFIG_PPC64 | ||
| 930 | ppnode = pci_bus_to_OF_node(pdev->bus); | ||
| 931 | #else | ||
| 932 | struct pci_controller *host; | ||
| 933 | host = pci_bus_to_host(pdev->bus); | ||
| 934 | ppnode = host ? host->arch_data : NULL; | ||
| 935 | #endif | ||
| 936 | /* No node for host bridge ? give up */ | ||
| 937 | if (ppnode == NULL) | ||
| 938 | return -EINVAL; | ||
| 939 | } else | ||
| 940 | /* We found a P2P bridge, check if it has a node */ | ||
| 941 | ppnode = pci_device_to_OF_node(ppdev); | ||
| 942 | |||
| 943 | /* Ok, we have found a parent with a device-node, hand over to | ||
| 944 | * the OF parsing code. | ||
| 945 | * We build a unit address from the linux device to be used for | ||
| 946 | * resolution. Note that we use the linux bus number which may | ||
| 947 | * not match your firmware bus numbering. | ||
| 948 | * Fortunately, in most cases, interrupt-map-mask doesn't include | ||
| 949 | * the bus number as part of the matching. | ||
| 950 | * You should still be careful about that though if you intend | ||
| 951 | * to rely on this function (you ship a firmware that doesn't | ||
| 952 | * create device nodes for all PCI devices). | ||
| 953 | */ | ||
| 954 | if (ppnode) | ||
| 955 | break; | ||
| 956 | |||
| 957 | /* We can only get here if we hit a P2P bridge with no node, | ||
| 958 | * let's do standard swizzling and try again | ||
| 959 | */ | ||
| 960 | lspec = of_irq_pci_swizzle(PCI_SLOT(pdev->devfn), lspec); | ||
| 961 | pdev = ppdev; | ||
| 962 | } | ||
| 963 | |||
| 964 | laddr[0] = (pdev->bus->number << 16) | ||
| 965 | | (pdev->devfn << 8); | ||
| 966 | laddr[1] = laddr[2] = 0; | ||
| 967 | return of_irq_map_raw(ppnode, &lspec, laddr, out_irq); | ||
| 968 | } | ||
| 969 | EXPORT_SYMBOL_GPL(of_irq_map_pci); | ||
| 970 | |||
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c index 6eb7e49b394a..cda022657324 100644 --- a/arch/powerpc/kernel/rtas_pci.c +++ b/arch/powerpc/kernel/rtas_pci.c | |||
| @@ -297,19 +297,9 @@ unsigned long __init find_and_init_phbs(void) | |||
| 297 | struct device_node *node; | 297 | struct device_node *node; |
| 298 | struct pci_controller *phb; | 298 | struct pci_controller *phb; |
| 299 | unsigned int index; | 299 | unsigned int index; |
| 300 | unsigned int root_size_cells = 0; | ||
| 301 | unsigned int *opprop = NULL; | ||
| 302 | struct device_node *root = of_find_node_by_path("/"); | 300 | struct device_node *root = of_find_node_by_path("/"); |
| 303 | 301 | ||
| 304 | if (ppc64_interrupt_controller == IC_OPEN_PIC) { | ||
| 305 | opprop = (unsigned int *)get_property(root, | ||
| 306 | "platform-open-pic", NULL); | ||
| 307 | } | ||
| 308 | |||
| 309 | root_size_cells = prom_n_size_cells(root); | ||
| 310 | |||
| 311 | index = 0; | 302 | index = 0; |
| 312 | |||
| 313 | for (node = of_get_next_child(root, NULL); | 303 | for (node = of_get_next_child(root, NULL); |
| 314 | node != NULL; | 304 | node != NULL; |
| 315 | node = of_get_next_child(root, node)) { | 305 | node = of_get_next_child(root, node)) { |
| @@ -324,13 +314,6 @@ unsigned long __init find_and_init_phbs(void) | |||
| 324 | setup_phb(node, phb); | 314 | setup_phb(node, phb); |
| 325 | pci_process_bridge_OF_ranges(phb, node, 0); | 315 | pci_process_bridge_OF_ranges(phb, node, 0); |
| 326 | pci_setup_phb_io(phb, index == 0); | 316 | pci_setup_phb_io(phb, index == 0); |
| 327 | #ifdef CONFIG_PPC_PSERIES | ||
| 328 | /* XXX This code need serious fixing ... --BenH */ | ||
| 329 | if (ppc64_interrupt_controller == IC_OPEN_PIC && pSeries_mpic) { | ||
| 330 | int addr = root_size_cells * (index + 2) - 1; | ||
| 331 | mpic_assign_isu(pSeries_mpic, index, opprop[addr]); | ||
| 332 | } | ||
| 333 | #endif | ||
| 334 | index++; | 317 | index++; |
| 335 | } | 318 | } |
| 336 | 319 | ||
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index ba7cd50d820d..e0df2ba1ab9f 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
| @@ -51,7 +51,6 @@ | |||
| 51 | 51 | ||
| 52 | extern void bootx_init(unsigned long r4, unsigned long phys); | 52 | extern void bootx_init(unsigned long r4, unsigned long phys); |
| 53 | 53 | ||
| 54 | boot_infos_t *boot_infos; | ||
| 55 | struct ide_machdep_calls ppc_ide_md; | 54 | struct ide_machdep_calls ppc_ide_md; |
| 56 | 55 | ||
| 57 | int boot_cpuid; | 56 | int boot_cpuid; |
| @@ -240,7 +239,6 @@ void __init setup_arch(char **cmdline_p) | |||
| 240 | ppc_md.init_early(); | 239 | ppc_md.init_early(); |
| 241 | 240 | ||
| 242 | find_legacy_serial_ports(); | 241 | find_legacy_serial_ports(); |
| 243 | finish_device_tree(); | ||
| 244 | 242 | ||
| 245 | smp_setup_cpu_maps(); | 243 | smp_setup_cpu_maps(); |
| 246 | 244 | ||
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index ac7276c40685..fd1785e4c9bb 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
| @@ -361,12 +361,15 @@ void __init setup_system(void) | |||
| 361 | 361 | ||
| 362 | /* | 362 | /* |
| 363 | * Fill the ppc64_caches & systemcfg structures with informations | 363 | * Fill the ppc64_caches & systemcfg structures with informations |
| 364 | * retrieved from the device-tree. Need to be called before | 364 | * retrieved from the device-tree. |
| 365 | * finish_device_tree() since the later requires some of the | ||
| 366 | * informations filled up here to properly parse the interrupt tree. | ||
| 367 | */ | 365 | */ |
| 368 | initialize_cache_info(); | 366 | initialize_cache_info(); |
| 369 | 367 | ||
| 368 | /* | ||
| 369 | * Initialize irq remapping subsystem | ||
| 370 | */ | ||
| 371 | irq_early_init(); | ||
| 372 | |||
| 370 | #ifdef CONFIG_PPC_RTAS | 373 | #ifdef CONFIG_PPC_RTAS |
| 371 | /* | 374 | /* |
| 372 | * Initialize RTAS if available | 375 | * Initialize RTAS if available |
| @@ -394,12 +397,6 @@ void __init setup_system(void) | |||
| 394 | find_legacy_serial_ports(); | 397 | find_legacy_serial_ports(); |
| 395 | 398 | ||
| 396 | /* | 399 | /* |
| 397 | * "Finish" the device-tree, that is do the actual parsing of | ||
| 398 | * some of the properties like the interrupt map | ||
| 399 | */ | ||
| 400 | finish_device_tree(); | ||
| 401 | |||
| 402 | /* | ||
| 403 | * Initialize xmon | 400 | * Initialize xmon |
| 404 | */ | 401 | */ |
| 405 | #ifdef CONFIG_XMON_DEFAULT | 402 | #ifdef CONFIG_XMON_DEFAULT |
| @@ -427,8 +424,6 @@ void __init setup_system(void) | |||
| 427 | 424 | ||
| 428 | printk("-----------------------------------------------------\n"); | 425 | printk("-----------------------------------------------------\n"); |
| 429 | printk("ppc64_pft_size = 0x%lx\n", ppc64_pft_size); | 426 | printk("ppc64_pft_size = 0x%lx\n", ppc64_pft_size); |
| 430 | printk("ppc64_interrupt_controller = 0x%ld\n", | ||
| 431 | ppc64_interrupt_controller); | ||
| 432 | printk("physicalMemorySize = 0x%lx\n", lmb_phys_mem_size()); | 427 | printk("physicalMemorySize = 0x%lx\n", lmb_phys_mem_size()); |
| 433 | printk("ppc64_caches.dcache_line_size = 0x%x\n", | 428 | printk("ppc64_caches.dcache_line_size = 0x%x\n", |
| 434 | ppc64_caches.dline_size); | 429 | ppc64_caches.dline_size); |
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c index cdf5867838a6..fad8580f9081 100644 --- a/arch/powerpc/kernel/vio.c +++ b/arch/powerpc/kernel/vio.c | |||
| @@ -218,7 +218,6 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node) | |||
| 218 | { | 218 | { |
| 219 | struct vio_dev *viodev; | 219 | struct vio_dev *viodev; |
| 220 | unsigned int *unit_address; | 220 | unsigned int *unit_address; |
| 221 | unsigned int *irq_p; | ||
| 222 | 221 | ||
| 223 | /* we need the 'device_type' property, in order to match with drivers */ | 222 | /* we need the 'device_type' property, in order to match with drivers */ |
| 224 | if (of_node->type == NULL) { | 223 | if (of_node->type == NULL) { |
| @@ -243,16 +242,7 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node) | |||
| 243 | 242 | ||
| 244 | viodev->dev.platform_data = of_node_get(of_node); | 243 | viodev->dev.platform_data = of_node_get(of_node); |
| 245 | 244 | ||
| 246 | viodev->irq = NO_IRQ; | 245 | viodev->irq = irq_of_parse_and_map(of_node, 0); |
| 247 | irq_p = (unsigned int *)get_property(of_node, "interrupts", NULL); | ||
| 248 | if (irq_p) { | ||
| 249 | int virq = virt_irq_create_mapping(*irq_p); | ||
| 250 | if (virq == NO_IRQ) { | ||
| 251 | printk(KERN_ERR "Unable to allocate interrupt " | ||
| 252 | "number for %s\n", of_node->full_name); | ||
| 253 | } else | ||
| 254 | viodev->irq = irq_offset_up(virq); | ||
| 255 | } | ||
| 256 | 246 | ||
| 257 | snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address); | 247 | snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address); |
| 258 | viodev->name = of_node->name; | 248 | viodev->name = of_node->name; |
