blob: 02439dc0ba83136209b0945a1cb77d39601e244b [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
Ralf Baechle94dee172006-07-02 14:41:42 +010060static struct irq_chip kn02_irq_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090061 .name = "KN02-CSR",
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 .ack = ack_kn02_irq,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090063 .mask = mask_kn02_irq,
64 .mask_ack = ack_kn02_irq,
65 .unmask = unmask_kn02_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070066};
67
68
69void __init init_kn02_irqs(int base)
70{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000071 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
72 KN02_CSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 int i;
74
75 /* Mask interrupts. */
Maciej W. Rozycki64dac502005-06-22 20:56:26 +000076 cached_kn02_csr &= ~KN02_CSR_IOINTEN;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 *csr = cached_kn02_csr;
78 iob();
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090080 for (i = base; i < base + KN02_IRQ_LINES; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +090081 set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 kn02_irq_base = base;
84}