Merge tag 'u-boot-atmel-fixes-2021.01-b' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / arch / arm / mach-imx / imx8 / ahab.c
index cf3c7d7..4bb7c46 100644 (file)
@@ -4,7 +4,9 @@
  */
 
 #include <common.h>
+#include <command.h>
 #include <errno.h>
+#include <log.h>
 #include <asm/io.h>
 #include <asm/arch/sci/sci.h>
 #include <asm/mach-imx/sys_proto.h>
@@ -12,6 +14,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/image.h>
 #include <console.h>
+#include <cpu_func.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -24,7 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static inline bool check_in_dram(ulong addr)
 {
        int i;
-       bd_t *bd = gd->bd;
+       struct bd_info *bd = gd->bd;
 
        for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
                if (bd->bi_dram[i].size) {
@@ -75,7 +78,7 @@ int authenticate_os_container(ulong addr)
        memcpy((void *)SEC_SECURE_RAM_BASE, (const void *)addr,
               ALIGN(length, CONFIG_SYS_CACHELINE_SIZE));
 
-       err = sc_seco_authenticate(-1, SC_MISC_AUTH_CONTAINER,
+       err = sc_seco_authenticate(-1, SC_SECO_AUTH_CONTAINER,
                                   SECO_LOCAL_SEC_SEC_SECURE_RAM_BASE);
        if (err) {
                printf("Authenticate container hdr failed, return %d\n",
@@ -90,22 +93,21 @@ int authenticate_os_container(ulong addr)
                                            sizeof(struct container_hdr) +
                                            i * sizeof(struct boot_img_t));
 
-               debug("img %d, dst 0x%llx, src 0x%lx, size 0x%x\n",
-                     i, img->dst, img->offset + addr, img->size);
+               debug("img %d, dst 0x%x, src 0x%lux, size 0x%x\n",
+                     i, (uint32_t) img->dst, img->offset + addr, img->size);
 
                memcpy((void *)img->dst, (const void *)(img->offset + addr),
                       img->size);
 
                s = img->dst & ~(CONFIG_SYS_CACHELINE_SIZE - 1);
-               e = ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE);
+               e = ALIGN(img->dst + img->size, CONFIG_SYS_CACHELINE_SIZE) - 1;
 
                flush_dcache_range(s, e);
 
                /* Find the memreg and set permission for seco pt */
                err = sc_rm_find_memreg(-1, &mr, s, e);
                if (err) {
-                       printf("Not found memreg for image: %d, error %d\n",
-                              i, err);
+                       printf("Error: can't find memreg for image load address 0x%llx, error %d\n", img->dst, err);
                        ret = -ENOMEM;
                        goto exit;
                }
@@ -123,7 +125,7 @@ int authenticate_os_container(ulong addr)
                        goto exit;
                }
 
-               err = sc_seco_authenticate(-1, SC_MISC_VERIFY_IMAGE,
+               err = sc_seco_authenticate(-1, SC_SECO_VERIFY_IMAGE,
                                           (1 << i));
                if (err) {
                        printf("Authenticate img %d failed, return %d\n",
@@ -144,14 +146,14 @@ int authenticate_os_container(ulong addr)
        }
 
 exit:
-       if (sc_seco_authenticate(-1, SC_MISC_REL_CONTAINER, 0) != SC_ERR_NONE)
+       if (sc_seco_authenticate(-1, SC_SECO_REL_CONTAINER, 0) != SC_ERR_NONE)
                printf("Error: release container failed!\n");
 
        return ret;
 }
 
-static int do_authenticate(cmd_tbl_t *cmdtp, int flag, int argc,
-                          char * const argv[])
+static int do_authenticate(struct cmd_tbl *cmdtp, int flag, int argc,
+                          char *const argv[])
 {
        ulong addr;
 
@@ -251,8 +253,8 @@ static void display_ahab_auth_event(u32 event)
        }
 }
 
-static int do_ahab_status(cmd_tbl_t *cmdtp, int flag, int argc,
-                         char * const argv[])
+static int do_ahab_status(struct cmd_tbl *cmdtp, int flag, int argc,
+                         char *const argv[])
 {
        int err;
        u8 idx = 0U;
@@ -298,8 +300,8 @@ static int confirm_close(void)
        return 0;
 }
 
-static int do_ahab_close(cmd_tbl_t *cmdtp, int flag, int argc,
-                        char * const argv[])
+static int do_ahab_close(struct cmd_tbl *cmdtp, int flag, int argc,
+                        char *const argv[])
 {
        int err;
        u16 lc;