From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F6E2C433F5 for ; Wed, 13 Oct 2021 13:49:27 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFA08610D0 for ; Wed, 13 Oct 2021 13:49:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AFA08610D0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8016083172; Wed, 13 Oct 2021 15:49:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="FRiZ8j0q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 789348356F; Wed, 13 Oct 2021 15:49:22 +0200 (CEST) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 68DF28291E for ; Wed, 13 Oct 2021 15:49:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wr1-x42d.google.com with SMTP id g25so8694305wrb.2 for ; Wed, 13 Oct 2021 06:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XYtDKH1WLYPyvGPQbUnfFQKEUfo4tqKl2XlbLqtk2d4=; b=FRiZ8j0qy5uKSv1yaQzWkAdPiT2YfKOqeacG26hrnZKjdHoKSb1IBP9k/pSNjl4wa3 LxZgdvj2XQtMHYt2Gn613qya0BuW/6vVrQks1fYAdW2hw3E5bWNVtG8v3gC9qBVKymZ6 NS7c2J3Tu4c1jCuaEt8td2HKD/uRmJS27BSclOsk0blc0yLubLTCW4IfzFsyPLknI8Td 4j3q1TeVr9g9qDv3XJ8SaJI+tGrysjspJS2wdqFyatpfSrISIExsRWYmTGllzij8Yjxh 0kYnBEvdX3qOa+k+bH/ZqofM6ML73IVAlx7YAxaUs8Jzy/hb4/VLdtPKTJaytmBiQKxt kzjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XYtDKH1WLYPyvGPQbUnfFQKEUfo4tqKl2XlbLqtk2d4=; b=5btt1NjO6H4ulCYvwsY19F/NiuNjDdAihvTLKEqXy0dQPWtXPWpQj83yth3d0n2hHO mnycvvEi3lRU0LuNSiWMW3Gt4zNUO3o+Gn7nnUNP2BAEybSe1rEaXloyMqc/zhY22P9/ wgvWe9f0xdWEzt5m3vrpczld2hQqvp552YuVwjVYFfOHbeOm3oqm6Q17GZX4M8xSDG1Q IRhSOwyXsCDIFp+u7PA4FKU/Qu7lZTFQ6CbzY/ussgb0WFe3VELB/ClXtrVdVkJrEjhr lAJCmUW6gw8sQL3sqLYBjcFulWVeMfmDk0FuIX26cz8vq8hqjgLcp7/LwzYzrjhU65Fe PDkQ== X-Gm-Message-State: AOAM533uraFjzNuChOV6EUntrxg3noEhddQ9pcCHi2aZsffJKtK3WPRj fJ12FA/eBFkHjT7luBF2U4THaQ== X-Google-Smtp-Source: ABdhPJzs+w5oQw3Gvd6ECUmZ1XyvREpLLDHEiWgh5N77hSq3SptoT6Ai8vx+1/47BiBrp+SSrJPanQ== X-Received: by 2002:a05:600c:22c6:: with SMTP id 6mr13440121wmg.106.1634132957325; Wed, 13 Oct 2021 06:49:17 -0700 (PDT) Received: from trex (60.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.60]) by smtp.gmail.com with ESMTPSA id n68sm5369295wmn.13.2021.10.13.06.49.16 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Oct 2021 06:49:16 -0700 (PDT) From: "Jorge Ramirez-Ortiz, Foundries" X-Google-Original-From: "Jorge Ramirez-Ortiz, Foundries" Date: Wed, 13 Oct 2021 15:49:16 +0200 To: Michal Simek Cc: "Jorge Ramirez-Ortiz, Foundries" , ashok.reddy.soma@xilinx.com, adrian.fiergolski@fastree3d.com, t.karthik.reddy@xilinx.com, sjg@chromium.org, mike.looijmans@topic.nl, u-boot@lists.denx.de, igor.opaniuk@foundries.io Subject: Re: [PATCHv2] zynqmp: restore the jtag interface Message-ID: <20211013134916.GA19410@trex> References: <20211013082514.24031-1-jorge@foundries.io> <20211013114028.GA562@trex> <69a88ca2-76be-49a2-7870-8a83dd1743c7@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <69a88ca2-76be-49a2-7870-8a83dd1743c7@xilinx.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 13/10/21, Michal Simek wrote: > > > On 10/13/21 13:40, Jorge Ramirez-Ortiz, Foundries wrote: > > On 13/10/21, Michal Simek wrote: > > > > > > > > > On 10/13/21 10:25, Jorge Ramirez-Ortiz wrote: > > > > When boot.bin is configured for secure boot the CSU will disable the > > > > JTAG interface on all cases. > > > > > > > > Some boards might rely on this interface for flashing to QSPI in which > > > > case those systems might end up bricked during development. > > > > > > > > This commit will restore the interface under CSU control > > > > > > > > Signed-off-by: Jorge Ramirez-Ortiz > > > > --- > > > > > > I can't see changelog here. What has changed in 3 minutes between v1 and v2? > > > > Not in 3 minutes but in 3 months: the first version was submited on > > 2021-07-16. > > > > The first patch sent this morning was missing the "v2" tag hence why I > > resent three minutes later. > > I didn't compare them. Just got two patches. One which looked as v1 and > second as v2. > > https://lists.denx.de/pipermail/u-boot/2021-October/thread.html > > > > > > v2 addresses the issues you mentioned with the original patch from > > July. > > > > v2 > > -- > > Macros added to hardware.h > > Used CONFIG_IS_ENABLED where possible > > Fixed Kconfig identation > > Removed unnecessary Kconfig default > > > > > > > > > arch/arm/mach-zynqmp/Kconfig | 8 +++++ > > > > arch/arm/mach-zynqmp/include/mach/hardware.h | 31 +++++++++++++++----- > > > > board/xilinx/zynqmp/zynqmp.c | 20 ++++++++++++- > > > > 3 files changed, 51 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig > > > > index f7b08db355..ee0895d9a2 100644 > > > > --- a/arch/arm/mach-zynqmp/Kconfig > > > > +++ b/arch/arm/mach-zynqmp/Kconfig > > > > @@ -149,6 +149,14 @@ config SPL_ZYNQMP_ALT_BOOTMODE_ENABLED > > > > Overwrite bootmode selected via boot mode pins to tell SPL what should > > > > be the next boot device. > > > > +config SPL_ZYNQMP_RESTORE_JTAG > > > > + bool "Restore JTAG" > > > > + depends on SPL > > > > + help > > > > + Booting SPL in secure mode causes the CSU to disable the JTAG interface > > > > + even if no eFuses were burnt. This option restores the interface if > > > > + possible. > > > > + > > > > config ZYNQ_SDHCI_MAX_FREQ > > > > default 200000000 > > > > diff --git a/arch/arm/mach-zynqmp/include/mach/hardware.h b/arch/arm/mach-zynqmp/include/mach/hardware.h > > > > index eebf38551c..e6a3ee4a57 100644 > > > > --- a/arch/arm/mach-zynqmp/include/mach/hardware.h > > > > +++ b/arch/arm/mach-zynqmp/include/mach/hardware.h > > > > @@ -39,20 +39,26 @@ > > > > #define RESET_REASON_INTERNAL BIT(1) > > > > #define RESET_REASON_EXTERNAL BIT(0) > > > > +#define CRLAPB_DBG_LPD_CTRL_SETUP_CLK 0x01002002 > > > > +#define CRLAPB_RST_LPD_DBG_RESET 0 > > > > + > > > > struct crlapb_regs { > > > > u32 reserved0[36]; > > > > u32 cpu_r5_ctrl; /* 0x90 */ > > > > - u32 reserved1[37]; > > > > + u32 reserved1[7]; > > > > + u32 dbg_lpd_ctrl; /* 0xB0 */ > > > > + u32 reserved2[29]; > > > > u32 timestamp_ref_ctrl; /* 0x128 */ > > > > - u32 reserved2[53]; > > > > + u32 reserved3[53]; > > > > u32 boot_mode; /* 0x200 */ > > > > - u32 reserved3_0[7]; > > > > + u32 reserved4_0[7]; > > > > u32 reset_reason; /* 0x220 */ > > > > - u32 reserved3_1[6]; > > > > + u32 reserved4_1[6]; > > > > u32 rst_lpd_top; /* 0x23C */ > > > > - u32 reserved4[4]; > > > > + u32 rst_lpd_dbg; /* 0x240 */ > > > > + u32 reserved5[3]; > > > > u32 boot_pin_ctrl; /* 0x250 */ > > > > - u32 reserved5[21]; > > > > + u32 reserved6[21]; > > > > }; > > > > #define crlapb_base ((struct crlapb_regs *)ZYNQMP_CRL_APB_BASEADDR) > > > > @@ -141,12 +147,23 @@ struct apu_regs { > > > > #define ZYNQMP_SILICON_VER_MASK 0xF > > > > #define ZYNQMP_SILICON_VER_SHIFT 0 > > > > +#define CSU_JTAG_SEC_GATE_DISABLE GENMASK(7, 0) > > > > +#define CSU_JTAG_DAP_ENABLE_DEBUG GENMASK(7, 0) > > > > +#define CSU_JTAG_CHAIN_WR_SETUP GENMASK(1, 0) > > > > +#define CSU_PCAP_PROG_RELEASE_PL BIT(0) > > > > + > > > > struct csu_regs { > > > > u32 reserved0[4]; > > > > u32 multi_boot; > > > > - u32 reserved1[11]; > > > > + u32 reserved1[7]; > > > > + u32 jtag_chain_status_wr; > > > > + u32 jtag_chain_status; > > > > + u32 jtag_sec; > > > > + u32 jtag_dap_cfg; > > > > u32 idcode; > > > > u32 version; > > > > + u32 reserved2[3055]; > > > > + u32 pcap_prog; > > > > }; > > > > #define csu_base ((struct csu_regs *)ZYNQMP_CSU_BASEADDR) > > > > diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c > > > > index 000a7cde8d..483f0b9ab2 100644 > > > > --- a/board/xilinx/zynqmp/zynqmp.c > > > > +++ b/board/xilinx/zynqmp/zynqmp.c > > > > @@ -358,6 +358,21 @@ static int multi_boot(void) > > > > return multiboot; > > > > } > > > > +#if defined(CONFIG_SPL_BUILD) > > > > +static void restore_jtag(void) > > > > +{ > > > > + if (current_el() != 3) > > > > + return; > > > > + > > > > + writel(CSU_JTAG_SEC_GATE_DISABLE, &csu_base->jtag_sec); > > > > + writel(CSU_JTAG_DAP_ENABLE_DEBUG, &csu_base->jtag_dap_cfg); > > > > + writel(CSU_JTAG_CHAIN_WR_SETUP, &csu_base->jtag_chain_status_wr); > > > > + writel(CRLAPB_DBG_LPD_CTRL_SETUP_CLK, &crlapb_base->dbg_lpd_ctrl); > > > > + writel(CRLAPB_RST_LPD_DBG_RESET, &crlapb_base->rst_lpd_dbg); > > > > + writel(CSU_PCAP_PROG_RELEASE_PL, &csu_base->pcap_prog); > > > > +} > > > > +#endif > > > > + > > > > #define PS_SYSMON_ANALOG_BUS_VAL 0x3210 > > > > #define PS_SYSMON_ANALOG_BUS_REG 0xFFA50914 > > > > @@ -377,11 +392,14 @@ int board_init(void) > > > > zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, > > > > zynqmp_pm_cfg_obj_size); > > > > printf("Silicon version:\t%d\n", zynqmp_get_silicon_version()); > > > > + > > > > + /* the CSU disables the JTAG interface when secure boot is enabled */ > > > > + if (CONFIG_IS_ENABLED(SPL_ZYNQMP_RESTORE_JTAG)) > > > > + restore_jtag(); > > > > #else > > > > if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) > > > > xilinx_read_eeprom(); > > > > #endif > > > > - > > > > > > Unrelated. > > > > ? > > checkpatch will fail if we leave two carriage returns > > What is the exact issue are you getting? um, must have been an error on my side. sent v3 deleting the removal of the unrelated empty line thanks > > M