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 CC532C433EF for ; Wed, 13 Oct 2021 13:03:46 +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 1071F610CB for ; Wed, 13 Oct 2021 13:03:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1071F610CB 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 08707834C1; Wed, 13 Oct 2021 15:03:44 +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="l4jKlZuy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6976F83173; Wed, 13 Oct 2021 15:03:42 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20626.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::626]) (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 4552583246 for ; Wed, 13 Oct 2021 15:03:34 +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=N2Bfj6x+pMypnpBY2QvWyrsYE4spzjCj7lPyapmca2efMxCGcnOrOpb2srTzlRx3EUHZQPTQRiEX2ubVxQ0Fxst46hl+JoS3iRNLGeL5Wv2PWdzJL2L4qkZcO+tsK0OnlsPmvGjNdPG6nZhGGZMBpEp9A5WSey/8C9J0C6WrpDrPrCFJa9nEH0Lg57iFYUhiHffiLJOGm8oAxBqQWtidi3Rs0b1c+qER0t8t+oY7fQWpHx39okjGFjGrSAEfx61zLsOZS2BgYoVlGc18UC8wUBmnr7zIJr8G9IWG/FGqrHFYXnQydoZXpgVVwm74E5MvRzR9XgQGYDoj5QFPPIOp4g== 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=EPsRIYtzy34By35ym5GDqdAhRZNylqMgD0/MM46ueXY=; b=ADaauL6eommnEAV7aq1fwxvRryRSe4eOjLRzOEWy0nPggCnxHDrYYtKPbZdhozllTJWUCqiSeiMpGcSp/VzY6Umo/TR8aeic2jmMeW7WrC7bWzSLl0LOYSXabHQZg7mRkt0I558Ffc602QdHwrFk2AuTxrqGyYLeO6xA0BOJJTjvr/udGmnxNgFvddG4tJXb3QBSHBOLk91tGTUXVWNGw04DCMqv2NfvyR0/3mnphg++iJoDqXrIB5miO7/lMPBsk3PViuOy2YqCGcv+B3zZRXJV8KJzpYPa3d1c4BJNN5O8RQlhix7iMgBpjdqSx3yEClfTAat8K+lepv6ZQgRIRA== 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=EPsRIYtzy34By35ym5GDqdAhRZNylqMgD0/MM46ueXY=; b=l4jKlZuySPxk2SPDUXTLTuP2fB2byexEBiFqRYc0CbvxdIgTVf2qC4amGn0Ee5cDBtmE2OYcusxDnN7GLKQGZfFG5fGjuROJPj7ZYRhPFZgv4pH3Pf2VqrnIGzI6D4MXzUPiBy6igLhtzmol95KrlJlwGeMTehxvVNPTdGoi6z0= Received: from BN0PR04CA0169.namprd04.prod.outlook.com (2603:10b6:408:eb::24) by BY5PR02MB6502.namprd02.prod.outlook.com (2603:10b6:a03:1da::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Wed, 13 Oct 2021 13:03:30 +0000 Received: from BN1NAM02FT017.eop-nam02.prod.protection.outlook.com (2603:10b6:408:eb:cafe::ad) by BN0PR04CA0169.outlook.office365.com (2603:10b6:408:eb::24) 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 13:03:30 +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 BN1NAM02FT017.mail.protection.outlook.com (10.13.2.134) 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 13:03:29 +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 06:03:27 -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 06:03:27 -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=53218) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1madup-00027e-IS; Wed, 13 Oct 2021 06:03:27 -0700 Message-ID: <69a88ca2-76be-49a2-7870-8a83dd1743c7@xilinx.com> Date: Wed, 13 Oct 2021 15:03:25 +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, Foundries" , Michal Simek CC: , , , , , , References: <20211013082514.24031-1-jorge@foundries.io> <20211013114028.GA562@trex> From: Michal Simek In-Reply-To: <20211013114028.GA562@trex> 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: bc45d9e6-21ab-4e10-1af9-08d98e49daa0 X-MS-TrafficTypeDiagnostic: BY5PR02MB6502: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jj/+8OpCaOMWH1oiozqeyyWhSwWlbu3QqykhbQTA8iDb0Ym817yI5lU3nj1p8+Buz8kXmFW+xPVAxtZ9UmFKliWXzmZM4HsuqfViEQ0d9tXGdR/Nfsy7OH/JeEieBMh3PdBFfb4RnvZD9uaJpK/4DW5vCajp0Ost0fezkR23MIVlUx1+Wt14RqY/PgDdk8hpa2Do4A7M7d5YwOTJ5kv1FK/4gnRxBx8cK8rAsdjN1C/cY3kKQfZZLd2kl3hqnrOK4F6RiBRBKmjBc+WDcvZOSQmoroqcaGQNflGgtVlAp3PhznXVPHS2JSyhpHfdQW6EoMcvLudml7pj3Bi7viXL7r4qkpeQNXZ3WcRjBHGVoWxZLsyR6AjunHNSsBdFpDwwRYChrzts1SVVQzX4RTb+HaLzyuej9GJkKU6uVeeBzCZTUnVOObTeGVC3CLHLtOYibK7OnVvB43A1X0AEjf25WFIaQ/oaO6HJSTAxFyNjFpwTVoX7F/a4zHcy1lw1YfrwiUylTockpgJgfUAhjHFQvb4HcsjDFDC8I8FGgcRcXyx0da1lpTRpQfVqios7y5tUFX1tr/3ikh9+GvDERN1mYkF6q2FnzU7OsHVVdGNgtC2QPc52dnUfUXTgpoXVgHbNjCWFaGXiyOnO0Wsi9TW8FjaNnYJhveaZyIBo5bvl8SEs7CSeLHG8kpyNUKMe4zzKmJd0/99aPbKnxHtJtP+F0uwVsGx4Gfw0m2QOkeZiR4YkN6gHrkT02dEySatVI/5EsYkaZhSWZJQcfGSmCW5mtccqaL4obV7P0w/2FRYNHeUNyVXkroFGSNzx7tgV0uovWmiCsSJzfArK7Yf2lD2ijxJfRGRzh5NYFzzxDUF3pRA= 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)(508600001)(82310400003)(8676002)(44832011)(36756003)(7636003)(36906005)(31686004)(54906003)(316002)(31696002)(47076005)(336012)(356005)(70586007)(8936002)(53546011)(26005)(426003)(70206006)(83380400001)(2906002)(2616005)(36860700001)(9786002)(4326008)(966005)(5660300002)(110136005)(186003)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 13:03:29.9829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc45d9e6-21ab-4e10-1af9-08d98e49daa0 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: BN1NAM02FT017.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR02MB6502 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 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? M