blob: 5a9be4c93584e68a7c70e95775e5ef01aa23c97a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/mips/dec/kn02-irq.c
3 *
4 * DECstation 5000/200 (KN02) Control and Status Register
5 * interrupts.
6 *
Maciej W. Rozycki64dac502005-06-22 20:56:26 +00007 * Copyright (c) 2002, 2003, 2005 Maciej W. Rozycki
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
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 Torvalds1da177e2005-04-16 15:20:36 -070017#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 */
30u32 cached_kn02_csr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32
33static int kn02_irq_base;
34
35
36static inline void unmask_kn02_irq(unsigned int irq)
37{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000038 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
39 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41 cached_kn02_csr |= (1 << (irq - kn02_irq_base + 16));
42 *csr = cached_kn02_csr;
43}
44
45static inline void mask_kn02_irq(unsigned int irq)
46{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000047 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
48 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50 cached_kn02_csr &= ~(1 << (irq - kn02_irq_base + 16));
51 *csr = cached_kn02_csr;
52}
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054static void ack_kn02_irq(unsigned int irq)
55{
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 mask_kn02_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 iob();
58}
59
60static void end_kn02_irq(unsigned int irq)
61{
62 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090063 unmask_kn02_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064}
65
Ralf Baechle94dee172006-07-02 14:41:42 +010066static struct irq_chip kn02_irq_type = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 .typename = "KN02-CSR",
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 .ack = ack_kn02_irq,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090069 .mask = mask_kn02_irq,
70 .mask_ack = ack_kn02_irq,
71 .unmask = unmask_kn02_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 .end = end_kn02_irq,
73};
74
75
76void __init init_kn02_irqs(int base)
77{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000078 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
79 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 int i;
81
82 /* Mask interrupts. */
Maciej W. Rozycki64dac502005-06-22 20:56:26 +000083 cached_kn02_csr &= ~KN02_CSR_IOINTEN;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 *csr = cached_kn02_csr;
85 iob();
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090087 for (i = base; i < base + KN02_IRQ_LINES; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +090088 set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 kn02_irq_base = base;
91}