summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Rosengren <robert.rosengren@stericsson.com>2010-12-14 09:28:58 +0100
committerMichael BRANDT <michael.brandt@stericsson.com>2010-12-15 10:00:48 +0100
commite4dff321799fc342638be45618bf0fc44b74b186 (patch)
tree5fbeeb1fa80d1faca8824475527a68903aa83a14
parentc0d5e1d2461f8135492a79f3e5259ac324ee1a96 (diff)
db8500: Move ISSW code out from itp.c
Splitting security related code from itp.c into sec_bridge.c ST-Ericsson ID: WP275634 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I813daf0d0eaea4645e7d990bf467f19b0af968db Signed-off-by: Robert Rosengren <robert.rosengren@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/10895 Reviewed-by: QATOOLS Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com>
-rw-r--r--cpu/arm_cortexa9/db8500/Makefile2
-rw-r--r--cpu/arm_cortexa9/db8500/itp.c88
-rw-r--r--cpu/arm_cortexa9/db8500/sec_bridge.c84
-rw-r--r--include/asm-arm/arch-db8500/sec_bridge.h23
4 files changed, 115 insertions, 82 deletions
diff --git a/cpu/arm_cortexa9/db8500/Makefile b/cpu/arm_cortexa9/db8500/Makefile
index 0832867a9..08292bda6 100644
--- a/cpu/arm_cortexa9/db8500/Makefile
+++ b/cpu/arm_cortexa9/db8500/Makefile
@@ -36,7 +36,7 @@ COBJS += interrupts.o
COBJS += prcmu.o
COBJS += timer.o
-COBJS-$(CONFIG_ITP_LOAD) += itp.o cspsa_fp.o
+COBJS-$(CONFIG_ITP_LOAD) += cspsa_fp.o itp.o sec_bridge.o
COBJS += $(COBJS-y)
SRCS := $(START:.o=.S) $(COBJS:.o=.c)
diff --git a/cpu/arm_cortexa9/db8500/itp.c b/cpu/arm_cortexa9/db8500/itp.c
index ae13dcbb1..03716a571 100644
--- a/cpu/arm_cortexa9/db8500/itp.c
+++ b/cpu/arm_cortexa9/db8500/itp.c
@@ -12,86 +12,13 @@
#include <asm/arch/ab8500.h>
#include <asm/arch/itp.h>
#include <asm/arch/cspsa_fp.h>
+#include <asm/arch/sec_bridge.h>
-#define SEC_ROM_FORCE_CLEAN_MASK 0x0020
-#define SEC_ROM_RET_OK 0x01
-#define ISSWAPI_SECURE_LOAD 0x10000002
-#define ISSWAPI_FLUSH_BOOT_CODE 0x11000003
#define IPL_ITEM_ID 0x02
-typedef u32 (*boot_rom_bridge_func_t)(const u32 , const u32, const va_list);
-
-static boot_rom_bridge_func_t hw_sec_rom_pub_bridge;
-
-struct sec_rom_cut_desc {
- u32 cutid_addr;
- u32 cutid;
- u32 bridge_func;
-};
-
-static const struct sec_rom_cut_desc cuttable[] = {
- { 0x9001DBF4, 0x008500B0, 0x90017300 },
- { 0x9001FFF4, 0x008500A1, 0x90018300 },
- { 0x9001FFF4, 0x005500A0, 0x90018300 },
- { 0x9001FFF4, 0x008500A0, 0x90018300 },
-};
-
static u32 cspsa_key;
-static u32 itp_call_secure_service(const u32 serviceid,
- const u32 secureconfig,
- ...)
-{
- va_list ap;
- u32 returnvalue;
-
- va_start(ap, secureconfig);
-
- returnvalue = hw_sec_rom_pub_bridge(serviceid,
- secureconfig,
- ap);
-
- va_end(ap);
- return returnvalue;
-}
-
-static int itp_init_bridge(void)
-{
- u8 cutnb = 0;
-
- hw_sec_rom_pub_bridge = NULL;
- while ((cutnb < ARRAY_SIZE(cuttable)) &&
- (cuttable[cutnb].cutid != *(u32 *)(cuttable[cutnb].cutid_addr)))
- cutnb++;
-
- if (cutnb < ARRAY_SIZE(cuttable)) {
- hw_sec_rom_pub_bridge =
- (boot_rom_bridge_func_t)cuttable[cutnb].bridge_func;
- return 0;
- }
-
- printf("itp_init_bridge: cutid not found\n");
- return 1;
-}
-
-static int itp_flush_issw(void)
-{
- u32 ret;
-
- ret = itp_call_secure_service(ISSWAPI_FLUSH_BOOT_CODE,
- SEC_ROM_FORCE_CLEAN_MASK,
- 0,
- 0);
-
- if (ret != SEC_ROM_RET_OK) {
- printf("itp_flush_issw: ISSWAPI_FLUSH_BOOT_CODE: %d\n",
- ret);
- return 1;
- }
-
- return 0;
-}
static int itp_load_ipl(block_dev_desc_t *block_dev)
{
@@ -113,10 +40,10 @@ static int itp_load_ipl(block_dev_desc_t *block_dev)
/* Get CutID */
ab8500_cutid = ab8500_read(AB8500_MISC, AB8500_REV_REG);
- returnvalue = itp_call_secure_service((u32)ISSWAPI_SECURE_LOAD,
- SEC_ROM_FORCE_CLEAN_MASK,
- IPL_ITEM_ID,
- ab8500_cutid);
+ returnvalue = sec_bridge_call_secure_service((u32)ISSWAPI_SECURE_LOAD,
+ SEC_ROM_FORCE_CLEAN_MASK,
+ IPL_ITEM_ID,
+ ab8500_cutid);
if (returnvalue != SEC_ROM_RET_OK) {
printf("itp_load_ipl: ISSWAPI_SECURE_LOAD: %d\n",
returnvalue);
@@ -186,7 +113,7 @@ int itp_load_itp_and_modem(block_dev_desc_t *block_dev)
debug("\nitp_load_itp_and_modem\n");
- if (itp_init_bridge()) {
+ if (sec_bridge_init_bridge()) {
retval = 1;
goto exit;
}
@@ -216,8 +143,7 @@ int itp_load_itp_and_modem(block_dev_desc_t *block_dev)
exit:
/* Always Flush */
- if (hw_sec_rom_pub_bridge != NULL)
- itp_flush_issw();
+ sec_bridge_flush_issw();
if ((cspsa_key & ITP_LOAD_ITP) && !retval)
/* U-boot execution will end here */
diff --git a/cpu/arm_cortexa9/db8500/sec_bridge.c b/cpu/arm_cortexa9/db8500/sec_bridge.c
new file mode 100644
index 000000000..fb94804eb
--- /dev/null
+++ b/cpu/arm_cortexa9/db8500/sec_bridge.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * Author: Mikael Larsson <mikael.xt.larsson@stericsson.com> for ST-Ericsson.
+ *
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+
+#include <common.h>
+#include <asm/arch/sec_bridge.h>
+
+typedef u32 (*boot_rom_bridge_func_t)(const u32 , const u32, const va_list);
+static boot_rom_bridge_func_t hw_sec_rom_pub_bridge;
+
+struct sec_rom_cut_desc {
+ u32 cutid_addr;
+ u32 cutid;
+ u32 bridge_func;
+};
+
+static const struct sec_rom_cut_desc cuttable[] = {
+ { 0x9001DBF4, 0x008500B0, 0x90017300 },
+ { 0x9001FFF4, 0x008500A1, 0x90018300 },
+ { 0x9001FFF4, 0x005500A0, 0x90018300 },
+ { 0x9001FFF4, 0x008500A0, 0x90018300 },
+};
+
+int sec_bridge_init_bridge(void)
+{
+ u8 cutnb = 0;
+
+ hw_sec_rom_pub_bridge = NULL;
+
+ while ((cutnb < ARRAY_SIZE(cuttable)) &&
+ (cuttable[cutnb].cutid != *(u32 *)(cuttable[cutnb].cutid_addr)))
+ cutnb++;
+
+ if (cutnb < ARRAY_SIZE(cuttable)) {
+ hw_sec_rom_pub_bridge =
+ (boot_rom_bridge_func_t)cuttable[cutnb].bridge_func;
+
+ return 0;
+ }
+
+ printf("sec_bridge_init_bridge: cutid not found\n");
+ return 1;
+}
+
+u32 sec_bridge_call_secure_service(const u32 serviceid,
+ const u32 secureconfig,
+ ...)
+{
+ va_list ap;
+ u32 returnvalue;
+
+ va_start(ap, secureconfig);
+
+ returnvalue = hw_sec_rom_pub_bridge(serviceid,
+ secureconfig,
+ ap);
+
+ va_end(ap);
+ return returnvalue;
+}
+
+int sec_bridge_flush_issw(void)
+{
+ u32 ret;
+
+ if (hw_sec_rom_pub_bridge != NULL) {
+
+ ret = sec_bridge_call_secure_service(ISSWAPI_FLUSH_BOOT_CODE,
+ SEC_ROM_FORCE_CLEAN_MASK,
+ 0,
+ 0);
+
+ if (ret != SEC_ROM_RET_OK) {
+ printf("sec_bridge_flush_issw: ISSWAPI_FLUSH_BOOT_CODE: %d\n",
+ ret);
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/include/asm-arm/arch-db8500/sec_bridge.h b/include/asm-arm/arch-db8500/sec_bridge.h
new file mode 100644
index 000000000..c02bc38a3
--- /dev/null
+++ b/include/asm-arm/arch-db8500/sec_bridge.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * Author: Mikael Larsson <mikael.xt.larsson@stericsson.com> for ST-Ericsson.
+ *
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+#ifndef _SEC_BRIDGE_H
+#define _SEC_BRIDGE_H
+
+#include <common.h>
+
+#define SEC_ROM_FORCE_CLEAN_MASK 0x0020
+#define SEC_ROM_RET_OK 0x01
+
+#define ISSWAPI_SECURE_LOAD 0x10000002
+#define ISSWAPI_FLUSH_BOOT_CODE 0x11000003
+
+int sec_bridge_init_bridge(void);
+u32 sec_bridge_call_secure_service(const u32 serviceid,
+ const u32 secureconfig, ...);
+int sec_bridge_flush_issw(void);
+#endif