blob: ef365cc04bd9c3463603403b8ce86c9183677728 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
3 *
4 * Copyright (C) 1997 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 *
10 * This is a duplicate of open_pic.c that deals with U3s MPIC on
11 * G5 PowerMacs. It's the same file except it's using big endian
12 * register accesses
13 */
14
15#include <linux/config.h>
16#include <linux/types.h>
17#include <linux/kernel.h>
18#include <linux/sched.h>
19#include <linux/init.h>
20#include <linux/irq.h>
21#include <linux/interrupt.h>
22#include <linux/sysdev.h>
23#include <linux/errno.h>
24#include <asm/ptrace.h>
25#include <asm/signal.h>
26#include <asm/io.h>
27#include <asm/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/sections.h>
29#include <asm/open_pic.h>
30#include <asm/i8259.h>
Paul Mackerrasfd582ec2005-10-11 22:08:12 +100031#include <asm/machdep.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include "open_pic_defs.h"
34
35void *OpenPIC2_Addr;
36static volatile struct OpenPIC *OpenPIC2 = NULL;
37/*
38 * We define OpenPIC_InitSenses table thusly:
39 * bit 0x1: sense, 0 for edge and 1 for level.
40 * bit 0x2: polarity, 0 for negative, 1 for positive.
41 */
42extern u_int OpenPIC_NumInitSenses;
43extern u_char *OpenPIC_InitSenses;
44extern int use_of_interrupt_tree;
45
46static u_int NumProcessors;
47static u_int NumSources;
48static int open_pic2_irq_offset;
49static volatile OpenPIC_Source *ISR[NR_IRQS];
50
51/* Global Operations */
52static void openpic2_disable_8259_pass_through(void);
53static void openpic2_set_priority(u_int pri);
54static void openpic2_set_spurious(u_int vector);
55
56/* Timer Interrupts */
57static void openpic2_inittimer(u_int timer, u_int pri, u_int vector);
58static void openpic2_maptimer(u_int timer, u_int cpumask);
59
60/* Interrupt Sources */
61static void openpic2_enable_irq(u_int irq);
62static void openpic2_disable_irq(u_int irq);
63static void openpic2_initirq(u_int irq, u_int pri, u_int vector, int polarity,
64 int is_level);
65static void openpic2_mapirq(u_int irq, u_int cpumask, u_int keepmask);
66
67/*
68 * These functions are not used but the code is kept here
69 * for completeness and future reference.
70 */
71static void openpic2_reset(void);
72#ifdef notused
73static void openpic2_enable_8259_pass_through(void);
74static u_int openpic2_get_priority(void);
75static u_int openpic2_get_spurious(void);
76static void openpic2_set_sense(u_int irq, int sense);
77#endif /* notused */
78
79/*
80 * Description of the openpic for the higher-level irq code
81 */
82static void openpic2_end_irq(unsigned int irq_nr);
83static void openpic2_ack_irq(unsigned int irq_nr);
84
85struct hw_interrupt_type open_pic2 = {
Thomas Gleixner2830e212005-09-10 00:26:40 -070086 .typename = " OpenPIC2 ",
87 .enable = openpic2_enable_irq,
88 .disable = openpic2_disable_irq,
89 .ack = openpic2_ack_irq,
90 .end = openpic2_end_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070091};
92
93/*
94 * Accesses to the current processor's openpic registers
95 * On cascaded controller, this is only CPU 0
96 */
97#define THIS_CPU Processor[0]
98#define DECL_THIS_CPU
99#define CHECK_THIS_CPU
100
101#if 1
102#define check_arg_ipi(ipi) \
103 if (ipi < 0 || ipi >= OPENPIC_NUM_IPI) \
104 printk("open_pic.c:%d: illegal ipi %d\n", __LINE__, ipi);
105#define check_arg_timer(timer) \
106 if (timer < 0 || timer >= OPENPIC_NUM_TIMERS) \
107 printk("open_pic.c:%d: illegal timer %d\n", __LINE__, timer);
108#define check_arg_vec(vec) \
109 if (vec < 0 || vec >= OPENPIC_NUM_VECTORS) \
110 printk("open_pic.c:%d: illegal vector %d\n", __LINE__, vec);
111#define check_arg_pri(pri) \
112 if (pri < 0 || pri >= OPENPIC_NUM_PRI) \
113 printk("open_pic.c:%d: illegal priority %d\n", __LINE__, pri);
114/*
115 * Print out a backtrace if it's out of range, since if it's larger than NR_IRQ's
116 * data has probably been corrupted and we're going to panic or deadlock later
117 * anyway --Troy
118 */
119extern unsigned long* _get_SP(void);
120#define check_arg_irq(irq) \
121 if (irq < open_pic2_irq_offset || irq >= NumSources+open_pic2_irq_offset \
122 || ISR[irq - open_pic2_irq_offset] == 0) { \
123 printk("open_pic.c:%d: illegal irq %d\n", __LINE__, irq); \
124 /*print_backtrace(_get_SP());*/ }
125#define check_arg_cpu(cpu) \
126 if (cpu < 0 || cpu >= NumProcessors){ \
127 printk("open_pic2.c:%d: illegal cpu %d\n", __LINE__, cpu); \
128 /*print_backtrace(_get_SP());*/ }
129#else
130#define check_arg_ipi(ipi) do {} while (0)
131#define check_arg_timer(timer) do {} while (0)
132#define check_arg_vec(vec) do {} while (0)
133#define check_arg_pri(pri) do {} while (0)
134#define check_arg_irq(irq) do {} while (0)
135#define check_arg_cpu(cpu) do {} while (0)
136#endif
137
138static u_int openpic2_read(volatile u_int *addr)
139{
140 u_int val;
141
142 val = in_be32(addr);
143 return val;
144}
145
146static inline void openpic2_write(volatile u_int *addr, u_int val)
147{
148 out_be32(addr, val);
149}
150
151static inline u_int openpic2_readfield(volatile u_int *addr, u_int mask)
152{
153 u_int val = openpic2_read(addr);
154 return val & mask;
155}
156
157inline void openpic2_writefield(volatile u_int *addr, u_int mask,
158 u_int field)
159{
160 u_int val = openpic2_read(addr);
161 openpic2_write(addr, (val & ~mask) | (field & mask));
162}
163
164static inline void openpic2_clearfield(volatile u_int *addr, u_int mask)
165{
166 openpic2_writefield(addr, mask, 0);
167}
168
169static inline void openpic2_setfield(volatile u_int *addr, u_int mask)
170{
171 openpic2_writefield(addr, mask, mask);
172}
173
174static void openpic2_safe_writefield(volatile u_int *addr, u_int mask,
175 u_int field)
176{
177 openpic2_setfield(addr, OPENPIC_MASK);
178 while (openpic2_read(addr) & OPENPIC_ACTIVITY);
179 openpic2_writefield(addr, mask | OPENPIC_MASK, field | OPENPIC_MASK);
180}
181
182static void openpic2_reset(void)
183{
184 openpic2_setfield(&OpenPIC2->Global.Global_Configuration0,
185 OPENPIC_CONFIG_RESET);
186 while (openpic2_readfield(&OpenPIC2->Global.Global_Configuration0,
187 OPENPIC_CONFIG_RESET))
188 mb();
189}
190
191void __init openpic2_set_sources(int first_irq, int num_irqs, void *first_ISR)
192{
193 volatile OpenPIC_Source *src = first_ISR;
194 int i, last_irq;
195
196 last_irq = first_irq + num_irqs;
197 if (last_irq > NumSources)
198 NumSources = last_irq;
199 if (src == 0)
200 src = &((struct OpenPIC *)OpenPIC2_Addr)->Source[first_irq];
201 for (i = first_irq; i < last_irq; ++i, ++src)
202 ISR[i] = src;
203}
204
205/*
206 * The `offset' parameter defines where the interrupts handled by the
207 * OpenPIC start in the space of interrupt numbers that the kernel knows
208 * about. In other words, the OpenPIC's IRQ0 is numbered `offset' in the
209 * kernel's interrupt numbering scheme.
210 * We assume there is only one OpenPIC.
211 */
212void __init openpic2_init(int offset)
213{
214 u_int t, i;
215 u_int timerfreq;
216 const char *version;
217
218 if (!OpenPIC2_Addr) {
219 printk("No OpenPIC2 found !\n");
220 return;
221 }
222 OpenPIC2 = (volatile struct OpenPIC *)OpenPIC2_Addr;
223
224 if (ppc_md.progress) ppc_md.progress("openpic: enter", 0x122);
225
226 t = openpic2_read(&OpenPIC2->Global.Feature_Reporting0);
227 switch (t & OPENPIC_FEATURE_VERSION_MASK) {
228 case 1:
229 version = "1.0";
230 break;
231 case 2:
232 version = "1.2";
233 break;
234 case 3:
235 version = "1.3";
236 break;
237 default:
238 version = "?";
239 break;
240 }
241 NumProcessors = ((t & OPENPIC_FEATURE_LAST_PROCESSOR_MASK) >>
242 OPENPIC_FEATURE_LAST_PROCESSOR_SHIFT) + 1;
243 if (NumSources == 0)
244 openpic2_set_sources(0,
245 ((t & OPENPIC_FEATURE_LAST_SOURCE_MASK) >>
246 OPENPIC_FEATURE_LAST_SOURCE_SHIFT) + 1,
247 NULL);
248 printk("OpenPIC (2) Version %s (%d CPUs and %d IRQ sources) at %p\n",
249 version, NumProcessors, NumSources, OpenPIC2);
250 timerfreq = openpic2_read(&OpenPIC2->Global.Timer_Frequency);
251 if (timerfreq)
252 printk("OpenPIC timer frequency is %d.%06d MHz\n",
253 timerfreq / 1000000, timerfreq % 1000000);
254
255 open_pic2_irq_offset = offset;
256
257 /* Initialize timer interrupts */
258 if ( ppc_md.progress ) ppc_md.progress("openpic2: timer",0x3ba);
259 for (i = 0; i < OPENPIC_NUM_TIMERS; i++) {
260 /* Disabled, Priority 0 */
261 openpic2_inittimer(i, 0, OPENPIC2_VEC_TIMER+i+offset);
262 /* No processor */
263 openpic2_maptimer(i, 0);
264 }
265
266 /* Initialize external interrupts */
267 if (ppc_md.progress) ppc_md.progress("openpic2: external",0x3bc);
268
269 openpic2_set_priority(0xf);
270
271 /* Init all external sources, including possibly the cascade. */
272 for (i = 0; i < NumSources; i++) {
273 int sense;
274
275 if (ISR[i] == 0)
276 continue;
277
278 /* the bootloader may have left it enabled (bad !) */
279 openpic2_disable_irq(i+offset);
280
281 sense = (i < OpenPIC_NumInitSenses)? OpenPIC_InitSenses[i]: \
282 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE);
283
284 if (sense & IRQ_SENSE_MASK)
285 irq_desc[i+offset].status = IRQ_LEVEL;
286
287 /* Enabled, Priority 8 */
288 openpic2_initirq(i, 8, i+offset, (sense & IRQ_POLARITY_MASK),
289 (sense & IRQ_SENSE_MASK));
290 /* Processor 0 */
291 openpic2_mapirq(i, 1<<0, 0);
292 }
293
294 /* Init descriptors */
295 for (i = offset; i < NumSources + offset; i++)
296 irq_desc[i].handler = &open_pic2;
297
298 /* Initialize the spurious interrupt */
299 if (ppc_md.progress) ppc_md.progress("openpic2: spurious",0x3bd);
300 openpic2_set_spurious(OPENPIC2_VEC_SPURIOUS+offset);
301
302 openpic2_disable_8259_pass_through();
303 openpic2_set_priority(0);
304
305 if (ppc_md.progress) ppc_md.progress("openpic2: exit",0x222);
306}
307
308#ifdef notused
309static void openpic2_enable_8259_pass_through(void)
310{
311 openpic2_clearfield(&OpenPIC2->Global.Global_Configuration0,
312 OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);
313}
314#endif /* notused */
315
316/* This can't be __init, it is used in openpic_sleep_restore_intrs */
317static void openpic2_disable_8259_pass_through(void)
318{
319 openpic2_setfield(&OpenPIC2->Global.Global_Configuration0,
320 OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);
321}
322
323/*
324 * Find out the current interrupt
325 */
326u_int openpic2_irq(void)
327{
328 u_int vec;
329 DECL_THIS_CPU;
330
331 CHECK_THIS_CPU;
332 vec = openpic2_readfield(&OpenPIC2->THIS_CPU.Interrupt_Acknowledge,
333 OPENPIC_VECTOR_MASK);
334 return vec;
335}
336
337void openpic2_eoi(void)
338{
339 DECL_THIS_CPU;
340
341 CHECK_THIS_CPU;
342 openpic2_write(&OpenPIC2->THIS_CPU.EOI, 0);
343 /* Handle PCI write posting */
344 (void)openpic2_read(&OpenPIC2->THIS_CPU.EOI);
345}
346
347#ifdef notused
348static u_int openpic2_get_priority(void)
349{
350 DECL_THIS_CPU;
351
352 CHECK_THIS_CPU;
353 return openpic2_readfield(&OpenPIC2->THIS_CPU.Current_Task_Priority,
354 OPENPIC_CURRENT_TASK_PRIORITY_MASK);
355}
356#endif /* notused */
357
358static void __init openpic2_set_priority(u_int pri)
359{
360 DECL_THIS_CPU;
361
362 CHECK_THIS_CPU;
363 check_arg_pri(pri);
364 openpic2_writefield(&OpenPIC2->THIS_CPU.Current_Task_Priority,
365 OPENPIC_CURRENT_TASK_PRIORITY_MASK, pri);
366}
367
368/*
369 * Get/set the spurious vector
370 */
371#ifdef notused
372static u_int openpic2_get_spurious(void)
373{
374 return openpic2_readfield(&OpenPIC2->Global.Spurious_Vector,
375 OPENPIC_VECTOR_MASK);
376}
377#endif /* notused */
378
379/* This can't be __init, it is used in openpic_sleep_restore_intrs */
380static void openpic2_set_spurious(u_int vec)
381{
382 check_arg_vec(vec);
383 openpic2_writefield(&OpenPIC2->Global.Spurious_Vector, OPENPIC_VECTOR_MASK,
384 vec);
385}
386
387static DEFINE_SPINLOCK(openpic2_setup_lock);
388
389/*
390 * Initialize a timer interrupt (and disable it)
391 *
392 * timer: OpenPIC timer number
393 * pri: interrupt source priority
394 * vec: the vector it will produce
395 */
396static void __init openpic2_inittimer(u_int timer, u_int pri, u_int vec)
397{
398 check_arg_timer(timer);
399 check_arg_pri(pri);
400 check_arg_vec(vec);
401 openpic2_safe_writefield(&OpenPIC2->Global.Timer[timer].Vector_Priority,
402 OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK,
403 (pri << OPENPIC_PRIORITY_SHIFT) | vec);
404}
405
406/*
407 * Map a timer interrupt to one or more CPUs
408 */
409static void __init openpic2_maptimer(u_int timer, u_int cpumask)
410{
411 check_arg_timer(timer);
412 openpic2_write(&OpenPIC2->Global.Timer[timer].Destination,
413 cpumask);
414}
415
416/*
417 * Initalize the interrupt source which will generate an NMI.
418 * This raises the interrupt's priority from 8 to 9.
419 *
420 * irq: The logical IRQ which generates an NMI.
421 */
422void __init
423openpic2_init_nmi_irq(u_int irq)
424{
425 check_arg_irq(irq);
426 openpic2_safe_writefield(&ISR[irq - open_pic2_irq_offset]->Vector_Priority,
427 OPENPIC_PRIORITY_MASK,
428 9 << OPENPIC_PRIORITY_SHIFT);
429}
430
431/*
432 *
433 * All functions below take an offset'ed irq argument
434 *
435 */
436
437
438/*
439 * Enable/disable an external interrupt source
440 *
441 * Externally called, irq is an offseted system-wide interrupt number
442 */
443static void openpic2_enable_irq(u_int irq)
444{
445 volatile u_int *vpp;
446
447 check_arg_irq(irq);
448 vpp = &ISR[irq - open_pic2_irq_offset]->Vector_Priority;
449 openpic2_clearfield(vpp, OPENPIC_MASK);
450 /* make sure mask gets to controller before we return to user */
451 do {
452 mb(); /* sync is probably useless here */
453 } while (openpic2_readfield(vpp, OPENPIC_MASK));
454}
455
456static void openpic2_disable_irq(u_int irq)
457{
458 volatile u_int *vpp;
459 u32 vp;
460
461 check_arg_irq(irq);
462 vpp = &ISR[irq - open_pic2_irq_offset]->Vector_Priority;
463 openpic2_setfield(vpp, OPENPIC_MASK);
464 /* make sure mask gets to controller before we return to user */
465 do {
466 mb(); /* sync is probably useless here */
467 vp = openpic2_readfield(vpp, OPENPIC_MASK | OPENPIC_ACTIVITY);
468 } while((vp & OPENPIC_ACTIVITY) && !(vp & OPENPIC_MASK));
469}
470
471
472/*
473 * Initialize an interrupt source (and disable it!)
474 *
475 * irq: OpenPIC interrupt number
476 * pri: interrupt source priority
477 * vec: the vector it will produce
478 * pol: polarity (1 for positive, 0 for negative)
479 * sense: 1 for level, 0 for edge
480 */
481static void __init
482openpic2_initirq(u_int irq, u_int pri, u_int vec, int pol, int sense)
483{
484 openpic2_safe_writefield(&ISR[irq]->Vector_Priority,
485 OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
486 OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK,
487 (pri << OPENPIC_PRIORITY_SHIFT) | vec |
488 (pol ? OPENPIC_POLARITY_POSITIVE :
489 OPENPIC_POLARITY_NEGATIVE) |
490 (sense ? OPENPIC_SENSE_LEVEL : OPENPIC_SENSE_EDGE));
491}
492
493/*
494 * Map an interrupt source to one or more CPUs
495 */
496static void openpic2_mapirq(u_int irq, u_int physmask, u_int keepmask)
497{
498 if (ISR[irq] == 0)
499 return;
500 if (keepmask != 0)
501 physmask |= openpic2_read(&ISR[irq]->Destination) & keepmask;
502 openpic2_write(&ISR[irq]->Destination, physmask);
503}
504
505#ifdef notused
506/*
507 * Set the sense for an interrupt source (and disable it!)
508 *
509 * sense: 1 for level, 0 for edge
510 */
511static void openpic2_set_sense(u_int irq, int sense)
512{
513 if (ISR[irq] != 0)
514 openpic2_safe_writefield(&ISR[irq]->Vector_Priority,
515 OPENPIC_SENSE_LEVEL,
516 (sense ? OPENPIC_SENSE_LEVEL : 0));
517}
518#endif /* notused */
519
520/* No spinlocks, should not be necessary with the OpenPIC
521 * (1 register = 1 interrupt and we have the desc lock).
522 */
523static void openpic2_ack_irq(unsigned int irq_nr)
524{
525 openpic2_disable_irq(irq_nr);
526 openpic2_eoi();
527}
528
529static void openpic2_end_irq(unsigned int irq_nr)
530{
531 if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
532 openpic2_enable_irq(irq_nr);
533}
534
535int
536openpic2_get_irq(struct pt_regs *regs)
537{
538 int irq = openpic2_irq();
539
540 if (irq == (OPENPIC2_VEC_SPURIOUS + open_pic2_irq_offset))
541 irq = -1;
542 return irq;
543}
544
545#ifdef CONFIG_PM
546
547/*
548 * We implement the IRQ controller as a sysdev and put it
549 * to sleep at powerdown stage (the callback is named suspend,
550 * but it's old semantics, for the Device Model, it's really
551 * powerdown). The possible problem is that another sysdev that
552 * happens to be suspend after this one will have interrupts off,
553 * that may be an issue... For now, this isn't an issue on pmac
554 * though...
555 */
556
557static u32 save_ipi_vp[OPENPIC_NUM_IPI];
558static u32 save_irq_src_vp[OPENPIC_MAX_SOURCES];
559static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
560static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
561static int openpic_suspend_count;
562
563static void openpic2_cached_enable_irq(u_int irq)
564{
565 check_arg_irq(irq);
566 save_irq_src_vp[irq - open_pic2_irq_offset] &= ~OPENPIC_MASK;
567}
568
569static void openpic2_cached_disable_irq(u_int irq)
570{
571 check_arg_irq(irq);
572 save_irq_src_vp[irq - open_pic2_irq_offset] |= OPENPIC_MASK;
573}
574
575/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
576 * we need something better to deal with that... Maybe switch to S1 for
577 * cpufreq changes
578 */
Richard Purdiee36d3942005-09-16 19:27:53 -0700579int openpic2_suspend(struct sys_device *sysdev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580{
581 int i;
582 unsigned long flags;
583
584 spin_lock_irqsave(&openpic2_setup_lock, flags);
585
586 if (openpic_suspend_count++ > 0) {
587 spin_unlock_irqrestore(&openpic2_setup_lock, flags);
588 return 0;
589 }
590
591 open_pic2.enable = openpic2_cached_enable_irq;
592 open_pic2.disable = openpic2_cached_disable_irq;
593
594 for (i=0; i<NumProcessors; i++) {
595 save_cpu_task_pri[i] = openpic2_read(&OpenPIC2->Processor[i].Current_Task_Priority);
596 openpic2_writefield(&OpenPIC2->Processor[i].Current_Task_Priority,
597 OPENPIC_CURRENT_TASK_PRIORITY_MASK, 0xf);
598 }
599
600 for (i=0; i<OPENPIC_NUM_IPI; i++)
601 save_ipi_vp[i] = openpic2_read(&OpenPIC2->Global.IPI_Vector_Priority(i));
602 for (i=0; i<NumSources; i++) {
603 if (ISR[i] == 0)
604 continue;
605 save_irq_src_vp[i] = openpic2_read(&ISR[i]->Vector_Priority) & ~OPENPIC_ACTIVITY;
606 save_irq_src_dest[i] = openpic2_read(&ISR[i]->Destination);
607 }
608
609 spin_unlock_irqrestore(&openpic2_setup_lock, flags);
610
611 return 0;
612}
613
614/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
615 * we need something better to deal with that... Maybe switch to S1 for
616 * cpufreq changes
617 */
618int openpic2_resume(struct sys_device *sysdev)
619{
620 int i;
621 unsigned long flags;
622 u32 vppmask = OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
623 OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK |
624 OPENPIC_MASK;
625
626 spin_lock_irqsave(&openpic2_setup_lock, flags);
627
628 if ((--openpic_suspend_count) > 0) {
629 spin_unlock_irqrestore(&openpic2_setup_lock, flags);
630 return 0;
631 }
632
633 openpic2_reset();
634
635 /* OpenPIC sometimes seem to need some time to be fully back up... */
636 do {
637 openpic2_set_spurious(OPENPIC2_VEC_SPURIOUS+open_pic2_irq_offset);
638 } while(openpic2_readfield(&OpenPIC2->Global.Spurious_Vector, OPENPIC_VECTOR_MASK)
639 != (OPENPIC2_VEC_SPURIOUS + open_pic2_irq_offset));
640
641 openpic2_disable_8259_pass_through();
642
643 for (i=0; i<OPENPIC_NUM_IPI; i++)
644 openpic2_write(&OpenPIC2->Global.IPI_Vector_Priority(i),
645 save_ipi_vp[i]);
646 for (i=0; i<NumSources; i++) {
647 if (ISR[i] == 0)
648 continue;
649 openpic2_write(&ISR[i]->Destination, save_irq_src_dest[i]);
650 openpic2_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
651 /* make sure mask gets to controller before we return to user */
652 do {
653 openpic2_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
654 } while (openpic2_readfield(&ISR[i]->Vector_Priority, vppmask)
655 != (save_irq_src_vp[i] & vppmask));
656 }
657 for (i=0; i<NumProcessors; i++)
658 openpic2_write(&OpenPIC2->Processor[i].Current_Task_Priority,
659 save_cpu_task_pri[i]);
660
661 open_pic2.enable = openpic2_enable_irq;
662 open_pic2.disable = openpic2_disable_irq;
663
664 spin_unlock_irqrestore(&openpic2_setup_lock, flags);
665
666 return 0;
667}
668
669#endif /* CONFIG_PM */
670
671/* HACK ALERT */
672static struct sysdev_class openpic2_sysclass = {
673 set_kset_name("openpic2"),
674};
675
676static struct sys_device device_openpic2 = {
677 .id = 0,
678 .cls = &openpic2_sysclass,
679};
680
681static struct sysdev_driver driver_openpic2 = {
682#ifdef CONFIG_PM
683 .suspend = &openpic2_suspend,
684 .resume = &openpic2_resume,
685#endif /* CONFIG_PM */
686};
687
688static int __init init_openpic2_sysfs(void)
689{
690 int rc;
691
692 if (!OpenPIC2_Addr)
693 return -ENODEV;
694 printk(KERN_DEBUG "Registering openpic2 with sysfs...\n");
695 rc = sysdev_class_register(&openpic2_sysclass);
696 if (rc) {
697 printk(KERN_ERR "Failed registering openpic sys class\n");
698 return -ENODEV;
699 }
700 rc = sysdev_register(&device_openpic2);
701 if (rc) {
702 printk(KERN_ERR "Failed registering openpic sys device\n");
703 return -ENODEV;
704 }
705 rc = sysdev_driver_register(&openpic2_sysclass, &driver_openpic2);
706 if (rc) {
707 printk(KERN_ERR "Failed registering openpic sys driver\n");
708 return -ENODEV;
709 }
710 return 0;
711}
712
713subsys_initcall(init_openpic2_sysfs);
714