18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * External Interrupt Controller on Spider South Bridge 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Arnd Bergmann <arndb@de.ibm.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 118c2ecf20Sopenharmony_ci#include <linux/irq.h> 128c2ecf20Sopenharmony_ci#include <linux/ioport.h> 138c2ecf20Sopenharmony_ci#include <linux/pgtable.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <asm/prom.h> 168c2ecf20Sopenharmony_ci#include <asm/io.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include "interrupt.h" 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* register layout taken from Spider spec, table 7.4-4 */ 218c2ecf20Sopenharmony_cienum { 228c2ecf20Sopenharmony_ci TIR_DEN = 0x004, /* Detection Enable Register */ 238c2ecf20Sopenharmony_ci TIR_MSK = 0x084, /* Mask Level Register */ 248c2ecf20Sopenharmony_ci TIR_EDC = 0x0c0, /* Edge Detection Clear Register */ 258c2ecf20Sopenharmony_ci TIR_PNDA = 0x100, /* Pending Register A */ 268c2ecf20Sopenharmony_ci TIR_PNDB = 0x104, /* Pending Register B */ 278c2ecf20Sopenharmony_ci TIR_CS = 0x144, /* Current Status Register */ 288c2ecf20Sopenharmony_ci TIR_LCSA = 0x150, /* Level Current Status Register A */ 298c2ecf20Sopenharmony_ci TIR_LCSB = 0x154, /* Level Current Status Register B */ 308c2ecf20Sopenharmony_ci TIR_LCSC = 0x158, /* Level Current Status Register C */ 318c2ecf20Sopenharmony_ci TIR_LCSD = 0x15c, /* Level Current Status Register D */ 328c2ecf20Sopenharmony_ci TIR_CFGA = 0x200, /* Setting Register A0 */ 338c2ecf20Sopenharmony_ci TIR_CFGB = 0x204, /* Setting Register B0 */ 348c2ecf20Sopenharmony_ci /* 0x208 ... 0x3ff Setting Register An/Bn */ 358c2ecf20Sopenharmony_ci TIR_PPNDA = 0x400, /* Packet Pending Register A */ 368c2ecf20Sopenharmony_ci TIR_PPNDB = 0x404, /* Packet Pending Register B */ 378c2ecf20Sopenharmony_ci TIR_PIERA = 0x408, /* Packet Output Error Register A */ 388c2ecf20Sopenharmony_ci TIR_PIERB = 0x40c, /* Packet Output Error Register B */ 398c2ecf20Sopenharmony_ci TIR_PIEN = 0x444, /* Packet Output Enable Register */ 408c2ecf20Sopenharmony_ci TIR_PIPND = 0x454, /* Packet Output Pending Register */ 418c2ecf20Sopenharmony_ci TIRDID = 0x484, /* Spider Device ID Register */ 428c2ecf20Sopenharmony_ci REISTIM = 0x500, /* Reissue Command Timeout Time Setting */ 438c2ecf20Sopenharmony_ci REISTIMEN = 0x504, /* Reissue Command Timeout Setting */ 448c2ecf20Sopenharmony_ci REISWAITEN = 0x508, /* Reissue Wait Control*/ 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define SPIDER_CHIP_COUNT 4 488c2ecf20Sopenharmony_ci#define SPIDER_SRC_COUNT 64 498c2ecf20Sopenharmony_ci#define SPIDER_IRQ_INVALID 63 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct spider_pic { 528c2ecf20Sopenharmony_ci struct irq_domain *host; 538c2ecf20Sopenharmony_ci void __iomem *regs; 548c2ecf20Sopenharmony_ci unsigned int node_id; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_cistatic struct spider_pic spider_pics[SPIDER_CHIP_COUNT]; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic struct spider_pic *spider_irq_data_to_pic(struct irq_data *d) 598c2ecf20Sopenharmony_ci{ 608c2ecf20Sopenharmony_ci return irq_data_get_irq_chip_data(d); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic void __iomem *spider_get_irq_config(struct spider_pic *pic, 648c2ecf20Sopenharmony_ci unsigned int src) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci return pic->regs + TIR_CFGA + 8 * src; 678c2ecf20Sopenharmony_ci} 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic void spider_unmask_irq(struct irq_data *d) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci struct spider_pic *pic = spider_irq_data_to_pic(d); 728c2ecf20Sopenharmony_ci void __iomem *cfg = spider_get_irq_config(pic, irqd_to_hwirq(d)); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci out_be32(cfg, in_be32(cfg) | 0x30000000u); 758c2ecf20Sopenharmony_ci} 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistatic void spider_mask_irq(struct irq_data *d) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci struct spider_pic *pic = spider_irq_data_to_pic(d); 808c2ecf20Sopenharmony_ci void __iomem *cfg = spider_get_irq_config(pic, irqd_to_hwirq(d)); 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci out_be32(cfg, in_be32(cfg) & ~0x30000000u); 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistatic void spider_ack_irq(struct irq_data *d) 868c2ecf20Sopenharmony_ci{ 878c2ecf20Sopenharmony_ci struct spider_pic *pic = spider_irq_data_to_pic(d); 888c2ecf20Sopenharmony_ci unsigned int src = irqd_to_hwirq(d); 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci /* Reset edge detection logic if necessary 918c2ecf20Sopenharmony_ci */ 928c2ecf20Sopenharmony_ci if (irqd_is_level_type(d)) 938c2ecf20Sopenharmony_ci return; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* Only interrupts 47 to 50 can be set to edge */ 968c2ecf20Sopenharmony_ci if (src < 47 || src > 50) 978c2ecf20Sopenharmony_ci return; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci /* Perform the clear of the edge logic */ 1008c2ecf20Sopenharmony_ci out_be32(pic->regs + TIR_EDC, 0x100 | (src & 0xf)); 1018c2ecf20Sopenharmony_ci} 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic int spider_set_irq_type(struct irq_data *d, unsigned int type) 1048c2ecf20Sopenharmony_ci{ 1058c2ecf20Sopenharmony_ci unsigned int sense = type & IRQ_TYPE_SENSE_MASK; 1068c2ecf20Sopenharmony_ci struct spider_pic *pic = spider_irq_data_to_pic(d); 1078c2ecf20Sopenharmony_ci unsigned int hw = irqd_to_hwirq(d); 1088c2ecf20Sopenharmony_ci void __iomem *cfg = spider_get_irq_config(pic, hw); 1098c2ecf20Sopenharmony_ci u32 old_mask; 1108c2ecf20Sopenharmony_ci u32 ic; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci /* Note that only level high is supported for most interrupts */ 1138c2ecf20Sopenharmony_ci if (sense != IRQ_TYPE_NONE && sense != IRQ_TYPE_LEVEL_HIGH && 1148c2ecf20Sopenharmony_ci (hw < 47 || hw > 50)) 1158c2ecf20Sopenharmony_ci return -EINVAL; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci /* Decode sense type */ 1188c2ecf20Sopenharmony_ci switch(sense) { 1198c2ecf20Sopenharmony_ci case IRQ_TYPE_EDGE_RISING: 1208c2ecf20Sopenharmony_ci ic = 0x3; 1218c2ecf20Sopenharmony_ci break; 1228c2ecf20Sopenharmony_ci case IRQ_TYPE_EDGE_FALLING: 1238c2ecf20Sopenharmony_ci ic = 0x2; 1248c2ecf20Sopenharmony_ci break; 1258c2ecf20Sopenharmony_ci case IRQ_TYPE_LEVEL_LOW: 1268c2ecf20Sopenharmony_ci ic = 0x0; 1278c2ecf20Sopenharmony_ci break; 1288c2ecf20Sopenharmony_ci case IRQ_TYPE_LEVEL_HIGH: 1298c2ecf20Sopenharmony_ci case IRQ_TYPE_NONE: 1308c2ecf20Sopenharmony_ci ic = 0x1; 1318c2ecf20Sopenharmony_ci break; 1328c2ecf20Sopenharmony_ci default: 1338c2ecf20Sopenharmony_ci return -EINVAL; 1348c2ecf20Sopenharmony_ci } 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci /* Configure the source. One gross hack that was there before and 1378c2ecf20Sopenharmony_ci * that I've kept around is the priority to the BE which I set to 1388c2ecf20Sopenharmony_ci * be the same as the interrupt source number. I don't know whether 1398c2ecf20Sopenharmony_ci * that's supposed to make any kind of sense however, we'll have to 1408c2ecf20Sopenharmony_ci * decide that, but for now, I'm not changing the behaviour. 1418c2ecf20Sopenharmony_ci */ 1428c2ecf20Sopenharmony_ci old_mask = in_be32(cfg) & 0x30000000u; 1438c2ecf20Sopenharmony_ci out_be32(cfg, old_mask | (ic << 24) | (0x7 << 16) | 1448c2ecf20Sopenharmony_ci (pic->node_id << 4) | 0xe); 1458c2ecf20Sopenharmony_ci out_be32(cfg + 4, (0x2 << 16) | (hw & 0xff)); 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci return 0; 1488c2ecf20Sopenharmony_ci} 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_cistatic struct irq_chip spider_pic = { 1518c2ecf20Sopenharmony_ci .name = "SPIDER", 1528c2ecf20Sopenharmony_ci .irq_unmask = spider_unmask_irq, 1538c2ecf20Sopenharmony_ci .irq_mask = spider_mask_irq, 1548c2ecf20Sopenharmony_ci .irq_ack = spider_ack_irq, 1558c2ecf20Sopenharmony_ci .irq_set_type = spider_set_irq_type, 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_cistatic int spider_host_map(struct irq_domain *h, unsigned int virq, 1598c2ecf20Sopenharmony_ci irq_hw_number_t hw) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci irq_set_chip_data(virq, h->host_data); 1628c2ecf20Sopenharmony_ci irq_set_chip_and_handler(virq, &spider_pic, handle_level_irq); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci /* Set default irq type */ 1658c2ecf20Sopenharmony_ci irq_set_irq_type(virq, IRQ_TYPE_NONE); 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci return 0; 1688c2ecf20Sopenharmony_ci} 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_cistatic int spider_host_xlate(struct irq_domain *h, struct device_node *ct, 1718c2ecf20Sopenharmony_ci const u32 *intspec, unsigned int intsize, 1728c2ecf20Sopenharmony_ci irq_hw_number_t *out_hwirq, unsigned int *out_flags) 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci{ 1758c2ecf20Sopenharmony_ci /* Spider interrupts have 2 cells, first is the interrupt source, 1768c2ecf20Sopenharmony_ci * second, well, I don't know for sure yet ... We mask the top bits 1778c2ecf20Sopenharmony_ci * because old device-trees encode a node number in there 1788c2ecf20Sopenharmony_ci */ 1798c2ecf20Sopenharmony_ci *out_hwirq = intspec[0] & 0x3f; 1808c2ecf20Sopenharmony_ci *out_flags = IRQ_TYPE_LEVEL_HIGH; 1818c2ecf20Sopenharmony_ci return 0; 1828c2ecf20Sopenharmony_ci} 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_cistatic const struct irq_domain_ops spider_host_ops = { 1858c2ecf20Sopenharmony_ci .map = spider_host_map, 1868c2ecf20Sopenharmony_ci .xlate = spider_host_xlate, 1878c2ecf20Sopenharmony_ci}; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistatic void spider_irq_cascade(struct irq_desc *desc) 1908c2ecf20Sopenharmony_ci{ 1918c2ecf20Sopenharmony_ci struct irq_chip *chip = irq_desc_get_chip(desc); 1928c2ecf20Sopenharmony_ci struct spider_pic *pic = irq_desc_get_handler_data(desc); 1938c2ecf20Sopenharmony_ci unsigned int cs, virq; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci cs = in_be32(pic->regs + TIR_CS) >> 24; 1968c2ecf20Sopenharmony_ci if (cs == SPIDER_IRQ_INVALID) 1978c2ecf20Sopenharmony_ci virq = 0; 1988c2ecf20Sopenharmony_ci else 1998c2ecf20Sopenharmony_ci virq = irq_linear_revmap(pic->host, cs); 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci if (virq) 2028c2ecf20Sopenharmony_ci generic_handle_irq(virq); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci chip->irq_eoi(&desc->irq_data); 2058c2ecf20Sopenharmony_ci} 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci/* For hooking up the cascade we have a problem. Our device-tree is 2088c2ecf20Sopenharmony_ci * crap and we don't know on which BE iic interrupt we are hooked on at 2098c2ecf20Sopenharmony_ci * least not the "standard" way. We can reconstitute it based on two 2108c2ecf20Sopenharmony_ci * informations though: which BE node we are connected to and whether 2118c2ecf20Sopenharmony_ci * we are connected to IOIF0 or IOIF1. Right now, we really only care 2128c2ecf20Sopenharmony_ci * about the IBM cell blade and we know that its firmware gives us an 2138c2ecf20Sopenharmony_ci * interrupt-map property which is pretty strange. 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_cistatic unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic) 2168c2ecf20Sopenharmony_ci{ 2178c2ecf20Sopenharmony_ci unsigned int virq; 2188c2ecf20Sopenharmony_ci const u32 *imap, *tmp; 2198c2ecf20Sopenharmony_ci int imaplen, intsize, unit; 2208c2ecf20Sopenharmony_ci struct device_node *iic; 2218c2ecf20Sopenharmony_ci struct device_node *of_node; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci of_node = irq_domain_get_of_node(pic->host); 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci /* First, we check whether we have a real "interrupts" in the device 2268c2ecf20Sopenharmony_ci * tree in case the device-tree is ever fixed 2278c2ecf20Sopenharmony_ci */ 2288c2ecf20Sopenharmony_ci virq = irq_of_parse_and_map(of_node, 0); 2298c2ecf20Sopenharmony_ci if (virq) 2308c2ecf20Sopenharmony_ci return virq; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci /* Now do the horrible hacks */ 2338c2ecf20Sopenharmony_ci tmp = of_get_property(of_node, "#interrupt-cells", NULL); 2348c2ecf20Sopenharmony_ci if (tmp == NULL) 2358c2ecf20Sopenharmony_ci return 0; 2368c2ecf20Sopenharmony_ci intsize = *tmp; 2378c2ecf20Sopenharmony_ci imap = of_get_property(of_node, "interrupt-map", &imaplen); 2388c2ecf20Sopenharmony_ci if (imap == NULL || imaplen < (intsize + 1)) 2398c2ecf20Sopenharmony_ci return 0; 2408c2ecf20Sopenharmony_ci iic = of_find_node_by_phandle(imap[intsize]); 2418c2ecf20Sopenharmony_ci if (iic == NULL) 2428c2ecf20Sopenharmony_ci return 0; 2438c2ecf20Sopenharmony_ci imap += intsize + 1; 2448c2ecf20Sopenharmony_ci tmp = of_get_property(iic, "#interrupt-cells", NULL); 2458c2ecf20Sopenharmony_ci if (tmp == NULL) { 2468c2ecf20Sopenharmony_ci of_node_put(iic); 2478c2ecf20Sopenharmony_ci return 0; 2488c2ecf20Sopenharmony_ci } 2498c2ecf20Sopenharmony_ci intsize = *tmp; 2508c2ecf20Sopenharmony_ci /* Assume unit is last entry of interrupt specifier */ 2518c2ecf20Sopenharmony_ci unit = imap[intsize - 1]; 2528c2ecf20Sopenharmony_ci /* Ok, we have a unit, now let's try to get the node */ 2538c2ecf20Sopenharmony_ci tmp = of_get_property(iic, "ibm,interrupt-server-ranges", NULL); 2548c2ecf20Sopenharmony_ci if (tmp == NULL) { 2558c2ecf20Sopenharmony_ci of_node_put(iic); 2568c2ecf20Sopenharmony_ci return 0; 2578c2ecf20Sopenharmony_ci } 2588c2ecf20Sopenharmony_ci /* ugly as hell but works for now */ 2598c2ecf20Sopenharmony_ci pic->node_id = (*tmp) >> 1; 2608c2ecf20Sopenharmony_ci of_node_put(iic); 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci /* Ok, now let's get cracking. You may ask me why I just didn't match 2638c2ecf20Sopenharmony_ci * the iic host from the iic OF node, but that way I'm still compatible 2648c2ecf20Sopenharmony_ci * with really really old old firmwares for which we don't have a node 2658c2ecf20Sopenharmony_ci */ 2668c2ecf20Sopenharmony_ci /* Manufacture an IIC interrupt number of class 2 */ 2678c2ecf20Sopenharmony_ci virq = irq_create_mapping(NULL, 2688c2ecf20Sopenharmony_ci (pic->node_id << IIC_IRQ_NODE_SHIFT) | 2698c2ecf20Sopenharmony_ci (2 << IIC_IRQ_CLASS_SHIFT) | 2708c2ecf20Sopenharmony_ci unit); 2718c2ecf20Sopenharmony_ci if (!virq) 2728c2ecf20Sopenharmony_ci printk(KERN_ERR "spider_pic: failed to map cascade !"); 2738c2ecf20Sopenharmony_ci return virq; 2748c2ecf20Sopenharmony_ci} 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cistatic void __init spider_init_one(struct device_node *of_node, int chip, 2788c2ecf20Sopenharmony_ci unsigned long addr) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci struct spider_pic *pic = &spider_pics[chip]; 2818c2ecf20Sopenharmony_ci int i, virq; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci /* Map registers */ 2848c2ecf20Sopenharmony_ci pic->regs = ioremap(addr, 0x1000); 2858c2ecf20Sopenharmony_ci if (pic->regs == NULL) 2868c2ecf20Sopenharmony_ci panic("spider_pic: can't map registers !"); 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci /* Allocate a host */ 2898c2ecf20Sopenharmony_ci pic->host = irq_domain_add_linear(of_node, SPIDER_SRC_COUNT, 2908c2ecf20Sopenharmony_ci &spider_host_ops, pic); 2918c2ecf20Sopenharmony_ci if (pic->host == NULL) 2928c2ecf20Sopenharmony_ci panic("spider_pic: can't allocate irq host !"); 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci /* Go through all sources and disable them */ 2958c2ecf20Sopenharmony_ci for (i = 0; i < SPIDER_SRC_COUNT; i++) { 2968c2ecf20Sopenharmony_ci void __iomem *cfg = pic->regs + TIR_CFGA + 8 * i; 2978c2ecf20Sopenharmony_ci out_be32(cfg, in_be32(cfg) & ~0x30000000u); 2988c2ecf20Sopenharmony_ci } 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci /* do not mask any interrupts because of level */ 3018c2ecf20Sopenharmony_ci out_be32(pic->regs + TIR_MSK, 0x0); 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci /* enable interrupt packets to be output */ 3048c2ecf20Sopenharmony_ci out_be32(pic->regs + TIR_PIEN, in_be32(pic->regs + TIR_PIEN) | 0x1); 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci /* Hook up the cascade interrupt to the iic and nodeid */ 3078c2ecf20Sopenharmony_ci virq = spider_find_cascade_and_node(pic); 3088c2ecf20Sopenharmony_ci if (!virq) 3098c2ecf20Sopenharmony_ci return; 3108c2ecf20Sopenharmony_ci irq_set_handler_data(virq, pic); 3118c2ecf20Sopenharmony_ci irq_set_chained_handler(virq, spider_irq_cascade); 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci printk(KERN_INFO "spider_pic: node %d, addr: 0x%lx %pOF\n", 3148c2ecf20Sopenharmony_ci pic->node_id, addr, of_node); 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci /* Enable the interrupt detection enable bit. Do this last! */ 3178c2ecf20Sopenharmony_ci out_be32(pic->regs + TIR_DEN, in_be32(pic->regs + TIR_DEN) | 0x1); 3188c2ecf20Sopenharmony_ci} 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_civoid __init spider_init_IRQ(void) 3218c2ecf20Sopenharmony_ci{ 3228c2ecf20Sopenharmony_ci struct resource r; 3238c2ecf20Sopenharmony_ci struct device_node *dn; 3248c2ecf20Sopenharmony_ci int chip = 0; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci /* XXX node numbers are totally bogus. We _hope_ we get the device 3278c2ecf20Sopenharmony_ci * nodes in the right order here but that's definitely not guaranteed, 3288c2ecf20Sopenharmony_ci * we need to get the node from the device tree instead. 3298c2ecf20Sopenharmony_ci * There is currently no proper property for it (but our whole 3308c2ecf20Sopenharmony_ci * device-tree is bogus anyway) so all we can do is pray or maybe test 3318c2ecf20Sopenharmony_ci * the address and deduce the node-id 3328c2ecf20Sopenharmony_ci */ 3338c2ecf20Sopenharmony_ci for_each_node_by_name(dn, "interrupt-controller") { 3348c2ecf20Sopenharmony_ci if (of_device_is_compatible(dn, "CBEA,platform-spider-pic")) { 3358c2ecf20Sopenharmony_ci if (of_address_to_resource(dn, 0, &r)) { 3368c2ecf20Sopenharmony_ci printk(KERN_WARNING "spider-pic: Failed\n"); 3378c2ecf20Sopenharmony_ci continue; 3388c2ecf20Sopenharmony_ci } 3398c2ecf20Sopenharmony_ci } else if (of_device_is_compatible(dn, "sti,platform-spider-pic") 3408c2ecf20Sopenharmony_ci && (chip < 2)) { 3418c2ecf20Sopenharmony_ci static long hard_coded_pics[] = 3428c2ecf20Sopenharmony_ci { 0x24000008000ul, 0x34000008000ul}; 3438c2ecf20Sopenharmony_ci r.start = hard_coded_pics[chip]; 3448c2ecf20Sopenharmony_ci } else 3458c2ecf20Sopenharmony_ci continue; 3468c2ecf20Sopenharmony_ci spider_init_one(dn, chip++, r.start); 3478c2ecf20Sopenharmony_ci } 3488c2ecf20Sopenharmony_ci} 349