1 // SPDX-License-Identifier: GPL-2.0
3 * Operating System Services (OSS) chip handling
4 * Written by Joshua M. Thompson (funaho@jurai.org)
7 * This chip is used in the IIfx in place of VIA #2. It acts like a fancy
8 * VIA chip with prorammable interrupt levels.
10 * 990502 (jmt) - Major rewrite for new interrupt architecture as well as some
11 * recent insights into OSS operational details.
12 * 990610 (jmt) - Now taking full advantage of the OSS. Interrupts are mapped
13 * to mostly match the A/UX interrupt scheme supported on the
14 * VIA side. Also added support for enabling the ISM irq again
15 * since we now have a functional IOP manager.
18 #include <linux/types.h>
19 #include <linux/kernel.h>
21 #include <linux/delay.h>
22 #include <linux/init.h>
23 #include <linux/irq.h>
25 #include <asm/macintosh.h>
26 #include <asm/macints.h>
27 #include <asm/mac_via.h>
28 #include <asm/mac_oss.h>
33 volatile struct mac_oss
*oss
;
39 void __init
oss_init(void)
43 if (macintosh_config
->ident
!= MAC_MODEL_IIFX
)
46 oss
= (struct mac_oss
*) OSS_BASE
;
47 pr_debug("OSS detected at %p", oss
);
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
] = 0;
58 * Handle OSS interrupts.
59 * XXX how do you clear a pending IRQ? is it even necessary?
62 static void oss_iopism_irq(struct irq_desc
*desc
)
64 generic_handle_irq(IRQ_MAC_ADB
);
67 static void oss_scsi_irq(struct irq_desc
*desc
)
69 generic_handle_irq(IRQ_MAC_SCSI
);
72 static void oss_nubus_irq(struct irq_desc
*desc
)
77 events
= oss
->irq_pending
& OSS_IP_NUBUS
;
78 irq_num
= NUBUS_SOURCE_BASE
+ 5;
79 irq_bit
= OSS_IP_NUBUS5
;
81 if (events
& irq_bit
) {
83 generic_handle_irq(irq_num
);
90 static void oss_iopscc_irq(struct irq_desc
*desc
)
92 generic_handle_irq(IRQ_MAC_SCC
);
96 * Register the OSS and NuBus interrupt dispatchers.
98 * This IRQ mapping is laid out with two things in mind: first, we try to keep
99 * things on their own levels to avoid having to do double-dispatches. Second,
100 * the levels match as closely as possible the alternate IRQ mapping mode (aka
101 * "A/UX mode") available on some VIA machines.
104 #define OSS_IRQLEV_IOPISM IRQ_AUTO_1
105 #define OSS_IRQLEV_SCSI IRQ_AUTO_2
106 #define OSS_IRQLEV_NUBUS IRQ_AUTO_3
107 #define OSS_IRQLEV_IOPSCC IRQ_AUTO_4
108 #define OSS_IRQLEV_VIA1 IRQ_AUTO_6
110 void __init
oss_register_interrupts(void)
112 irq_set_chained_handler(OSS_IRQLEV_IOPISM
, oss_iopism_irq
);
113 irq_set_chained_handler(OSS_IRQLEV_SCSI
, oss_scsi_irq
);
114 irq_set_chained_handler(OSS_IRQLEV_NUBUS
, oss_nubus_irq
);
115 irq_set_chained_handler(OSS_IRQLEV_IOPSCC
, oss_iopscc_irq
);
116 irq_set_chained_handler(OSS_IRQLEV_VIA1
, via1_irq
);
118 /* OSS_VIA1 gets enabled here because it has no machspec interrupt. */
119 oss
->irq_level
[OSS_VIA1
] = OSS_IRQLEV_VIA1
;
123 * Enable an OSS interrupt
125 * It looks messy but it's rather straightforward. The switch() statement
126 * just maps the machspec interrupt numbers to the right OSS interrupt
127 * source (if the OSS handles that interrupt) and then sets the interrupt
128 * level for that source to nonzero, thus enabling the interrupt.
131 void oss_irq_enable(int irq
) {
134 oss
->irq_level
[OSS_IOPSCC
] = OSS_IRQLEV_IOPSCC
;
137 oss
->irq_level
[OSS_IOPISM
] = OSS_IRQLEV_IOPISM
;
140 oss
->irq_level
[OSS_SCSI
] = OSS_IRQLEV_SCSI
;
148 irq
-= NUBUS_SOURCE_BASE
;
149 oss
->irq_level
[irq
] = OSS_IRQLEV_NUBUS
;
153 if (IRQ_SRC(irq
) == 1)
158 * Disable an OSS interrupt
160 * Same as above except we set the source's interrupt level to zero,
161 * to disable the interrupt.
164 void oss_irq_disable(int irq
) {
167 oss
->irq_level
[OSS_IOPSCC
] = 0;
170 oss
->irq_level
[OSS_IOPISM
] = 0;
173 oss
->irq_level
[OSS_SCSI
] = 0;
181 irq
-= NUBUS_SOURCE_BASE
;
182 oss
->irq_level
[irq
] = 0;
186 if (IRQ_SRC(irq
) == 1)
187 via_irq_disable(irq
);