14 #include <linux/types.h>
35 const void *basep, *entryp;
36 unsigned long basesz, entrysz;
39 if (depth != 1 ||
strcmp(uname,
"ibm,opal") != 0)
42 basep = of_get_flat_dt_prop(node,
"opal-base-address", &basesz);
43 entryp = of_get_flat_dt_prop(node,
"opal-entry-address", &entrysz);
45 if (!basep || !entryp)
48 opal.
base = of_read_number(basep, basesz/4);
49 opal.
entry = of_read_number(entryp, entrysz/4);
51 pr_debug(
"OPAL Base = 0x%llx (basep=%p basesz=%ld)\n",
53 pr_debug(
"OPAL Entry = 0x%llx (entryp=%p basesz=%ld)\n",
56 powerpc_firmware_features |= FW_FEATURE_OPAL;
57 if (of_flat_dt_is_compatible(node,
"ibm,opal-v2")) {
58 powerpc_firmware_features |= FW_FEATURE_OPALv2;
59 printk(
"OPAL V2 detected !\n");
61 printk(
"OPAL V1 detected !\n");
116 if (firmware_has_feature(FW_FEATURE_OPALv2)) {
118 if (rc || len < total_len) {
119 spin_unlock_irqrestore(&opal_write_lock, flags);
132 while(total_len > 0 && (rc ==
OPAL_BUSY ||
150 spin_unlock_irqrestore(&opal_write_lock, flags);
159 static const char *opal_mc_ue_types[] = {
162 "Page table walk ifetch",
164 "Page table walk Load/Store",
166 static const char *opal_mc_slb_types[] = {
171 static const char *opal_mc_erat_types[] = {
176 static const char *opal_mc_tlb_types[] = {
188 pr_err(
"Machine Check Exception, Unknown event version %d !\n",
192 switch(evt.severity) {
212 printk(
"%s%s Machine check interrupt [%s]\n", level, sevstr,
214 "Recovered" :
"[Not recovered");
215 printk(
"%s Initiator: %s\n", level,
217 switch(evt.error_type) {
221 opal_mc_ue_types[evt.
u.
ue_error.ue_error_type]
223 printk(
"%s Error type: UE [%s]\n", level, subtype);
224 if (evt.
u.
ue_error.effective_address_provided)
225 printk(
"%s Effective address: %016llx\n",
226 level, evt.
u.
ue_error.effective_address);
227 if (evt.
u.
ue_error.physical_address_provided)
228 printk(
"%s Physial address: %016llx\n",
234 opal_mc_slb_types[evt.
u.
slb_error.slb_error_type]
236 printk(
"%s Error type: SLB [%s]\n", level, subtype);
237 if (evt.
u.
slb_error.effective_address_provided)
238 printk(
"%s Effective address: %016llx\n",
244 opal_mc_erat_types[evt.
u.
erat_error.erat_error_type]
246 printk(
"%s Error type: ERAT [%s]\n", level, subtype);
248 printk(
"%s Effective address: %016llx\n",
254 opal_mc_tlb_types[evt.
u.
tlb_error.tlb_error_type]
256 printk(
"%s Error type: TLB [%s]\n", level, subtype);
257 if (evt.
u.
tlb_error.effective_address_provided)
258 printk(
"%s Effective address: %016llx\n",
263 printk(
"%s Error type: Unknown\n", level);
280 static int __init opal_init(
void)
288 pr_warn(
"opal: Node not found\n");
291 if (firmware_has_feature(FW_FEATURE_OPALv2))
294 consoles = of_node_get(opal_node);
300 of_platform_device_create(np,
NULL,
NULL);
302 of_node_put(consoles);
306 pr_debug(
"opal: Found %d interrupts reserved for OPAL\n",
307 irqs ? (irqlen / 4) : 0);
308 for (i = 0; irqs && i < (irqlen / 4); i++, irqs++) {
312 pr_warning(
"opal: Failed to map irq 0x%x\n", hwirq);
318 " (0x%x)\n", rc, irq, hwirq);