Merge "app: aboot: Add qseecom test command for 9206"
diff --git a/platform/init.c b/platform/init.c
index 0488c53..9044bac 100644
--- a/platform/init.c
+++ b/platform/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2008 Travis Geiselbrecht
  *
- * Copyright (c) 2014-2016,2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016,2019-2020 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
@@ -180,6 +180,10 @@
 	return 0;
 #endif
 }
+__WEAK void *target_mmc_device()
+{
+	return NULL;
+}
 
 /* function to update boot device base, for emmc targets. */
 __WEAK void platform_boot_dev_cmdline(char *buf)
@@ -193,6 +197,11 @@
 	}
 
 	dev = (struct mmc_device *)target_mmc_device();
+	if (!dev) {
+		dprintf(CRITICAL,"ERROR: Invalid mmc device");
+		return;
+	}
+
 	boot_dev_str_sz = ((sizeof(dev->host.base))*2) + 7;
 	if (boot_dev_str_sz > sizeof(char) * BOOT_DEV_MAX_LEN) {
 		dprintf(CRITICAL,"ERROR: Invalid buf sz - Failed to populate boot device");
diff --git a/platform/mdm9607/platform.c b/platform/mdm9607/platform.c
index 1be8698..701a3a1 100644
--- a/platform/mdm9607/platform.c
+++ b/platform/mdm9607/platform.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015,2020 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
@@ -53,6 +53,8 @@
 #define SCRATCH_REGION1_VIRT_START_128            0x88000000
 #define SCRATCH_REGION2_VIRT_START_128            (SCRATCH_REGION1_VIRT_START_128 + SCRATCH_REGION1_SIZE_128)
 
+#define SCRATCH_REGION2_VIRT_START_256 (SCRATCH_REGION_256 + SCRATCH_REGION_SIZE_256)
+
 static void ddr_based_mmu_mappings(mmu_section_t *table, uint32_t table_size);
 static uint64_t ddr_size;
 static void board_ddr_detect();
@@ -80,8 +82,9 @@
 };
 
 mmu_section_t mmu_section_table_256[] = {
-	{SCRATCH_REGION_256,         SCRATCH_REGION_256,          SCRATCH_REGION_SIZE_256/ MB,      SCRATCH_MEMORY},
-	{KERNEL_REGION,              KERNEL_REGION,               KERNEL_REGION_SIZE/ MB,           SCRATCH_MEMORY},
+	{SCRATCH_REGION_256,  SCRATCH_REGION_256,             SCRATCH_REGION_SIZE_256/ MB,  SCRATCH_MEMORY},
+	{SCRATCH_REGION2_256, SCRATCH_REGION2_VIRT_START_256, SCRATCH_REGION2_SIZE_256/ MB, SCRATCH_MEMORY},
+	{KERNEL_REGION,       KERNEL_REGION,                  KERNEL_REGION_SIZE/ MB,       SCRATCH_MEMORY},
 };
 
 static void board_ddr_detect()
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index 024b5c3..b1390b9 100755
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015,2017-2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015,2017-2020 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
@@ -1293,7 +1293,7 @@
 	} else if (table->version == DEV_TREE_VERSION_V2) {
 		dt_entry_size = sizeof(struct dt_entry_v2);
 	} else if (table->version == DEV_TREE_VERSION_V3) {
-		dt_entry_size = sizeof(struct dt_entry);
+		dt_entry_size = DEV_TREE_DT_ENTRY_SIZE_V3;
 	} else {
 		dprintf(CRITICAL, "ERROR: Unsupported version (%d) in DT table \n",
 				table->version);
@@ -1766,7 +1766,7 @@
 			if (cur_dt_entry->board_hw_subtype == 0)
 				cur_dt_entry->board_hw_subtype = (cur_dt_entry->variant_id >> 0x18);
 
-			table_ptr += sizeof(struct dt_entry);
+			table_ptr += DEV_TREE_DT_ENTRY_SIZE_V3;
 			break;
 		default:
 			dprintf(CRITICAL, "ERROR: Unsupported version (%d) in DT table \n",
diff --git a/platform/msm_shared/include/dev_tree.h b/platform/msm_shared/include/dev_tree.h
index 4449286..754e4af 100644
--- a/platform/msm_shared/include/dev_tree.h
+++ b/platform/msm_shared/include/dev_tree.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014,2017-2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014,2017-2020 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
@@ -41,6 +41,7 @@
 #define DEV_TREE_VERSION_V3     3
 
 #define DEV_TREE_HEADER_SIZE    12
+#define DEV_TREE_DT_ENTRY_SIZE_V3 40
 
 #define DTB_MAGIC               0xedfe0dd0
 #define DTB_OFFSET              0x2C
diff --git a/target/mdm9607/meminfo.c b/target/mdm9607/meminfo.c
index 31eea83..3196cfc 100644
--- a/target/mdm9607/meminfo.c
+++ b/target/mdm9607/meminfo.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015,2020 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
@@ -103,5 +103,5 @@
 		return (SCRATCH_REGION1_SIZE_128 + SCRATCH_REGION2_SIZE_128);
 	else
 		/*256MB DDR scratch size*/
-		return (SCRATCH_REGION_SIZE_256);
+		return (SCRATCH_REGION_SIZE_256 + SCRATCH_REGION2_SIZE_256);
 }
diff --git a/target/mdm9607/rules.mk b/target/mdm9607/rules.mk
index 555cf51..422b906 100644
--- a/target/mdm9607/rules.mk
+++ b/target/mdm9607/rules.mk
@@ -12,14 +12,16 @@
 SCRATCH_REGION1_128                     := 0x86000000
 SCRATCH_REGION1_SIZE_128                := 0x01a00000  # 26MB
 SCRATCH_REGION2_128                     := 0x80000000
-SCRATCH_REGION2_SIZE_128                := 0x02900000   # 41M
+SCRATCH_REGION2_SIZE_128                := 0x02900000  # 41M
 
 KERNEL_REGION                           := 0x80000000
-KERNEL_REGION_SIZE                      := 0x2000000 # 20MB
+KERNEL_REGION_SIZE                      := 0x02000000  # 32MB
 
 SCRATCH_ADDR_256                        := 0x88000000
 SCRATCH_REGION_256                      := 0x88000000
+SCRATCH_REGION2_256                     := 0x82A00000
 SCRATCH_REGION_SIZE_256                 := 0x08000000  # 128MB
+SCRATCH_REGION2_SIZE_256                := 0x05000000  # 80MB
 
 BASE_ADDR                               := 0x80000000
 
@@ -39,11 +41,13 @@
 	SCRATCH_ADDR_128=$(SCRATCH_ADDR_128) \
 	SCRATCH_ADDR_256=$(SCRATCH_ADDR_256) \
 	SCRATCH_REGION_256=$(SCRATCH_REGION_256) \
+	SCRATCH_REGION2_256=$(SCRATCH_REGION2_256) \
 	SCRATCH_REGION1_128=$(SCRATCH_REGION1_128) \
 	SCRATCH_REGION2_128=$(SCRATCH_REGION2_128) \
 	SCRATCH_REGION1_SIZE_128=$(SCRATCH_REGION1_SIZE_128) \
 	SCRATCH_REGION2_SIZE_128=$(SCRATCH_REGION2_SIZE_128) \
 	SCRATCH_REGION_SIZE_256=$(SCRATCH_REGION_SIZE_256) \
+	SCRATCH_REGION2_SIZE_256=$(SCRATCH_REGION2_SIZE_256) \
 	KERNEL_REGION=$(KERNEL_REGION) \
 	KERNEL_REGION_SIZE=$(KERNEL_REGION_SIZE)