我已经成功地使用pm_power_off
函数指针使我的自定义 Linux 板通过 i2c 调用其电源管理芯片(关闭电源)。
我也想要 Linuxhalt
命令来关闭电源。
我怎样才能做到这一点?
的 (ARM) 代码machine_halt
没有类似于machine_power_off
's的指针pm_power_off
。
拱/臂/内核/reboot.c:
/*
* Halting simply requires that the secondary CPUs stop performing any
* activity (executing tasks, handling interrupts). smp_send_stop()
* achieves this.
*/
void machine_halt(void)
{
local_irq_disable();
smp_send_stop();
local_irq_disable();
while (1);
}
/*
* Power-off simply requires that the secondary CPUs stop performing any
* activity (executing tasks, handling interrupts). smp_send_stop()
* achieves this. When the system power is turned off, it will take all CPUs
* with it.
*/
void machine_power_off(void)
{
local_irq_disable();
smp_send_stop();
if (pm_power_off)
pm_power_off();
}
我显然可以 hack machine_halt
,但如果可能的话,我想“正确”地做到这一点。
我是否错过了一些可能导致halt
命令执行“关机”的东西(可能在用户空间中)?
更新:感谢您的回答和您的所有评论,他们帮助我意识到实际问题是什么。
我的问题是:
我有一个输入边缘,可用于自定义电源管理单元。将其视为启动按钮,没有停止或重置功能。我完全控制了 PMU 代码(它是作为 i2c 从机运行的 ATMEGA)。
- 如果 Linux 内核正在运行,我希望忽略边缘。
- 如果 CPU 断电,我希望 edge 给 CPU 上电。
- 如果 Linux 内核停止,我希望边缘重置 CPU。
案例1很简单,没什么可做的。
案例 2 很简单,pm_power_off
在我的驱动程序中定义将 i2c 消息发送到 PMU。pm_power_off
幸运的是,i2c 子系统在被调用时仍处于工作状态。
案例 3 是问题 - 我正在寻找一个pm_halt
定义,将 i2c 消息发送到 PMU。
也许还有另一种方式,如 0andriy 评论?
内核中是否有一个地方可以用几赫兹的 i2c 消息不断刺激 PMU,除非机器是halt
ed?
答案在:https ://unix.stackexchange.com/a/42576/17288内容如下:
“* 如今,halt 足够聪明,可以在启用 ACPI 时自动调用 poweroff。事实上,它们现在在功能上是等效的。”
也许有一些方法可以提供或连接到 ACPI - 我将不得不阅读它。