]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
drivers: renesas: rom: Move to common
authorBiju Das <biju.das.jz@bp.renesas.com>
Wed, 16 Dec 2020 10:56:03 +0000 (10:56 +0000)
committerBiju Das <biju.das.jz@bp.renesas.com>
Wed, 13 Jan 2021 13:03:48 +0000 (13:03 +0000)
Move rom driver code to common directory, so that the same
code can be re-used by both R-Car Gen3 and RZ/G2 platforms.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Change-Id: I399dfb5eff186db76d26fa9c54bea88bee66789c

drivers/renesas/common/rom/rom_api.c [new file with mode: 0644]
drivers/renesas/common/rom/rom_api.h [new file with mode: 0644]
drivers/renesas/rcar/rom/rom_api.c [deleted file]
drivers/renesas/rcar/rom/rom_api.h [deleted file]
plat/renesas/common/common.mk
plat/renesas/rcar/platform.mk

diff --git a/drivers/renesas/common/rom/rom_api.c b/drivers/renesas/common/rom/rom_api.c
new file mode 100644 (file)
index 0000000..fda2815
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stdint.h>
+
+#include <lib/mmio.h>
+
+#include "rcar_def.h"
+#include "rom_api.h"
+
+typedef uint32_t(*rom_secure_boot_api_f) (uint32_t *key, uint32_t *cert,
+                                         rom_read_flash_f pFuncReadFlash);
+
+typedef uint32_t(*rom_get_lcs_api_f) (uint32_t *lcs);
+
+#define OLD_API_TABLE1 (0U)    /* H3 Ver.1.0/Ver.1.1 */
+#define OLD_API_TABLE2 (1U)    /* H3 Ver.2.0 */
+#define OLD_API_TABLE3 (2U)    /* M3 Ver.1.0 */
+#define NEW_API_TABLE  (3U)    /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3, D3, V3M WS2.0 */
+#define NEW_API_TABLE2 (4U)    /* V3M WS1.0 */
+#define API_TABLE_MAX  (5U)    /* table max */
+                               /* Later than H3 Ver.2.0 */
+
+static uint32_t get_table_index(void)
+{
+       uint32_t product;
+       uint32_t cut_ver;
+       uint32_t index;
+
+       product = mmio_read_32(RCAR_PRR) & PRR_PRODUCT_MASK;
+       cut_ver = mmio_read_32(RCAR_PRR) & PRR_CUT_MASK;
+
+       switch (product) {
+       case PRR_PRODUCT_H3:
+               if (cut_ver == PRR_PRODUCT_10)
+                       index = OLD_API_TABLE1;
+               else if (cut_ver == PRR_PRODUCT_11)
+                       index = OLD_API_TABLE1;
+               else if (cut_ver == PRR_PRODUCT_20)
+                       index = OLD_API_TABLE2;
+               else
+                       /* Later than H3 Ver.2.0 */
+                       index = NEW_API_TABLE;
+               break;
+       case PRR_PRODUCT_M3:
+               if (cut_ver == PRR_PRODUCT_10)
+                       index = OLD_API_TABLE3;
+               else
+                       /* M3 Ver.1.1 or later */
+                       index = NEW_API_TABLE;
+               break;
+       case PRR_PRODUCT_V3M:
+               if (cut_ver == PRR_PRODUCT_10)
+                       /* V3M WS1.0 */
+                       index = NEW_API_TABLE2;
+               else
+                       /* V3M WS2.0 or later */
+                       index = NEW_API_TABLE;
+               break;
+       default:
+               index = NEW_API_TABLE;
+               break;
+       }
+
+       return index;
+}
+
+uint32_t rcar_rom_secure_boot_api(uint32_t *key, uint32_t *cert,
+                            rom_read_flash_f read_flash)
+{
+       static const uintptr_t rom_api_table[API_TABLE_MAX] = {
+               0xEB10DD64U,    /* H3 Ver.1.0/Ver.1.1 */
+               0xEB116ED4U,    /* H3 Ver.2.0 */
+               0xEB1102FCU,    /* M3 Ver.1.0 */
+               0xEB100180U,    /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3, D3, V3M WS2.0 */
+               0xEB110128U,    /* V3M WS1.0 */
+       };
+       rom_secure_boot_api_f secure_boot;
+       uint32_t index;
+
+       index = get_table_index();
+       secure_boot = (rom_secure_boot_api_f) rom_api_table[index];
+
+       return secure_boot(key, cert, read_flash);
+}
+
+uint32_t rcar_rom_get_lcs(uint32_t *lcs)
+{
+       static const uintptr_t rom_get_lcs_table[API_TABLE_MAX] = {
+               0xEB10DFE0U,    /* H3 Ver.1.0/Ver.1.1 */
+               0xEB117150U,    /* H3 Ver.2.0 */
+               0xEB110578U,    /* M3 Ver.1.0 */
+               0xEB10018CU,    /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3, D3, V3M WS2.0 */
+               0xEB1103A4U,    /* V3M WS1.0 */
+       };
+       rom_get_lcs_api_f get_lcs;
+       uint32_t index;
+
+       index = get_table_index();
+       get_lcs = (rom_get_lcs_api_f) rom_get_lcs_table[index];
+
+       return get_lcs(lcs);
+}
diff --git a/drivers/renesas/common/rom/rom_api.h b/drivers/renesas/common/rom/rom_api.h
new file mode 100644 (file)
index 0000000..1d5b03d
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ROM_API_H
+#define ROM_API_H
+
+#include <stdint.h>
+
+#define SBROM_OK                               (0x00000000U)
+#define SBROM_ILLEGAL_INPUT_PARAM_ERR          (0x0B000001U)
+#define SBROM_ILLEGAL_OEM_HASH_VALUE_ERR       (0x0B000008U)
+#define SBROM_ILLEGAL_LCS_FOR_OPERATION_ERR    (0x0B000010U)
+#define SBROM_HASH_NOT_PROGRAMMED_ERR          (0x0B000100U)
+#define SBROM_PUB_KEY_HASH_VALIDATION_FAILURE  (0xF1000006U)
+#define SBROM_RSA_SIG_VERIFICATION_FAILED      (0xF1000007U)
+
+#define LCS_CM                                 (0x0U)
+#define LCS_DM                                 (0x1U)
+#define LCS_SD                                 (0x3U)
+#define LCS_SE                                 (0x5U)
+#define LCS_FA                                 (0x7U)
+
+typedef uint32_t(*rom_read_flash_f) (uint64_t src, uint8_t *dst, uint32_t len);
+uint32_t rcar_rom_secure_boot_api(uint32_t *key, uint32_t *cert,
+                                 rom_read_flash_f f);
+uint32_t rcar_rom_get_lcs(uint32_t *lcs);
+
+#endif /* ROM_API_H */
diff --git a/drivers/renesas/rcar/rom/rom_api.c b/drivers/renesas/rcar/rom/rom_api.c
deleted file mode 100644 (file)
index fda2815..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stdint.h>
-
-#include <lib/mmio.h>
-
-#include "rcar_def.h"
-#include "rom_api.h"
-
-typedef uint32_t(*rom_secure_boot_api_f) (uint32_t *key, uint32_t *cert,
-                                         rom_read_flash_f pFuncReadFlash);
-
-typedef uint32_t(*rom_get_lcs_api_f) (uint32_t *lcs);
-
-#define OLD_API_TABLE1 (0U)    /* H3 Ver.1.0/Ver.1.1 */
-#define OLD_API_TABLE2 (1U)    /* H3 Ver.2.0 */
-#define OLD_API_TABLE3 (2U)    /* M3 Ver.1.0 */
-#define NEW_API_TABLE  (3U)    /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3, D3, V3M WS2.0 */
-#define NEW_API_TABLE2 (4U)    /* V3M WS1.0 */
-#define API_TABLE_MAX  (5U)    /* table max */
-                               /* Later than H3 Ver.2.0 */
-
-static uint32_t get_table_index(void)
-{
-       uint32_t product;
-       uint32_t cut_ver;
-       uint32_t index;
-
-       product = mmio_read_32(RCAR_PRR) & PRR_PRODUCT_MASK;
-       cut_ver = mmio_read_32(RCAR_PRR) & PRR_CUT_MASK;
-
-       switch (product) {
-       case PRR_PRODUCT_H3:
-               if (cut_ver == PRR_PRODUCT_10)
-                       index = OLD_API_TABLE1;
-               else if (cut_ver == PRR_PRODUCT_11)
-                       index = OLD_API_TABLE1;
-               else if (cut_ver == PRR_PRODUCT_20)
-                       index = OLD_API_TABLE2;
-               else
-                       /* Later than H3 Ver.2.0 */
-                       index = NEW_API_TABLE;
-               break;
-       case PRR_PRODUCT_M3:
-               if (cut_ver == PRR_PRODUCT_10)
-                       index = OLD_API_TABLE3;
-               else
-                       /* M3 Ver.1.1 or later */
-                       index = NEW_API_TABLE;
-               break;
-       case PRR_PRODUCT_V3M:
-               if (cut_ver == PRR_PRODUCT_10)
-                       /* V3M WS1.0 */
-                       index = NEW_API_TABLE2;
-               else
-                       /* V3M WS2.0 or later */
-                       index = NEW_API_TABLE;
-               break;
-       default:
-               index = NEW_API_TABLE;
-               break;
-       }
-
-       return index;
-}
-
-uint32_t rcar_rom_secure_boot_api(uint32_t *key, uint32_t *cert,
-                            rom_read_flash_f read_flash)
-{
-       static const uintptr_t rom_api_table[API_TABLE_MAX] = {
-               0xEB10DD64U,    /* H3 Ver.1.0/Ver.1.1 */
-               0xEB116ED4U,    /* H3 Ver.2.0 */
-               0xEB1102FCU,    /* M3 Ver.1.0 */
-               0xEB100180U,    /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3, D3, V3M WS2.0 */
-               0xEB110128U,    /* V3M WS1.0 */
-       };
-       rom_secure_boot_api_f secure_boot;
-       uint32_t index;
-
-       index = get_table_index();
-       secure_boot = (rom_secure_boot_api_f) rom_api_table[index];
-
-       return secure_boot(key, cert, read_flash);
-}
-
-uint32_t rcar_rom_get_lcs(uint32_t *lcs)
-{
-       static const uintptr_t rom_get_lcs_table[API_TABLE_MAX] = {
-               0xEB10DFE0U,    /* H3 Ver.1.0/Ver.1.1 */
-               0xEB117150U,    /* H3 Ver.2.0 */
-               0xEB110578U,    /* M3 Ver.1.0 */
-               0xEB10018CU,    /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3, D3, V3M WS2.0 */
-               0xEB1103A4U,    /* V3M WS1.0 */
-       };
-       rom_get_lcs_api_f get_lcs;
-       uint32_t index;
-
-       index = get_table_index();
-       get_lcs = (rom_get_lcs_api_f) rom_get_lcs_table[index];
-
-       return get_lcs(lcs);
-}
diff --git a/drivers/renesas/rcar/rom/rom_api.h b/drivers/renesas/rcar/rom/rom_api.h
deleted file mode 100644 (file)
index 1d5b03d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ROM_API_H
-#define ROM_API_H
-
-#include <stdint.h>
-
-#define SBROM_OK                               (0x00000000U)
-#define SBROM_ILLEGAL_INPUT_PARAM_ERR          (0x0B000001U)
-#define SBROM_ILLEGAL_OEM_HASH_VALUE_ERR       (0x0B000008U)
-#define SBROM_ILLEGAL_LCS_FOR_OPERATION_ERR    (0x0B000010U)
-#define SBROM_HASH_NOT_PROGRAMMED_ERR          (0x0B000100U)
-#define SBROM_PUB_KEY_HASH_VALIDATION_FAILURE  (0xF1000006U)
-#define SBROM_RSA_SIG_VERIFICATION_FAILED      (0xF1000007U)
-
-#define LCS_CM                                 (0x0U)
-#define LCS_DM                                 (0x1U)
-#define LCS_SD                                 (0x3U)
-#define LCS_SE                                 (0x5U)
-#define LCS_FA                                 (0x7U)
-
-typedef uint32_t(*rom_read_flash_f) (uint64_t src, uint8_t *dst, uint32_t len);
-uint32_t rcar_rom_secure_boot_api(uint32_t *key, uint32_t *cert,
-                                 rom_read_flash_f f);
-uint32_t rcar_rom_get_lcs(uint32_t *lcs);
-
-#endif /* ROM_API_H */
index dda7c89f2c80269844ab8d38e3522a095b4a163a..09ff1d513c753be75e419319344ca128015015cf 100644 (file)
@@ -91,6 +91,7 @@ BL2_SOURCES   +=      ${RCAR_GIC_SOURCES}                             \
                        drivers/renesas/common/emmc/emmc_init.c         \
                        drivers/renesas/common/emmc/emmc_read.c         \
                        drivers/renesas/common/emmc/emmc_cmd.c          \
