3 #include <linux/types.h>
4 #include <linux/kernel.h>
6 #include <linux/reboot.h>
11 #include <asm/machdep.h>
13 #include <asm/cell-regs.h>
18 static void dump_fir(int cpu
)
20 struct cbe_pmd_regs __iomem
*pregs
= cbe_get_cpu_pmd_regs(cpu
);
21 struct cbe_iic_regs __iomem
*iregs
= cbe_get_cpu_iic_regs(cpu
);
26 /* Todo: do some nicer parsing of bits and based on them go down
27 * to other sub-units FIRs and not only IIC
29 printk(KERN_ERR
"Global Checkstop FIR : 0x%016lx\n",
30 in_be64(&pregs
->checkstop_fir
));
31 printk(KERN_ERR
"Global Recoverable FIR : 0x%016lx\n",
32 in_be64(&pregs
->checkstop_fir
));
33 printk(KERN_ERR
"Global MachineCheck FIR : 0x%016lx\n",
34 in_be64(&pregs
->spec_att_mchk_fir
));
38 printk(KERN_ERR
"IOC FIR : 0x%016lx\n",
39 in_be64(&iregs
->ioc_fir
));
43 void cbe_system_error_exception(struct pt_regs
*regs
)
45 int cpu
= smp_processor_id();
47 printk(KERN_ERR
"System Error Interrupt on CPU %d !\n", cpu
);
52 void cbe_maintenance_exception(struct pt_regs
*regs
)
54 int cpu
= smp_processor_id();
57 * Nothing implemented for the maintenance interrupt at this point
60 printk(KERN_ERR
"Unhandled Maintenance interrupt on CPU %d !\n", cpu
);
64 void cbe_thermal_exception(struct pt_regs
*regs
)
66 int cpu
= smp_processor_id();
69 * Nothing implemented for the thermal interrupt at this point
72 printk(KERN_ERR
"Unhandled Thermal interrupt on CPU %d !\n", cpu
);
76 static int cbe_machine_check_handler(struct pt_regs
*regs
)
78 int cpu
= smp_processor_id();
80 printk(KERN_ERR
"Machine Check Interrupt on CPU %d !\n", cpu
);
83 /* No recovery from this code now, lets continue */
88 struct list_head list
;
94 static LIST_HEAD(ptcal_list
);
96 static int ptcal_start_tok
, ptcal_stop_tok
;
98 static int __init
cbe_ptcal_enable_on_node(int nid
, int order
)
100 struct ptcal_area
*area
;
104 #ifdef CONFIG_CRASH_DUMP
105 rtas_call(ptcal_stop_tok
, 1, 1, NULL
, nid
);
108 area
= kmalloc(sizeof(*area
), GFP_KERNEL
);
114 area
->pages
= alloc_pages_node(area
->nid
, GFP_KERNEL
, area
->order
);
119 addr
= __pa(page_address(area
->pages
));
122 if (rtas_call(ptcal_start_tok
, 3, 1, NULL
, area
->nid
,
123 (unsigned int)(addr
>> 32),
124 (unsigned int)(addr
& 0xffffffff))) {
125 printk(KERN_ERR
"%s: error enabling PTCAL on node %d!\n",
130 list_add(&area
->list
, &ptcal_list
);
135 __free_pages(area
->pages
, area
->order
);
142 static int __init
cbe_ptcal_enable(void)
145 struct device_node
*np
;
146 int order
, found_mic
= 0;
148 np
= of_find_node_by_path("/rtas");
152 size
= of_get_property(np
, "ibm,cbe-ptcal-size", NULL
);
156 pr_debug("%s: enabling PTCAL, size = 0x%x\n", __FUNCTION__
, *size
);
157 order
= get_order(*size
);
160 /* support for malta device trees, with be@/mic@ nodes */
161 for_each_node_by_type(np
, "mic-tm") {
162 cbe_ptcal_enable_on_node(of_node_to_nid(np
), order
);
169 /* support for older device tree - use cpu nodes */
170 for_each_node_by_type(np
, "cpu") {
171 const u32
*nid
= of_get_property(np
, "node-id", NULL
);
173 printk(KERN_ERR
"%s: node %s is missing node-id?\n",
174 __FUNCTION__
, np
->full_name
);
177 cbe_ptcal_enable_on_node(*nid
, order
);
181 return found_mic
? 0 : -ENODEV
;
184 static int cbe_ptcal_disable(void)
186 struct ptcal_area
*area
, *tmp
;
189 pr_debug("%s: disabling PTCAL\n", __FUNCTION__
);
191 list_for_each_entry_safe(area
, tmp
, &ptcal_list
, list
) {
192 /* disable ptcal on this node */
193 if (rtas_call(ptcal_stop_tok
, 1, 1, NULL
, area
->nid
)) {
194 printk(KERN_ERR
"%s: error disabling PTCAL "
195 "on node %d!\n", __FUNCTION__
,
201 /* ensure we can access the PTCAL area */
202 memset(page_address(area
->pages
), 0,
203 1 << (area
->order
+ PAGE_SHIFT
));
206 list_del(&area
->list
);
207 __free_pages(area
->pages
, area
->order
);
214 static int cbe_ptcal_notify_reboot(struct notifier_block
*nb
,
215 unsigned long code
, void *data
)
217 return cbe_ptcal_disable();
220 static struct notifier_block cbe_ptcal_reboot_notifier
= {
221 .notifier_call
= cbe_ptcal_notify_reboot
224 int __init
cbe_ptcal_init(void)
227 ptcal_start_tok
= rtas_token("ibm,cbe-start-ptcal");
228 ptcal_stop_tok
= rtas_token("ibm,cbe-stop-ptcal");
230 if (ptcal_start_tok
== RTAS_UNKNOWN_SERVICE
231 || ptcal_stop_tok
== RTAS_UNKNOWN_SERVICE
)
234 ret
= register_reboot_notifier(&cbe_ptcal_reboot_notifier
);
236 printk(KERN_ERR
"Can't disable PTCAL, so not enabling\n");
240 return cbe_ptcal_enable();
243 arch_initcall(cbe_ptcal_init
);
245 void __init
cbe_ras_init(void)
250 * Enable System Error & thermal interrupts and wakeup conditions
253 hid0
= mfspr(SPRN_HID0
);
254 hid0
|= HID0_CBE_THERM_INT_EN
| HID0_CBE_THERM_WAKEUP
|
255 HID0_CBE_SYSERR_INT_EN
| HID0_CBE_SYSERR_WAKEUP
;
256 mtspr(SPRN_HID0
, hid0
);
260 * Install machine check handler. Leave setting of precise mode to
261 * what the firmware did for now
263 ppc_md
.machine_check_exception
= cbe_machine_check_handler
;
267 * For now, we assume that IOC_FIR is already set to forward some
268 * error conditions to the System Error handler. If that is not true
269 * then it will have to be fixed up here.