1 /* 2 * Baboon Custom IC Management 3 * 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. 7 */ 8 9 #include <linux/types.h> 10 #include <linux/kernel.h> 11 #include <linux/mm.h> 12 #include <linux/delay.h> 13 #include <linux/init.h> 14 #include <linux/irq.h> 15 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> 21 22 /* #define DEBUG_IRQS */ 23 24 int baboon_present; 25 static volatile struct baboon *baboon; 26 static unsigned char baboon_disabled; 27 28 #if 0 29 extern int macide_ack_intr(struct ata_channel *); 30 #endif 31 32 /* 33 * Baboon initialization. 34 */ 35 36 void __init baboon_init(void) 37 { 38 if (macintosh_config->ident != MAC_MODEL_PB190) { 39 baboon = NULL; 40 baboon_present = 0; 41 return; 42 } 43 44 baboon = (struct baboon *) BABOON_BASE; 45 baboon_present = 1; 46 47 printk("Baboon detected at %p\n", baboon); 48 } 49 50 /* 51 * Baboon interrupt handler. This works a lot like a VIA. 52 */ 53 54 static void baboon_irq(unsigned int irq, struct irq_desc *desc) 55 { 56 int irq_bit, irq_num; 57 unsigned char events; 58 59 #ifdef DEBUG_IRQS 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); 63 #endif 64 65 events = baboon->mb_ifr & 0x07; 66 if (!events) 67 return; 68 69 irq_num = IRQ_BABOON_0; 70 irq_bit = 1; 71 do { 72 if (events & irq_bit) { 73 baboon->mb_ifr &= ~irq_bit; 74 generic_handle_irq(irq_num); 75 } 76 irq_bit <<= 1; 77 irq_num++; 78 } while(events >= irq_bit); 79 #if 0 80 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL); 81 /* for now we need to smash all interrupts */ 82 baboon->mb_ifr &= ~events; 83 #endif 84 } 85 86 /* 87 * Register the Baboon interrupt dispatcher on nubus slot $C. 88 */ 89 90 void __init baboon_register_interrupts(void) 91 { 92 baboon_disabled = 0; 93 irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq); 94 } 95 96 /* 97 * The means for masking individual baboon interrupts remains a mystery, so 98 * enable the umbrella interrupt only when no baboon interrupt is disabled. 99 */ 100 101 void baboon_irq_enable(int irq) 102 { 103 int irq_idx = IRQ_IDX(irq); 104 105 #ifdef DEBUG_IRQUSE 106 printk("baboon_irq_enable(%d)\n", irq); 107 #endif 108 109 baboon_disabled &= ~(1 << irq_idx); 110 if (!baboon_disabled) 111 mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C)); 112 } 113 114 void baboon_irq_disable(int irq) 115 { 116 int irq_idx = IRQ_IDX(irq); 117 118 #ifdef DEBUG_IRQUSE 119 printk("baboon_irq_disable(%d)\n", irq); 120 #endif 121 122 baboon_disabled |= 1 << irq_idx; 123 if (baboon_disabled) 124 mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C)); 125 } 126 127 void baboon_irq_clear(int irq) 128 { 129 int irq_idx = IRQ_IDX(irq); 130 131 baboon->mb_ifr &= ~(1 << irq_idx); 132 } 133 134 int baboon_irq_pending(int irq) 135 { 136 int irq_idx = IRQ_IDX(irq); 137 138 return baboon->mb_ifr & (1 << irq_idx); 139 } 140