From patchwork Sun Dec 29 19:07:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 962 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 341253F030 for ; Sun, 29 Dec 2019 20:07:54 +0100 (CET) Received: by mail-pl1-f198.google.com with SMTP id a2sf7728021plm.2 for ; Sun, 29 Dec 2019 11:07:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1577646473; cv=pass; d=google.com; s=arc-20160816; b=kfFvpx5dVuNykcT29j4dHNE6wKL3+g+TwahDT59VyeRHTywMOw7mhFaAgYNYVqumAE d04JpDPH/wiLXlLgOvRvSaL6oUr7BFqYeQsN9yEbmF1wR1GFyaVI1csV9GbW0BjcrGFW 9ehNLSASqCNzZkQ4izvqKwzLU2qv8BKDktb3vq3q1AEcqU8XHUE7jUs3KTvMH3AqZiXu MLNBTNLpQLHKgg8FvMPB9tg9fmZm7lIU+WV/mj9RxuhDBXEHbTU5pjCKIqA41jQ4/TJk sUG1/1YDPOlIht/qOwZTraDpBiTRPgnBCHg71RvtvgbTPwO/CE3MD3UkEvVsqUbyzpmR VjQA== 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=V8cxLCzvHXtVk0faOh9tIicCMV7sVgN9rTOh7jP3IRY=; b=RLL7+LX7v8NQvZer8sGHs9ncWpawvh5KYhpA7zAzewfTH30ah8sYxAZNtZjOLQ/hMY 8FanDDWPi4ISGzKcKFA+OSTzeyCONRz4swjnM9/FDb2yHmKOktVEkJBWS07n5aV9/Cr/ 2jNEuIUS8VcrP1z7DQAi0kbt89Z6cTfJAv6WY9Iwzg2cNSrdXbUw5FTGW776qYpGVtD8 Iwa1stJCJeERbPWu8rQzoA5DaVsjIvHOblWCbqPOl/9Rch/NwqtUCkyVcaW7SY3LCS20 waw2ByNARIhQ0n+pncJWcLjlfcWD/F2rb6hWz9sKI5muOmKcpb0yV41Bio+mApv1yF02 55Tg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WjRY+O1y; 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=V8cxLCzvHXtVk0faOh9tIicCMV7sVgN9rTOh7jP3IRY=; b=fQ1sFq8Ix5STH43M1STehj/Aw5Oj3N3PBU/oDZEMr6dTwxVncyx2J8pevEqtngObgN 7NyfPakL1dBOzX1upxKp95PC93IpfjRY7hn+Lmm8MrJp0HxMtfreHPd/3wgR+kkS3Yks xlVyVVH0kB+ErnO8WEfsPZnV1XnwRVnuFCxHo= 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=V8cxLCzvHXtVk0faOh9tIicCMV7sVgN9rTOh7jP3IRY=; b=FgMuq9APrv40/ft19NvK7+FkH5P8jMyvizEDu6nE056NRuoW+o+SxJpdoIddG7Gtbd MDQ4RW48fY+wS+1WIaN3Q3r8bKDqp+jpMbmCTO6D6B3OSR853gkq6EE00iq5hsJgrob6 x44v0BK7z3S67M/Ysxjzqe/GY2uAMszrIoEXexqBFWjXkhcBM27ZghuO7mfUy03rnNzo 6sXmIzpNRuneSFbP1dd5TapF/HDWSaTNIvaONs9pjA0DGuv3/djOCJry7Ko4OqGczl+/ uylW7PK7RJ4evKGMoxRJPlf3qbr1a018+2f2KZic572gVIXuH+i1dnqPXns3M74Tx+Zm OwAQ== X-Gm-Message-State: APjAAAU5QCc3iOMans6vhyqAs7+fYqZEEu9gnNG7lBLF9iWLDuGyiDK8 7spSWyDGyKNE28eeV6iWzgM4pYWK X-Google-Smtp-Source: APXvYqxns2Baq3KG+aV0gzAIaTtSIYO52B3NSDWYze01cZqY1WtmigMEM6Y+ziXtFQQFhOTOvr3L3w== X-Received: by 2002:a63:eb02:: with SMTP id t2mr67850158pgh.289.1577646472923; Sun, 29 Dec 2019 11:07:52 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:f8d:: with SMTP id 13ls6218573pjz.0.gmail; Sun, 29 Dec 2019 11:07:52 -0800 (PST) X-Received: by 2002:a17:902:a606:: with SMTP id u6mr65400480plq.171.1577646472385; Sun, 29 Dec 2019 11:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577646472; cv=none; d=google.com; s=arc-20160816; b=ZgbrctTaxphHn+BCh+VmNvIOAC5CDPCmcXK8W5jBI+cZsh2110+dDoptd+Fe4Q0BNM fqJJ7ManaC8xQnKbKUqrapMglFSc7MDOQt3SV2MPO9wiO1JbBOpMIHdbUDbEV1SwFi+E h+St6CSm6mvi0hkqd48N3fV4tKR3V4kXcUTcYnVVakC7JWO2NJoi+ugdybfWgSAJMJxk xHMUElQgSCgvUGFAngGlAZFxFB3HtprrMS10ogCPpZgFZmxaUNvGPY/0khP33XqYkdJH ZQkNpW3ax9W/1Aqrst9CnIfMdVXaXGlbuMYETRdx5UhcQd8fSkXwSbCXayyw/ZAbObtk x7cQ== 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=uZNNWtNMWQc294lHjUGEK/YALiO6/B2tdwJ4JYGKPGk=; b=mbpoexcv6vPo6ErBJ8c55fdou/rn92Pb5wtFVAEWsRWOXVMQyJXPvVDB2HJkm+FuIV C3TMQk8dFdbfgauqWnT5nNZnLLdzBiwCgrELLb1fSX1p+Vo7BzVWbJH+6aj16UtSJvFK 3fnl/NgNvWIaDXmi1eX9JgAzagU043ggVhLKHu/8Qwk6e0+afkT9ZbzUKU52nbf9LHIF VI0OMjTHHryC4v4w1U5V4sH4owSAJeJmtyqratsznamwWRNFB9gE9hjZxgANGk6a9tHO zDESP6fnT5JjZnIg61lTV4pZypGl7t63ySVTJELOcS6OVjnIasNpAuy7vJl1/rkDcXgB 9gzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WjRY+O1y; 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 5sor43260258pfb.67.2019.12.29.11.07.52 for (Google Transport Security); Sun, 29 Dec 2019 11:07:52 -0800 (PST) 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:a62:3603:: with SMTP id d3mr64554585pfa.37.1577646472053; Sun, 29 Dec 2019 11:07:52 -0800 (PST) Received: from localhost.localdomain ([2405:201:c809:c7d5:f590:ce0e:1ce1:c326]) by smtp.gmail.com with ESMTPSA id u10sm44879700pgg.41.2019.12.29.11.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 11:07:51 -0800 (PST) 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 Subject: [PATCH v3 4/5] rockchip: Add common reset cause Date: Mon, 30 Dec 2019 00:37:25 +0530 Message-Id: <20191229190726.29266-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191229190726.29266-1-jagan@amarulasolutions.com> References: <20191229190726.29266-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=WjRY+O1y; 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: , Add cpu reset cause in common cpu-info file. This would help to print the reset cause for various resets. Right now it support rk3288, rk3399. rest of rockchip platforms doesn't have reset cause support ye but this code is more feasible to extend the same. Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- arch/arm/include/asm/arch-rockchip/cru.h | 12 +++++ .../include/asm/arch-rockchip/cru_rk3288.h | 14 +----- arch/arm/mach-rockchip/cpu-info.c | 49 +++++++++++++++++++ arch/arm/mach-rockchip/rk3288/rk3288.c | 39 --------------- 4 files changed, 62 insertions(+), 52 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 5ed3fbfd07..e1dd9a89c2 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 7aa6efe46c..412b73e55f 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 rockchip_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 9bccbd4f68..4b0e99299a 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -5,10 +5,59 @@ */ #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"; + } + + /** + * reset_reason env is used by rk3288, due to special use case + * to figure it the boot behavior. so keep this as it is. + */ + env_set("reset_reason", cause); + + /* + * 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 */ diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c b/arch/arm/mach-rockchip/rk3288/rk3288.c index 47ee5d440b..18ea7f35fb 100644 --- a/arch/arm/mach-rockchip/rk3288/rk3288.c +++ b/arch/arm/mach-rockchip/rk3288/rk3288.c @@ -102,43 +102,6 @@ void board_debug_uart_init(void) } #endif -static void rk3288_detect_reset_reason(void) -{ - struct rockchip_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"; - } - - env_set("reset_reason", 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); -} - __weak int rk3288_board_late_init(void) { return 0; @@ -146,8 +109,6 @@ __weak int rk3288_board_late_init(void) int rk_board_late_init(void) { - rk3288_detect_reset_reason(); - return rk3288_board_late_init(); }