Skip to contentSkip to conversation

imx: Support i.MX6 High Assurance Boot authentication

PATCH Superseded Nitin Garg 1 participant 1 message Sep 3, 2014 Arm (32-bit)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Nitin Garg

author
#0 lore raw

PATCH v2 1/1 imx: Support i.MX6 High Assurance Boot authentication

When CONFIG_SECURE_BOOT is enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added command hab_auth_img can be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.

---

Changes in v2:
- Cleaned up clock code as per review comments
- Removed dead code as per review comments
- Re-written commit log as per review comments

 arch/arm/cpu/armv7/mx6/clock.c            |   32 +++++-
 arch/arm/cpu/armv7/mx6/hab.c              |  165 ++++++++++++++++++++++++++++-
 arch/arm/cpu/armv7/mx6/soc.c              |   15 +++
 arch/arm/include/asm/arch-mx6/clock.h     |    4 +
 arch/arm/include/asm/arch-mx6/sys_proto.h |    2 +-
 5 files changed, 215 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/mx6/clock.c +31 -1
index 820b8d5..db6a8fc 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
+ * Copyright (C) 2010-2014 Freescale Semiconductor, Inc.
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -543,6 +543,36 @@ int enable_pcie_clock(void)
 			       BM_ANADIG_PLL_ENET_ENABLE_PCIE);
 }
 
+#ifdef CONFIG_SECURE_BOOT
+void hab_caam_clock_enable(void)
+{
+	struct mxc_ccm_reg *const imx_ccm =
+		(struct mxc_ccm_reg *)CCM_BASE_ADDR;
+
+	/*CG4 ~ CG6, enable CAAM clocks*/
+	setbits_le32(&imx_ccm->CCGR0, MXC_CCM_CCGR0_CAAM_WRAPPER_IPG_MASK |
+		     MXC_CCM_CCGR0_CAAM_WRAPPER_ACLK_MASK |
+		     MXC_CCM_CCGR0_CAAM_SECURE_MEM_MASK);
+
+	/* Enable EMI slow clk */
+	setbits_le32(&imx_ccm->CCGR6, MXC_CCM_CCGR6_EMI_SLOW_MASK);
+}
+
+void hab_caam_clock_disable(void)
+{
+	struct mxc_ccm_reg *const imx_ccm =
+		(struct mxc_ccm_reg *)CCM_BASE_ADDR;
+
+	/*CG4 ~ CG6, disable CAAM clocks*/
+	clrbits_le32(&imx_ccm->CCGR0, MXC_CCM_CCGR0_CAAM_WRAPPER_IPG_MASK |
+		     MXC_CCM_CCGR0_CAAM_WRAPPER_ACLK_MASK |
+		     MXC_CCM_CCGR0_CAAM_SECURE_MEM_MASK);
+
+	/* Disable EMI slow clk */
+	clrbits_le32(&imx_ccm->CCGR6, MXC_CCM_CCGR6_EMI_SLOW_MASK);
+}
+#endif
+
 unsigned int mxc_get_clock(enum mxc_clock clk)
 {
 	switch (clk) {
arch/arm/cpu/armv7/mx6/hab.c +164 -1

197 lines not on this page · raw message

arch/arm/cpu/armv7/mx6/soc.c +15 -0
index b0c1306..9842efb 100644
@@ -409,10 +409,25 @@ int board_postclk_init(void)
 #ifndef CONFIG_SYS_DCACHE_OFF
 void enable_caches(void)
 {
+#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
+	enum dcache_option option = DCACHE_WRITETHROUGH;
+#else
+	enum dcache_option option = DCACHE_WRITEBACK;
+#endif
+
 	/* Avoid random hang when download by usb */
 	invalidate_dcache_all();
+
 	/* Enable D-cache. I-cache is already enabled in start.S */
 	dcache_enable();
+
+	/* Enable caching on OCRAM and ROM */
+	mmu_set_region_dcache_behaviour(ROMCP_ARB_BASE_ADDR,
+					ROMCP_ARB_END_ADDR,
+					option);
+	mmu_set_region_dcache_behaviour(IRAM_BASE_ADDR,
+					IRAM_SIZE,
+					option);
 }
 #endif
 
arch/arm/include/asm/arch-mx6/clock.h +4 -0
index 339c789..2482e1a 100644
@@ -2,6 +2,8 @@
  * (C) Copyright 2009
  * Stefano Babic, DENX Software Engineering, [email protected].
  *
+ * (C) Copyright 2014 Freescale Semiconductor, Inc.
+ *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
@@ -60,4 +62,6 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num);
 int enable_spi_clk(unsigned char enable, unsigned spi_num);
 void enable_ipu_clock(void);
 int enable_fec_anatop_clock(enum enet_freq freq);
+void hab_caam_clock_enable(void);
+void hab_caam_clock_disable(void);
 #endif /* __ASM_ARCH_CLOCK_H */
arch/arm/include/asm/arch-mx6/sys_proto.h +1 -1
index 306d699..0528453 100644
@@ -11,7 +11,7 @@
 #include <asm/imx-common/regs-common.h>
 #include "../arch-imx/cpu.h"
 
-#define soc_rev() (get_cpu_rev() & 0xFF)
+#define soc_rev() ((int)(get_cpu_rev() & 0xFF))
 #define is_soc_rev(rev)        (soc_rev() - rev)
 
 u32 get_nr_cpus(void);
Signature · 1 line
1.7.9.5