1 /* $Id: irq.c,v 1.1.2.4 2002/11/04 20:33:56 lethal Exp $
3 * arch/sh/boards/cqreek/irq.c
5 * Copyright (C) 2000 Niibe Yutaka
7 * CqREEK IDE/ISA Bridge Support.
11 #include <linux/irq.h>
12 #include <linux/init.h>
14 #include <asm/cqreek/cqreek.h>
16 #include <asm/io_generic.h>
18 #include <asm/machvec.h>
19 #include <asm/machvec_init.h>
22 struct cqreek_irq_data {
23 unsigned short mask_port; /* Port of Interrupt Mask Register */
24 unsigned short stat_port; /* Port of Interrupt Status Register */
25 unsigned short bit; /* Value of the bit */
27 static struct cqreek_irq_data cqreek_irq_data[NR_IRQS];
29 static void disable_cqreek_irq(unsigned int irq)
33 unsigned short mask_port = cqreek_irq_data[irq].mask_port;
34 unsigned short bit = cqreek_irq_data[irq].bit;
36 local_irq_save(flags);
38 mask = inw(mask_port) & ~bit;
39 outw_p(mask, mask_port);
40 local_irq_restore(flags);
43 static void enable_cqreek_irq(unsigned int irq)
47 unsigned short mask_port = cqreek_irq_data[irq].mask_port;
48 unsigned short bit = cqreek_irq_data[irq].bit;
50 local_irq_save(flags);
52 mask = inw(mask_port) | bit;
53 outw_p(mask, mask_port);
54 local_irq_restore(flags);
57 static void mask_and_ack_cqreek(unsigned int irq)
59 unsigned short stat_port = cqreek_irq_data[irq].stat_port;
60 unsigned short bit = cqreek_irq_data[irq].bit;
62 disable_cqreek_irq(irq);
63 /* Clear IRQ (it might be edge IRQ) */
65 outw_p(bit, stat_port);
68 static void end_cqreek_irq(unsigned int irq)
70 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
71 enable_cqreek_irq(irq);
74 static unsigned int startup_cqreek_irq(unsigned int irq)
76 enable_cqreek_irq(irq);
80 static void shutdown_cqreek_irq(unsigned int irq)
82 disable_cqreek_irq(irq);
85 static struct hw_interrupt_type cqreek_irq_type = {
86 .typename = "CqREEK-IRQ",
87 .startup = startup_cqreek_irq,
88 .shutdown = shutdown_cqreek_irq,
89 .enable = enable_cqreek_irq,
90 .disable = disable_cqreek_irq,
91 .ack = mask_and_ack_cqreek,
95 int cqreek_has_ide, cqreek_has_isa;
97 /* XXX: This is just for test for my NE2000 ISA board
98 What we really need is virtualized IRQ and demultiplexer like HP600 port */
99 void __init init_cqreek_IRQ(void)
101 if (cqreek_has_ide) {
102 cqreek_irq_data[14].mask_port = BRIDGE_IDE_INTR_MASK;
103 cqreek_irq_data[14].stat_port = BRIDGE_IDE_INTR_STAT;
104 cqreek_irq_data[14].bit = 1;
106 irq_desc[14].handler = &cqreek_irq_type;
107 irq_desc[14].status = IRQ_DISABLED;
108 irq_desc[14].action = 0;
109 irq_desc[14].depth = 1;
111 disable_cqreek_irq(14);
114 if (cqreek_has_isa) {
115 cqreek_irq_data[10].mask_port = BRIDGE_ISA_INTR_MASK;
116 cqreek_irq_data[10].stat_port = BRIDGE_ISA_INTR_STAT;
117 cqreek_irq_data[10].bit = (1 << 10);
119 /* XXX: Err... we may need demultiplexer for ISA irq... */
120 irq_desc[10].handler = &cqreek_irq_type;
121 irq_desc[10].status = IRQ_DISABLED;
122 irq_desc[10].action = 0;
123 irq_desc[10].depth = 1;
125 disable_cqreek_irq(10);