blob: ed90a8deabccf78d57c23eb956354fd2b205c262 [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
30
31static int kn02_irq_base;
32
33
34static inline void unmask_kn02_irq(unsigned int irq)
35{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000036 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
37 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 cached_kn02_csr |= (1 << (irq - kn02_irq_base + 16));
40 *csr = cached_kn02_csr;
41}
42
43static inline void mask_kn02_irq(unsigned int irq)
44{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000045 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
46 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48 cached_kn02_csr &= ~(1 << (irq - kn02_irq_base + 16));
49 *csr = cached_kn02_csr;
50}
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052static void ack_kn02_irq(unsigned int irq)
53{
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 mask_kn02_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 iob();
56}
57
Ralf Baechle94dee172006-07-02 14:41:42 +010058static struct irq_chip kn02_irq_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090059 .name = "KN02-CSR",
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 .ack = ack_kn02_irq,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090061 .mask = mask_kn02_irq,
62 .mask_ack = ack_kn02_irq,
63 .unmask = unmask_kn02_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064};
65
66
67void __init init_kn02_irqs(int base)
68{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000069 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
70 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 int i;
72
73 /* Mask interrupts. */
Maciej W. Rozycki64dac502005-06-22 20:56:26 +000074 cached_kn02_csr &= ~KN02_CSR_IOINTEN;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 *csr = cached_kn02_csr;
76 iob();
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090078 for (i = base; i < base + KN02_IRQ_LINES; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +090079 set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81 kn02_irq_base = base;
82}