2 * Baboon Custom IC Management
4 * The Baboon custom IC controls the IDE, PCMCIA and media bay on the
5 * PowerBook 190. It multiplexes multiple interrupt sources onto the
6 * Nubus slot $C interrupt.
9 #include <linux/types.h>
10 #include <linux/kernel.h>
12 #include <linux/delay.h>
13 #include <linux/init.h>
14 #ifdef CONFIG_GENERIC_HARDIRQS
15 #include <linux/irq.h>
18 #include <asm/traps.h>
19 #include <asm/bootinfo.h>
20 #include <asm/macintosh.h>
21 #include <asm/macints.h>
22 #include <asm/mac_baboon.h>
24 /* #define DEBUG_IRQS */
26 extern void mac_enable_irq(unsigned int);
27 extern void mac_disable_irq(unsigned int);
30 static volatile struct baboon *baboon;
31 static unsigned char baboon_disabled;
34 extern int macide_ack_intr(struct ata_channel *);
38 * Baboon initialization.
41 void __init baboon_init(void)
43 if (macintosh_config->ident != MAC_MODEL_PB190) {
49 baboon = (struct baboon *) BABOON_BASE;
52 printk("Baboon detected at %p\n", baboon);
56 * Baboon interrupt handler. This works a lot like a VIA.
59 #ifdef CONFIG_GENERIC_HARDIRQS
60 static void baboon_irq(unsigned int irq, struct irq_desc *desc)
66 printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
67 (uint) baboon->mb_control, (uint) baboon->mb_ifr,
68 (uint) baboon->mb_status);
71 events = baboon->mb_ifr & 0x07;
75 irq_num = IRQ_BABOON_0;
78 if (events & irq_bit) {
79 baboon->mb_ifr &= ~irq_bit;
80 generic_handle_irq(irq_num);
84 } while(events >= irq_bit);
86 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
87 /* for now we need to smash all interrupts */
88 baboon->mb_ifr &= ~events;
92 static irqreturn_t baboon_irq(int irq, void *dev_id)
98 printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
99 (uint) baboon->mb_control, (uint) baboon->mb_ifr,
100 (uint) baboon->mb_status);
103 if (!(events = baboon->mb_ifr & 0x07))
106 irq_num = IRQ_BABOON_0;
109 if (events & irq_bit) {
110 baboon->mb_ifr &= ~irq_bit;
111 generic_handle_irq(irq_num);
115 } while(events >= irq_bit);
117 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
118 /* for now we need to smash all interrupts */
119 baboon->mb_ifr &= ~events;
126 * Register the Baboon interrupt dispatcher on nubus slot $C.
129 void __init baboon_register_interrupts(void)
132 #ifdef CONFIG_GENERIC_HARDIRQS
133 irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);
135 if (request_irq(IRQ_NUBUS_C, baboon_irq, 0, "baboon", (void *)baboon))
136 pr_err("Couldn't register baboon interrupt\n");
141 * The means for masking individual baboon interrupts remains a mystery, so
142 * enable the umbrella interrupt only when no baboon interrupt is disabled.
145 void baboon_irq_enable(int irq)
147 int irq_idx = IRQ_IDX(irq);
150 printk("baboon_irq_enable(%d)\n", irq);
153 baboon_disabled &= ~(1 << irq_idx);
154 if (!baboon_disabled)
155 mac_enable_irq(IRQ_NUBUS_C);
158 void baboon_irq_disable(int irq)
160 int irq_idx = IRQ_IDX(irq);
163 printk("baboon_irq_disable(%d)\n", irq);
166 baboon_disabled |= 1 << irq_idx;
168 mac_disable_irq(IRQ_NUBUS_C);
171 void baboon_irq_clear(int irq)
173 int irq_idx = IRQ_IDX(irq);
175 baboon->mb_ifr &= ~(1 << irq_idx);
178 int baboon_irq_pending(int irq)
180 int irq_idx = IRQ_IDX(irq);
182 return baboon->mb_ifr & (1 << irq_idx);