blob: a7d280220662c747b720b30b7e8cedae31867ddc [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 Uytterhoevenddc7fd22011-07-13 21:48:30 +020012#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/macintosh.h>
15#include <asm/macints.h>
16#include <asm/mac_baboon.h>
17
Finn Thain217f6712007-05-01 22:32:58 +020018int baboon_present;
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020019static volatile struct baboon *baboon;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021/*
22 * Baboon initialization.
23 */
24
25void __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 Torvalds1da177e2005-04-16 15:20:36 -070035
Finn Thain0e37a232017-10-26 22:45:24 -040036 pr_debug("Baboon detected at %p\n", baboon);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
39/*
Finn Thaina1eb1cd2018-01-27 18:51:40 -050040 * Baboon interrupt handler.
41 * XXX how do you clear a pending IRQ? is it even necessary?
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 */
43
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020044static void baboon_irq(struct irq_desc *desc)
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020045{
Finn Thaina1eb1cd2018-01-27 18:51:40 -050046 short events, irq_bit;
47 int irq_num;
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020048
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020049 events = baboon->mb_ifr & 0x07;
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020050 irq_num = IRQ_BABOON_0;
51 irq_bit = 1;
52 do {
Finn Thaina1eb1cd2018-01-27 18:51:40 -050053 if (events & irq_bit) {
54 events &= ~irq_bit;
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020055 generic_handle_irq(irq_num);
56 }
Finn Thaina1eb1cd2018-01-27 18:51:40 -050057 ++irq_num;
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020058 irq_bit <<= 1;
Finn Thaina1eb1cd2018-01-27 18:51:40 -050059 } while (events);
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020060}
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020062/*
63 * Register the Baboon interrupt dispatcher on nubus slot $C.
64 */
65
66void __init baboon_register_interrupts(void)
67{
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020068 irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020069}
70
Finn Thain746e8d32008-11-18 20:45:21 +010071/*
Finn Thainfeb11e82011-10-24 01:11:19 +110072 * 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 Thain746e8d32008-11-18 20:45:21 +010078 */
79
80void baboon_irq_enable(int irq)
81{
Finn Thainfeb11e82011-10-24 01:11:19 +110082 mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C));
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
Finn Thain746e8d32008-11-18 20:45:21 +010085void baboon_irq_disable(int irq)
86{
Finn Thainfeb11e82011-10-24 01:11:19 +110087 mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C));
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}