// SPDX-License-Identifier: GPL-2.01/*2* Baboon Custom IC Management3*4* The Baboon custom IC controls the IDE, PCMCIA and media bay on the5* PowerBook 190. It multiplexes multiple interrupt sources onto the6* Nubus slot $C interrupt.7*/89#include <linux/types.h>10#include <linux/kernel.h>11#include <linux/irq.h>1213#include <asm/macintosh.h>14#include <asm/macints.h>15#include <asm/mac_baboon.h>1617#include "mac.h"1819int baboon_present;20static volatile struct baboon *baboon;2122/*23* Baboon initialization.24*/2526void __init baboon_init(void)27{28if (macintosh_config->ident != MAC_MODEL_PB190) {29baboon = NULL;30baboon_present = 0;31return;32}3334baboon = (struct baboon *) BABOON_BASE;35baboon_present = 1;3637pr_debug("Baboon detected at %p\n", baboon);38}3940/*41* Baboon interrupt handler.42* XXX how do you clear a pending IRQ? is it even necessary?43*/4445static void baboon_irq(struct irq_desc *desc)46{47short events, irq_bit;48int irq_num;4950events = baboon->mb_ifr & 0x07;51irq_num = IRQ_BABOON_0;52irq_bit = 1;53do {54if (events & irq_bit) {55events &= ~irq_bit;56generic_handle_irq(irq_num);57}58++irq_num;59irq_bit <<= 1;60} while (events);61}6263/*64* Register the Baboon interrupt dispatcher on nubus slot $C.65*/6667void __init baboon_register_interrupts(void)68{69irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);70}7172/*73* The means for masking individual Baboon interrupts remains a mystery.74* However, since we only use the IDE IRQ, we can just enable/disable all75* Baboon interrupts. If/when we handle more than one Baboon IRQ, we must76* either figure out how to mask them individually or else implement the77* same workaround that's used for NuBus slots (see nubus_disabled and78* via_nubus_irq_shutdown).79*/8081void baboon_irq_enable(int irq)82{83mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C));84}8586void baboon_irq_disable(int irq)87{88mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C));89}909192