2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Baboon Custom IC Management
|
|
|
|
*
|
|
|
|
* The Baboon custom IC controls the IDE, PCMCIA and media bay on the
|
|
|
|
* PowerBook 190. It multiplexes multiple interrupt sources onto the
|
|
|
|
* Nubus slot $C interrupt.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include <asm/traps.h>
|
|
|
|
#include <asm/bootinfo.h>
|
|
|
|
#include <asm/macintosh.h>
|
|
|
|
#include <asm/macints.h>
|
|
|
|
#include <asm/mac_baboon.h>
|
|
|
|
|
|
|
|
/* #define DEBUG_IRQS */
|
|
|
|
|
2008-11-19 02:45:21 +07:00
|
|
|
extern void mac_enable_irq(unsigned int);
|
|
|
|
extern void mac_disable_irq(unsigned int);
|
|
|
|
|
2007-05-02 03:32:58 +07:00
|
|
|
int baboon_present;
|
2008-07-18 02:16:25 +07:00
|
|
|
static volatile struct baboon *baboon;
|
2008-11-19 02:45:21 +07:00
|
|
|
static unsigned char baboon_disabled;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
extern int macide_ack_intr(struct ata_channel *);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Baboon initialization.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void __init baboon_init(void)
|
|
|
|
{
|
|
|
|
if (macintosh_config->ident != MAC_MODEL_PB190) {
|
|
|
|
baboon = NULL;
|
|
|
|
baboon_present = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
baboon = (struct baboon *) BABOON_BASE;
|
|
|
|
baboon_present = 1;
|
|
|
|
|
|
|
|
printk("Baboon detected at %p\n", baboon);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Baboon interrupt handler. This works a lot like a VIA.
|
|
|
|
*/
|
|
|
|
|
2008-07-18 02:16:25 +07:00
|
|
|
static irqreturn_t baboon_irq(int irq, void *dev_id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-05-02 03:32:56 +07:00
|
|
|
int irq_bit, irq_num;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned char events;
|
|
|
|
|
|
|
|
#ifdef DEBUG_IRQS
|
2007-05-02 03:32:58 +07:00
|
|
|
printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
(uint) baboon->mb_control, (uint) baboon->mb_ifr,
|
2007-05-02 03:32:58 +07:00
|
|
|
(uint) baboon->mb_status);
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!(events = baboon->mb_ifr & 0x07))
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
2007-05-02 03:32:56 +07:00
|
|
|
irq_num = IRQ_BABOON_0;
|
|
|
|
irq_bit = 1;
|
|
|
|
do {
|
2007-05-02 03:32:58 +07:00
|
|
|
if (events & irq_bit) {
|
2007-05-02 03:32:55 +07:00
|
|
|
baboon->mb_ifr &= ~irq_bit;
|
2007-05-02 03:32:56 +07:00
|
|
|
m68k_handle_int(irq_num);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-05-02 03:32:56 +07:00
|
|
|
irq_bit <<= 1;
|
|
|
|
irq_num++;
|
|
|
|
} while(events >= irq_bit);
|
2005-04-17 05:20:36 +07:00
|
|
|
#if 0
|
|
|
|
if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
|
|
|
|
/* for now we need to smash all interrupts */
|
|
|
|
baboon->mb_ifr &= ~events;
|
|
|
|
#endif
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2008-07-18 02:16:25 +07:00
|
|
|
/*
|
|
|
|
* Register the Baboon interrupt dispatcher on nubus slot $C.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void __init baboon_register_interrupts(void)
|
|
|
|
{
|
2008-11-19 02:45:21 +07:00
|
|
|
baboon_disabled = 0;
|
2008-12-30 20:02:27 +07:00
|
|
|
if (request_irq(IRQ_NUBUS_C, baboon_irq, 0, "baboon", (void *)baboon))
|
|
|
|
pr_err("Couldn't register baboon interrupt\n");
|
2008-07-18 02:16:25 +07:00
|
|
|
}
|
|
|
|
|
2008-11-19 02:45:21 +07:00
|
|
|
/*
|
|
|
|
* The means for masking individual baboon interrupts remains a mystery, so
|
|
|
|
* enable the umbrella interrupt only when no baboon interrupt is disabled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void baboon_irq_enable(int irq)
|
|
|
|
{
|
|
|
|
int irq_idx = IRQ_IDX(irq);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef DEBUG_IRQUSE
|
|
|
|
printk("baboon_irq_enable(%d)\n", irq);
|
|
|
|
#endif
|
2008-11-19 02:45:21 +07:00
|
|
|
|
|
|
|
baboon_disabled &= ~(1 << irq_idx);
|
|
|
|
if (!baboon_disabled)
|
|
|
|
mac_enable_irq(IRQ_NUBUS_C);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-11-19 02:45:21 +07:00
|
|
|
void baboon_irq_disable(int irq)
|
|
|
|
{
|
|
|
|
int irq_idx = IRQ_IDX(irq);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef DEBUG_IRQUSE
|
|
|
|
printk("baboon_irq_disable(%d)\n", irq);
|
|
|
|
#endif
|
2008-11-19 02:45:21 +07:00
|
|
|
|
|
|
|
baboon_disabled |= 1 << irq_idx;
|
|
|
|
if (baboon_disabled)
|
|
|
|
mac_disable_irq(IRQ_NUBUS_C);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-11-19 02:45:21 +07:00
|
|
|
void baboon_irq_clear(int irq)
|
|
|
|
{
|
|
|
|
int irq_idx = IRQ_IDX(irq);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
baboon->mb_ifr &= ~(1 << irq_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
int baboon_irq_pending(int irq)
|
|
|
|
{
|
2008-11-19 02:45:21 +07:00
|
|
|
int irq_idx = IRQ_IDX(irq);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return baboon->mb_ifr & (1 << irq_idx);
|
|
|
|
}
|