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 #include <linux/irq.h>
16 #include <asm/traps.h>
17 #include <asm/bootinfo.h>
18 #include <asm/macintosh.h>
19 #include <asm/macints.h>
20 #include <asm/mac_baboon.h>
22 /* #define DEBUG_IRQS */
25 static volatile struct baboon
*baboon
;
26 static unsigned char baboon_disabled
;
29 extern int macide_ack_intr(struct ata_channel
*);
33 * Baboon initialization.
36 void __init
baboon_init(void)
38 if (macintosh_config
->ident
!= MAC_MODEL_PB190
) {
44 baboon
= (struct baboon
*) BABOON_BASE
;
47 printk("Baboon detected at %p\n", baboon
);
51 * Baboon interrupt handler. This works a lot like a VIA.
54 static void baboon_irq(unsigned int irq
, struct irq_desc
*desc
)
60 printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
61 (uint
) baboon
->mb_control
, (uint
) baboon
->mb_ifr
,
62 (uint
) baboon
->mb_status
);
65 events
= baboon
->mb_ifr
& 0x07;
69 irq_num
= IRQ_BABOON_0
;
72 if (events
& irq_bit
) {
73 baboon
->mb_ifr
&= ~irq_bit
;
74 generic_handle_irq(irq_num
);
78 } while(events
>= irq_bit
);
80 if (baboon
->mb_ifr
& 0x02) macide_ack_intr(NULL
);
81 /* for now we need to smash all interrupts */
82 baboon
->mb_ifr
&= ~events
;
87 * Register the Baboon interrupt dispatcher on nubus slot $C.
90 void __init
baboon_register_interrupts(void)
93 irq_set_chained_handler(IRQ_NUBUS_C
, baboon_irq
);
97 * The means for masking individual baboon interrupts remains a mystery, so
98 * enable the umbrella interrupt only when no baboon interrupt is disabled.
101 void baboon_irq_enable(int irq
)
103 int irq_idx
= IRQ_IDX(irq
);
106 printk("baboon_irq_enable(%d)\n", irq
);
109 baboon_disabled
&= ~(1 << irq_idx
);
110 if (!baboon_disabled
)
111 mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C
));
114 void baboon_irq_disable(int irq
)
116 int irq_idx
= IRQ_IDX(irq
);
119 printk("baboon_irq_disable(%d)\n", irq
);
122 baboon_disabled
|= 1 << irq_idx
;
124 mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C
));
127 void baboon_irq_clear(int irq
)
129 int irq_idx
= IRQ_IDX(irq
);
131 baboon
->mb_ifr
&= ~(1 << irq_idx
);
134 int baboon_irq_pending(int irq
)
136 int irq_idx
= IRQ_IDX(irq
);
138 return baboon
->mb_ifr
& (1 << irq_idx
);