Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | /* |
3 | * Baboon Custom IC Management | |
4 | * | |
5 | * The Baboon custom IC controls the IDE, PCMCIA and media bay on the | |
6 | * PowerBook 190. It multiplexes multiple interrupt sources onto the | |
7 | * Nubus slot $C interrupt. | |
8 | */ | |
9 | ||
10 | #include <linux/types.h> | |
11 | #include <linux/kernel.h> | |
ddc7fd25 | 12 | #include <linux/irq.h> |
1da177e4 | 13 | |
1da177e4 LT |
14 | #include <asm/macintosh.h> |
15 | #include <asm/macints.h> | |
16 | #include <asm/mac_baboon.h> | |
17 | ||
217f6710 | 18 | int baboon_present; |
8dfbdf4a | 19 | static volatile struct baboon *baboon; |
1da177e4 | 20 | |
1da177e4 LT |
21 | /* |
22 | * Baboon initialization. | |
23 | */ | |
24 | ||
25 | void __init baboon_init(void) | |
26 | { | |
27 | if (macintosh_config->ident != MAC_MODEL_PB190) { | |
28 | baboon = NULL; | |
29 | baboon_present = 0; | |
30 | return; | |
31 | } | |
32 | ||
33 | baboon = (struct baboon *) BABOON_BASE; | |
34 | baboon_present = 1; | |
1da177e4 | 35 | |
0e37a23e | 36 | pr_debug("Baboon detected at %p\n", baboon); |
1da177e4 LT |
37 | } |
38 | ||
1da177e4 | 39 | /* |
a1eb1cdf FT |
40 | * Baboon interrupt handler. |
41 | * XXX how do you clear a pending IRQ? is it even necessary? | |
1da177e4 LT |
42 | */ |
43 | ||
bd0b9ac4 | 44 | static void baboon_irq(struct irq_desc *desc) |
9145db56 | 45 | { |
a1eb1cdf FT |
46 | short events, irq_bit; |
47 | int irq_num; | |
9145db56 | 48 | |
9145db56 | 49 | events = baboon->mb_ifr & 0x07; |
9145db56 GU |
50 | irq_num = IRQ_BABOON_0; |
51 | irq_bit = 1; | |
52 | do { | |
a1eb1cdf FT |
53 | if (events & irq_bit) { |
54 | events &= ~irq_bit; | |
9145db56 GU |
55 | generic_handle_irq(irq_num); |
56 | } | |
a1eb1cdf | 57 | ++irq_num; |
9145db56 | 58 | irq_bit <<= 1; |
a1eb1cdf | 59 | } while (events); |
9145db56 | 60 | } |
1da177e4 | 61 | |
8dfbdf4a AB |
62 | /* |
63 | * Register the Baboon interrupt dispatcher on nubus slot $C. | |
64 | */ | |
65 | ||
66 | void __init baboon_register_interrupts(void) | |
67 | { | |
9145db56 | 68 | irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq); |
8dfbdf4a AB |
69 | } |
70 | ||
746e8d3b | 71 | /* |
feb11e8a FT |
72 | * The means for masking individual Baboon interrupts remains a mystery. |
73 | * However, since we only use the IDE IRQ, we can just enable/disable all | |
74 | * Baboon interrupts. If/when we handle more than one Baboon IRQ, we must | |
75 | * either figure out how to mask them individually or else implement the | |
76 | * same workaround that's used for NuBus slots (see nubus_disabled and | |
77 | * via_nubus_irq_shutdown). | |
746e8d3b FT |
78 | */ |
79 | ||
80 | void baboon_irq_enable(int irq) | |
81 | { | |
feb11e8a | 82 | mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C)); |
1da177e4 LT |
83 | } |
84 | ||
746e8d3b FT |
85 | void baboon_irq_disable(int irq) |
86 | { | |
feb11e8a | 87 | mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C)); |
1da177e4 | 88 | } |