Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2410/bast-irq.c |
| 2 | * |
Ben Dooks | ccae941 | 2009-11-13 22:54:14 +0000 | [diff] [blame] | 3 | * Copyright 2003-2005 Simtec Electronics |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Ben Dooks <ben@simtec.co.uk> |
| 5 | * |
| 6 | * http://www.simtec.co.uk/products/EB2410ITX/ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 21 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | |
| 24 | #include <linux/init.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/sysdev.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 28 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 30 | #include <asm/mach-types.h> |
| 31 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 32 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <asm/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #include <asm/mach/irq.h> |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 36 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 37 | #include <mach/regs-irq.h> |
| 38 | #include <mach/bast-map.h> |
| 39 | #include <mach/bast-irq.h> |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 40 | |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 41 | #include <plat/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | #if 0 |
| 44 | #include <asm/debug-ll.h> |
| 45 | #endif |
| 46 | |
| 47 | #define irqdbf(x...) |
| 48 | #define irqdbf2(x...) |
| 49 | |
| 50 | |
| 51 | /* handle PC104 ISA interrupts from the system CPLD */ |
| 52 | |
| 53 | /* table of ISA irq nos to the relevant mask... zero means |
| 54 | * the irq is not implemented |
| 55 | */ |
| 56 | static unsigned char bast_pc104_irqmasks[] = { |
| 57 | 0, /* 0 */ |
| 58 | 0, /* 1 */ |
| 59 | 0, /* 2 */ |
| 60 | 1, /* 3 */ |
| 61 | 0, /* 4 */ |
| 62 | 2, /* 5 */ |
| 63 | 0, /* 6 */ |
| 64 | 4, /* 7 */ |
| 65 | 0, /* 8 */ |
| 66 | 0, /* 9 */ |
| 67 | 8, /* 10 */ |
| 68 | 0, /* 11 */ |
| 69 | 0, /* 12 */ |
| 70 | 0, /* 13 */ |
| 71 | 0, /* 14 */ |
| 72 | 0, /* 15 */ |
| 73 | }; |
| 74 | |
| 75 | static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 }; |
| 76 | |
| 77 | static void |
| 78 | bast_pc104_mask(unsigned int irqno) |
| 79 | { |
| 80 | unsigned long temp; |
| 81 | |
| 82 | temp = __raw_readb(BAST_VA_PC104_IRQMASK); |
| 83 | temp &= ~bast_pc104_irqmasks[irqno]; |
| 84 | __raw_writeb(temp, BAST_VA_PC104_IRQMASK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | static void |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 88 | bast_pc104_maskack(unsigned int irqno) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | { |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 90 | struct irq_desc *desc = irq_desc + IRQ_ISA; |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 91 | |
| 92 | bast_pc104_mask(irqno); |
| 93 | desc->chip->ack(IRQ_ISA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static void |
| 97 | bast_pc104_unmask(unsigned int irqno) |
| 98 | { |
| 99 | unsigned long temp; |
| 100 | |
| 101 | temp = __raw_readb(BAST_VA_PC104_IRQMASK); |
| 102 | temp |= bast_pc104_irqmasks[irqno]; |
| 103 | __raw_writeb(temp, BAST_VA_PC104_IRQMASK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 106 | static struct irq_chip bast_pc104_chip = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | .mask = bast_pc104_mask, |
| 108 | .unmask = bast_pc104_unmask, |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 109 | .ack = bast_pc104_maskack |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | static void |
| 113 | bast_irq_pc104_demux(unsigned int irq, |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 114 | struct irq_desc *desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
| 116 | unsigned int stat; |
| 117 | unsigned int irqno; |
| 118 | int i; |
| 119 | |
| 120 | stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf; |
| 121 | |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 122 | if (unlikely(stat == 0)) { |
| 123 | /* ack if we get an irq with nothing (ie, startup) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 125 | desc = irq_desc + IRQ_ISA; |
| 126 | desc->chip->ack(IRQ_ISA); |
| 127 | } else { |
| 128 | /* handle the IRQ */ |
| 129 | |
| 130 | for (i = 0; stat != 0; i++, stat >>= 1) { |
| 131 | if (stat & 1) { |
| 132 | irqno = bast_pc104_irqs[i]; |
Dmitry Baryshkov | d8aa025 | 2008-10-09 13:36:24 +0100 | [diff] [blame] | 133 | generic_handle_irq(irqno); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 134 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | } |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 138 | |
| 139 | static __init int bast_irq_init(void) |
| 140 | { |
| 141 | unsigned int i; |
| 142 | |
| 143 | if (machine_is_bast()) { |
Ben Dooks | 50f430e | 2009-11-13 22:54:12 +0000 | [diff] [blame] | 144 | printk(KERN_INFO "BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n"); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 145 | |
| 146 | /* zap all the IRQs */ |
| 147 | |
| 148 | __raw_writeb(0x0, BAST_VA_PC104_IRQMASK); |
| 149 | |
| 150 | set_irq_chained_handler(IRQ_ISA, bast_irq_pc104_demux); |
| 151 | |
Thomas Gleixner | 544b46d | 2006-07-01 22:32:39 +0100 | [diff] [blame] | 152 | /* register our IRQs */ |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 153 | |
| 154 | for (i = 0; i < 4; i++) { |
| 155 | unsigned int irqno = bast_pc104_irqs[i]; |
| 156 | |
| 157 | set_irq_chip(irqno, &bast_pc104_chip); |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 158 | set_irq_handler(irqno, handle_level_irq); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 159 | set_irq_flags(irqno, IRQF_VALID); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | arch_initcall(bast_irq_init); |