3
* Written by Joshua M. Thompson (funaho@jurai.org)
6
* This chip is used in the IIfx in place of VIA #2. It acts like a fancy
7
* VIA chip with prorammable interrupt levels.
9
* 990502 (jmt) - Major rewrite for new interrupt architecture as well as some
10
* recent insights into OSS operational details.
11
* 990610 (jmt) - Now taking full advantage of the OSS. Interrupts are mapped
12
* to mostly match the A/UX interrupt scheme supported on the
13
* VIA side. Also added support for enabling the ISM irq again
14
* since we now have a functional IOP manager.
17
#include <linux/types.h>
18
#include <linux/kernel.h>
20
#include <linux/delay.h>
21
#include <linux/init.h>
22
#include <linux/irq.h>
24
#include <asm/bootinfo.h>
25
#include <asm/macintosh.h>
26
#include <asm/macints.h>
27
#include <asm/mac_via.h>
28
#include <asm/mac_oss.h>
31
volatile struct mac_oss *oss;
33
extern void via1_irq(unsigned int irq, struct irq_desc *desc);
38
* The OSS "detection" code is actually in via_init() which is always called
39
* before us. Thus we can count on oss_present being valid on entry.
42
void __init oss_init(void)
46
if (!oss_present) return;
48
oss = (struct mac_oss *) OSS_BASE;
50
/* Disable all interrupts. Unlike a VIA it looks like we */
51
/* do this by setting the source's interrupt level to zero. */
53
for (i = 0; i <= OSS_NUM_SOURCES; i++) {
54
oss->irq_level[i] = OSS_IRQLEV_DISABLED;
56
/* If we disable VIA1 here, we never really handle it... */
57
oss->irq_level[OSS_VIA1] = OSS_IRQLEV_VIA1;
61
* Initialize OSS for Nubus access
64
void __init oss_nubus_init(void)
69
* Handle miscellaneous OSS interrupts. Right now that's just sound
70
* and SCSI; everything else is routed to its own autovector IRQ.
73
static void oss_irq(unsigned int irq, struct irq_desc *desc)
77
events = oss->irq_pending & (OSS_IP_SOUND|OSS_IP_SCSI);
82
if ((console_loglevel == 10) && !(events & OSS_IP_SCSI)) {
83
printk("oss_irq: irq %u events = 0x%04X\n", irq,
84
(int) oss->irq_pending);
87
/* FIXME: how do you clear a pending IRQ? */
89
if (events & OSS_IP_SOUND) {
90
oss->irq_pending &= ~OSS_IP_SOUND;
91
/* FIXME: call sound handler */
92
} else if (events & OSS_IP_SCSI) {
93
oss->irq_pending &= ~OSS_IP_SCSI;
94
generic_handle_irq(IRQ_MAC_SCSI);
96
/* FIXME: error check here? */
101
* Nubus IRQ handler, OSS style
103
* Unlike the VIA/RBV this is on its own autovector interrupt level.
106
static void oss_nubus_irq(unsigned int irq, struct irq_desc *desc)
108
int events, irq_bit, i;
110
events = oss->irq_pending & OSS_IP_NUBUS;
114
#ifdef DEBUG_NUBUS_INT
115
if (console_loglevel > 7) {
116
printk("oss_nubus_irq: events = 0x%04X\n", events);
119
/* There are only six slots on the OSS, not seven */
126
if (events & irq_bit) {
127
oss->irq_pending &= ~irq_bit;
128
generic_handle_irq(NUBUS_SOURCE_BASE + i);
130
} while(events & (irq_bit - 1));
134
* Register the OSS and NuBus interrupt dispatchers.
137
void __init oss_register_interrupts(void)
139
irq_set_chained_handler(OSS_IRQLEV_SCSI, oss_irq);
140
irq_set_chained_handler(OSS_IRQLEV_NUBUS, oss_nubus_irq);
141
irq_set_chained_handler(OSS_IRQLEV_SOUND, oss_irq);
142
irq_set_chained_handler(OSS_IRQLEV_VIA1, via1_irq);
146
* Enable an OSS interrupt
148
* It looks messy but it's rather straightforward. The switch() statement
149
* just maps the machspec interrupt numbers to the right OSS interrupt
150
* source (if the OSS handles that interrupt) and then sets the interrupt
151
* level for that source to nonzero, thus enabling the interrupt.
154
void oss_irq_enable(int irq) {
156
printk("oss_irq_enable(%d)\n", irq);
160
oss->irq_level[OSS_IOPSCC] = OSS_IRQLEV_IOPSCC;
163
oss->irq_level[OSS_IOPISM] = OSS_IRQLEV_IOPISM;
166
oss->irq_level[OSS_SCSI] = OSS_IRQLEV_SCSI;
174
irq -= NUBUS_SOURCE_BASE;
175
oss->irq_level[irq] = OSS_IRQLEV_NUBUS;
179
printk("%s unknown irq %d\n", __func__, irq);
186
* Disable an OSS interrupt
188
* Same as above except we set the source's interrupt level to zero,
189
* to disable the interrupt.
192
void oss_irq_disable(int irq) {
194
printk("oss_irq_disable(%d)\n", irq);
198
oss->irq_level[OSS_IOPSCC] = OSS_IRQLEV_DISABLED;
201
oss->irq_level[OSS_IOPISM] = OSS_IRQLEV_DISABLED;
204
oss->irq_level[OSS_SCSI] = OSS_IRQLEV_DISABLED;
212
irq -= NUBUS_SOURCE_BASE;
213
oss->irq_level[irq] = OSS_IRQLEV_DISABLED;
217
printk("%s unknown irq %d\n", __func__, irq);
224
* Clear an OSS interrupt
226
* Not sure if this works or not but it's the only method I could
227
* think of based on the contents of the mac_oss structure.
230
void oss_irq_clear(int irq) {
231
/* FIXME: how to do this on OSS? */
234
oss->irq_pending &= ~OSS_IP_IOPSCC;
237
oss->irq_pending &= ~OSS_IP_IOPISM;
240
oss->irq_pending &= ~OSS_IP_SCSI;
248
irq -= NUBUS_SOURCE_BASE;
249
oss->irq_pending &= ~(1 << irq);
255
* Check to see if a specific OSS interrupt is pending
258
int oss_irq_pending(int irq)
262
return oss->irq_pending & OSS_IP_IOPSCC;
265
return oss->irq_pending & OSS_IP_IOPISM;
268
return oss->irq_pending & OSS_IP_SCSI;
276
irq -= NUBUS_SOURCE_BASE;
277
return oss->irq_pending & (1 << irq);