platform: msm_shared: Get boot device base for emmc targets

Add functionality to get boot device base, for mmc devices.

Change-Id: Idb8bddaffa4b5112e0980ef3c576ef4552da37d2
Signed-off-by: Mayank Grover <groverm@codeaurora.org>
diff --git a/platform/init.c b/platform/init.c
index 46f934c..0488c53 100644
--- a/platform/init.c
+++ b/platform/init.c
@@ -28,6 +28,9 @@
 #include <boot_stats.h>
 #include <platform/iomap.h>
 #include <image_verify.h>
+#include <target.h>
+#include <boot_device.h>
+#include <mmc_wrapper.h>
 
 /*
  * default implementations of these routines, if the platform code
@@ -147,7 +150,7 @@
 	return 0;
 }
 
-__WEAK uint32_t use_hsonly_mode()
+__WEAK bool use_hsonly_mode()
 {
 	return 0;
 }
@@ -178,3 +181,24 @@
 #endif
 }
 
+/* function to update boot device base, for emmc targets. */
+__WEAK void platform_boot_dev_cmdline(char *buf)
+{
+	struct mmc_device *dev = NULL;
+	uint32_t boot_dev_str_sz = 0;
+
+	if (!buf) {
+		dprintf(CRITICAL,"ERROR: Invalid args- Failed to populate boot device");
+		return;
+	}
+
+	dev = (struct mmc_device *)target_mmc_device();
+	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");
+		return;
+	}
+
+	snprintf(buf, boot_dev_str_sz, "%x.sdhci", dev->host.base);
+	return;
+}
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index 5ad8faf..752a7e9 100644
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015,2017-2018 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015,2017-2019 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
@@ -49,7 +49,6 @@
 #include <boot_stats.h>
 #include <verifiedboot.h>
 
-#define BOOT_DEV_MAX_LEN        64
 #define NODE_PROPERTY_MAX_LEN   64
 #define ADD_OF(a, b) (UINT_MAX - b > a) ? (a + b) : UINT_MAX
 #define ADDR_ALIGNMENT 16
diff --git a/platform/msm_shared/include/boot_device.h b/platform/msm_shared/include/boot_device.h
index a0897ec..4e281f7 100644
--- a/platform/msm_shared/include/boot_device.h
+++ b/platform/msm_shared/include/boot_device.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014,2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014,2016,2019 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
@@ -59,6 +59,7 @@
 #ifndef MAX_GPT_NAME_SIZE
 #define MAX_GPT_NAME_SIZE 72
 #endif
+#define BOOT_DEV_MAX_LEN        64
 
 typedef struct {
 	char *name;