blob: c7ea6475ef9baf90707083f8cc6ab2451147d2d9 [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
21#if 0
22extern int macide_ack_intr(struct ata_channel *);
23#endif
24
25/*
26 * Baboon initialization.
27 */
28
29void __init baboon_init(void)
30{
31 if (macintosh_config->ident != MAC_MODEL_PB190) {
32 baboon = NULL;
33 baboon_present = 0;
34 return;
35 }
36
37 baboon = (struct baboon *) BABOON_BASE;
38 baboon_present = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Finn Thain0e37a232017-10-26 22:45:24 -040040 pr_debug("Baboon detected at %p\n", baboon);
Linus Torvalds1da177e2005-04-16 15:20:36 -070041}
42
43/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 * Baboon interrupt handler. This works a lot like a VIA.
45 */
46
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020047static void baboon_irq(struct irq_desc *desc)
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020048{
49 int irq_bit, irq_num;
50 unsigned char events;
51
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020052 events = baboon->mb_ifr & 0x07;
53 if (!events)
54 return;
55
56 irq_num = IRQ_BABOON_0;
57 irq_bit = 1;
58 do {
59 if (events & irq_bit) {
60 baboon->mb_ifr &= ~irq_bit;
61 generic_handle_irq(irq_num);
62 }
63 irq_bit <<= 1;
64 irq_num++;
65 } while(events >= irq_bit);
66#if 0
67 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
68 /* for now we need to smash all interrupts */
69 baboon->mb_ifr &= ~events;
70#endif
71}
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020073/*
74 * Register the Baboon interrupt dispatcher on nubus slot $C.
75 */
76
77void __init baboon_register_interrupts(void)
78{
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020079 irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020080}
81
Finn Thain746e8d32008-11-18 20:45:21 +010082/*
Finn Thainfeb11e82011-10-24 01:11:19 +110083 * The means for masking individual Baboon interrupts remains a mystery.
84 * However, since we only use the IDE IRQ, we can just enable/disable all
85 * Baboon interrupts. If/when we handle more than one Baboon IRQ, we must
86 * either figure out how to mask them individually or else implement the
87 * same workaround that's used for NuBus slots (see nubus_disabled and
88 * via_nubus_irq_shutdown).
Finn Thain746e8d32008-11-18 20:45:21 +010089 */
90
91void baboon_irq_enable(int irq)
92{
Finn Thainfeb11e82011-10-24 01:11:19 +110093 mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C));
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
Finn Thain746e8d32008-11-18 20:45:21 +010096void baboon_irq_disable(int irq)
97{
Finn Thainfeb11e82011-10-24 01:11:19 +110098 mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C));
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}