[FOSS_TLK]platform: tegra: use DT to enable rollback
Scott Long [Thu, 4 Dec 2014 18:21:16 +0000 (10:21 -0800)]
Bootloader will pass address of the DT to TLK which can
then use it to search for the "rollback-protection"
node to determine if rollback should be enabled or not.

Change-Id: I9b97fbd96168dc46f84778807b00ffae537eb330
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: http://git-master/r/707298
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
Tested-by: Varun Wadekar <vwadekar@nvidia.com>

include/kernel/boot_params.h
kernel/boot.c
platform/tegra/common/platform.c

index 2f34311..ed448cf 100644 (file)
@@ -39,6 +39,7 @@
 #define CMDLINE_DEVICE_UID2    "config.uid2"
 #define CMDLINE_DEVICE_UID3    "config.uid3"
 #define CMDLINE_TSEC_CARVEOUT  "tsec"
+#define CMDLINE_DTB_ADDR       "dtbaddr"
 
 #define DEVICE_UID_SIZE_WORDS  4
 #define PARAM_NAME_LEN         64              // in bytes
index d9e1dd3..3fa7826 100644 (file)
@@ -35,6 +35,7 @@ unsigned int tf_key_addr;
 unsigned int tf_key_size;
 uint32_t device_uid[DEVICE_UID_SIZE_WORDS];
 paddr_t tsec_carveout_size, tsec_carveout_base;
+paddr_t dtb_addr;
 
 extern unsigned int __bootarg_addr;
 
@@ -70,7 +71,8 @@ void parse_cmdline(void)
                {CMDLINE_DEVICE_UID3, &device_uid[3]},
                {CMDLINE_DEBUG_UART_ID, &debug_uart_id},
                {CMDLINE_TFKEY_ADDR, &tf_key_addr},
-               {CMDLINE_TFKEY_SIZE, &tf_key_size}
+               {CMDLINE_TFKEY_SIZE, &tf_key_size},
+               {CMDLINE_DTB_ADDR, &dtb_addr}
        };
 
        if (!boot_params_ptr ||
index c2c687a..3a9bac4 100644 (file)
@@ -28,6 +28,7 @@
 #include <rand.h>
 #include <string.h>
 #include <stdlib.h>
+#include <libfdt/libfdt.h>
 #include <lib/heap.h>
 #include <arch/arm/mmu.h>
 #include <arch/ops.h>
@@ -51,6 +52,7 @@ extern unsigned long boot_secondary_cpu_addr;
 extern unsigned int coldboot_normal_os;
 extern unsigned int normal_os_coldboot_fn;
 extern uint32_t device_uid[4];
+extern paddr_t dtb_addr;
 
 #if !defined(WITH_MONITOR_BIN)
 extern uint32_t __save_boot_regs[9];
@@ -229,14 +231,50 @@ int platform_ss_request_handler(void)
 
 int platform_ss_get_config(uint32_t *ss_config)
 {
+       void *fdt = dtb_addr;
+       char *status, *device_name;
+       int node;
+
        *ss_config = 0;
 
        /*
-        * If we're on an ODM production unit then enable rollback.
+        * Following conditions must be met to enable rollback:
+        *
+        *  - ODM production fuse must be set
+        *  - DT entry must indicate it should be on and which device to use
+        *
+        * Note failure to meet these conditions isn't an error; just means
+        * rollback will not be enabled.
         */
-       if (platform_fuse_get(FUSE_ID_ODM_PROD)) {
-               *ss_config |= OTE_SS_CONFIG_RB_ENABLE;
-       }
+
+       /* check ODM_PRODUCTION fuse */
+       if (!platform_fuse_get(FUSE_ID_ODM_PROD))
+               return 0;
+
+       /* now check DT entry */
+       if (fdt == NULL)
+               return 0;
+
+       node = fdt_path_offset(fdt, "/rollback-protection");
+       if (node < 0)
+               return 0;
+
+       /* get status and device_name props */
+       status = (char *)fdt_getprop(fdt, node, "status", NULL);
+       device_name = (char *)fdt_getprop(fdt, node, "device-name", NULL);
+       if (!status || !device_name)
+               return 0;
+
+       /* check that status=okay */
+       if (strcmp(status, "okay"))
+               return 0;
+
+       /* RPMB only for now */
+       if (strcmp(device_name, "sdmmc"))
+               return 0;
+
+       /* looks good so let the storage TA know rollback can be enabled */
+       *ss_config |= OTE_SS_CONFIG_RB_ENABLE;
 
        return 0;
 }