arch/powerpc/platforms/powernv/opal-power.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/opal-power.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/opal-power.c- Extension
.c- Size
- 4058 bytes
- Lines
- 175
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/reboot.hlinux/notifier.hlinux/of.hasm/opal.hasm/machdep.h
Detected Declarations
function detect_epowfunction poweroff_pendingfunction opal_power_control_eventfunction opal_power_control_init
Annotated Snippet
if (detect_epow()) {
pr_info("EPOW msg received. Powering off system\n");
orderly_poweroff(true);
}
break;
case OPAL_MSG_DPO:
pr_info("DPO msg received. Powering off system\n");
orderly_poweroff(true);
break;
case OPAL_MSG_SHUTDOWN:
type = be64_to_cpu(((struct opal_msg *)msg)->params[0]);
switch (type) {
case SOFT_REBOOT:
pr_info("Reboot requested\n");
orderly_reboot();
break;
case SOFT_OFF:
pr_info("Poweroff requested\n");
orderly_poweroff(true);
break;
default:
pr_err("Unknown power-control type %llu\n", type);
}
break;
default:
pr_err("Unknown OPAL message type %lu\n", msg_type);
}
return 0;
}
/* OPAL EPOW event notifier block */
static struct notifier_block opal_epow_nb = {
.notifier_call = opal_power_control_event,
.next = NULL,
.priority = 0,
};
/* OPAL DPO event notifier block */
static struct notifier_block opal_dpo_nb = {
.notifier_call = opal_power_control_event,
.next = NULL,
.priority = 0,
};
/* OPAL power-control event notifier block */
static struct notifier_block opal_power_control_nb = {
.notifier_call = opal_power_control_event,
.next = NULL,
.priority = 0,
};
int __init opal_power_control_init(void)
{
int ret, supported = 0;
struct device_node *np;
/* Register OPAL power-control events notifier */
ret = opal_message_notifier_register(OPAL_MSG_SHUTDOWN,
&opal_power_control_nb);
if (ret)
pr_err("Failed to register SHUTDOWN notifier, ret = %d\n", ret);
/* Determine OPAL EPOW, DPO support */
np = of_find_node_by_path("/ibm,opal/epow");
if (np) {
supported = of_device_is_compatible(np, "ibm,opal-v3-epow");
of_node_put(np);
}
if (!supported)
return 0;
pr_info("OPAL EPOW, DPO support detected.\n");
/* Register EPOW event notifier */
ret = opal_message_notifier_register(OPAL_MSG_EPOW, &opal_epow_nb);
if (ret)
pr_err("Failed to register EPOW notifier, ret = %d\n", ret);
/* Register DPO event notifier */
ret = opal_message_notifier_register(OPAL_MSG_DPO, &opal_dpo_nb);
if (ret)
pr_err("Failed to register DPO notifier, ret = %d\n", ret);
/* Check for any pending EPOW or DPO events. */
if (poweroff_pending())
orderly_poweroff(true);
return 0;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/reboot.h`, `linux/notifier.h`, `linux/of.h`, `asm/opal.h`, `asm/machdep.h`.
- Detected declarations: `function detect_epow`, `function poweroff_pending`, `function opal_power_control_event`, `function opal_power_control_init`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.