reboot: add reboot reason sys infterface [1/1]

PD#TV-9896

Problem:
provide sys interface to get last reboot reason

Solution:
add reboot reason sys infterface

Verify:
test pass on tl1_x301

Change-Id: I6c4046c892eff9f92506fadb0cddee7041c8f882
Signed-off-by: Hong Guo <hong.guo@amlogic.com>
This commit is contained in:
Hong Guo
2019-09-07 15:21:22 +08:00
committed by Tao Zeng
parent d508390213
commit fdc250b90f
3 changed files with 28 additions and 0 deletions

View File

@@ -319,6 +319,7 @@
compatible = "amlogic,reboot";
sys_reset = <0x84000009>;
sys_poweroff = <0x84000008>;
reboot_reason_addr = <0xff80023c>;
};
ram-dump {

View File

@@ -311,6 +311,7 @@
compatible = "amlogic,reboot";
sys_reset = <0x84000009>;
sys_poweroff = <0x84000008>;
reboot_reason_addr = <0xff80023c>;
};
ram-dump {

View File

@@ -34,6 +34,7 @@
#include <linux/kdebug.h>
#include <linux/arm-smccc.h>
static void __iomem *reboot_reason_vaddr;
static u32 psci_function_id_restart;
static u32 psci_function_id_poweroff;
static char *kernel_panic;
@@ -126,10 +127,27 @@ static struct notifier_block panic_notifier = {
.notifier_call = panic_notify,
};
ssize_t reboot_reason_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int value, len;
if (!reboot_reason_vaddr)
return 0;
value = readl(reboot_reason_vaddr);
value = (value >> 12) & 0xf;
len = sprintf(buf, "%d\n", value);
return len;
}
DEVICE_ATTR(reboot_reason, 0444, reboot_reason_show, NULL);
static int aml_restart_probe(struct platform_device *pdev)
{
u32 id;
int ret;
u32 paddr = 0;
if (!of_property_read_u32(pdev->dev.of_node, "sys_reset", &id)) {
psci_function_id_restart = id;
@@ -141,6 +159,14 @@ static int aml_restart_probe(struct platform_device *pdev)
pm_power_off = do_aml_poweroff;
}
ret = of_property_read_u32(pdev->dev.of_node,
"reboot_reason_addr", &paddr);
if (!ret) {
pr_debug("reboot_reason paddr: 0x%x\n", paddr);
reboot_reason_vaddr = ioremap(paddr, 0x4);
device_create_file(&pdev->dev, &dev_attr_reboot_reason);
}
ret = register_die_notifier(&panic_notifier);
if (ret != 0) {
pr_err("%s,register die notifier failed,ret =%d!\n",