Add support for jtag disable/enable and multiboot get/set for zynq
Subsystems (3)
cover Add support for jtag disable/enable and multiboot get/set for zynq
From: Lukas Funke <[email protected]>
This series adds support to enable/disable/lock the jtag interface from u-boot. This becomes handy if secure boot is used but debugging should be poissible for non-productions builds.
The series also adds support to get/set the multiboot register in order to ensure a freash bootimage search after soft reset.
Stefan Herbrechtsmeier (3):
zynq: Add get function for multi boot address register
zynq: Add function to enable JTAG
zynq: Add function to lock JTAG enable bits
arch/arm/mach-zynq/cpu.c | 48 ++++++++++++++++++++- arch/arm/mach-zynq/include/mach/hardware.h | 3 +- arch/arm/mach-zynq/include/mach/sys_proto.h | 4 ++ 3 files changed, 52 insertions(+), 3 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/3 zynq: Add get function for multi boot address register
From: Stefan Herbrechtsmeier <[email protected]>
This commit adds a function to get/set the multiboot register. This becomes handy in order to ensure a fresh bootimage search after reset.
---
arch/arm/mach-zynq/cpu.c | 19 +++++++++++++++++-- arch/arm/mach-zynq/include/mach/hardware.h | 3 ++- arch/arm/mach-zynq/include/mach/sys_proto.h | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-)
arch/arm/mach-zynq/cpu.c +17 -2
@@ -14,8 +14,9 @@#include <asm/arch/ps7_init_gpl.h> #include <asm/arch/sys_proto.h> -#define ZYNQ_SILICON_VER_MASK 0xF0000000 -#define ZYNQ_SILICON_VER_SHIFT 28 +#define ZYNQ_SILICON_VER_MASK 0xF0000000 +#define ZYNQ_SILICON_VER_SHIFT 28 +#define ZYNQ_MULTIBOOT_ADDR_MASK 0x00001FFF#if CONFIG_IS_ENABLED (FPGA ) xilinx_desc fpga = {
@@ -79,6 +80,20 @@ unsigned int zynq_get_silicon_version(void) >> ZYNQ_SILICON_VER_SHIFT; } +unsigned int zynq_get_mulitboot_addr (void ) +{ +return readl (&devcfg_base->multiboot_addr) &ZYNQ_MULTIBOOT_ADDR_MASK ; +} + +void zynq_set_mulitboot_addr (unsigned int value) +{ +unsigned int v =readl (&devcfg_base->multiboot_addr); + + v &= ~ZYNQ_MULTIBOOT_ADDR_MASK ; + v |= value &ZYNQ_MULTIBOOT_ADDR_MASK ; +writel (v, &devcfg_base->multiboot_addr); +} +void reset_cpu (void ) {zynq_slcr_cpu_reset ();
arch/arm/mach-zynq/include/mach/hardware.h +2 -1
@@ -96,7 +96,8 @@ struct devcfg_regs {u32 dma_src_len;/* 0x20 */ u32 dma_dst_len;/* 0x24 */ u32 rom_shadow;/* 0x28 */ -u32 reserved1[2 ]; +u32 multiboot_addr;/* 0x2c */ +u32 reserved1[1 ];u32 unlock;/* 0x34 */ u32 reserved2[18 ];u32 mctrl;/* 0x80 */
arch/arm/mach-zynq/include/mach/sys_proto.h +2 -0
@@ -16,5 +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 unsigned int zynq_get_silicon_version (void ); +extern unsigned int zynq_get_mulitboot_addr (void ); +extern void zynq_set_mulitboot_addr (unsigned int );#endif /* _SYS_PROTO_H_ */
Signature · 1 line
2.30.2
PATCH 2/3 zynq: Add function to enable JTAG
In reply to [email protected]From: Stefan Herbrechtsmeier <[email protected]>
In non-secure boot mode jtag is restored by the BootROM. In secure boot mode jtag has to be restored by the trusted application, i.e. the bootloader.
This commit adds a function to enable the jtag interface on zynq devices from u-boot.
---
arch/arm/mach-zynq/cpu.c | 19 +++++++++++++++++++ arch/arm/mach-zynq/include/mach/sys_proto.h | 1 + 2 files changed, 20 insertions(+)
arch/arm/mach-zynq/cpu.c +19 -0
@@ -14,6 +14,13 @@#include <asm/arch/ps7_init_gpl.h> #include <asm/arch/sys_proto.h> +#define ZYNQ_DEV_CFG_CTRL_DAP_EN GENMASK(0, 2) +#define ZYNQ_DEV_CFG_CTRL_DBGEN BIT(3) +#define ZYNQ_DEV_CFG_CTRL_NIDEN BIT(4) +#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_SILICON_VER_MASK 0xF0000000#define ZYNQ_SILICON_VER_SHIFT 28#define ZYNQ_MULTIBOOT_ADDR_MASK 0x00001FFF
@@ -74,6 +81,18 @@ int arch_cpu_init(void)return 0 ; } +void zynq_enable_jtag (void ) +{ +unsigned int v; + + v =readl (&devcfg_base->ctrl); + v &= ~ZYNQ_DEV_CFG_CTRL_JTAG_CHAIN_DIS ; + v |=ZYNQ_DEV_CFG_CTRL_DAP_EN |ZYNQ_DEV_CFG_CTRL_DBGEN + |ZYNQ_DEV_CFG_CTRL_NIDEN |ZYNQ_DEV_CFG_CTRL_NIDEN + |ZYNQ_DEV_CFG_CTRL_SPIDEM |ZYNQ_DEV_CFG_CTRL_SPNIDEN ; +writel (v, &devcfg_base->ctrl); +} +unsigned int zynq_get_silicon_version (void ) {return (readl (&devcfg_base->mctrl) &ZYNQ_SILICON_VER_MASK )
arch/arm/mach-zynq/include/mach/sys_proto.h +1 -0
@@ -15,6 +15,7 @@ extern u32 zynq_slcr_get_boot_mode(void);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 unsigned int zynq_get_silicon_version (void );extern unsigned int zynq_get_mulitboot_addr (void );extern void zynq_set_mulitboot_addr (unsigned int );
Signature · 1 line
2.30.2
PATCH 3/3 zynq: Add function to lock JTAG enable bits
In reply to [email protected]From: Stefan Herbrechtsmeier <[email protected]>
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.
---
arch/arm/mach-zynq/cpu.c | 10 ++++++++++ arch/arm/mach-zynq/include/mach/sys_proto.h | 1 + 2 files changed, 11 insertions(+)
arch/arm/mach-zynq/cpu.c +10 -0
@@ -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 )
arch/arm/mach-zynq/include/mach/sys_proto.h +1 -0
@@ -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 );
Signature · 1 line
2.30.2
Michal Simek
maintainerHi,
Quoted 9 lines · On 3/28/24 10:01, [email protected] wrote:
From: Lukas Funke <[email protected]>
This series adds support to enable/disable/lock the jtag interface from u-boot. This becomes handy if secure boot is used but debugging should be poissible for non-productions builds.
The series also adds support to get/set the multiboot register in order to ensure a freash bootimage search after soft reset.
nit: typo here.
I understand what you do and why but completely missing wiring for using it.
Likely you are calling it from your code but pretty much when this is applied it is just dead code. Can we wire it up somehow?
1/3 - showing multiboot at boot
Then do similar things as are done with SPL_ZYNQMP_ALT_BOOTMODE
2/3 this is pretty much the same what it is done via ZYNQMP_RESTORE_JTAG (also please rename it to be aligned together).
3/3 - I would be fine if this is connected to zynq specific command for example (unlock can be wired like that too).
Thanks,
Michal