Commit | Line | Data |
---|---|---|
9918cda5 UKK |
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> | |
5e69b945 | 12 | #include <linux/kernel_stat.h> |
fced80c7 | 13 | #include <linux/io.h> |
9918cda5 | 14 | #include <asm/mach/irq.h> |
a09e64fb RK |
15 | #include <mach/regs-sys-common.h> |
16 | #include <mach/irqs.h> | |
17 | #include <mach/board.h> | |
9918cda5 UKK |
18 | |
19 | #include "generic.h" | |
20 | ||
ed6f5987 UKK |
21 | /* simple interrupt prio table: prio(x) < prio(y) <=> x < y */ |
22 | #define irq2prio(i) (i) | |
23 | #define prio2irq(p) (p) | |
24 | ||
9b3ffe52 | 25 | static void ns9xxx_mask_irq(struct irq_data *d) |
9918cda5 UKK |
26 | { |
27 | /* XXX: better use cpp symbols */ | |
9b3ffe52 | 28 | int prio = irq2prio(d->irq); |
ed6f5987 UKK |
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)); | |
9918cda5 UKK |
32 | } |
33 | ||
68293105 | 34 | static void ns9xxx_eoi_irq(struct irq_data *d) |
9918cda5 | 35 | { |
361c7ad6 | 36 | __raw_writel(0, SYS_ISRADDR); |
9918cda5 UKK |
37 | } |
38 | ||
9b3ffe52 | 39 | static void ns9xxx_unmask_irq(struct irq_data *d) |
9918cda5 UKK |
40 | { |
41 | /* XXX: better use cpp symbols */ | |
9b3ffe52 | 42 | int prio = irq2prio(d->irq); |
ed6f5987 UKK |
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)); | |
9918cda5 UKK |
46 | } |
47 | ||
48 | static struct irq_chip ns9xxx_chip = { | |
68293105 | 49 | .irq_eoi = ns9xxx_eoi_irq, |
9b3ffe52 | 50 | .irq_mask = ns9xxx_mask_irq, |
9b3ffe52 | 51 | .irq_unmask = ns9xxx_unmask_irq, |
9918cda5 UKK |
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) | |
ed6f5987 UKK |
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)); | |
9918cda5 | 65 | |
9918cda5 | 66 | for (i = 0; i < 32; ++i) |
ed6f5987 | 67 | __raw_writel(prio2irq(i), SYS_IVA(i)); |
9918cda5 | 68 | |
724ce5ee | 69 | for (i = 0; i <= 31; ++i) { |
f38c02f3 | 70 | irq_set_chip_and_handler(i, &ns9xxx_chip, handle_fasteoi_irq); |
9918cda5 | 71 | set_irq_flags(i, IRQF_VALID); |
68293105 | 72 | irq_set_status_flags(i, IRQ_LEVEL); |
9918cda5 UKK |
73 | } |
74 | } |