Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/virtex: Use generic xilinx irqchip driver

The Xilinx interrupt controller driver is now available in drivers/irqchip.
Switch to using that driver.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

authored by

Zubair Lutfullah Kakakhel and committed by
Marc Zyngier
8328255f 8a11da59

+9 -213
+1 -1
arch/powerpc/include/asm/xilinx_intc.h
··· 14 14 #ifdef __KERNEL__ 15 15 16 16 extern void __init xilinx_intc_init_tree(void); 17 - extern unsigned int xilinx_intc_get_irq(void); 17 + extern unsigned int xintc_get_irq(void); 18 18 19 19 #endif /* __KERNEL__ */ 20 20 #endif /* _ASM_POWERPC_XILINX_INTC_H */
+1
arch/powerpc/platforms/40x/Kconfig
··· 64 64 default n 65 65 select XILINX_VIRTEX_II_PRO 66 66 select XILINX_VIRTEX_4_FX 67 + select XILINX_INTC 67 68 help 68 69 This option enables generic support for Xilinx Virtex based boards. 69 70
+1 -1
arch/powerpc/platforms/40x/virtex.c
··· 48 48 .probe = virtex_probe, 49 49 .setup_arch = xilinx_pci_init, 50 50 .init_IRQ = xilinx_intc_init_tree, 51 - .get_irq = xilinx_intc_get_irq, 51 + .get_irq = xintc_get_irq, 52 52 .restart = ppc4xx_reset_system, 53 53 .calibrate_decr = generic_calibrate_decr, 54 54 };
+1
arch/powerpc/platforms/44x/Kconfig
··· 241 241 depends on 44x 242 242 default n 243 243 select XILINX_VIRTEX_5_FXT 244 + select XILINX_INTC 244 245 help 245 246 This option enables generic support for Xilinx Virtex based boards 246 247 that use a 440 based processor in the Virtex 5 FXT FPGA architecture.
+1 -1
arch/powerpc/platforms/44x/virtex.c
··· 54 54 .probe = virtex_probe, 55 55 .setup_arch = xilinx_pci_init, 56 56 .init_IRQ = xilinx_intc_init_tree, 57 - .get_irq = xilinx_intc_get_irq, 57 + .get_irq = xintc_get_irq, 58 58 .calibrate_decr = generic_calibrate_decr, 59 59 .restart = ppc4xx_reset_system, 60 60 };
+2 -209
arch/powerpc/sysdev/xilinx_intc.c
··· 29 29 #include <asm/processor.h> 30 30 #include <asm/i8259.h> 31 31 #include <asm/irq.h> 32 - 33 - /* 34 - * INTC Registers 35 - */ 36 - #define XINTC_ISR 0 /* Interrupt Status */ 37 - #define XINTC_IPR 4 /* Interrupt Pending */ 38 - #define XINTC_IER 8 /* Interrupt Enable */ 39 - #define XINTC_IAR 12 /* Interrupt Acknowledge */ 40 - #define XINTC_SIE 16 /* Set Interrupt Enable bits */ 41 - #define XINTC_CIE 20 /* Clear Interrupt Enable bits */ 42 - #define XINTC_IVR 24 /* Interrupt Vector */ 43 - #define XINTC_MER 28 /* Master Enable */ 44 - 45 - static struct irq_domain *master_irqhost; 46 - 47 - #define XILINX_INTC_MAXIRQS (32) 48 - 49 - /* The following table allows the interrupt type, edge or level, 50 - * to be cached after being read from the device tree until the interrupt 51 - * is mapped 52 - */ 53 - static int xilinx_intc_typetable[XILINX_INTC_MAXIRQS]; 54 - 55 - /* Map the interrupt type from the device tree to the interrupt types 56 - * used by the interrupt subsystem 57 - */ 58 - static unsigned char xilinx_intc_map_senses[] = { 59 - IRQ_TYPE_EDGE_RISING, 60 - IRQ_TYPE_EDGE_FALLING, 61 - IRQ_TYPE_LEVEL_HIGH, 62 - IRQ_TYPE_LEVEL_LOW, 63 - }; 64 - 65 - /* 66 - * The interrupt controller is setup such that it doesn't work well with 67 - * the level interrupt handler in the kernel because the handler acks the 68 - * interrupt before calling the application interrupt handler. To deal with 69 - * that, we use 2 different irq chips so that different functions can be 70 - * used for level and edge type interrupts. 71 - * 72 - * IRQ Chip common (across level and edge) operations 73 - */ 74 - static void xilinx_intc_mask(struct irq_data *d) 75 - { 76 - int irq = irqd_to_hwirq(d); 77 - void * regs = irq_data_get_irq_chip_data(d); 78 - pr_debug("mask: %d\n", irq); 79 - out_be32(regs + XINTC_CIE, 1 << irq); 80 - } 81 - 82 - static int xilinx_intc_set_type(struct irq_data *d, unsigned int flow_type) 83 - { 84 - return 0; 85 - } 86 - 87 - /* 88 - * IRQ Chip level operations 89 - */ 90 - static void xilinx_intc_level_unmask(struct irq_data *d) 91 - { 92 - int irq = irqd_to_hwirq(d); 93 - void * regs = irq_data_get_irq_chip_data(d); 94 - pr_debug("unmask: %d\n", irq); 95 - out_be32(regs + XINTC_SIE, 1 << irq); 96 - 97 - /* ack level irqs because they can't be acked during 98 - * ack function since the handle_level_irq function 99 - * acks the irq before calling the inerrupt handler 100 - */ 101 - out_be32(regs + XINTC_IAR, 1 << irq); 102 - } 103 - 104 - static struct irq_chip xilinx_intc_level_irqchip = { 105 - .name = "Xilinx Level INTC", 106 - .irq_mask = xilinx_intc_mask, 107 - .irq_mask_ack = xilinx_intc_mask, 108 - .irq_unmask = xilinx_intc_level_unmask, 109 - .irq_set_type = xilinx_intc_set_type, 110 - }; 111 - 112 - /* 113 - * IRQ Chip edge operations 114 - */ 115 - static void xilinx_intc_edge_unmask(struct irq_data *d) 116 - { 117 - int irq = irqd_to_hwirq(d); 118 - void *regs = irq_data_get_irq_chip_data(d); 119 - pr_debug("unmask: %d\n", irq); 120 - out_be32(regs + XINTC_SIE, 1 << irq); 121 - } 122 - 123 - static void xilinx_intc_edge_ack(struct irq_data *d) 124 - { 125 - int irq = irqd_to_hwirq(d); 126 - void * regs = irq_data_get_irq_chip_data(d); 127 - pr_debug("ack: %d\n", irq); 128 - out_be32(regs + XINTC_IAR, 1 << irq); 129 - } 130 - 131 - static struct irq_chip xilinx_intc_edge_irqchip = { 132 - .name = "Xilinx Edge INTC", 133 - .irq_mask = xilinx_intc_mask, 134 - .irq_unmask = xilinx_intc_edge_unmask, 135 - .irq_ack = xilinx_intc_edge_ack, 136 - .irq_set_type = xilinx_intc_set_type, 137 - }; 138 - 139 - /* 140 - * IRQ Host operations 141 - */ 142 - 143 - /** 144 - * xilinx_intc_xlate - translate virq# from device tree interrupts property 145 - */ 146 - static int xilinx_intc_xlate(struct irq_domain *h, struct device_node *ct, 147 - const u32 *intspec, unsigned int intsize, 148 - irq_hw_number_t *out_hwirq, 149 - unsigned int *out_flags) 150 - { 151 - if ((intsize < 2) || (intspec[0] >= XILINX_INTC_MAXIRQS)) 152 - return -EINVAL; 153 - 154 - /* keep a copy of the interrupt type til the interrupt is mapped 155 - */ 156 - xilinx_intc_typetable[intspec[0]] = xilinx_intc_map_senses[intspec[1]]; 157 - 158 - /* Xilinx uses 2 interrupt entries, the 1st being the h/w 159 - * interrupt number, the 2nd being the interrupt type, edge or level 160 - */ 161 - *out_hwirq = intspec[0]; 162 - *out_flags = xilinx_intc_map_senses[intspec[1]]; 163 - 164 - return 0; 165 - } 166 - static int xilinx_intc_map(struct irq_domain *h, unsigned int virq, 167 - irq_hw_number_t irq) 168 - { 169 - irq_set_chip_data(virq, h->host_data); 170 - 171 - if (xilinx_intc_typetable[irq] == IRQ_TYPE_LEVEL_HIGH || 172 - xilinx_intc_typetable[irq] == IRQ_TYPE_LEVEL_LOW) { 173 - irq_set_chip_and_handler(virq, &xilinx_intc_level_irqchip, 174 - handle_level_irq); 175 - } else { 176 - irq_set_chip_and_handler(virq, &xilinx_intc_edge_irqchip, 177 - handle_edge_irq); 178 - } 179 - return 0; 180 - } 181 - 182 - static const struct irq_domain_ops xilinx_intc_ops = { 183 - .map = xilinx_intc_map, 184 - .xlate = xilinx_intc_xlate, 185 - }; 186 - 187 - struct irq_domain * __init 188 - xilinx_intc_init(struct device_node *np) 189 - { 190 - struct irq_domain * irq; 191 - void * regs; 192 - 193 - /* Find and map the intc registers */ 194 - regs = of_iomap(np, 0); 195 - if (!regs) { 196 - pr_err("xilinx_intc: could not map registers\n"); 197 - return NULL; 198 - } 199 - 200 - /* Setup interrupt controller */ 201 - out_be32(regs + XINTC_IER, 0); /* disable all irqs */ 202 - out_be32(regs + XINTC_IAR, ~(u32) 0); /* Acknowledge pending irqs */ 203 - out_be32(regs + XINTC_MER, 0x3UL); /* Turn on the Master Enable. */ 204 - 205 - /* Allocate and initialize an irq_domain structure. */ 206 - irq = irq_domain_add_linear(np, XILINX_INTC_MAXIRQS, &xilinx_intc_ops, 207 - regs); 208 - if (!irq) 209 - panic(__FILE__ ": Cannot allocate IRQ host\n"); 210 - 211 - return irq; 212 - } 213 - 214 - int xilinx_intc_get_irq(void) 215 - { 216 - void * regs = master_irqhost->host_data; 217 - pr_debug("get_irq:\n"); 218 - return irq_linear_revmap(master_irqhost, in_be32(regs + XINTC_IVR)); 219 - } 32 + #include <linux/irqchip.h> 220 33 221 34 #if defined(CONFIG_PPC_I8259) 222 35 /* ··· 78 265 static inline void xilinx_i8259_setup_cascade(void) { return; } 79 266 #endif /* defined(CONFIG_PPC_I8259) */ 80 267 81 - static const struct of_device_id xilinx_intc_match[] __initconst = { 82 - { .compatible = "xlnx,opb-intc-1.00.c", }, 83 - { .compatible = "xlnx,xps-intc-1.00.a", }, 84 - {} 85 - }; 86 - 87 268 /* 88 269 * Initialize master Xilinx interrupt controller 89 270 */ 90 271 void __init xilinx_intc_init_tree(void) 91 272 { 92 - struct device_node *np; 93 - 94 - /* find top level interrupt controller */ 95 - for_each_matching_node(np, xilinx_intc_match) { 96 - if (!of_get_property(np, "interrupts", NULL)) 97 - break; 98 - } 99 - BUG_ON(!np); 100 - 101 - master_irqhost = xilinx_intc_init(np); 102 - BUG_ON(!master_irqhost); 103 - 104 - irq_set_default_host(master_irqhost); 105 - of_node_put(np); 106 - 273 + irqchip_init(); 107 274 xilinx_i8259_setup_cascade(); 108 275 }
+2 -1
drivers/irqchip/irq-xilinx-intc.c
··· 237 237 238 238 } 239 239 240 - IRQCHIP_DECLARE(xilinx_intc, "xlnx,xps-intc-1.00.a", xilinx_intc_of_init); 240 + IRQCHIP_DECLARE(xilinx_intc_xps, "xlnx,xps-intc-1.00.a", xilinx_intc_of_init); 241 + IRQCHIP_DECLARE(xilinx_intc_opb, "xlnx,opb-intc-1.00.c", xilinx_intc_of_init);