app: aboot: Simplify the code to use reboot reason

cleanup the reboot reason code to use either of PON register or IMEM
cookie based on the feature flag instead of checking the both.

Change-Id: I20c081cc2d3e59aed0a380954c0f40e10d9474e0
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 9d139a4..d049acb 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -76,6 +76,7 @@
 #include <wdog.h>
 #endif
 
+#include <reboot.h>
 #include "image_verify.h"
 #include "recovery.h"
 #include "bootimg.h"
@@ -125,20 +126,6 @@
 
 #define MAX_TAGS_SIZE   1024
 
-#define RECOVERY_HARD_RESET_MODE   0x01
-#define FASTBOOT_HARD_RESET_MODE   0x02
-#define RTC_HARD_RESET_MODE        0x03
-#define DM_VERITY_ENFORCING_HARD_RESET_MODE 0x04
-#define DM_VERITY_LOGGING_HARD_RESET_MODE   0x05
-#define DM_VERITY_KEYSCLEAR_HARD_RESET_MODE 0x06
-
-#define RECOVERY_MODE        0x77665502
-#define FASTBOOT_MODE        0x77665500
-#define ALARM_BOOT           0x77665503
-#define DM_VERITY_LOGGING    0x77665508
-#define DM_VERITY_ENFORCING  0x77665509
-#define DM_VERITY_KEYSCLEAR  0x7766550A
-
 /* make 4096 as default size to ensure EFS,EXT4's erasing */
 #define DEFAULT_ERASE_SIZE  4096
 #define MAX_PANEL_BUF_SIZE 128
@@ -3256,7 +3243,6 @@
 void aboot_init(const struct app_descriptor *app)
 {
 	unsigned reboot_mode = 0;
-	unsigned hard_reboot_mode = 0;
 	bool boot_into_fastboot = false;
 
 	/* Setup page size information for nv storage */
@@ -3336,27 +3322,35 @@
 		boot_into_fastboot = true;
 	#endif
 
+#if USE_PON_REBOOT_REG
+	reboot_mode = check_hard_reboot_mode();
+#else
 	reboot_mode = check_reboot_mode();
-	hard_reboot_mode = check_hard_reboot_mode();
-	if (reboot_mode == RECOVERY_MODE ||
-		hard_reboot_mode == RECOVERY_HARD_RESET_MODE) {
+#endif
+	if (reboot_mode == RECOVERY_MODE)
+	{
 		boot_into_recovery = 1;
-	} else if(reboot_mode == FASTBOOT_MODE ||
-		hard_reboot_mode == FASTBOOT_HARD_RESET_MODE) {
+	}
+	else if(reboot_mode == FASTBOOT_MODE)
+	{
 		boot_into_fastboot = true;
-	} else if(reboot_mode == ALARM_BOOT ||
-		hard_reboot_mode == RTC_HARD_RESET_MODE) {
+	}
+	else if(reboot_mode == ALARM_BOOT)
+	{
 		boot_reason_alarm = true;
-	} else if(reboot_mode == DM_VERITY_ENFORCING ||
-		hard_reboot_mode == DM_VERITY_ENFORCING_HARD_RESET_MODE) {
+	}
+	else if (reboot_mode == DM_VERITY_ENFORCING)
+	{
 		device.verity_mode = 1;
 		write_device_info(&device);
-	} else if(reboot_mode == DM_VERITY_LOGGING ||
-		hard_reboot_mode == DM_VERITY_LOGGING_HARD_RESET_MODE) {
+	}
+	else if (reboot_mode == DM_VERITY_LOGGING)
+	{
 		device.verity_mode = 0;
 		write_device_info(&device);
-	} else if(reboot_mode == DM_VERITY_KEYSCLEAR ||
-		hard_reboot_mode == DM_VERITY_KEYSCLEAR_HARD_RESET_MODE) {
+	}
+	else if (reboot_mode == DM_VERITY_KEYSCLEAR)
+	{
 		if(send_delete_keys_to_tz())
 			ASSERT(0);
 	}