1*da2014a2SPaul Mundt /* 2*da2014a2SPaul Mundt * linux/arch/sh/boards/renesas/rts7751r2d/irq.c 3*da2014a2SPaul Mundt * 4*da2014a2SPaul Mundt * Copyright (C) 2007 Magnus Damm 5*da2014a2SPaul Mundt * Copyright (C) 2000 Kazumoto Kojima 6*da2014a2SPaul Mundt * 7*da2014a2SPaul Mundt * Renesas Technology Sales RTS7751R2D Support, R2D-PLUS and R2D-1. 8*da2014a2SPaul Mundt * 9*da2014a2SPaul Mundt * Modified for RTS7751R2D by 10*da2014a2SPaul Mundt * Atom Create Engineering Co., Ltd. 2002. 11*da2014a2SPaul Mundt */ 12*da2014a2SPaul Mundt #include <linux/init.h> 13*da2014a2SPaul Mundt #include <linux/irq.h> 14*da2014a2SPaul Mundt #include <linux/interrupt.h> 15*da2014a2SPaul Mundt #include <linux/io.h> 16*da2014a2SPaul Mundt #include <asm/rts7751r2d.h> 17*da2014a2SPaul Mundt 18*da2014a2SPaul Mundt #define R2D_NR_IRL 13 19*da2014a2SPaul Mundt 20*da2014a2SPaul Mundt enum { 21*da2014a2SPaul Mundt UNUSED = 0, 22*da2014a2SPaul Mundt 23*da2014a2SPaul Mundt /* board specific interrupt sources (R2D-1 and R2D-PLUS) */ 24*da2014a2SPaul Mundt EXT, /* EXT_INT0-3 */ 25*da2014a2SPaul Mundt RTC_T, RTC_A, /* Real Time Clock */ 26*da2014a2SPaul Mundt AX88796, /* Ethernet controller (R2D-1 board) */ 27*da2014a2SPaul Mundt KEY, /* Key input (R2D-PLUS board) */ 28*da2014a2SPaul Mundt SDCARD, /* SD Card */ 29*da2014a2SPaul Mundt CF_CD, CF_IDE, /* CF Card Detect + CF IDE */ 30*da2014a2SPaul Mundt SM501, /* SM501 aka Voyager */ 31*da2014a2SPaul Mundt PCI_INTD_RTL8139, /* Ethernet controller */ 32*da2014a2SPaul Mundt PCI_INTC_PCI1520, /* Cardbus/PCMCIA bridge */ 33*da2014a2SPaul Mundt PCI_INTB_RTL8139, /* Ethernet controller with HUB (R2D-PLUS board) */ 34*da2014a2SPaul Mundt PCI_INTB_SLOT, /* PCI Slot 3.3v (R2D-1 board) */ 35*da2014a2SPaul Mundt PCI_INTA_SLOT, /* PCI Slot 3.3v */ 36*da2014a2SPaul Mundt TP, /* Touch Panel */ 37*da2014a2SPaul Mundt }; 38*da2014a2SPaul Mundt 39*da2014a2SPaul Mundt #ifdef CONFIG_RTS7751R2D_1 40*da2014a2SPaul Mundt 41*da2014a2SPaul Mundt /* Vectors for R2D-1 */ 42*da2014a2SPaul Mundt static struct intc_vect vectors_r2d_1[] __initdata = { 43*da2014a2SPaul Mundt INTC_IRQ(EXT, IRQ_EXT), 44*da2014a2SPaul Mundt INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A), 45*da2014a2SPaul Mundt INTC_IRQ(AX88796, IRQ_AX88796), INTC_IRQ(SDCARD, IRQ_SDCARD), 46*da2014a2SPaul Mundt INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), /* ng */ 47*da2014a2SPaul Mundt INTC_IRQ(SM501, IRQ_VOYAGER), 48*da2014a2SPaul Mundt INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD), 49*da2014a2SPaul Mundt INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC), 50*da2014a2SPaul Mundt INTC_IRQ(PCI_INTB_SLOT, IRQ_PCI_INTB), 51*da2014a2SPaul Mundt INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA), 52*da2014a2SPaul Mundt INTC_IRQ(TP, IRQ_TP), 53*da2014a2SPaul Mundt }; 54*da2014a2SPaul Mundt 55*da2014a2SPaul Mundt /* IRLMSK mask register layout for R2D-1 */ 56*da2014a2SPaul Mundt static struct intc_mask_reg mask_registers_r2d_1[] __initdata = { 57*da2014a2SPaul Mundt { 0xa4000000, 0, 16, /* IRLMSK */ 58*da2014a2SPaul Mundt { TP, PCI_INTA_SLOT, PCI_INTB_SLOT, 59*da2014a2SPaul Mundt PCI_INTC_PCI1520, PCI_INTD_RTL8139, 60*da2014a2SPaul Mundt SM501, CF_IDE, CF_CD, SDCARD, AX88796, 61*da2014a2SPaul Mundt RTC_A, RTC_T, 0, 0, 0, EXT } }, 62*da2014a2SPaul Mundt }; 63*da2014a2SPaul Mundt 64*da2014a2SPaul Mundt /* IRLn to IRQ table for R2D-1 */ 65*da2014a2SPaul Mundt static unsigned char irl2irq_r2d_1[R2D_NR_IRL] __initdata = { 66*da2014a2SPaul Mundt IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC, 67*da2014a2SPaul Mundt IRQ_VOYAGER, IRQ_AX88796, IRQ_RTC_A, IRQ_RTC_T, 68*da2014a2SPaul Mundt IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT, 69*da2014a2SPaul Mundt IRQ_TP, 70*da2014a2SPaul Mundt }; 71*da2014a2SPaul Mundt 72*da2014a2SPaul Mundt static DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1", vectors_r2d_1, 73*da2014a2SPaul Mundt NULL, mask_registers_r2d_1, NULL, NULL); 74*da2014a2SPaul Mundt 75*da2014a2SPaul Mundt #endif /* CONFIG_RTS7751R2D_1 */ 76*da2014a2SPaul Mundt 77*da2014a2SPaul Mundt #ifdef CONFIG_RTS7751R2D_PLUS 78*da2014a2SPaul Mundt 79*da2014a2SPaul Mundt /* Vectors for R2D-PLUS */ 80*da2014a2SPaul Mundt static struct intc_vect vectors_r2d_plus[] __initdata = { 81*da2014a2SPaul Mundt INTC_IRQ(EXT, IRQ_EXT), 82*da2014a2SPaul Mundt INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A), 83*da2014a2SPaul Mundt INTC_IRQ(KEY, IRQ_KEY), INTC_IRQ(SDCARD, IRQ_SDCARD), 84*da2014a2SPaul Mundt INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), 85*da2014a2SPaul Mundt INTC_IRQ(SM501, IRQ_VOYAGER), 86*da2014a2SPaul Mundt INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD), 87*da2014a2SPaul Mundt INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC), 88*da2014a2SPaul Mundt INTC_IRQ(PCI_INTB_RTL8139, IRQ_PCI_INTB), 89*da2014a2SPaul Mundt INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA), 90*da2014a2SPaul Mundt INTC_IRQ(TP, IRQ_TP), 91*da2014a2SPaul Mundt }; 92*da2014a2SPaul Mundt 93*da2014a2SPaul Mundt /* IRLMSK mask register layout for R2D-PLUS */ 94*da2014a2SPaul Mundt static struct intc_mask_reg mask_registers_r2d_plus[] __initdata = { 95*da2014a2SPaul Mundt { 0xa4000000, 0, 16, /* IRLMSK */ 96*da2014a2SPaul Mundt { TP, PCI_INTA_SLOT, PCI_INTB_RTL8139, 97*da2014a2SPaul Mundt PCI_INTC_PCI1520, PCI_INTD_RTL8139, 98*da2014a2SPaul Mundt SM501, CF_IDE, CF_CD, SDCARD, KEY, 99*da2014a2SPaul Mundt RTC_A, RTC_T, 0, 0, 0, EXT } }, 100*da2014a2SPaul Mundt }; 101*da2014a2SPaul Mundt 102*da2014a2SPaul Mundt /* IRLn to IRQ table for R2D-PLUS */ 103*da2014a2SPaul Mundt static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] __initdata = { 104*da2014a2SPaul Mundt IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC, 105*da2014a2SPaul Mundt IRQ_VOYAGER, IRQ_KEY, IRQ_RTC_A, IRQ_RTC_T, 106*da2014a2SPaul Mundt IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT, 107*da2014a2SPaul Mundt IRQ_TP, 108*da2014a2SPaul Mundt }; 109*da2014a2SPaul Mundt 110*da2014a2SPaul Mundt static DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus", vectors_r2d_plus, 111*da2014a2SPaul Mundt NULL, mask_registers_r2d_plus, NULL, NULL); 112*da2014a2SPaul Mundt 113*da2014a2SPaul Mundt #endif /* CONFIG_RTS7751R2D_PLUS */ 114*da2014a2SPaul Mundt 115*da2014a2SPaul Mundt static unsigned char irl2irq[R2D_NR_IRL]; 116*da2014a2SPaul Mundt 117*da2014a2SPaul Mundt int rts7751r2d_irq_demux(int irq) 118*da2014a2SPaul Mundt { 119*da2014a2SPaul Mundt if (irq >= R2D_NR_IRL || !irl2irq[irq]) 120*da2014a2SPaul Mundt return irq; 121*da2014a2SPaul Mundt 122*da2014a2SPaul Mundt return irl2irq[irq]; 123*da2014a2SPaul Mundt } 124*da2014a2SPaul Mundt 125*da2014a2SPaul Mundt /* 126*da2014a2SPaul Mundt * Initialize IRQ setting 127*da2014a2SPaul Mundt */ 128*da2014a2SPaul Mundt void __init init_rts7751r2d_IRQ(void) 129*da2014a2SPaul Mundt { 130*da2014a2SPaul Mundt struct intc_desc *d; 131*da2014a2SPaul Mundt 132*da2014a2SPaul Mundt switch (ctrl_inw(PA_VERREG) & 0xf0) { 133*da2014a2SPaul Mundt #ifdef CONFIG_RTS7751R2D_PLUS 134*da2014a2SPaul Mundt case 0x10: 135*da2014a2SPaul Mundt printk(KERN_INFO "Using R2D-PLUS interrupt controller.\n"); 136*da2014a2SPaul Mundt d = &intc_desc_r2d_plus; 137*da2014a2SPaul Mundt memcpy(irl2irq, irl2irq_r2d_plus, R2D_NR_IRL); 138*da2014a2SPaul Mundt break; 139*da2014a2SPaul Mundt #endif 140*da2014a2SPaul Mundt #ifdef CONFIG_RTS7751R2D_1 141*da2014a2SPaul Mundt case 0x00: /* according to manual */ 142*da2014a2SPaul Mundt case 0x30: /* in reality */ 143*da2014a2SPaul Mundt printk(KERN_INFO "Using R2D-1 interrupt controller.\n"); 144*da2014a2SPaul Mundt d = &intc_desc_r2d_1; 145*da2014a2SPaul Mundt memcpy(irl2irq, irl2irq_r2d_1, R2D_NR_IRL); 146*da2014a2SPaul Mundt break; 147*da2014a2SPaul Mundt #endif 148*da2014a2SPaul Mundt default: 149*da2014a2SPaul Mundt printk(KERN_INFO "Unknown R2D interrupt controller 0x%04x\n", 150*da2014a2SPaul Mundt ctrl_inw(PA_VERREG)); 151*da2014a2SPaul Mundt return; 152*da2014a2SPaul Mundt } 153*da2014a2SPaul Mundt 154*da2014a2SPaul Mundt register_intc_controller(d); 155*da2014a2SPaul Mundt } 156