target: msm8916: add support for checking hard reset reason
Use the spare register in PMIC power-on peripheral to store the device
restart reason and mark it as hard reset reason. So need to add function
to check the restart reason.
Change-Id: I17c020ffc8083d15e29e807782f83ab37433983c
diff --git a/include/platform.h b/include/platform.h
index b65395e..e71c407 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -53,6 +53,7 @@
unsigned board_machtype(void);
unsigned board_platform_id(void);
unsigned check_reboot_mode(void);
+unsigned check_hard_reboot_mode(void);
void platform_uninit_timer(void);
void reboot_device(unsigned);
int set_download_mode(enum dload_mode mode);
diff --git a/target/init.c b/target/init.c
index 79e0466..c866187 100644
--- a/target/init.c
+++ b/target/init.c
@@ -1,6 +1,8 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
@@ -66,6 +68,11 @@
return 0;
}
+__WEAK unsigned check_hard_reboot_mode(void)
+{
+ return 0;
+}
+
__WEAK void reboot_device(unsigned reboot_reason)
{
}
diff --git a/target/msm8916/init.c b/target/msm8916/init.c
index 0289973..4b1f26b 100644
--- a/target/msm8916/init.c
+++ b/target/msm8916/init.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -66,6 +66,7 @@
#endif
#define FASTBOOT_MODE 0x77665500
+#define PON_SOFT_RB_SPARE 0x88F
#define CE1_INSTANCE 1
#define CE_EE 1
@@ -241,6 +242,21 @@
return restart_reason;
}
+unsigned check_hard_reboot_mode(void)
+{
+ uint8_t hard_restart_reason = 0;
+ uint8_t value = 0;
+
+ /* Read reboot reason and scrub it
+ * Bit-5, bit-6 and bit-7 of SOFT_RB_SPARE for hard reset reason
+ */
+ value = pm8x41_reg_read(PON_SOFT_RB_SPARE);
+ hard_restart_reason = value >> 5;
+ pm8x41_reg_write(PON_SOFT_RB_SPARE, value & 0x1f);
+
+ return hard_restart_reason;
+}
+
static int scm_dload_mode(int mode)
{
int ret = 0;