From patchwork Mon Aug 26 18:20:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1153388 X-Patchwork-Delegate: ykai007@gmail.com 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=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="JD+kGEMh"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46HL6Z3C6Tz9s00 for ; Tue, 27 Aug 2019 04:25:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 24B10C222EA; Mon, 26 Aug 2019 18:23:16 +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_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 D1849C222AD; Mon, 26 Aug 2019 18:22:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0AE21C222CA; Mon, 26 Aug 2019 18:21:29 +0000 (UTC) Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by lists.denx.de (Postfix) with ESMTPS id 8CAB6C222B3 for ; Mon, 26 Aug 2019 18:21:26 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id e12so16104907otp.10 for ; Mon, 26 Aug 2019 11:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V7KXtS4UY6UlB13Z0yXdsQzffMPbipOXSFmQnsy4Ilw=; b=JD+kGEMhSci/yu60AiRN98LWqPTk9GCsK1jZ5Eg8X+HIRw1TDGhROQGVSDzfmNszUl Sz4peEwGsaupqCXK8ESvPAOt01a1D88pb4G0T+G1V8zUrYj6MnwQJyzXfNzFIjc+lHhZ KVBhx0DIOiFfE7dYCYrJ9Y6EN/83zUdcYNe/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V7KXtS4UY6UlB13Z0yXdsQzffMPbipOXSFmQnsy4Ilw=; b=CxKY6ZXX01u8ErGyvJ54sGY/1LBCf5Ht7BVouDbEuoOU0nrrasyKEDMOn3/v9K3q64 beQ6TFD5madB65fHZ1NVUQUX2vigPqGPv7gdmbtS3kVBZct+xiLPU8s4sQxxM6zPGVL4 eiemM0YCBh20nX/IJY/W0JOXFH4NUDykLIWc4ya9LRQbux++27+135zebAdK81QETSZS tVTgxQGTfmpxlDqbhyaHeLT6ZsR2TcrlTTZy7vC7fMgJ8nQpp2yyD08stLz3p7MlKp29 SltF3qN7qd/G8QEv0zFE1Y7PK6cOQn+kMi3sfntmvUJbKIeTnyb8zIsM9TElLqE7qTyP syyQ== X-Gm-Message-State: APjAAAW5q/tow7Ri80PV8nqcMVd+S8x6inKpbxAE/FGwRGQmMzosjm8u eFJkb/o0HO80QjIJX9fhXXUdEQ== X-Google-Smtp-Source: APXvYqxztPJ/KvwkBIG33Jx0PZ6+KgqZ6kXXUNwSFsjsdo/rAFMF993qniQIJgNj/Sr7seJLNGDOUQ== X-Received: by 2002:a9d:2cc:: with SMTP id 70mr13662029otl.145.1566843685166; Mon, 26 Aug 2019 11:21:25 -0700 (PDT) Received: from jagan-XPS-13-9350.attlocal.net ([2600:1700:7430:38e0:d5b0:4823:33c8:5e46]) by smtp.gmail.com with ESMTPSA id c11sm4401461otr.54.2019.08.26.11.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 11:21:24 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Date: Mon, 26 Aug 2019 23:50:59 +0530 Message-Id: <20190826182111.30999-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190826182111.30999-1-jagan@amarulasolutions.com> References: <20190826182111.30999-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Akash Gajjar , linux-rockchip@lists.infradead.org Subject: [U-Boot] [PATCH v2 04/16] rockchip: Add rk3399 reset cause 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add reset cause for rk3399 in common cpu-info file. This would help to print the reset cause for various resets. Common code for various rockchip reset cause will add it in future. Signed-off-by: Jagan Teki --- arch/arm/include/asm/arch-rockchip/cru.h | 12 +++++++ arch/arm/mach-rockchip/cpu-info.c | 43 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 3d1927580f..e267a71ca6 100644 --- a/arch/arm/include/asm/arch-rockchip/cru.h +++ b/arch/arm/include/asm/arch-rockchip/cru.h @@ -11,4 +11,16 @@ # include #endif +/* CRU_GLB_RST_ST */ +enum { + GLB_POR_RST, + FST_GLB_RST_ST = BIT(0), + SND_GLB_RST_ST = BIT(1), + FST_GLB_TSADC_RST_ST = BIT(2), + SND_GLB_TSADC_RST_ST = BIT(3), + FST_GLB_WDT_RST_ST = BIT(4), + SND_GLB_WDT_RST_ST = BIT(5), + GLB_RST_ST_MASK = GENMASK(5, 0), +}; + #endif /* _ROCKCHIP_CLOCK_H */ diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c index 90ce65d9ff..63d867fe78 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -5,10 +5,53 @@ */ #include +#include +#include +#include +#include +#include + +static char *get_reset_cause(void) +{ + struct rockchip_cru *cru = rockchip_get_cru(); + char *cause = NULL; + + if (IS_ERR(cru)) + return cause; + + switch (cru->glb_rst_st) { + case GLB_POR_RST: + cause = "POR"; + break; + case FST_GLB_RST_ST: + case SND_GLB_RST_ST: + cause = "RST"; + break; + case FST_GLB_TSADC_RST_ST: + case SND_GLB_TSADC_RST_ST: + cause = "THERMAL"; + break; + case FST_GLB_WDT_RST_ST: + case SND_GLB_WDT_RST_ST: + cause = "WDOG"; + break; + default: + cause = "unknown reset"; + } + + /* + * Clear glb_rst_st, so we can determine the last reset cause + * for following resets. + */ + rk_clrreg(&cru->glb_rst_st, GLB_RST_ST_MASK); + + return cause; +} int print_cpuinfo(void) { printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC); + printf("Reset cause: %s\n", get_reset_cause()); /* TODO print operating temparature and clock */