Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/mips/dec/kn02-irq.c |
| 3 | * |
| 4 | * DECstation 5000/200 (KN02) Control and Status Register |
| 5 | * interrupts. |
| 6 | * |
Maciej W. Rozycki | 64dac50 | 2005-06-22 20:56:26 +0000 | [diff] [blame] | 7 | * Copyright (c) 2002, 2003, 2005 Maciej W. Rozycki |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation; either version |
| 12 | * 2 of the License, or (at your option) any later version. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/types.h> |
| 18 | |
| 19 | #include <asm/dec/kn02.h> |
| 20 | |
| 21 | |
| 22 | /* |
| 23 | * Bits 7:0 of the Control Register are write-only -- the |
| 24 | * corresponding bits of the Status Register have a different |
| 25 | * meaning. Hence we use a cache. It speeds up things a bit |
| 26 | * as well. |
| 27 | * |
| 28 | * There is no default value -- it has to be initialized. |
| 29 | */ |
| 30 | u32 cached_kn02_csr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | |
| 33 | static int kn02_irq_base; |
| 34 | |
| 35 | |
| 36 | static inline void unmask_kn02_irq(unsigned int irq) |
| 37 | { |
Maciej W. Rozycki | a5fc9c0 | 2005-07-01 16:10:40 +0000 | [diff] [blame] | 38 | volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + |
| 39 | KN02_CSR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | cached_kn02_csr |= (1 << (irq - kn02_irq_base + 16)); |
| 42 | *csr = cached_kn02_csr; |
| 43 | } |
| 44 | |
| 45 | static inline void mask_kn02_irq(unsigned int irq) |
| 46 | { |
Maciej W. Rozycki | a5fc9c0 | 2005-07-01 16:10:40 +0000 | [diff] [blame] | 47 | volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + |
| 48 | KN02_CSR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | cached_kn02_csr &= ~(1 << (irq - kn02_irq_base + 16)); |
| 51 | *csr = cached_kn02_csr; |
| 52 | } |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | static void ack_kn02_irq(unsigned int irq) |
| 55 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | mask_kn02_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | iob(); |
| 58 | } |
| 59 | |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 60 | static struct irq_chip kn02_irq_type = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 61 | .name = "KN02-CSR", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | .ack = ack_kn02_irq, |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 63 | .mask = mask_kn02_irq, |
| 64 | .mask_ack = ack_kn02_irq, |
| 65 | .unmask = unmask_kn02_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | |
| 69 | void __init init_kn02_irqs(int base) |
| 70 | { |
Maciej W. Rozycki | a5fc9c0 | 2005-07-01 16:10:40 +0000 | [diff] [blame] | 71 | volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + |
| 72 | KN02_CSR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | int i; |
| 74 | |
| 75 | /* Mask interrupts. */ |
Maciej W. Rozycki | 64dac50 | 2005-06-22 20:56:26 +0000 | [diff] [blame] | 76 | cached_kn02_csr &= ~KN02_CSR_IOINTEN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | *csr = cached_kn02_csr; |
| 78 | iob(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 80 | for (i = base; i < base + KN02_IRQ_LINES; i++) |
Atsushi Nemoto | 1417836 | 2006-11-14 01:13:18 +0900 | [diff] [blame] | 81 | set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | kn02_irq_base = base; |
| 84 | } |