blob: 514acde3cd4005067adf3a0f7adddbc2334ea263 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Geert Uytterhoevenddc7fd22011-07-13 21:48:30 +020011#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/macintosh.h>
14#include <asm/macints.h>
15#include <asm/mac_baboon.h>
16
Finn Thain217f6712007-05-01 22:32:58 +020017int baboon_present;
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020018static volatile struct baboon *baboon;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#if 0
21extern int macide_ack_intr(struct ata_channel *);
22#endif
23
24/*
25 * Baboon initialization.
26 */
27
28void __init baboon_init(void)
29{
30 if (macintosh_config->ident != MAC_MODEL_PB190) {
31 baboon = NULL;
32 baboon_present = 0;
33 return;
34 }
35
36 baboon = (struct baboon *) BABOON_BASE;
37 baboon_present = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 printk("Baboon detected at %p\n", baboon);
40}
41
42/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 * Baboon interrupt handler. This works a lot like a VIA.
44 */
45
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020046static void baboon_irq(struct irq_desc *desc)
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020047{
48 int irq_bit, irq_num;
49 unsigned char events;
50
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020051 events = baboon->mb_ifr & 0x07;
52 if (!events)
53 return;
54
55 irq_num = IRQ_BABOON_0;
56 irq_bit = 1;
57 do {
58 if (events & irq_bit) {
59 baboon->mb_ifr &= ~irq_bit;
60 generic_handle_irq(irq_num);
61 }
62 irq_bit <<= 1;
63 irq_num++;
64 } while(events >= irq_bit);
65#if 0
66 if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
67 /* for now we need to smash all interrupts */
68 baboon->mb_ifr &= ~events;
69#endif
70}
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020072/*
73 * Register the Baboon interrupt dispatcher on nubus slot $C.
74 */
75
76void __init baboon_register_interrupts(void)
77{
Geert Uytterhoeven9145db52011-08-10 12:48:29 +020078 irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);
Adrian Bunk8dfbdf42008-07-17 21:16:25 +020079}
80
Finn Thain746e8d32008-11-18 20:45:21 +010081/*
Finn Thainfeb11e82011-10-24 01:11:19 +110082 * The means for masking individual Baboon interrupts remains a mystery.
83 * However, since we only use the IDE IRQ, we can just enable/disable all
84 * Baboon interrupts. If/when we handle more than one Baboon IRQ, we must
85 * either figure out how to mask them individually or else implement the
86 * same workaround that's used for NuBus slots (see nubus_disabled and
87 * via_nubus_irq_shutdown).
Finn Thain746e8d32008-11-18 20:45:21 +010088 */
89
90void baboon_irq_enable(int irq)
91{
Finn Thainfeb11e82011-10-24 01:11:19 +110092 mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C));
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Finn Thain746e8d32008-11-18 20:45:21 +010095void baboon_irq_disable(int irq)
96{
Finn Thainfeb11e82011-10-24 01:11:19 +110097 mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C));
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}