#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;
.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;
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",