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> |
Kay Sievers | edbaa60 | 2011-12-21 16:26:03 -0800 | [diff] [blame] | 27 | #include <linux/device.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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/irq.h> |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 31 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/mach/irq.h> |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 33 | |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 34 | #include <mach/hardware.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 35 | #include <mach/regs-irq.h> |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 36 | |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 37 | #include "bast.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | #define irqdbf(x...) |
| 40 | #define irqdbf2(x...) |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | /* handle PC104 ISA interrupts from the system CPLD */ |
| 43 | |
| 44 | /* table of ISA irq nos to the relevant mask... zero means |
| 45 | * the irq is not implemented |
| 46 | */ |
| 47 | static unsigned char bast_pc104_irqmasks[] = { |
| 48 | 0, /* 0 */ |
| 49 | 0, /* 1 */ |
| 50 | 0, /* 2 */ |
| 51 | 1, /* 3 */ |
| 52 | 0, /* 4 */ |
| 53 | 2, /* 5 */ |
| 54 | 0, /* 6 */ |
| 55 | 4, /* 7 */ |
| 56 | 0, /* 8 */ |
| 57 | 0, /* 9 */ |
| 58 | 8, /* 10 */ |
| 59 | 0, /* 11 */ |
| 60 | 0, /* 12 */ |
| 61 | 0, /* 13 */ |
| 62 | 0, /* 14 */ |
| 63 | 0, /* 15 */ |
| 64 | }; |
| 65 | |
| 66 | static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 }; |
| 67 | |
| 68 | static void |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 69 | bast_pc104_mask(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | { |
| 71 | unsigned long temp; |
| 72 | |
| 73 | temp = __raw_readb(BAST_VA_PC104_IRQMASK); |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 74 | temp &= ~bast_pc104_irqmasks[data->irq]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | __raw_writeb(temp, BAST_VA_PC104_IRQMASK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static void |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 79 | bast_pc104_maskack(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | { |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 81 | struct irq_desc *desc = irq_desc + BAST_IRQ_ISA; |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 82 | |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 83 | bast_pc104_mask(data); |
| 84 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | static void |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 88 | bast_pc104_unmask(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | { |
| 90 | unsigned long temp; |
| 91 | |
| 92 | temp = __raw_readb(BAST_VA_PC104_IRQMASK); |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 93 | temp |= bast_pc104_irqmasks[data->irq]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | __raw_writeb(temp, BAST_VA_PC104_IRQMASK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 97 | static struct irq_chip bast_pc104_chip = { |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 98 | .irq_mask = bast_pc104_mask, |
| 99 | .irq_unmask = bast_pc104_unmask, |
| 100 | .irq_ack = bast_pc104_maskack |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
Thomas Gleixner | bd0b9ac | 2015-09-14 10:42:37 +0200 | [diff] [blame] | 103 | static void bast_irq_pc104_demux(struct irq_desc *desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | { |
| 105 | unsigned int stat; |
| 106 | unsigned int irqno; |
| 107 | int i; |
| 108 | |
| 109 | stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf; |
| 110 | |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 111 | if (unlikely(stat == 0)) { |
| 112 | /* ack if we get an irq with nothing (ie, startup) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 114 | desc = irq_desc + BAST_IRQ_ISA; |
Lennert Buytenhek | 57436c2d | 2011-01-03 19:15:54 +0900 | [diff] [blame] | 115 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 116 | } else { |
| 117 | /* handle the IRQ */ |
| 118 | |
| 119 | for (i = 0; stat != 0; i++, stat >>= 1) { |
| 120 | if (stat & 1) { |
| 121 | irqno = bast_pc104_irqs[i]; |
Dmitry Baryshkov | d8aa025 | 2008-10-09 13:36:24 +0100 | [diff] [blame] | 122 | generic_handle_irq(irqno); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 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 | } |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 127 | |
| 128 | static __init int bast_irq_init(void) |
| 129 | { |
| 130 | unsigned int i; |
| 131 | |
| 132 | if (machine_is_bast()) { |
Ben Dooks | 50f430e | 2009-11-13 22:54:12 +0000 | [diff] [blame] | 133 | printk(KERN_INFO "BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n"); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 134 | |
| 135 | /* zap all the IRQs */ |
| 136 | |
| 137 | __raw_writeb(0x0, BAST_VA_PC104_IRQMASK); |
| 138 | |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 139 | irq_set_chained_handler(BAST_IRQ_ISA, bast_irq_pc104_demux); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 140 | |
Thomas Gleixner | 544b46d | 2006-07-01 22:32:39 +0100 | [diff] [blame] | 141 | /* register our IRQs */ |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 142 | |
| 143 | for (i = 0; i < 4; i++) { |
| 144 | unsigned int irqno = bast_pc104_irqs[i]; |
| 145 | |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 146 | irq_set_chip_and_handler(irqno, &bast_pc104_chip, |
| 147 | handle_level_irq); |
Rob Herring | e8d36d5 | 2015-07-27 15:55:13 -0500 | [diff] [blame] | 148 | irq_clear_status_flags(irqno, IRQ_NOREQUEST); |
Ben Dooks | bafa49c | 2005-09-07 17:24:48 +0100 | [diff] [blame] | 149 | } |
| 150 | } |
| 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | arch_initcall(bast_irq_init); |