4 * Copyright (C) 2001 Dave Engebretsen IBM Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 2001/09/21 : engebret : Created with minimal EPOW and HW exception support.
26 #include <linux/ptrace.h>
27 #include <linux/errno.h>
28 #include <linux/threads.h>
29 #include <linux/kernel_stat.h>
30 #include <linux/signal.h>
31 #include <linux/sched.h>
32 #include <linux/ioport.h>
33 #include <linux/interrupt.h>
34 #include <linux/timex.h>
35 #include <linux/init.h>
36 #include <linux/slab.h>
37 #include <linux/pci.h>
38 #include <linux/delay.h>
39 #include <linux/irq.h>
40 #include <linux/proc_fs.h>
41 #include <linux/random.h>
42 #include <linux/sysrq.h>
44 #include <asm/uaccess.h>
45 #include <asm/bitops.h>
46 #include <asm/system.h>
48 #include <asm/pgtable.h>
50 #include <asm/cache.h>
52 #include <asm/ptrace.h>
53 #include <asm/iSeries/LparData.h>
54 #include <asm/machdep.h>
56 #include <asm/ppcdebug.h>
58 static void ras_epow_interrupt(int irq, void *dev_id, struct pt_regs * regs);
59 static void ras_error_interrupt(int irq, void *dev_id, struct pt_regs * regs);
60 void init_ras_IRQ(void);
65 * Initialize handlers for the set of interrupts caused by hardware errors
66 * and power system events.
68 void init_ras_IRQ(void) {
69 struct device_node *np;
70 unsigned int *ireg, len, i;
72 if((np = find_path_device("/event-sources/internal-errors")) &&
73 (ireg = (unsigned int *)get_property(np, "open-pic-interrupt",
75 for(i=0; i<(len / sizeof(*ireg)); i++) {
76 request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS,
77 &ras_error_interrupt, 0,
83 if((np = find_path_device("/event-sources/epow-events")) &&
84 (ireg = (unsigned int *)get_property(np, "open-pic-interrupt",
86 for(i=0; i<(len / sizeof(*ireg)); i++) {
87 request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS,
88 &ras_epow_interrupt, 0,
96 * Handle power subsystem events (EPOW).
98 * Presently we just log the event has occured. This should be fixed
99 * to examine the type of power failure and take appropriate action where
100 * the time horizon permits something useful to be done.
103 ras_epow_interrupt(int irq, void *dev_id, struct pt_regs * regs)
105 struct rtas_error_log log_entry;
106 unsigned int size = sizeof(log_entry);
107 long status = 0xdeadbeef;
109 status = rtas_call(rtas_token("check-exception"), 6, 1, NULL,
111 EPOW_WARNING | POWERMGM_EVENTS,
112 1, /* Time Critical */
113 __pa(&log_entry), size);
115 udbg_printf("EPOW <0x%lx 0x%lx>\n",
116 *((unsigned long *)&log_entry), status);
118 "EPOW <0x%lx 0x%lx>\n",*((unsigned long *)&log_entry), status);
122 * Handle hardware error interrupts.
124 * RTAS check-exception is called to collect data on the exception. If
125 * the error is deemed recoverable, we log a warning and return.
126 * For nonrecoverable errors, an error is logged and we stop all processing
127 * as quickly as possible in order to prevent propagation of the failure.
130 ras_error_interrupt(int irq, void *dev_id, struct pt_regs * regs)
132 struct rtas_error_log log_entry;
133 unsigned int size = sizeof(log_entry);
134 long status = 0xdeadbeef;
136 status = rtas_call(rtas_token("check-exception"), 6, 1, NULL,
139 1, /* Time Critical */
140 __pa(&log_entry), size);
143 (log_entry.severity >= SEVERITY_ERROR_SYNC)) {
144 udbg_printf("HW Error <0x%lx 0x%lx>\n",
145 *((unsigned long *)&log_entry), status);
147 "Error: Fatal hardware error <0x%lx 0x%lx>\n",
148 *((unsigned long *)&log_entry), status);
151 /* Don't actually power off when debugging so we can test
152 * without actually failing while injecting errors.
157 udbg_printf("Recoverable HW Error <0x%lx 0x%lx>\n",
158 *((unsigned long *)&log_entry), status);
160 "Warning: Recoverable hardware error <0x%lx 0x%lx>\n",
161 *((unsigned long *)&log_entry), status);