Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-clps711x/irq.c |
| 3 | * |
| 4 | * Copyright (C) 2000 Deep Blue Solutions Ltd. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/list.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | #include <asm/mach/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 25 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/irq.h> |
| 27 | |
| 28 | #include <asm/hardware/clps7111.h> |
| 29 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 30 | static void int1_mask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
| 32 | u32 intmr1; |
| 33 | |
| 34 | intmr1 = clps_readl(INTMR1); |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 35 | intmr1 &= ~(1 << d->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | clps_writel(intmr1, INTMR1); |
| 37 | } |
| 38 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 39 | static void int1_ack(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | { |
| 41 | u32 intmr1; |
| 42 | |
| 43 | intmr1 = clps_readl(INTMR1); |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 44 | intmr1 &= ~(1 << d->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | clps_writel(intmr1, INTMR1); |
| 46 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 47 | switch (d->irq) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | case IRQ_CSINT: clps_writel(0, COEOI); break; |
| 49 | case IRQ_TC1OI: clps_writel(0, TC1EOI); break; |
| 50 | case IRQ_TC2OI: clps_writel(0, TC2EOI); break; |
| 51 | case IRQ_RTCMI: clps_writel(0, RTCEOI); break; |
| 52 | case IRQ_TINT: clps_writel(0, TEOI); break; |
| 53 | case IRQ_UMSINT: clps_writel(0, UMSEOI); break; |
| 54 | } |
| 55 | } |
| 56 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 57 | static void int1_unmask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
| 59 | u32 intmr1; |
| 60 | |
| 61 | intmr1 = clps_readl(INTMR1); |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 62 | intmr1 |= 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | clps_writel(intmr1, INTMR1); |
| 64 | } |
| 65 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 66 | static struct irq_chip int1_chip = { |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 67 | .irq_ack = int1_ack, |
| 68 | .irq_mask = int1_mask, |
| 69 | .irq_unmask = int1_unmask, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 72 | static void int2_mask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | { |
| 74 | u32 intmr2; |
| 75 | |
| 76 | intmr2 = clps_readl(INTMR2); |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 77 | intmr2 &= ~(1 << (d->irq - 16)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | clps_writel(intmr2, INTMR2); |
| 79 | } |
| 80 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 81 | static void int2_ack(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | { |
| 83 | u32 intmr2; |
| 84 | |
| 85 | intmr2 = clps_readl(INTMR2); |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 86 | intmr2 &= ~(1 << (d->irq - 16)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | clps_writel(intmr2, INTMR2); |
| 88 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 89 | switch (d->irq) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | case IRQ_KBDINT: clps_writel(0, KBDEOI); break; |
| 91 | } |
| 92 | } |
| 93 | |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 94 | static void int2_unmask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | { |
| 96 | u32 intmr2; |
| 97 | |
| 98 | intmr2 = clps_readl(INTMR2); |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 99 | intmr2 |= 1 << (d->irq - 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | clps_writel(intmr2, INTMR2); |
| 101 | } |
| 102 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 103 | static struct irq_chip int2_chip = { |
Lennert Buytenhek | 8ad357c | 2010-11-29 10:26:56 +0100 | [diff] [blame] | 104 | .irq_ack = int2_ack, |
| 105 | .irq_mask = int2_mask, |
| 106 | .irq_unmask = int2_unmask, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | void __init clps711x_init_irq(void) |
| 110 | { |
| 111 | unsigned int i; |
| 112 | |
| 113 | for (i = 0; i < NR_IRQS; i++) { |
| 114 | if (INT1_IRQS & (1 << i)) { |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 115 | irq_set_chip_and_handler(i, &int1_chip, |
| 116 | handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | set_irq_flags(i, IRQF_VALID | IRQF_PROBE); |
| 118 | } |
| 119 | if (INT2_IRQS & (1 << i)) { |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 120 | irq_set_chip_and_handler(i, &int2_chip, |
| 121 | handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | set_irq_flags(i, IRQF_VALID | IRQF_PROBE); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | * Disable interrupts |
| 128 | */ |
| 129 | clps_writel(0, INTMR1); |
| 130 | clps_writel(0, INTMR2); |
| 131 | |
| 132 | /* |
| 133 | * Clear down any pending interrupts |
| 134 | */ |
| 135 | clps_writel(0, COEOI); |
| 136 | clps_writel(0, TC1EOI); |
| 137 | clps_writel(0, TC2EOI); |
| 138 | clps_writel(0, RTCEOI); |
| 139 | clps_writel(0, TEOI); |
| 140 | clps_writel(0, UMSEOI); |
| 141 | clps_writel(0, SYNCIO); |
| 142 | clps_writel(0, KBDEOI); |
| 143 | } |