[PATCH 3/3] zynq: Add function to lock JTAG enable bits

lukas.funke-oss at weidmueller.com lukas.funke-oss at weidmueller.com
Thu Mar 28 10:01:10 CET 2024


From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>

Add function to prevent debug access from being enabled. If the debug
lock is set the debug access cannot be enabled after a soft-reset.
The debug access can only be enabled after a power-on-reset is
performed.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
Signed-off-by: Lukas Funke <lukas.funke at weidmueller.com>
---

 arch/arm/mach-zynq/cpu.c                    | 10 ++++++++++
 arch/arm/mach-zynq/include/mach/sys_proto.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c
index b8d413b69a..e6151bc21d 100644
--- a/arch/arm/mach-zynq/cpu.c
+++ b/arch/arm/mach-zynq/cpu.c
@@ -20,6 +20,7 @@
 #define ZYNQ_DEV_CFG_CTRL_SPIDEM		BIT(5)
 #define ZYNQ_DEV_CFG_CTRL_SPNIDEN		BIT(6)
 #define ZYNQ_DEV_CFG_CTRL_JTAG_CHAIN_DIS	BIT(23)
+#define ZYNQ_DEV_CFG_LOCK_DBG_LOCK		BIT(0)
 
 #define ZYNQ_SILICON_VER_MASK		0xF0000000
 #define ZYNQ_SILICON_VER_SHIFT		28
@@ -93,6 +94,15 @@ void zynq_enable_jtag(void)
 	writel(v, &devcfg_base->ctrl);
 }
 
+void zynq_lock_jtag(void)
+{
+	unsigned int v;
+
+	v = readl(&devcfg_base->lock);
+	v |= ZYNQ_DEV_CFG_LOCK_DBG_LOCK;
+	writel(v, &devcfg_base->lock);
+}
+
 unsigned int zynq_get_silicon_version(void)
 {
 	return (readl(&devcfg_base->mctrl) & ZYNQ_SILICON_VER_MASK)
diff --git a/arch/arm/mach-zynq/include/mach/sys_proto.h b/arch/arm/mach-zynq/include/mach/sys_proto.h
index f583ef090d..3377fe2c23 100644
--- a/arch/arm/mach-zynq/include/mach/sys_proto.h
+++ b/arch/arm/mach-zynq/include/mach/sys_proto.h
@@ -16,6 +16,7 @@ extern u32 zynq_slcr_get_idcode(void);
 extern int zynq_slcr_get_mio_pin_status(const char *periph);
 extern void zynq_ddrc_init(void);
 extern void zynq_enable_jtag(void);
+extern void zynq_lock_jtag(void);
 extern unsigned int zynq_get_silicon_version(void);
 extern unsigned int zynq_get_mulitboot_addr(void);
 extern void zynq_set_mulitboot_addr(unsigned int);
-- 
2.30.2



More information about the U-Boot mailing list