Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ns9xxx/irq.c |
| 3 | * |
| 4 | * Copyright (C) 2006,2007 by Digi International Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published by |
| 9 | * the Free Software Foundation. |
| 10 | */ |
| 11 | #include <linux/interrupt.h> |
Uwe Kleine-König | 5e69b94 | 2008-02-29 13:27:53 +0100 | [diff] [blame] | 12 | #include <linux/kernel_stat.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 13 | #include <linux/io.h> |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 14 | #include <asm/mach/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 15 | #include <mach/regs-sys-common.h> |
| 16 | #include <mach/irqs.h> |
| 17 | #include <mach/board.h> |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 18 | |
| 19 | #include "generic.h" |
| 20 | |
Uwe Kleine-König | ed6f598 | 2007-12-11 16:52:50 +0100 | [diff] [blame] | 21 | /* simple interrupt prio table: prio(x) < prio(y) <=> x < y */ |
| 22 | #define irq2prio(i) (i) |
| 23 | #define prio2irq(p) (p) |
| 24 | |
Lennert Buytenhek | 9b3ffe5 | 2010-11-29 10:38:34 +0100 | [diff] [blame] | 25 | static void ns9xxx_mask_irq(struct irq_data *d) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 26 | { |
| 27 | /* XXX: better use cpp symbols */ |
Lennert Buytenhek | 9b3ffe5 | 2010-11-29 10:38:34 +0100 | [diff] [blame] | 28 | int prio = irq2prio(d->irq); |
Uwe Kleine-König | ed6f598 | 2007-12-11 16:52:50 +0100 | [diff] [blame] | 29 | u32 ic = __raw_readl(SYS_IC(prio / 4)); |
| 30 | ic &= ~(1 << (7 + 8 * (3 - (prio & 3)))); |
| 31 | __raw_writel(ic, SYS_IC(prio / 4)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 32 | } |
| 33 | |
Thomas Gleixner | 6829310 | 2011-02-02 21:41:27 +0000 | [diff] [blame] | 34 | static void ns9xxx_eoi_irq(struct irq_data *d) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 35 | { |
Uwe Kleine-König | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame] | 36 | __raw_writel(0, SYS_ISRADDR); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 37 | } |
| 38 | |
Lennert Buytenhek | 9b3ffe5 | 2010-11-29 10:38:34 +0100 | [diff] [blame] | 39 | static void ns9xxx_unmask_irq(struct irq_data *d) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 40 | { |
| 41 | /* XXX: better use cpp symbols */ |
Lennert Buytenhek | 9b3ffe5 | 2010-11-29 10:38:34 +0100 | [diff] [blame] | 42 | int prio = irq2prio(d->irq); |
Uwe Kleine-König | ed6f598 | 2007-12-11 16:52:50 +0100 | [diff] [blame] | 43 | u32 ic = __raw_readl(SYS_IC(prio / 4)); |
| 44 | ic |= 1 << (7 + 8 * (3 - (prio & 3))); |
| 45 | __raw_writel(ic, SYS_IC(prio / 4)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static struct irq_chip ns9xxx_chip = { |
Thomas Gleixner | 6829310 | 2011-02-02 21:41:27 +0000 | [diff] [blame] | 49 | .irq_eoi = ns9xxx_eoi_irq, |
Lennert Buytenhek | 9b3ffe5 | 2010-11-29 10:38:34 +0100 | [diff] [blame] | 50 | .irq_mask = ns9xxx_mask_irq, |
Lennert Buytenhek | 9b3ffe5 | 2010-11-29 10:38:34 +0100 | [diff] [blame] | 51 | .irq_unmask = ns9xxx_unmask_irq, |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | void __init ns9xxx_init_irq(void) |
| 55 | { |
| 56 | int i; |
| 57 | |
| 58 | /* disable all IRQs */ |
| 59 | for (i = 0; i < 8; ++i) |
Uwe Kleine-König | ed6f598 | 2007-12-11 16:52:50 +0100 | [diff] [blame] | 60 | __raw_writel(prio2irq(4 * i) << 24 | |
| 61 | prio2irq(4 * i + 1) << 16 | |
| 62 | prio2irq(4 * i + 2) << 8 | |
| 63 | prio2irq(4 * i + 3), |
| 64 | SYS_IC(i)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 65 | |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 66 | for (i = 0; i < 32; ++i) |
Uwe Kleine-König | ed6f598 | 2007-12-11 16:52:50 +0100 | [diff] [blame] | 67 | __raw_writel(prio2irq(i), SYS_IVA(i)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 68 | |
Uwe Kleine-König | 724ce5e | 2008-02-15 08:41:06 +0100 | [diff] [blame] | 69 | for (i = 0; i <= 31; ++i) { |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 70 | irq_set_chip_and_handler(i, &ns9xxx_chip, handle_fasteoi_irq); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 71 | set_irq_flags(i, IRQF_VALID); |
Thomas Gleixner | 6829310 | 2011-02-02 21:41:27 +0000 | [diff] [blame] | 72 | irq_set_status_flags(i, IRQ_LEVEL); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 73 | } |
| 74 | } |