+                       drivers/renesas/common/rom/rom_api.c            \
                        drivers/io/io_storage.c
 
 BL31_SOURCES   +=      ${RCAR_GIC_SOURCES}                             \
index ca6fe6b73fb83932402ac12cb76e3555bf400a09..4cd2f93b586960b61c0a23784e3a01c12fa8154b 100644 (file)
@@ -305,7 +305,7 @@ PLAT_INCLUDES       +=      -Idrivers/renesas/rcar/ddr              \
                        -Idrivers/renesas/common/iic_dvfs       \
                        -Idrivers/renesas/rcar/avs              \
                        -Idrivers/renesas/common/delay          \
-                       -Idrivers/renesas/rcar/rom              \
+                       -Idrivers/renesas/common/rom            \
                        -Idrivers/renesas/common/scif           \
                        -Idrivers/renesas/common/emmc           \
                        -Idrivers/renesas/common/pwrc           \
@@ -325,7 +325,6 @@ BL2_SOURCES +=      plat/renesas/rcar/aarch64/platform_common.c     \
                        drivers/renesas/rcar/dma/dma_driver.c           \
                        drivers/renesas/rcar/avs/avs_driver.c           \
                        drivers/renesas/rcar/watchdog/swdt.c            \
-                       drivers/renesas/rcar/rom/rom_api.c              \
                        drivers/renesas/rcar/board/board.c
 
 BL31_SOURCES   +=      plat/renesas/rcar/plat_topology.c               \