[FOSS_TLK]platform: tegra: modify DT rollback handling
Scott Long [Tue, 10 Feb 2015 18:26:56 +0000 (10:26 -0800)]
Remove use of the DTB rollback status property as
it can be used to disable rollback when it should
not be.

Check rollback configuration on all T210-based projects
and ensure it must be on if the ODM_PRODUCTION fuse is
blown.

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

platform/tegra/common/platform.c
platform/tegra/include/platform/platform_p.h
platform/tegra/rules.mk

index 01ff9b0..0dbecb6 100644 (file)
@@ -229,58 +229,50 @@ int platform_ss_request_handler(void)
        return 0;
 }
 
-int platform_ss_get_config(uint32_t *ss_config)
+#if defined(WITH_ROLLBACK_PROTECTION)
+static void platform_ss_parse_dtb(uint32_t *ss_config)
 {
        void *fdt = dtb_addr;
-       char *status, *device_name;
+       char *device_name;
        int node;
 
-       *ss_config = 0;
-
-       /*
-        * 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.
-        */
-
-       /* check ODM_PRODUCTION fuse */
-       if (!platform_fuse_get(FUSE_ID_ODM_PROD))
-               return 0;
-
-       /* now check DT entry */
        if (fdt == NULL)
-               return 0;
+               panic("no DTB available\n");
 
        node = fdt_path_offset(fdt, "/rollback-protection");
        if (node < 0)
-               return 0;
+               panic("no rollback node available\n");
 
        /* 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;
+       if (!device_name)
+               panic("no rollback device-name property specified\n");
 
        /* check for rollback device */
-       if (!strcmp(device_name, "sdmmc")) {
+       if (!strcmp(device_name, "sdmmc"))
                *ss_config |= OTE_SS_CONFIG_RPMB_ENABLE;
-       } else if (!strcmp(device_name, "cpc")) {
+       else if (!strcmp(device_name, "cpc"))
                *ss_config |= OTE_SS_CONFIG_CPC_ENABLE;
-       } else {
-               dprintf(CRITICAL, "%s: unknown device: %s\n", __func__,
+       else
+               panic("unknown rollback device-name property specified: %s\n",
                        device_name);
-               return 1;
-       }
+}
+#endif
 
-       return 0;
+void platform_ss_get_config(uint32_t *ss_config)
+{
+       *ss_config = 0;
+
+#if defined(WITH_ROLLBACK_PROTECTION)
+       /* no rollback if ODM_PRODUCTION not blown */
+       if (!platform_fuse_get(FUSE_ID_ODM_PROD))
+               return;
+
+       /* get rollback device info from dtb */
+       platform_ss_parse_dtb(ss_config);
+
+       dprintf(SPEW, "%s: *ss_config 0x%x\n", __func__, *ss_config);
+#endif
 }
 
 void platform_get_device_id(te_device_id_args_t *out)
index 53bc5f6..5926a47 100644 (file)
@@ -46,7 +46,7 @@ void platform_enable_debug_intf(void);
 void platform_set_intr_ready_state(bool, struct tz_monitor_frame *frame);
 status_t platform_ss_register_handler(struct tz_monitor_frame *frame);
 int platform_ss_request_handler(void);
-int platform_ss_get_config(uint32_t *ss_config);
+void platform_ss_get_config(uint32_t *ss_config);
 void platform_get_device_id(te_device_id_args_t *args);
 uint32_t platform_get_time_us(void);
 void platform_clean_invalidate_cache_range(vaddr_t range, uint32_t size);
index 9bf97b5..994b794 100644 (file)
@@ -65,6 +65,13 @@ else
        DEBUG := 1
 endif
 
+# Enable storage rollback protection for desired devices.
+ifeq ($(filter t210,$(TARGET_TEGRA_VERSION)), $(TARGET_TEGRA_VERSION))
+       WITH_ROLLBACK_PROTECTION := 1
+else
+       WITH_ROLLBACK_PROTECTION := 0
+endif
+
 # relocate image to provided physaddr via MMU
 ARM_USE_MMU_RELOC := true
 
@@ -74,7 +81,8 @@ ARM_USE_CPU_CACHING := true
 DEFINES += VMEMBASE=$(VMEMBASE) \
        VMEMSIZE=$(VMEMSIZE) \
        DEBUG=$(DEBUG) \
-       WITH_CPU_EARLY_INIT=1
+       WITH_CPU_EARLY_INIT=1 \
+       WITH_ROLLBACK_PROTECTION=$(WITH_ROLLBACK_PROTECTION)
 
 # use a two segment memory layout, where all of the read-only sections
 # of the binary reside in rom, and the read/write are in memory. The