MLK-17405 iMX8QM: Add athentication for HDMI/DP firmware
authorOliver Brown <oliver.brown@nxp.com>
Thu, 14 Feb 2019 14:13:34 +0000 (08:13 -0600)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 11:28:17 +0000 (04:28 -0700)
Add firmware athentication to the hdp and hdprx load functions.
If hdp_authenticate_fw is set to yes, the hdp tx firmware is athenticated.
If hdprx_authenticate_fw is set to yes, the hdp rx firmware is athenticated.

Signed-off-by: Oliver Brown <oliver.brown@nxp.com>
(cherry picked from commit 6c0246888012c50127b40f1ab6fa6d581f725f7a)

drivers/video/imx/hdp_load.c
drivers/video/imx/hdprx_load.c
drivers/video/imx/scfw_utils.h

index 4012753..ed5f2b4 100644 (file)
@@ -65,16 +65,18 @@ int do_hdp(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                unsigned long offset  = 0x2000;
                const int iram_size   = 0x10000;
                const int dram_size   = 0x8000;
+               const char *s;
 
                if (argc > 2) {
                        address = simple_strtoul(argv[2], NULL, 0);
                        if (argc > 3)
                                offset = simple_strtoul(argv[3], NULL, 0);
-               } else
+               } else {
                        printf("Missing address\n");
+               }
 
                printf("Loading hdp firmware from 0x%016lx offset 0x%016lx\n",
-                       address, offset);
+                      address, offset);
                display_set_power(SC_PM_PW_MODE_ON);
                display_set_clocks();
                display_enable_clocks(ON);
@@ -83,8 +85,14 @@ int do_hdp(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                                     (unsigned char *)(address + offset +
                                                       iram_size),
                                     dram_size);
+
+               s = env_get("hdp_authenticate_fw");
+               if (s && !strcmp(s, "yes"))
+                       SC_MISC_AUTH(-1, SC_MISC_SECO_AUTH_HDMI_TX_FW, 0);
+
                display_enable_clocks(OFF);
                printf("Loading hdp firmware Complete\n");
+
                /* do not turn off hdmi power or firmware load will be lost */
        } else {
                printf("test error argc %d\n", argc);
@@ -92,8 +100,8 @@ int do_hdp(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
        return 0;
 }
-/***************************************************/
 
+/***************************************************/
 U_BOOT_CMD(
        hdp,  CONFIG_SYS_MAXARGS, 1, do_hdp,
        "load hdmi firmware ",
@@ -101,5 +109,9 @@ U_BOOT_CMD(
        "hdpload [address] [<offset>]\n"
        "        address - address where the binary image starts\n"
        "        <offset> - IRAM offset in the binary image (8192 default)\n"
+       "\n"
+       "        if \"hdp_authenticate_fw\" is set to \"yes\", the seco\n"
+       "        will authenticate the firmware and load HDCP keys.\n"
+       "\n"
        "tracescfw - Trace SCFW API calls for video commands\n"
        );
index 80b4c17..501bc7f 100644 (file)
@@ -35,22 +35,28 @@ int do_hdprx(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                unsigned long offset  = 0x2000;
                const int iram_size   = 0x10000;
                const int dram_size   = 0x8000;
+               const char *s;
 
                if (argc > 2) {
                        address = simple_strtoul(argv[2], NULL, 0);
                        if (argc > 3)
                                offset = simple_strtoul(argv[3], NULL, 0);
-               } else
+               } else {
                        printf("Missing address\n");
+               }
 
-               printf("Loading hdp rx firmware from 0x%016lx offset 0x%016lx\n",
-                       address, offset);
+               printf("Loading hdprx firmware from 0x%016lx offset 0x%016lx\n",
+                      address, offset);
                hdmi_rx_set_power(SC_PM_PW_MODE_ON);
                hdp_rx_loadfirmware((unsigned char *)(address + offset),
-                                    iram_size,
-                                    (unsigned char *)(address + offset +
-                                                      iram_size),
-                                    dram_size);
+                                   iram_size,
+                                   (unsigned char *)(address + offset +
+                                                     iram_size),
+                                   dram_size);
+
+               s = env_get("hdprx_authenticate_fw");
+               if (s && !strcmp(s, "yes"))
+                       SC_MISC_AUTH(-1, SC_MISC_SECO_AUTH_HDMI_RX_FW, 0);
                printf("Loading hdp rx firmware Complete\n");
                /* do not turn off hdmi power or firmware load will be lost */
        } else {
@@ -59,8 +65,8 @@ int do_hdprx(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
        return 0;
 }
-/***************************************************/
 
+/***************************************************/
 U_BOOT_CMD(
        hdprx,  CONFIG_SYS_MAXARGS, 1, do_hdprx,
        "load hdmi rx firmware ",
@@ -68,5 +74,9 @@ U_BOOT_CMD(
        "hdpload [address] [<offset>]\n"
        "        address - address where the binary image starts\n"
        "        <offset> - IRAM offset in the binary image (8192 default)\n"
+       "\n"
+       "        if \"hdprx_authenticate_fw\" is set to \"yes\", the seco\n"
+       "        will authenticate the firmware and load HDCP keys.\n"
+       "\n"
        "tracescfw - Trace SCFW API calls for video commands\n"
        );
index 59e173d..bf11872 100644 (file)
@@ -87,4 +87,16 @@ do { \
                       __LINE__, _res_str, __enable__, _ret);\
 } while (0)
 
+#define SC_MISC_AUTH(__ipcHndl__, __cmd__, __addr__) \
+do { \
+       sc_err_t _ret; \
+       if (g_debug_scfw) \
+                       printf("(%4d) sc_misc_seco_authenticate ->  cmd %d addr %d\n",\
+                              __LINE__, __cmd__, __addr__);\
+       _ret = sc_seco_authenticate(__ipcHndl__, __cmd__, __addr__); \
+       if (_ret != SC_ERR_NONE) \
+               printf("(%4d)>> sc_misc_seco_authenticate cmd %d addr %d (error = %d)\n", \
+                       __LINE__, __cmd__, __addr__, _ret); \
+} while (0)
+
 #endif /*_SCFW_UTILS_H_ */