blob: 4a86dcff3fcd521bfea8232ce0dcdc3427c33e31 [file] [log] [blame]
Grant Likely4dc97832007-10-02 12:15:23 +10001/*
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 Herring26a20562013-09-26 07:40:04 -050026#include <linux/of_address.h>
Rob Herringc11eede2013-11-10 23:19:08 -060027#include <linux/of_irq.h>
Grant Likely4dc97832007-10-02 12:15:23 +100028#include <asm/io.h>
29#include <asm/processor.h>
Grant Likely1745fbc2009-06-06 10:15:03 -060030#include <asm/i8259.h>
Grant Likely4dc97832007-10-02 12:15:23 +100031#include <asm/irq.h>
Zubair Lutfullah Kakakhel83282552016-11-14 12:13:51 +000032#include <linux/irqchip.h>
Grant Likely4dc97832007-10-02 12:15:23 +100033
Grant Likely1745fbc2009-06-06 10:15:03 -060034#if defined(CONFIG_PPC_I8259)
35/*
36 * Support code for cascading to 8259 interrupt controllers
37 */
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020038static void xilinx_i8259_cascade(struct irq_desc *desc)
Grant Likely1745fbc2009-06-06 10:15:03 -060039{
Thomas Gleixnerec775d02011-03-25 16:45:20 +010040 struct irq_chip *chip = irq_desc_get_chip(desc);
Grant Likely1745fbc2009-06-06 10:15:03 -060041 unsigned int cascade_irq = i8259_irq();
Lennert Buytenhek73909af2011-03-08 22:27:07 +000042
Grant Likely1745fbc2009-06-06 10:15:03 -060043 if (cascade_irq)
44 generic_handle_irq(cascade_irq);
45
46 /* Let xilinx_intc end the interrupt */
Lennert Buytenhek73909af2011-03-08 22:27:07 +000047 chip->irq_unmask(&desc->irq_data);
Grant Likely1745fbc2009-06-06 10:15:03 -060048}
49
50static 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 Gleixnerec775d02011-03-25 16:45:20 +010067 irq_set_chained_handler(cascade_irq, xilinx_i8259_cascade);
Grant Likely1745fbc2009-06-06 10:15:03 -060068
Roderick Colenbrandere52ba9c2009-06-06 10:15:24 -060069 /* 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 Likely1745fbc2009-06-06 10:15:03 -060074 out:
75 of_node_put(cascade_node);
76}
77#else
78static inline void xilinx_i8259_setup_cascade(void) { return; }
79#endif /* defined(CONFIG_PPC_I8259) */
80
Grant Likely1745fbc2009-06-06 10:15:03 -060081/*
82 * Initialize master Xilinx interrupt controller
83 */
Grant Likely4dc97832007-10-02 12:15:23 +100084void __init xilinx_intc_init_tree(void)
85{
Zubair Lutfullah Kakakhel83282552016-11-14 12:13:51 +000086 irqchip_init();
Grant Likely1745fbc2009-06-06 10:15:03 -060087 xilinx_i8259_setup_cascade();
Grant Likely4dc97832007-10-02 12:15:23 +100088}