]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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/ide.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_BABOON */ | |
23 | /* #define DEBUG_IRQS */ | |
24 | ||
25 | int baboon_present,baboon_active; | |
26 | volatile struct baboon *baboon; | |
27 | ||
2850bc27 | 28 | irqreturn_t baboon_irq(int, void *); |
1da177e4 LT |
29 | |
30 | #if 0 | |
31 | extern int macide_ack_intr(struct ata_channel *); | |
32 | #endif | |
33 | ||
34 | /* | |
35 | * Baboon initialization. | |
36 | */ | |
37 | ||
38 | void __init baboon_init(void) | |
39 | { | |
40 | if (macintosh_config->ident != MAC_MODEL_PB190) { | |
41 | baboon = NULL; | |
42 | baboon_present = 0; | |
43 | return; | |
44 | } | |
45 | ||
46 | baboon = (struct baboon *) BABOON_BASE; | |
47 | baboon_present = 1; | |
48 | baboon_active = 0; | |
49 | ||
50 | printk("Baboon detected at %p\n", baboon); | |
51 | } | |
52 | ||
53 | /* | |
54 | * Register the Baboon interrupt dispatcher on nubus slot $C. | |
55 | */ | |
56 | ||
57 | void __init baboon_register_interrupts(void) | |
58 | { | |
59 | request_irq(IRQ_NUBUS_C, baboon_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST, | |
60 | "baboon", (void *) baboon); | |
61 | } | |
62 | ||
63 | /* | |
64 | * Baboon interrupt handler. This works a lot like a VIA. | |
65 | */ | |
66 | ||
2850bc27 | 67 | irqreturn_t baboon_irq(int irq, void *dev_id) |
1da177e4 | 68 | { |
67dfb153 | 69 | int irq_bit, irq_num; |
1da177e4 LT |
70 | unsigned char events; |
71 | ||
72 | #ifdef DEBUG_IRQS | |
73 | printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X active %02X\n", | |
74 | (uint) baboon->mb_control, (uint) baboon->mb_ifr, | |
75 | (uint) baboon->mb_status, baboon_active); | |
76 | #endif | |
77 | ||
78 | if (!(events = baboon->mb_ifr & 0x07)) | |
79 | return IRQ_NONE; | |
80 | ||
67dfb153 FT |
81 | irq_num = IRQ_BABOON_0; |
82 | irq_bit = 1; | |
83 | do { | |
1da177e4 LT |
84 | if (events & irq_bit/* & baboon_active*/) { |
85 | baboon_active &= ~irq_bit; | |
647b804c | 86 | baboon->mb_ifr &= ~irq_bit; |
67dfb153 | 87 | m68k_handle_int(irq_num); |
1da177e4 | 88 | baboon_active |= irq_bit; |
1da177e4 | 89 | } |
67dfb153 FT |
90 | irq_bit <<= 1; |
91 | irq_num++; | |
92 | } while(events >= irq_bit); | |
1da177e4 LT |
93 | #if 0 |
94 | if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL); | |
95 | /* for now we need to smash all interrupts */ | |
96 | baboon->mb_ifr &= ~events; | |
97 | #endif | |
98 | return IRQ_HANDLED; | |
99 | } | |
100 | ||
101 | void baboon_irq_enable(int irq) { | |
102 | int irq_idx = IRQ_IDX(irq); | |
103 | ||
104 | #ifdef DEBUG_IRQUSE | |
105 | printk("baboon_irq_enable(%d)\n", irq); | |
106 | #endif | |
107 | baboon_active |= (1 << irq_idx); | |
108 | } | |
109 | ||
110 | void baboon_irq_disable(int irq) { | |
111 | int irq_idx = IRQ_IDX(irq); | |
112 | ||
113 | #ifdef DEBUG_IRQUSE | |
114 | printk("baboon_irq_disable(%d)\n", irq); | |
115 | #endif | |
116 | baboon_active &= ~(1 << irq_idx); | |
117 | } | |
118 | ||
119 | void baboon_irq_clear(int irq) { | |
120 | int irq_idx = IRQ_IDX(irq); | |
121 | ||
122 | baboon->mb_ifr &= ~(1 << irq_idx); | |
123 | } | |
124 | ||
125 | int baboon_irq_pending(int irq) | |
126 | { | |
127 | int irq_idx = IRQ_IDX(irq); | |
128 | ||
129 | return baboon->mb_ifr & (1 << irq_idx); | |
130 | } |