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