From patchwork Thu May 17 13:31:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 915452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="tSmD7bRA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40msdg3RN6z9s1B for ; Thu, 17 May 2018 23:31:19 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0EBD8C21F52; Thu, 17 May 2018 13:31:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 18F50C21E8A; Thu, 17 May 2018 13:31:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 919FBC21E8A; Thu, 17 May 2018 13:31:11 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 2296DC21E02 for ; Thu, 17 May 2018 13:31:11 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id w18-v6so1950567wrn.6 for ; Thu, 17 May 2018 06:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=PB0yWd+iCFZcbqr9UnWUl+ALbiiZiZAXUsRjQV2ywnM=; b=tSmD7bRA2wV1ALU/B4YtZGQQ63QEntiynbSscUpFFtNvykZE+CAiqnLU8pu3BeYc8p nWP8wl62sxVmB/EZiP5QL9kmCarHeflKTXvPajqQoyJgALuPDcrpB3LJ5AwoOLCzOPUM 1sotuLIgGP7YYBVYEkJMlU2jfqa5hP7IHyeqB+TR91LLvWOsYSsSvVkcdModCXQkg5RB IVDW7YacbIOzQFkWcjTRjOdNDoCns0eLAOeUQpKW4ThlWraqpNYPTkgQ66OsXrFTQ4VL cdUNlqCtiyS+xZ/tfq47krrbzqYLjXxcABGceqiMU2z80Q8z7mHcrwxyRftOqkbyc5pf HpTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=PB0yWd+iCFZcbqr9UnWUl+ALbiiZiZAXUsRjQV2ywnM=; b=b2HAPODylxKLU2xZU0vQhRqM1ARs9UeaXaA+nQwlmCxg+0lqa3U5u3gXJ5lG2K8fBA DIkNFd0A5UJJr6LeVuYgf6YGzeJOIjI3qiOuQNTEd8TkgHRG31JWjSzrHAuN4nueTx6r 7XiJjaTYbqIGficZIfUm7wERfyPL/WEIzAazEBw7l6VUTL5O8c47FVnSPof/qC0Hsv/C jZmANKJq2aOISRfMe8jlGUnny+g9MZEUaWQ6vjsijyg3dT7Z8xpcBL4LtKycJWmWAmlv pNV76TVn6cgbq+3ztV8s2d6Sc0kctiXcMb8CNeRXkGts8o0hWZFN7Q+XtjfiyjCCKnKN EU0g== X-Gm-Message-State: ALKqPwfoOcEwS1QedzmwX0aXkR6QJvtWTlFZ8l5aBvXWX8HOjInAJ4Ur uvPDAt4zeAfNnbVe3mlj028CL7Hy X-Google-Smtp-Source: AB8JxZqbcnku7QD3nlMY/fFFduQHke8jHMjROWokPMB25iLL6vGxySbmkX6S4uKTmXxmFf8rU5LxQw== X-Received: by 2002:adf:9466:: with SMTP id 93-v6mr4121003wrq.264.1526563870545; Thu, 17 May 2018 06:31:10 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id w11-v6sm5880697wrn.86.2018.05.17.06.31.09 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 17 May 2018 06:31:09 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de Date: Thu, 17 May 2018 15:31:06 +0200 Message-Id: X-Mailer: git-send-email 2.17.0 Subject: [U-Boot] [PATCH] arm64: zynqmp: Show reset reason X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Read reset reason reg and show it in log and also save it as variable. reset_reasons table is setting up priorities for variable. Signed-off-by: Michal Simek --- arch/arm/include/asm/arch-zynqmp/hardware.h | 12 +++++- board/xilinx/zynqmp/zynqmp.c | 43 +++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/arch-zynqmp/hardware.h b/arch/arm/include/asm/arch-zynqmp/hardware.h index 3f1f9498e356..7961a247e196 100644 --- a/arch/arm/include/asm/arch-zynqmp/hardware.h +++ b/arch/arm/include/asm/arch-zynqmp/hardware.h @@ -33,6 +33,14 @@ #define PS_MODE2 BIT(2) #define PS_MODE3 BIT(3) +#define RESET_REASON_DEBUG_SYS BIT(6) +#define RESET_REASON_SOFT BIT(5) +#define RESET_REASON_SRST BIT(4) +#define RESET_REASON_PSONLY BIT(3) +#define RESET_REASON_PMU BIT(2) +#define RESET_REASON_INTERNAL BIT(1) +#define RESET_REASON_EXTERNAL BIT(0) + struct crlapb_regs { u32 reserved0[36]; u32 cpu_r5_ctrl; /* 0x90 */ @@ -40,7 +48,9 @@ struct crlapb_regs { u32 timestamp_ref_ctrl; /* 0x128 */ u32 reserved2[53]; u32 boot_mode; /* 0x200 */ - u32 reserved3[14]; + u32 reserved3_0[7]; + u32 reset_reason; /* 0x220 */ + u32 reserved3_1[6]; u32 rst_lpd_top; /* 0x23C */ u32 reserved4[4]; u32 boot_pin_ctrl; /* 0x250 */ diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 551921b888a0..4d886a914fa9 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -476,6 +476,47 @@ static int create_mmc_boot_commands(void) return 0; } +static const struct { + u32 bit; + const char *name; +} reset_reasons[] = { + { RESET_REASON_EXTERNAL, "EXTERNAL" }, + { RESET_REASON_INTERNAL, "INTERNAL" }, + { RESET_REASON_SOFT, "SOFT" }, + { RESET_REASON_PSONLY, "PS-ONLY" }, + { RESET_REASON_SRST, "SRST" }, + { RESET_REASON_PMU, "PMU" }, + { RESET_REASON_DEBUG_SYS, "DEBUG" }, + {} +}; + +static u32 reset_reason(bool print) +{ + u32 ret; + int i; + const char *reason = NULL; + + ret = readl(&crlapb_base->reset_reason); + + if (print) + puts("Reset reason:\t"); + + for (i = 0; i < ARRAY_SIZE(reset_reasons); i++) { + if (ret & reset_reasons[i].bit) { + reason = reset_reasons[i].name; + if (print) + printf("%s ", reset_reasons[i].name); + } + } + + if (print) + puts("\n"); + + env_set("reset_reason", reason); + + return ret; +} + int board_late_init(void) { u32 reg = 0; @@ -593,6 +634,8 @@ int board_late_init(void) env_set("boot_targets", new_targets); + reset_reason(true); + return 0; }