From d5236d38d3ffd8547b0fbbc8604c36c9221fe1a8 Mon Sep 17 00:00:00 2001 From: Oliver Brown Date: Thu, 14 Feb 2019 08:13:34 -0600 Subject: [PATCH] MLK-17405 iMX8QM: Add athentication for HDMI/DP firmware 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 (cherry picked from commit 6c0246888012c50127b40f1ab6fa6d581f725f7a) --- drivers/video/imx/hdp_load.c | 18 +++++++++++++++--- drivers/video/imx/hdprx_load.c | 26 ++++++++++++++++++-------- drivers/video/imx/scfw_utils.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/drivers/video/imx/hdp_load.c b/drivers/video/imx/hdp_load.c index 4012753989..ed5f2b4977 100644 --- a/drivers/video/imx/hdp_load.c +++ b/drivers/video/imx/hdp_load.c @@ -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] []\n" " address - address where the binary image starts\n" " - 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" ); diff --git a/drivers/video/imx/hdprx_load.c b/drivers/video/imx/hdprx_load.c index 80b4c1774d..501bc7f3c1 100644 --- a/drivers/video/imx/hdprx_load.c +++ b/drivers/video/imx/hdprx_load.c @@ -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] []\n" " address - address where the binary image starts\n" " - 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" ); diff --git a/drivers/video/imx/scfw_utils.h b/drivers/video/imx/scfw_utils.h index 59e173df48..bf11872ab1 100644 --- a/drivers/video/imx/scfw_utils.h +++ b/drivers/video/imx/scfw_utils.h @@ -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_ */ -- 2.17.1