From patchwork Mon Jul 29 07:47:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 813 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BFAEF3F0E1 for ; Mon, 29 Jul 2019 09:47:40 +0200 (CEST) Received: by mail-pf1-f200.google.com with SMTP id e20sf37980114pfd.3 for ; Mon, 29 Jul 2019 00:47:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1564386459; cv=pass; d=google.com; s=arc-20160816; b=osrWQfwFgFq8X7DW4UPXxQIvqDaoNETDMbEAPk7fP/osXAxFr/16oyGWOaf9ff1DkI A0iar6jh35yTemtToySg65WIwcTx9kd86j0gUrxVhcbw1S1LQUtXC0wWi9WDeR0j/HdC gQc8bDcd3Ud5pQp7l5AUI874GWWIKzZRgEVAofh7wAZ5V+Uhfxz9MPXLZJD+oSH0kpq/ aHeJRBgY8G5nakPvwBts2vZpWB3tVv71zlRvRj8m3EFIZ+NLaSL4ytEh2c63QPZYdH3F 7BUqHGNxryQzjYty6rNBkWK7yQqda/LvdS6jPahwG2WC1GVnYbV3C/lJQtTos0Ee1eRI moIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=L4Vt4R8Ld7zgocpV2828VAtDsOz7MflVAvgvpCK/ER4=; b=NNazB3efMfp2+KZXm0vxh9Zvm8ccEBwguOC0xjL+PfZMDW1mjBqM7aCAeIdjAc5pbd u3tDwqjZMrVHN9cM33t4zjM2atIgxLmLzoHzwY2iN88Ps71A4UU2GXWETFLDsJzR7HvD OrUi2m+DE2wL9TKQIyqicIvb4OUuSGLzfeSsDfTl00GTQRSxyHfcU3RpT7zxGyD4vyAi RGmIQFKFrRv3dh1eTRUhQb/lUYEM0I7dxjZwRzaMIVqCmrviopRfePlWI8fZk9XV0Sdj O3sS+5pn6mPvKE8O+nCtDw/jbojIovS+4d+kAOfIMRVrix048RrUCWrD61T+fofdy0CZ BKFA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="afvLBT/W"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=L4Vt4R8Ld7zgocpV2828VAtDsOz7MflVAvgvpCK/ER4=; b=ovmSrnKMuw816njoiMmnyozkiGKQjwPbvSbz4r8wHgD8+Qzzh0X7SCToIti/4IRa8y IOW6AnJYUMPxo6p7VudoAOsQm6iZoAn/xt+uAAQw2hgbjkGSdzu46+0MikPUlaeXFUAd Jv6Zz0QjceaS6+ouBgpi9l1BDlbxDBOCqf7Yk= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=L4Vt4R8Ld7zgocpV2828VAtDsOz7MflVAvgvpCK/ER4=; b=kO1EqHISw7s2dcBqK4kdPMVGi06f6cMLITKKWPDJu2jcBps1qGmUnsU/cGsL87o02i 2V5Id68eXoozaAzjnUVdw0VsPoaZWazEhvc1yVTbt2pqdqyMYPAypT3LGyfb4PuQ0N73 XooqbZHKQl+AHc4UbZPGdl7dgQUTk3jA4Lbuu7CRq7xjSCLOSExWsqKdksX+wUgWHcVC cCCGSLdJtXrhmqO/XXgOvZqolwuwXv70KLctm2woppy2wrIWRXHwsfpWdXjYgYidINmw Jnp8UCjwR4CqGD+fuO4i+3jU1XZa9Z0uG/3Qib422VY4UelOE4Q+UrpzzwFlUFNaDNdf FZqA== X-Gm-Message-State: APjAAAXVM1BgD3kOigKU1lgtFLDPw4S5G7uRtHXPBdo3mZ2z+8ojz2I4 Nphc7FExH9eCpaRWH8TaPtIC8vBL X-Google-Smtp-Source: APXvYqyYqEdg8XUdDPN7woiPaKssH498q6RQ9M7tMjo9vz9ToCNJGX04R0+qUrR0d1W1l0j5mNAvAg== X-Received: by 2002:a65:60d3:: with SMTP id r19mr77919664pgv.91.1564386459367; Mon, 29 Jul 2019 00:47:39 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:a9:: with SMTP id a38ls16918970pla.5.gmail; Mon, 29 Jul 2019 00:47:39 -0700 (PDT) X-Received: by 2002:a17:902:2869:: with SMTP id e96mr104842728plb.203.1564386458968; Mon, 29 Jul 2019 00:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564386458; cv=none; d=google.com; s=arc-20160816; b=MW7rb7NuuL0p/unQyzuxk3rHI6lWBuxHPi24vxcjyT9x0emvsPulacctz2JhdGzV82 1V1Ky1YA/ScBNAodmc45Zz/vAyk8qksX7l8uF/yv9+w5/M82GLPiAXdDwFwZNMw1jBuy 1jyPEfHMgF8PUQcMZy9Rig1axaLRlSDfZMNc+Gf3+S02ntLFLI1PX0mvTBjPha3D6qLA +7idslVIznNYsXRCNh4FaVxk9ah0ih1KNywZ+45ccy44L7h4g/eTo0wQ36ds70EIc7Tu xpaO2S3r0Ja87XaLPA0aa9r+c3ganFK3Qt/w8hhPVFn4BauBLP7HRHeCNxt2r8TmamG/ icjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=PeStiX165xrcK3wOyhqM1gLga3q5yUQWbEfSl5LTn2Q=; b=xUYrCsxgNzr0ZWG33hTGO8ihilOdjoV+2fnulteVUWBwObAn5fOZVyvX/dyDvrluvS Q25lhMvSCbkIgcMdv0WTqyk8IA5hpFIC0kVwwNohuqiAV9e/sKZP9LHqh9iVrI7OdX7I yk8mBXdH3lDpAZBemLQFYlivSrDf3QTMpsxVjuJdbm9PEOVBmbngtbgrkOIFWqIQjU7N tQMnkqqiukjPA41qRdfyzhu2/yS7vvkZ8PvBWZxsE/rfjnTb/x4seh6BkWFkNYI6+yEj pZ59zdmgnQceb2peGPLBthc86iIYuPXLhrHzcbpbrP0L7xzGXYPT+qCf5JdFH9/+fgt7 zgMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="afvLBT/W"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r11sor72630460pjb.8.2019.07.29.00.47.38 for (Google Transport Security); Mon, 29 Jul 2019 00:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90b:f0f:: with SMTP id br15mr112231709pjb.101.1564386458628; Mon, 29 Jul 2019 00:47:38 -0700 (PDT) Received: from localhost.localdomain ([49.206.203.41]) by smtp.gmail.com with ESMTPSA id h14sm75723348pfq.22.2019.07.29.00.47.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 00:47:38 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: Akash Gajjar , u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki , Wadim Egorov Subject: [PATCH 04/15] rockchip: Add common reset reason Date: Mon, 29 Jul 2019 13:17:00 +0530 Message-Id: <20190729074711.16988-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190729074711.16988-1-jagan@amarulasolutions.com> References: <20190729074711.16988-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="afvLBT/W"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Right now the reset reason supported by rk3288 and which is printing on board late function. Support the same reset reason for rk3399 as well, since it is sharing same cru register mark the code into common area. Printing reset reason below SoC information would really help instead of printing in board late call, so support this as part of cpu_info. Cc: Wadim Egorov Signed-off-by: Jagan Teki --- arch/arm/include/asm/arch-rockchip/cru.h | 12 ++++++ .../include/asm/arch-rockchip/cru_rk3288.h | 14 +------ arch/arm/mach-rockchip/cpu-info.c | 41 +++++++++++++++++++ arch/arm/mach-rockchip/rk3288-board.c | 39 ------------------ 4 files changed, 54 insertions(+), 52 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 3b1a3bae71..b54e21d6f1 100644 --- a/arch/arm/include/asm/arch-rockchip/cru.h +++ b/arch/arm/include/asm/arch-rockchip/cru.h @@ -13,4 +13,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/include/asm/arch-rockchip/cru_rk3288.h b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h index e891f20b37..7acb1c7208 100644 --- a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h +++ b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h @@ -51,7 +51,7 @@ struct rk3288_cru { u32 cru_glb_cnt_th; u32 cru_glb_rst_con; u32 reserved3; - u32 cru_glb_rst_st; + u32 glb_rst_st; u32 reserved4; u32 cru_sdmmc_con[2]; u32 cru_sdio0_con[2]; @@ -227,16 +227,4 @@ enum { CLKF_MASK = 0x1fff << CLKF_SHIFT, }; -/* 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 diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c index 088fc806a6..8e56999b05 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -5,6 +5,38 @@ */ #include +#include +#include +#include +#include +#include + +static char *rockchip_reset_reason(unsigned int glb_rst_st) +{ + char *reason; + + switch (glb_rst_st) { + case GLB_POR_RST: + reason = "POR"; + break; + case FST_GLB_RST_ST: + case SND_GLB_RST_ST: + reason = "RST"; + break; + case FST_GLB_TSADC_RST_ST: + case SND_GLB_TSADC_RST_ST: + reason = "THERMAL"; + break; + case FST_GLB_WDT_RST_ST: + case SND_GLB_WDT_RST_ST: + reason = "WDOG"; + break; + default: + reason = "unknown reset"; + } + + return reason; +} int print_cpuinfo(void) { @@ -13,12 +45,21 @@ int print_cpuinfo(void) /* TODO print operating temparature and clock */ # ifdef CONFIG_ROCKCHIP_RK3288 puts("RK3288\n"); + struct rk3288_cru *cru = rockchip_get_cru(); # elif CONFIG_ROCKCHIP_RK3399 puts("RK3399\n"); + struct rk3399_cru *cru = rockchip_get_cru(); # else # warning Please update cpu.c with correct CPU information puts("Family\n"); # endif + if (IS_ERR(cru)) + return -EINVAL; + + printf("Reset cause: %s\n", rockchip_reset_reason(cru->glb_rst_st)); + + rk_clrreg(&cru->glb_rst_st, GLB_RST_ST_MASK); + return 0; } diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c index 613264d7ee..3e5cd9bad9 100644 --- a/arch/arm/mach-rockchip/rk3288-board.c +++ b/arch/arm/mach-rockchip/rk3288-board.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -44,48 +43,10 @@ int rk3288_qos_init(void) return 0; } -static void rk3288_detect_reset_reason(void) -{ - struct rk3288_cru *cru = rockchip_get_cru(); - const char *reason; - - if (IS_ERR(cru)) - return; - - switch (cru->cru_glb_rst_st) { - case GLB_POR_RST: - reason = "POR"; - break; - case FST_GLB_RST_ST: - case SND_GLB_RST_ST: - reason = "RST"; - break; - case FST_GLB_TSADC_RST_ST: - case SND_GLB_TSADC_RST_ST: - reason = "THERMAL"; - break; - case FST_GLB_WDT_RST_ST: - case SND_GLB_WDT_RST_ST: - reason = "WDOG"; - break; - default: - reason = "unknown reset"; - } - - printf("Reset cause: %s\n", reason); - - /* - * Clear cru_glb_rst_st, so we can determine the last reset cause - * for following resets. - */ - rk_clrreg(&cru->cru_glb_rst_st, GLB_RST_ST_MASK); -} - int board_late_init(void) { setup_boot_mode(); rk3288_qos_init(); - rk3288_detect_reset_reason(); return rk_board_late_init(); }