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 | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame^] | 12 | #include <asm/io.h> |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 13 | #include <asm/mach/irq.h> |
| 14 | #include <asm/mach-types.h> |
| 15 | #include <asm/arch-ns9xxx/regs-sys.h> |
| 16 | #include <asm/arch-ns9xxx/irqs.h> |
| 17 | #include <asm/arch-ns9xxx/board.h> |
| 18 | |
| 19 | #include "generic.h" |
| 20 | |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 21 | static void ns9xxx_mask_irq(unsigned int irq) |
| 22 | { |
| 23 | /* XXX: better use cpp symbols */ |
Uwe Kleine-König | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame^] | 24 | u32 ic = __raw_readl(SYS_IC(irq / 4)); |
| 25 | ic &= ~(1 << (7 + 8 * (3 - (irq & 3)))); |
| 26 | __raw_writel(ic, SYS_IC(irq / 4)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | static void ns9xxx_ack_irq(unsigned int irq) |
| 30 | { |
Uwe Kleine-König | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame^] | 31 | __raw_writel(0, SYS_ISRADDR); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static void ns9xxx_maskack_irq(unsigned int irq) |
| 35 | { |
| 36 | ns9xxx_mask_irq(irq); |
| 37 | ns9xxx_ack_irq(irq); |
| 38 | } |
| 39 | |
| 40 | static void ns9xxx_unmask_irq(unsigned int irq) |
| 41 | { |
| 42 | /* XXX: better use cpp symbols */ |
Uwe Kleine-König | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame^] | 43 | u32 ic = __raw_readl(SYS_IC(irq / 4)); |
| 44 | ic |= 1 << (7 + 8 * (3 - (irq & 3))); |
| 45 | __raw_writel(ic, SYS_IC(irq / 4)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static struct irq_chip ns9xxx_chip = { |
| 49 | .ack = ns9xxx_ack_irq, |
| 50 | .mask = ns9xxx_mask_irq, |
| 51 | .mask_ack = ns9xxx_maskack_irq, |
| 52 | .unmask = ns9xxx_unmask_irq, |
| 53 | }; |
| 54 | |
| 55 | void __init ns9xxx_init_irq(void) |
| 56 | { |
| 57 | int i; |
| 58 | |
| 59 | /* disable all IRQs */ |
| 60 | for (i = 0; i < 8; ++i) |
Uwe Kleine-König | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame^] | 61 | __raw_writel((4 * i) << 24 | (4 * i + 1) << 16 | |
| 62 | (4 * i + 2) << 8 | (4 * i + 3), SYS_IC(i)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 63 | |
| 64 | /* simple interrupt prio table: |
| 65 | * prio(x) < prio(y) <=> x < y |
| 66 | */ |
| 67 | for (i = 0; i < 32; ++i) |
Uwe Kleine-König | 361c7ad | 2007-09-30 20:36:33 +0100 | [diff] [blame^] | 68 | __raw_writel(i, SYS_IVA(i)); |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 69 | |
| 70 | for (i = IRQ_WATCHDOG; i <= IRQ_EXT3; ++i) { |
| 71 | set_irq_chip(i, &ns9xxx_chip); |
| 72 | set_irq_handler(i, handle_level_irq); |
| 73 | set_irq_flags(i, IRQF_VALID); |
| 74 | } |
| 75 | } |