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 816E8C433F5 for ; Wed, 13 Oct 2021 08:37:32 +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 AE48C60D43 for ; Wed, 13 Oct 2021 08:37:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AE48C60D43 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xilinx.com 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 A71B780644; Wed, 13 Oct 2021 10:37:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="KglesmXC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2833383116; Wed, 13 Oct 2021 10:37:27 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20616.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::616]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 45B4C83359 for ; Wed, 13 Oct 2021 10:37:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michals@xilinx.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eiGmdJTr/jqDiU8v9mc7BQyvVnAoORmpcSXhHXG3zEn2uD1Sq2ut3B6N1bzAEHKkoCvfFvaY+V1g2uG0Pz+ZT2hGiNeRbEWa2dt4XAMNmzMTdd1sVXvlK6hbbh30Vp6Rjdc/QlzPVJa1164d75wCFnnRBzjMEuFC2x3gjT+8xXK4yP07ksyOnACXIGgVmPQ2GOhSCj0KpD2Kh/0amyvVG3lCy5UERRFSGM1T9/riBFAxfld0JlYNb7iB+5gfYCbNYA16LwPOUQjGKNEiJKqDMDM8hJfmLLSoPCYc4HIMuz265MDwDTGiydBhaEjjG9afpM224FICJeeVZdPR0c13Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UUSenbMLzEFZrdR2yye9S5DsJvrbJxuQf01w+txeVpk=; b=Yi1Enq1yBAv0L2kN8RPypm+7CwyFI4BcvR6h/iALCWHqjXpid/t20QM8yRva19Mu83rg/1qoemUZuSaZ6VZZj07CEOs3cDW2HasU4bTAAUuNBRw1BfmZmO2a+4t3x/XMzq6PM5gGWgaAjBu396XQNlcQdhEBGDV3X0WRC/rz1//ucBucsFCNEvaYyN71Jsp1jhGSbPG8gztoqBtv2LUvT9S89ragkp+Nfp8SYTIpPMKWchwODnBMjYfP1Al1oJmAUhZ++RzVtIhWT+uylirRLg8pgbetmhAT0/wnJZ1bbdD931Y3HBdP0+VlXg71SCyrPf7eYyfG4BO0njZpJvBcpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=foundries.io smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UUSenbMLzEFZrdR2yye9S5DsJvrbJxuQf01w+txeVpk=; b=KglesmXCRI7TnICYHZwiW4e4HhQHn4v62gv8JxwFzYT11BxtBrewBxEMLR8KEgWmG5I5ptE2J2r1jAEH3DWxF7v/vEbtljBFR4oJRzF5fsVsFPAGlpvxK3wi/dECI3pouC7FMY3HbvkfDdYa/ajOIqsrH4/JJMw7Bawz+rVxzOU= Received: from BN9PR03CA0562.namprd03.prod.outlook.com (2603:10b6:408:138::27) by BL3PR02MB8097.namprd02.prod.outlook.com (2603:10b6:208:35c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Wed, 13 Oct 2021 08:37:19 +0000 Received: from BN1NAM02FT035.eop-nam02.prod.protection.outlook.com (2603:10b6:408:138:cafe::d6) by BN9PR03CA0562.outlook.office365.com (2603:10b6:408:138::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 08:37:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; foundries.io; dkim=none (message not signed) header.d=none;foundries.io; dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT035.mail.protection.outlook.com (10.13.2.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4587.18 via Frontend Transport; Wed, 13 Oct 2021 08:37:18 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 13 Oct 2021 01:37:18 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 13 Oct 2021 01:37:18 -0700 Envelope-to: jorge@foundries.io, adrian.fiergolski@fastree3d.com, sjg@chromium.org, mike.looijmans@topic.nl, u-boot@lists.denx.de, igor.opaniuk@foundries.io Received: from [10.254.241.49] (port=58120) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1maZlF-0001Cf-Pd; Wed, 13 Oct 2021 01:37:18 -0700 Message-ID: Date: Wed, 13 Oct 2021 10:37:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCHv2] zynqmp: restore the jtag interface Content-Language: en-US To: Jorge Ramirez-Ortiz , , , , CC: , , , References: <20211013082514.24031-1-jorge@foundries.io> From: Michal Simek In-Reply-To: <20211013082514.24031-1-jorge@foundries.io> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61d79f85-e8a5-478c-4a10-08d98e24ab11 X-MS-TrafficTypeDiagnostic: BL3PR02MB8097: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:530; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V9ixUo98H+Cy41PtFZwqwZTXdhNg3Sf7p5A9bJPvlW75bkc5oVrUXClhFXj/qhJNeY97s23cYvMU/90BlodiMpI+8Y+iipIZtbWYt9FpE3NC1kwp4UO/BTo85zTVdYNO4gxYe9KcJ6tKN1UZ+mtnQtld7Hecpfu6+fxq0qWVmlBFlbFi5UFF3JbX1y2WFTrsfN28ByaeuQ2Wt9E/1lvNoYk3j+CCdKTvG24dutOX1ZKIX8Q8XKsTCpPBYDbNxoQzYnKbde/qfuWkymnCEz8IGanAYq5aOxexDPl8GrF8uLCCQSViXe2LYJRUWWpN8gM7+fyp7DyiptpMX6Zh5DOmH5n+BA5QuTFwRtLmdjdtvfsHWjljOddeUcSZrb1w9QwVJiMqZwSz7Kkz/z9K/x79JmMi//n8LTR7YfBii+QScCW8WVz2wHDeBnf8LD27zkkhpeoUQzyBHGohr6ShtQ3QrSx6Neww2/e89Gq7uzuePvC2QRrELLEK80GfEw/m5TgzqUTHIY4UeJlInWH0pvjymjF9Y6eIShjjkxuHdM4f1h92aPWezdWaI9Xtaafe12ZJlrWdY7fpJHBEy7RLCRJf5uYvquUYLPar06mmTkFG76Of+5mt77MhFT91wh3thQFb15N/Ukukt6t8PvqljWw/NxdLsDsw+RuR38Atq/jKcadGjme8SapZHqwL5FYDxd5XYOpG13sT01Y5LKj6PNTjVaR8IQG6OFXBdansc+iL51UwS1ORyUBUro0c9UbRi58P29cQDYYdYWR9foJxnaOAb2EBySNGtGdihu5gZI76u/k= X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(46966006)(36840700001)(356005)(186003)(6636002)(83380400001)(336012)(31686004)(70206006)(2906002)(36906005)(70586007)(4326008)(44832011)(6666004)(47076005)(36756003)(53546011)(316002)(5660300002)(9786002)(26005)(7636003)(2616005)(426003)(31696002)(110136005)(8936002)(8676002)(54906003)(82310400003)(36860700001)(508600001)(50156003)(2101003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 08:37:18.8160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61d79f85-e8a5-478c-4a10-08d98e24ab11 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT035.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8097 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 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? > 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. > printf("EL Level:\tEL%d\n", current_el()); > > /* Bug in ROM sets wrong value in this register */ > M