blob: 37199f742c4590ba6bb302f7fa37766aa3606342 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * DECstation 5000/200 (KN02) Control and Status Register
3 * interrupts.
4 *
Maciej W. Rozycki64dac502005-06-22 20:56:26 +00005 * Copyright (c) 2002, 2003, 2005 Maciej W. Rozycki
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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 Torvalds1da177e2005-04-16 15:20:36 -070015#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 */
28u32 cached_kn02_csr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030static int kn02_irq_base;
31
Thomas Gleixner009c2002011-03-23 21:08:51 +000032static void unmask_kn02_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000034 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
35 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Thomas Gleixner009c2002011-03-23 21:08:51 +000037 cached_kn02_csr |= (1 << (d->irq - kn02_irq_base + 16));
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 *csr = cached_kn02_csr;
39}
40
Thomas Gleixner009c2002011-03-23 21:08:51 +000041static void mask_kn02_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000043 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
44 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Thomas Gleixner009c2002011-03-23 21:08:51 +000046 cached_kn02_csr &= ~(1 << (d->irq - kn02_irq_base + 16));
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 *csr = cached_kn02_csr;
48}
49
Thomas Gleixner009c2002011-03-23 21:08:51 +000050static void ack_kn02_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Thomas Gleixner009c2002011-03-23 21:08:51 +000052 mask_kn02_irq(d);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 iob();
54}
55
Ralf Baechle94dee172006-07-02 14:41:42 +010056static struct irq_chip kn02_irq_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090057 .name = "KN02-CSR",
Thomas Gleixner009c2002011-03-23 21:08:51 +000058 .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 Torvalds1da177e2005-04-16 15:20:36 -070062};
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064void __init init_kn02_irqs(int base)
65{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000066 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
67 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 int i;
69
70 /* Mask interrupts. */
Maciej W. Rozycki64dac502005-06-22 20:56:26 +000071 cached_kn02_csr &= ~KN02_CSR_IOINTEN;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 *csr = cached_kn02_csr;
73 iob();
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090075 for (i = base; i < base + KN02_IRQ_LINES; i++)
Thomas Gleixnere4ec7982011-03-27 15:19:28 +020076 irq_set_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78 kn02_irq_base = base;
79}