sh: Convert SystemH board support from hw_interrupt_type to irq_chip
[linux-2.6] / arch / sh / boards / mach-systemh / irq.c
1 /*
2  * linux/arch/sh/boards/renesas/systemh/irq.c
3  *
4  * Copyright (C) 2000  Kazumoto Kojima
5  *
6  * Hitachi SystemH Support.
7  *
8  * Modified for 7751 SystemH by
9  * Jonathan Short.
10  */
11
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <linux/interrupt.h>
15 #include <linux/io.h>
16
17 #include <mach/systemh7751.h>
18 #include <asm/smc37c93x.h>
19
20 /* address of external interrupt mask register
21  * address must be set prior to use these (maybe in init_XXX_irq())
22  * XXX : is it better to use .config than specifying it in code? */
23 static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
24 static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
25
26 /* forward declaration */
27 static void enable_systemh_irq(unsigned int irq);
28 static void disable_systemh_irq(unsigned int irq);
29 static void mask_and_ack_systemh(unsigned int);
30
31 static struct irq_chip systemh_irq_type = {
32         .name = " SystemH Register",
33         .unmask = enable_systemh_irq,
34         .mask = disable_systemh_irq,
35         .ack = mask_and_ack_systemh,
36 };
37
38 static void disable_systemh_irq(unsigned int irq)
39 {
40         if (systemh_irq_mask_register) {
41                 unsigned long val, mask = 0x01 << 1;
42
43                 /* Clear the "irq"th bit in the mask and set it in the request */
44                 val = ctrl_inl((unsigned long)systemh_irq_mask_register);
45                 val &= ~mask;
46                 ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
47
48                 val = ctrl_inl((unsigned long)systemh_irq_request_register);
49                 val |= mask;
50                 ctrl_outl(val, (unsigned long)systemh_irq_request_register);
51         }
52 }
53
54 static void enable_systemh_irq(unsigned int irq)
55 {
56         if (systemh_irq_mask_register) {
57                 unsigned long val, mask = 0x01 << 1;
58
59                 /* Set "irq"th bit in the mask register */
60                 val = ctrl_inl((unsigned long)systemh_irq_mask_register);
61                 val |= mask;
62                 ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
63         }
64 }
65
66 static void mask_and_ack_systemh(unsigned int irq)
67 {
68         disable_systemh_irq(irq);
69 }
70
71 void make_systemh_irq(unsigned int irq)
72 {
73         disable_irq_nosync(irq);
74         set_irq_chip_and_handler(irq, &systemh_irq_type, handle_level_irq);
75         disable_systemh_irq(irq);
76 }