Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/sh/boards/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/config.h> | |
13 | #include <linux/init.h> | |
14 | #include <linux/irq.h> | |
15 | ||
16 | #include <linux/hdreg.h> | |
17 | #include <linux/ide.h> | |
18 | #include <asm/io.h> | |
19 | #include <asm/mach/7751systemh.h> | |
20 | #include <asm/smc37c93x.h> | |
21 | ||
22 | /* address of external interrupt mask register | |
23 | * address must be set prior to use these (maybe in init_XXX_irq()) | |
24 | * XXX : is it better to use .config than specifying it in code? */ | |
25 | static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004; | |
26 | static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000; | |
27 | ||
28 | /* forward declaration */ | |
29 | static unsigned int startup_systemh_irq(unsigned int irq); | |
30 | static void shutdown_systemh_irq(unsigned int irq); | |
31 | static void enable_systemh_irq(unsigned int irq); | |
32 | static void disable_systemh_irq(unsigned int irq); | |
33 | static void mask_and_ack_systemh(unsigned int); | |
34 | static void end_systemh_irq(unsigned int irq); | |
35 | ||
36 | /* hw_interrupt_type */ | |
37 | static struct hw_interrupt_type systemh_irq_type = { | |
38 | " SystemH Register", | |
39 | startup_systemh_irq, | |
40 | shutdown_systemh_irq, | |
41 | enable_systemh_irq, | |
42 | disable_systemh_irq, | |
43 | mask_and_ack_systemh, | |
44 | end_systemh_irq | |
45 | }; | |
46 | ||
47 | static unsigned int startup_systemh_irq(unsigned int irq) | |
48 | { | |
49 | enable_systemh_irq(irq); | |
50 | return 0; /* never anything pending */ | |
51 | } | |
52 | ||
53 | static void shutdown_systemh_irq(unsigned int irq) | |
54 | { | |
55 | disable_systemh_irq(irq); | |
56 | } | |
57 | ||
58 | static void disable_systemh_irq(unsigned int irq) | |
59 | { | |
60 | if (systemh_irq_mask_register) { | |
61 | unsigned long flags; | |
62 | unsigned long val, mask = 0x01 << 1; | |
63 | ||
64 | /* Clear the "irq"th bit in the mask and set it in the request */ | |
65 | local_irq_save(flags); | |
66 | ||
67 | val = ctrl_inl((unsigned long)systemh_irq_mask_register); | |
68 | val &= ~mask; | |
69 | ctrl_outl(val, (unsigned long)systemh_irq_mask_register); | |
70 | ||
71 | val = ctrl_inl((unsigned long)systemh_irq_request_register); | |
72 | val |= mask; | |
73 | ctrl_outl(val, (unsigned long)systemh_irq_request_register); | |
74 | ||
75 | local_irq_restore(flags); | |
76 | } | |
77 | } | |
78 | ||
79 | static void enable_systemh_irq(unsigned int irq) | |
80 | { | |
81 | if (systemh_irq_mask_register) { | |
82 | unsigned long flags; | |
83 | unsigned long val, mask = 0x01 << 1; | |
84 | ||
85 | /* Set "irq"th bit in the mask register */ | |
86 | local_irq_save(flags); | |
87 | val = ctrl_inl((unsigned long)systemh_irq_mask_register); | |
88 | val |= mask; | |
89 | ctrl_outl(val, (unsigned long)systemh_irq_mask_register); | |
90 | local_irq_restore(flags); | |
91 | } | |
92 | } | |
93 | ||
94 | static void mask_and_ack_systemh(unsigned int irq) | |
95 | { | |
96 | disable_systemh_irq(irq); | |
97 | } | |
98 | ||
99 | static void end_systemh_irq(unsigned int irq) | |
100 | { | |
101 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | |
102 | enable_systemh_irq(irq); | |
103 | } | |
104 | ||
105 | void make_systemh_irq(unsigned int irq) | |
106 | { | |
107 | disable_irq_nosync(irq); | |
108 | irq_desc[irq].handler = &systemh_irq_type; | |
109 | disable_systemh_irq(irq); | |
110 | } | |
111 |