Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/stddef.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/of_platform.h> |
| 14 | |
| 15 | #include <asm/system.h> |
| 16 | #include <asm/mpic.h> |
| 17 | #include <asm/i8259.h> |
| 18 | |
| 19 | #ifdef CONFIG_PPC_I8259 |
| 20 | static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc) |
| 21 | { |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 22 | struct irq_chip *chip = irq_desc_get_chip(desc); |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 23 | unsigned int cascade_irq = i8259_irq(); |
Lennert Buytenhek | 5b25088 | 2011-03-07 13:59:23 +0000 | [diff] [blame] | 24 | |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 25 | if (cascade_irq != NO_IRQ) |
| 26 | generic_handle_irq(cascade_irq); |
Lennert Buytenhek | 5b25088 | 2011-03-07 13:59:23 +0000 | [diff] [blame] | 27 | |
| 28 | chip->irq_eoi(&desc->irq_data); |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 29 | } |
| 30 | #endif /* CONFIG_PPC_I8259 */ |
| 31 | |
| 32 | void __init mpc86xx_init_irq(void) |
| 33 | { |
| 34 | struct mpic *mpic; |
| 35 | struct device_node *np; |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 36 | #ifdef CONFIG_PPC_I8259 |
| 37 | struct device_node *cascade_node = NULL; |
| 38 | int cascade_irq; |
| 39 | #endif |
| 40 | |
| 41 | /* Determine PIC address. */ |
| 42 | np = of_find_node_by_type(NULL, "open-pic"); |
| 43 | if (np == NULL) |
| 44 | return; |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 45 | |
Kyle Moffett | 8bf4156 | 2011-12-02 06:27:59 +0000 | [diff] [blame^] | 46 | mpic = mpic_alloc(np, 0, |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 47 | MPIC_PRIMARY | MPIC_WANTS_RESET | |
Kumar Gala | 3c10c9c | 2008-10-28 18:01:39 +0000 | [diff] [blame] | 48 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
| 49 | MPIC_SINGLE_DEST_CPU, |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 50 | 0, 256, " MPIC "); |
| 51 | of_node_put(np); |
| 52 | BUG_ON(mpic == NULL); |
| 53 | |
| 54 | mpic_init(mpic); |
| 55 | |
| 56 | #ifdef CONFIG_PPC_I8259 |
| 57 | /* Initialize i8259 controller */ |
| 58 | for_each_node_by_type(np, "interrupt-controller") |
| 59 | if (of_device_is_compatible(np, "chrp,iic")) { |
| 60 | cascade_node = np; |
| 61 | break; |
| 62 | } |
| 63 | |
| 64 | if (cascade_node == NULL) { |
| 65 | printk(KERN_DEBUG "Could not find i8259 PIC\n"); |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); |
| 70 | if (cascade_irq == NO_IRQ) { |
| 71 | printk(KERN_ERR "Failed to map cascade interrupt\n"); |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | i8259_init(cascade_node, 0); |
| 76 | of_node_put(cascade_node); |
| 77 | |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 78 | irq_set_chained_handler(cascade_irq, mpc86xx_8259_cascade); |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 79 | #endif |
| 80 | } |