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>
15 #include <asm/traps.h>
16 #include <asm/bootinfo.h>
17 #include <asm/macintosh.h>
18 #include <asm/macints.h>
19 #include <asm/mac_baboon.h>
21 /* #define DEBUG_IRQS */
23 extern void mac_enable_irq(unsigned int);
24 extern void mac_disable_irq(unsigned int);
27 static volatile struct baboon *baboon;
28 static unsigned char baboon_disabled;
31 extern int macide_ack_intr(struct ata_channel *);
35 * Baboon initialization.
38 void __init baboon_init(void)
40 if (macintosh_config->ident != MAC_MODEL_PB190) {
46 baboon = (struct baboon *) BABOON_BASE;
49 printk("Baboon detected at %p\n", baboon);
53 * Baboon interrupt handler. This works a lot like a VIA.
56 static irqreturn_t baboon_irq(int irq, void *dev_id)
62 printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
63 (uint) baboon->mb_control, (uint) baboon->mb_ifr,
64 (uint) baboon->mb_status);
67 if (!(events = baboon->mb_ifr & 0x07))
70 irq_num = IRQ_BABOON_0;
73 if (events & irq_bit) {
74 baboon->mb_ifr &= ~irq_bit;
75 m68k_handle_int(irq_num);
79 } while(events >= irq_bit);
81 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
82 /* for now we need to smash all interrupts */
83 baboon->mb_ifr &= ~events;
89 * Register the Baboon interrupt dispatcher on nubus slot $C.
92 void __init baboon_register_interrupts(void)
95 if (request_irq(IRQ_NUBUS_C, baboon_irq, 0, "baboon", (void *)baboon))
96 pr_err("Couldn't register baboon interrupt\n");
100 * The means for masking individual baboon interrupts remains a mystery, so
101 * enable the umbrella interrupt only when no baboon interrupt is disabled.
104 void baboon_irq_enable(int irq)
106 int irq_idx = IRQ_IDX(irq);
109 printk("baboon_irq_enable(%d)\n", irq);
112 baboon_disabled &= ~(1 << irq_idx);
113 if (!baboon_disabled)
114 mac_enable_irq(IRQ_NUBUS_C);
117 void baboon_irq_disable(int irq)
119 int irq_idx = IRQ_IDX(irq);
122 printk("baboon_irq_disable(%d)\n", irq);
125 baboon_disabled |= 1 << irq_idx;
127 mac_disable_irq(IRQ_NUBUS_C);
130 void baboon_irq_clear(int irq)
132 int irq_idx = IRQ_IDX(irq);
134 baboon->mb_ifr &= ~(1 << irq_idx);
137 int baboon_irq_pending(int irq)
139 int irq_idx = IRQ_IDX(irq);
141 return baboon->mb_ifr & (1 << irq_idx);