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