Grant Likely | 4dc9783 | 2007-10-02 12:15:23 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Interrupt controller driver for Xilinx Virtex FPGAs |
| 3 | * |
| 4 | * Copyright (C) 2007 Secret Lab Technologies Ltd. |
| 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public License |
| 7 | * version 2. This program is licensed "as is" without any warranty of any |
| 8 | * kind, whether express or implied. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * This is a driver for the interrupt controller typically found in |
| 14 | * Xilinx Virtex FPGA designs. |
| 15 | * |
| 16 | * The interrupt sense levels are hard coded into the FPGA design with |
| 17 | * typically a 1:1 relationship between irq lines and devices (no shared |
| 18 | * irq lines). Therefore, this driver does not attempt to handle edge |
| 19 | * and level interrupts differently. |
| 20 | */ |
| 21 | #undef DEBUG |
| 22 | |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/irq.h> |
| 25 | #include <linux/of.h> |
Rob Herring | 26a2056 | 2013-09-26 07:40:04 -0500 | [diff] [blame] | 26 | #include <linux/of_address.h> |
Rob Herring | c11eede | 2013-11-10 23:19:08 -0600 | [diff] [blame] | 27 | #include <linux/of_irq.h> |
Grant Likely | 4dc9783 | 2007-10-02 12:15:23 +1000 | [diff] [blame] | 28 | #include <asm/io.h> |
| 29 | #include <asm/processor.h> |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 30 | #include <asm/i8259.h> |
Grant Likely | 4dc9783 | 2007-10-02 12:15:23 +1000 | [diff] [blame] | 31 | #include <asm/irq.h> |
Zubair Lutfullah Kakakhel | 8328255 | 2016-11-14 12:13:51 +0000 | [diff] [blame] | 32 | #include <linux/irqchip.h> |
Grant Likely | 4dc9783 | 2007-10-02 12:15:23 +1000 | [diff] [blame] | 33 | |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 34 | #if defined(CONFIG_PPC_I8259) |
| 35 | /* |
| 36 | * Support code for cascading to 8259 interrupt controllers |
| 37 | */ |
Thomas Gleixner | bd0b9ac | 2015-09-14 10:42:37 +0200 | [diff] [blame] | 38 | static void xilinx_i8259_cascade(struct irq_desc *desc) |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 39 | { |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 40 | struct irq_chip *chip = irq_desc_get_chip(desc); |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 41 | unsigned int cascade_irq = i8259_irq(); |
Lennert Buytenhek | 73909af | 2011-03-08 22:27:07 +0000 | [diff] [blame] | 42 | |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 43 | if (cascade_irq) |
| 44 | generic_handle_irq(cascade_irq); |
| 45 | |
| 46 | /* Let xilinx_intc end the interrupt */ |
Lennert Buytenhek | 73909af | 2011-03-08 22:27:07 +0000 | [diff] [blame] | 47 | chip->irq_unmask(&desc->irq_data); |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static void __init xilinx_i8259_setup_cascade(void) |
| 51 | { |
| 52 | struct device_node *cascade_node; |
| 53 | int cascade_irq; |
| 54 | |
| 55 | /* Initialize i8259 controller */ |
| 56 | cascade_node = of_find_compatible_node(NULL, NULL, "chrp,iic"); |
| 57 | if (!cascade_node) |
| 58 | return; |
| 59 | |
| 60 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); |
| 61 | if (!cascade_irq) { |
| 62 | pr_err("virtex_ml510: Failed to map cascade interrupt\n"); |
| 63 | goto out; |
| 64 | } |
| 65 | |
| 66 | i8259_init(cascade_node, 0); |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 67 | irq_set_chained_handler(cascade_irq, xilinx_i8259_cascade); |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 68 | |
Roderick Colenbrander | e52ba9c | 2009-06-06 10:15:24 -0600 | [diff] [blame] | 69 | /* Program irq 7 (usb/audio), 14/15 (ide) to level sensitive */ |
| 70 | /* This looks like a dirty hack to me --gcl */ |
| 71 | outb(0xc0, 0x4d0); |
| 72 | outb(0xc0, 0x4d1); |
| 73 | |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 74 | out: |
| 75 | of_node_put(cascade_node); |
| 76 | } |
| 77 | #else |
| 78 | static inline void xilinx_i8259_setup_cascade(void) { return; } |
| 79 | #endif /* defined(CONFIG_PPC_I8259) */ |
| 80 | |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 81 | /* |
| 82 | * Initialize master Xilinx interrupt controller |
| 83 | */ |
Grant Likely | 4dc9783 | 2007-10-02 12:15:23 +1000 | [diff] [blame] | 84 | void __init xilinx_intc_init_tree(void) |
| 85 | { |
Zubair Lutfullah Kakakhel | 8328255 | 2016-11-14 12:13:51 +0000 | [diff] [blame] | 86 | irqchip_init(); |
Grant Likely | 1745fbc | 2009-06-06 10:15:03 -0600 | [diff] [blame] | 87 | xilinx_i8259_setup_cascade(); |
Grant Likely | 4dc9783 | 2007-10-02 12:15:23 +1000 | [diff] [blame] | 88 | } |