2 * Apple Peripheral System Controller (PSC)
4 * The PSC is used on the AV Macs to control IO functions not handled
5 * by the VIAs (Ethernet, DSP, SCC).
9 * Try to figure out what's going on in pIFR5 and pIFR6. There seem to be
10 * persisant interrupt conditions in those registers and I have no idea what
11 * they are. Granted it doesn't affect since we're not enabling any interrupts
12 * on those levels at the moment, but it would be nice to know. I have a feeling
13 * they aren't actually interrupt lines but data lines (to the DSP?)
16 #include <linux/types.h>
17 #include <linux/kernel.h>
19 #include <linux/delay.h>
20 #include <linux/init.h>
21 #include <linux/irq.h>
23 #include <asm/traps.h>
24 #include <asm/macintosh.h>
25 #include <asm/macints.h>
26 #include <asm/mac_psc.h>
31 EXPORT_SYMBOL_GPL(psc
);
34 * Debugging dump, used in various places to see what's going on.
37 static void psc_debug_dump(void)
44 for (i
= 0x30 ; i
< 0x70 ; i
+= 0x10) {
45 printk(KERN_DEBUG
"PSC #%d: IFR = 0x%02X IER = 0x%02X\n",
47 (int) psc_read_byte(pIFRbase
+ i
),
48 (int) psc_read_byte(pIERbase
+ i
));
53 * Try to kill all DMA channels on the PSC. Not sure how this his
54 * supposed to work; this is code lifted from macmace.c and then
55 * expanded to cover what I think are the other 7 channels.
58 static __init
void psc_dma_die_die_die(void)
62 for (i
= 0 ; i
< 9 ; i
++) {
63 psc_write_word(PSC_CTL_BASE
+ (i
<< 4), 0x8800);
64 psc_write_word(PSC_CTL_BASE
+ (i
<< 4), 0x1000);
65 psc_write_word(PSC_CMD_BASE
+ (i
<< 5), 0x1100);
66 psc_write_word(PSC_CMD_BASE
+ (i
<< 5) + 0x10, 0x1100);
71 * Initialize the PSC. For now this just involves shutting down all
72 * interrupt sources using the IERs.
75 void __init
psc_init(void)
79 if (macintosh_config
->ident
!= MAC_MODEL_C660
80 && macintosh_config
->ident
!= MAC_MODEL_Q840
)
87 * The PSC is always at the same spot, but using psc
88 * keeps things consistent with the psc_xxxx functions.
91 psc
= (void *) PSC_BASE
;
93 pr_debug("PSC detected at %p\n", psc
);
95 psc_dma_die_die_die();
101 * Mask and clear all possible interrupts
104 for (i
= 0x30 ; i
< 0x70 ; i
+= 0x10) {
105 psc_write_byte(pIERbase
+ i
, 0x0F);
106 psc_write_byte(pIFRbase
+ i
, 0x0F);
111 * PSC interrupt handler. It's a lot like the VIA interrupt handler.
114 static void psc_irq(struct irq_desc
*desc
)
116 unsigned int offset
= (unsigned int)irq_desc_get_handler_data(desc
);
117 unsigned int irq
= irq_desc_get_irq(desc
);
118 int pIFR
= pIFRbase
+ offset
;
119 int pIER
= pIERbase
+ offset
;
121 unsigned char irq_bit
, events
;
123 events
= psc_read_byte(pIFR
) & psc_read_byte(pIER
) & 0xF;
130 if (events
& irq_bit
) {
131 psc_write_byte(pIFR
, irq_bit
);
132 generic_handle_irq(irq_num
);
136 } while (events
>= irq_bit
);
140 * Register the PSC interrupt dispatchers for autovector interrupts 3-6.
143 void __init
psc_register_interrupts(void)
145 irq_set_chained_handler_and_data(IRQ_AUTO_3
, psc_irq
, (void *)0x30);
146 irq_set_chained_handler_and_data(IRQ_AUTO_4
, psc_irq
, (void *)0x40);
147 irq_set_chained_handler_and_data(IRQ_AUTO_5
, psc_irq
, (void *)0x50);
148 irq_set_chained_handler_and_data(IRQ_AUTO_6
, psc_irq
, (void *)0x60);
151 void psc_irq_enable(int irq
) {
152 int irq_src
= IRQ_SRC(irq
);
153 int irq_idx
= IRQ_IDX(irq
);
154 int pIER
= pIERbase
+ (irq_src
<< 4);
156 psc_write_byte(pIER
, (1 << irq_idx
) | 0x80);
159 void psc_irq_disable(int irq
) {
160 int irq_src
= IRQ_SRC(irq
);
161 int irq_idx
= IRQ_IDX(irq
);
162 int pIER
= pIERbase
+ (irq_src
<< 4);
164 psc_write_byte(pIER
, 1 << irq_idx
);