Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Geert Uytterhoeven | ddc7fd2 | 2011-07-13 21:48:30 +0200 | [diff] [blame] | 12 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/macintosh.h> |
| 15 | #include <asm/macints.h> |
| 16 | #include <asm/mac_baboon.h> |
| 17 | |
Finn Thain | 217f671 | 2007-05-01 22:32:58 +0200 | [diff] [blame] | 18 | int baboon_present; |
Adrian Bunk | 8dfbdf4 | 2008-07-17 21:16:25 +0200 | [diff] [blame] | 19 | static volatile struct baboon *baboon; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Finn Thain | 0e37a23 | 2017-10-26 22:45:24 -0400 | [diff] [blame] | 36 | pr_debug("Baboon detected at %p\n", baboon); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /* |
Finn Thain | a1eb1cd | 2018-01-27 18:51:40 -0500 | [diff] [blame] | 40 | * Baboon interrupt handler. |
| 41 | * XXX how do you clear a pending IRQ? is it even necessary? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | */ |
| 43 | |
Thomas Gleixner | bd0b9ac | 2015-09-14 10:42:37 +0200 | [diff] [blame] | 44 | static void baboon_irq(struct irq_desc *desc) |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 45 | { |
Finn Thain | a1eb1cd | 2018-01-27 18:51:40 -0500 | [diff] [blame] | 46 | short events, irq_bit; |
| 47 | int irq_num; |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 48 | |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 49 | events = baboon->mb_ifr & 0x07; |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 50 | irq_num = IRQ_BABOON_0; |
| 51 | irq_bit = 1; |
| 52 | do { |
Finn Thain | a1eb1cd | 2018-01-27 18:51:40 -0500 | [diff] [blame] | 53 | if (events & irq_bit) { |
| 54 | events &= ~irq_bit; |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 55 | generic_handle_irq(irq_num); |
| 56 | } |
Finn Thain | a1eb1cd | 2018-01-27 18:51:40 -0500 | [diff] [blame] | 57 | ++irq_num; |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 58 | irq_bit <<= 1; |
Finn Thain | a1eb1cd | 2018-01-27 18:51:40 -0500 | [diff] [blame] | 59 | } while (events); |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 60 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Adrian Bunk | 8dfbdf4 | 2008-07-17 21:16:25 +0200 | [diff] [blame] | 62 | /* |
| 63 | * Register the Baboon interrupt dispatcher on nubus slot $C. |
| 64 | */ |
| 65 | |
| 66 | void __init baboon_register_interrupts(void) |
| 67 | { |
Geert Uytterhoeven | 9145db5 | 2011-08-10 12:48:29 +0200 | [diff] [blame] | 68 | irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq); |
Adrian Bunk | 8dfbdf4 | 2008-07-17 21:16:25 +0200 | [diff] [blame] | 69 | } |
| 70 | |
Finn Thain | 746e8d3 | 2008-11-18 20:45:21 +0100 | [diff] [blame] | 71 | /* |
Finn Thain | feb11e8 | 2011-10-24 01:11:19 +1100 | [diff] [blame] | 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). |
Finn Thain | 746e8d3 | 2008-11-18 20:45:21 +0100 | [diff] [blame] | 78 | */ |
| 79 | |
| 80 | void baboon_irq_enable(int irq) |
| 81 | { |
Finn Thain | feb11e8 | 2011-10-24 01:11:19 +1100 | [diff] [blame] | 82 | mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Finn Thain | 746e8d3 | 2008-11-18 20:45:21 +0100 | [diff] [blame] | 85 | void baboon_irq_disable(int irq) |
| 86 | { |
Finn Thain | feb11e8 | 2011-10-24 01:11:19 +1100 | [diff] [blame] | 87 | mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |