From 4e88bbf154ccab7ce7c9738bfdbe4c3f9b9a4cdf Mon Sep 17 00:00:00 2001 From: Gokul Sriram Palanisamy Date: Thu, 3 Aug 2017 18:25:47 +0530 Subject: [PATCH 1/2] ARM: qca: scm_call: Added fuseipq support Added scm_call wrapper to support fuseipq command to work with 64 bit scm_call. Change-Id: Ie1fd2925e9f7ed5b3eb57eb44b1c360d0d7de916 Signed-off-by: Gokul Sriram Palanisamy --- arch/arm/cpu/armv7/qca/common/scm.c | 20 ++++++++++++++++++++ arch/arm/include/asm/arch-qca-common/scm.h | 1 + board/qca/arm/common/cmd_blowsecfuse.c | 5 ++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arch/arm/cpu/armv7/qca/common/scm.c b/arch/arm/cpu/armv7/qca/common/scm.c index 5ea651665e..cdffb4933f 100644 --- a/arch/arm/cpu/armv7/qca/common/scm.c +++ b/arch/arm/cpu/armv7/qca/common/scm.c @@ -339,6 +339,26 @@ int qca_scm_call(u32 svc_id, u32 cmd_id, void *buf, size_t len) return ret; } +int qca_scm_fuseipq(u32 svc_id, u32 cmd_id, void *buf, size_t len) +{ + int ret = 0; + uint32_t *status; +#ifdef CONFIG_SCM_TZ64 + struct qca_scm_desc desc = {0}; + + desc.arginfo = QCA_SCM_ARGS(1, SCM_READ_OP); + desc.args[0] = *((unsigned int *)buf); + + ret = scm_call_64(svc_id, cmd_id, &desc); + + status = (uint32_t *)(*(((uint32_t *)buf) + 1)); + *status = desc.ret[0]; +#else + ret = scm_call(svc_id, cmd_id, buf, len, NULL, 0); +#endif + return ret; +} + int qca_scm_auth_kernel(void *cmd_buf, size_t cmd_len) { diff --git a/arch/arm/include/asm/arch-qca-common/scm.h b/arch/arm/include/asm/arch-qca-common/scm.h index aae16d3a8a..15d7eb9ad2 100644 --- a/arch/arm/include/asm/arch-qca-common/scm.h +++ b/arch/arm/include/asm/arch-qca-common/scm.h @@ -99,6 +99,7 @@ extern int qca_scm_call(u32 svc_id, u32 cmd_id, void *buf, size_t len); int qca_scm_call_write(u32, u32, u32 *, u32); int qca_scm_call_read(u32, u32, u32 *, u32 *); int qca_scm_sdi_v8(void); +int qca_scm_fuseipq(u32, u32, void *, size_t); #define MAX_QCA_SCM_RETS 3 #define MAX_QCA_SCM_ARGS 10 diff --git a/board/qca/arm/common/cmd_blowsecfuse.c b/board/qca/arm/common/cmd_blowsecfuse.c index 3fcc88e73c..d7742e671c 100644 --- a/board/qca/arm/common/cmd_blowsecfuse.c +++ b/board/qca/arm/common/cmd_blowsecfuse.c @@ -45,9 +45,8 @@ int do_fuseipq(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) fuseip.address = simple_strtoul(argv[1], NULL, 16); fuseip.status = (uint32_t)&fuse_status; - ret = scm_call(SCM_SVC_FUSE, TZ_BLOW_FUSE_SECDAT, - &fuseip, sizeof(fuseip), NULL, 0); - + ret = qca_scm_fuseipq(SCM_SVC_FUSE, TZ_BLOW_FUSE_SECDAT, + &fuseip, sizeof(fuseip)); if (ret || fuse_status) printf("%s: Error in QFPROM write (%d, %d)\n", From a62e9c2e84dceaff9c63fa41e6a8efeec8c70ac7 Mon Sep 17 00:00:00 2001 From: Gokul Sriram Palanisamy Date: Wed, 26 Jul 2017 12:05:21 +0530 Subject: [PATCH 2/2] ipq807x: Splitting EBICS dump if the size is greater than 1GB Change-Id: I043b124bef299e13147299e0c9e921520b17b1a5 Signed-off-by: Gokul Sriram Palanisamy --- board/qca/arm/common/cmd_bootqca.c | 86 +++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/board/qca/arm/common/cmd_bootqca.c b/board/qca/arm/common/cmd_bootqca.c index d85e1c63fe..b91cf4c328 100644 --- a/board/qca/arm/common/cmd_bootqca.c +++ b/board/qca/arm/common/cmd_bootqca.c @@ -32,6 +32,7 @@ #define DLOAD_MAGIC_COOKIE 0x10 #define XMK_STR(x)#x #define MK_STR(x)XMK_STR(x) +#define MAX_TFTP_SIZE 0x40000000 static int debug = 0; static char mtdids[256]; @@ -69,15 +70,52 @@ kernel_img_info_t kernel_img_info; char dtb_config_name[64]; +static int tftpdump (int is_aligned_access, uint32_t memaddr, uint32_t size, char *name) +{ + char runcmd[128]; + char *dumpdir; + + if ((dumpdir = getenv("dumpdir")) != NULL) { + printf("Using directory %s in TFTP server\n", dumpdir); + } else { + dumpdir = ""; + printf("Env 'dumpdir' not set. Using / dir in TFTP server\n"); + } + + if (is_aligned_access) { + if (IPQ_TEMP_DUMP_ADDR) { + snprintf(runcmd, sizeof(runcmd), "cp.l 0x%x 0x%x 0x%x", memaddr, + IPQ_TEMP_DUMP_ADDR, size / 4); + if (run_command(runcmd, 0) != CMD_RET_SUCCESS) + return CMD_RET_FAILURE; + + memaddr = IPQ_TEMP_DUMP_ADDR; + } else { + printf("%s needs aligned access and temp address is not defined. Skipping...", name); + return CMD_RET_FAILURE; + } + } + + snprintf(runcmd, sizeof(runcmd), "tftpput 0x%x 0x%x %s/%s", + memaddr, size, dumpdir, name); + + if (run_command(runcmd, 0) != CMD_RET_SUCCESS) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; + +} + static int do_dumpqca_data(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { - char runcmd[128]; char *serverip = NULL; /* dump to root of TFTP server if none specified */ - char *dumpdir; uint32_t memaddr; + uint32_t remaining; int indx; + int ebi_indx = 0; + int ret = CMD_RET_FAILURE; if (argc == 2) { serverip = argv[1]; @@ -92,40 +130,40 @@ static int do_dumpqca_data(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } } - if ((dumpdir = getenv("dumpdir")) != NULL) { - printf("Using directory %s in TFTP server\n", dumpdir); - } else { - dumpdir = ""; - printf("Env 'dumpdir' not set. Using / dir in TFTP server\n"); - } for (indx = 0; indx < dump_entries; indx++) { printf("\nProcessing %s:", dumpinfo[indx].name); memaddr = dumpinfo[indx].start; - if (!strncmp(dumpinfo[indx].name, "EBICS0.BIN", strlen("EBICS0.BIN"))) + if (!strncmp(dumpinfo[indx].name, "EBICS", strlen("EBICS"))) + { dumpinfo[indx].size = gd->ram_size; + remaining = dumpinfo[indx].size; + while (remaining > 0) { + snprintf(dumpinfo[indx].name, sizeof(dumpinfo[indx].name), "EBICS%d.BIN", ebi_indx); - if (dumpinfo[indx].is_aligned_access) { - if (IPQ_TEMP_DUMP_ADDR) { - snprintf(runcmd, sizeof(runcmd), "cp.l 0x%x 0x%x 0x%x", memaddr, - IPQ_TEMP_DUMP_ADDR, dumpinfo[indx].size / 4); - if (run_command(runcmd, 0) != CMD_RET_SUCCESS) + if (remaining > MAX_TFTP_SIZE) { + dumpinfo[indx].size = MAX_TFTP_SIZE; + } + else { + dumpinfo[indx].size = remaining; + } + ret = tftpdump (dumpinfo[indx].is_aligned_access, memaddr, dumpinfo[indx].size, dumpinfo[indx].name); + if (ret == CMD_RET_FAILURE) return CMD_RET_FAILURE; - memaddr = IPQ_TEMP_DUMP_ADDR; - } else { - printf("%s needs aligned access and temp address is not defined. Skipping...", dumpinfo[indx].name); - continue; + memaddr += dumpinfo[indx].size; + remaining -= dumpinfo[indx].size; + ebi_indx++; } } + else + { + ret = tftpdump (dumpinfo[indx].is_aligned_access, memaddr, dumpinfo[indx].size, dumpinfo[indx].name); + if (ret == CMD_RET_FAILURE) + return CMD_RET_FAILURE; + } - snprintf(runcmd, sizeof(runcmd), "tftpput 0x%x 0x%x %s/%s", - memaddr, dumpinfo[indx].size, - dumpdir, dumpinfo[indx].name); - - if (run_command(runcmd, 0) != CMD_RET_SUCCESS) - return CMD_RET_FAILURE; udelay(10000); /* give some delay for server */ } return CMD_RET_SUCCESS;