From patchwork Mon Apr 12 12:12:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 419539 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp1659359jaj; Mon, 12 Apr 2021 04:43:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9CmviC0lThFUSmEU63k4qopF1Dvbtk354E6el16weCtaWpBc5H0VTPpV63/ViosMZVR3y X-Received: by 2002:a17:907:c16:: with SMTP id ga22mr26617799ejc.120.1618227780972; Mon, 12 Apr 2021 04:43:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618227780; cv=pass; d=google.com; s=arc-20160816; b=HmXGSPFtZZcvgKZBE3om6fvn3G5EsP6+F2QAwa8FKh1wCiZD18dLzumZhPFspE67Ul o09NEqVDJnpGU/CDMSb7HecGQlq5vatXb9ykDsMjF7dkB1mESwwP/5jltaNDpN2UBdkU mYjskzI+0qWcD9F400gQT8fKU5vExar3uO+2KjaoAxksvlYqwrVEfIF/EYrcYXwagNZt liwO/1XzKLuI3F8xy6MHYRB6UdJJ8EZdcGH5nU5xHv4Qs3ULW1tRxXEPsKWqDA2Geuef wdpBba/bZrAUfDtuAPFhbc87aGgol9UeEN/QZI5Y/NLpfw9uDL4EKdSTUisgrHexhxM4 Vwig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=riev8FH2q2qYN2IoIOv5o5JHtbuAPDl7McYV7hBodWI=; b=u34FkC2j+vCQRfpXSVUMACouDacuxy9sKDfa3wPvwjMTSn2uY/2tq/1o4F8NSdkSdJ xP1EgeJ64SbOyAvMDvjVO/28gaxBPaCsRsGKpLt3oXvcKtqMX0QBM1nRZ0n90ihjwaSs wZfIGfreB2Tlv5+oORwYc1M0sObF8Rbm2ZjjvIQzF5bvic8gXYqXOCEnLiDC2k4ne3co luLBBdkXd8a5PkPofxTXs279NPLz54bSgkZM4JTXQOsLPfIBxIes6wPyOL5JAxUgLUil VETwEGvJ1ZtNbfp0MjpYZytplCHa7BYmPmsJZUa67FyM8+AhP5CRBXuGqgOu/2FZz6jM shVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=W2CnWQhw; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id df23si7325492edb.38.2021.04.12.04.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:43:00 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=W2CnWQhw; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E349C82037; Mon, 12 Apr 2021 13:42:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=oss.nxp.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=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="W2CnWQhw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 00BF481F66; Mon, 12 Apr 2021 13:41:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0623.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::623]) (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 4563781E72 for ; Mon, 12 Apr 2021 13:41:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=oss.nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@oss.nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmHFwUqrZe9vCWcFhrkapBpFHxZm9GUSpgEZAjIr3bjn5sYSU2+9QXOmGQwv5f9OlLkyQOHBGjY8EBFYcxDeDvaDJw1uEr3ZvgRDHZx2UJxRya9eQo66JY+g49W803151V9yby2Vxixag8+NEv6w+1xUQY0iKpeheWdL2NdhRDxVq55t4SmZWnTIlIaPKipispqVV6XF/R03BKMWESpVqa2Af65x0i8fOKNLMSANeYinltJ+voAZMFTKYwbc6dWJ96xjeYP4ygDXd7p3nryWU5fczoDFidYo+RF0f9OfC1O3pl/cHNdSqxoXdauV5DUToP8DB/m3rUcVdBROT3ImdQ== 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-SenderADCheck; bh=riev8FH2q2qYN2IoIOv5o5JHtbuAPDl7McYV7hBodWI=; b=AxJCpUIK0ksQLxCN9pqF8mYpFfhW9alyCi0OTqNx9trQakGmOjVVizUNr5X2UvPWZE3YcLLq46Np15IgpJppDbjd5H8FcvngHKlFuwQZS+dybwVvIiKbnYrFgkypqLFx6iAi9bNoHrZT2U3nIFiUUfxdkmYpWON7gLoafRrdcWNEwKQn3JxWSEq7ABTxXsaw4XAx2WN4R9HduQpfewQDIY5lPoDBF4ffm6C7GBRXSRipko8WRPm6NU4p5UU8huUHmveUx++tx7bwk1OBlYs5R4ALHq+5DS7l8fY+0oJNXZ4yOxPd0fnqoreZtZXg5REMWHkuEnO7nNcfgAdVgsjNYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=riev8FH2q2qYN2IoIOv5o5JHtbuAPDl7McYV7hBodWI=; b=W2CnWQhwpTc2Yl5Zbnylf/gNxsowQ1mmadwK/7x19/hJxgHYDmerclGTQGjl5rsbh/Ha6wRKICkLNQlEXCZpzWIQ58OqxJGPjZUbvWltcXR9TxwFlf7jAx0OiJXufiWmpmI2qckbTVX2g5qY7UabeGe3sQi989OMphJmWwpGhtY= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none; denx.de; dmarc=none action=none header.from=oss.nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4233.eurprd04.prod.outlook.com (2603:10a6:5:25::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 11:41:38 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c57a:6964:f72c:21cf]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c57a:6964:f72c:21cf%11]) with mapi id 15.20.3999.032; Mon, 12 Apr 2021 11:41:38 +0000 From: "Peng Fan (OSS)" To: sbabic@denx.de, festevam@gmail.com Cc: u-boot@lists.denx.de, uboot-imx@nxp.com, Peng Fan Subject: [PATCH 05/37] imx: imx8ulp: add get reset cause Date: Mon, 12 Apr 2021 20:12:34 +0800 Message-Id: <20210412121306.11484-6-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210412121306.11484-1-peng.fan@oss.nxp.com> References: <20210412121306.11484-1-peng.fan@oss.nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0401CA0009.apcprd04.prod.outlook.com (2603:1096:202:2::19) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by HK2PR0401CA0009.apcprd04.prod.outlook.com (2603:1096:202:2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Mon, 12 Apr 2021 11:41:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6fe46500-f21c-4f7c-4920-08d8fda7ef1a X-MS-TrafficTypeDiagnostic: DB7PR04MB4233: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:93; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tXHkFvelFsv2o7ardszWeKytsmXxDMSS3fnk47HD/jcTE4thVhwvabYVIxnPLiGGMF2ycE9sChzEENHpV773QPTywn4dKLZbW7TjAbXTi/JGIV78sFN5FSGamxCMK3/9TwH03aAj6TvOymdDIu8D33stybnbAFOG5Oj56nVsFw6sqAa53EmtE/AoYoShg9MJXATO2bHeVRhRlpjaNgZiFntF7QG9B3FZg/AC40qIiy001PlYN74svAt9y4ocZLEs+skcCdG73Z33bvthRZ0VQgsU+VLeXNBQDXHjvJ9YhYdH0elE4Pe+8q1HALEn+iOoSe+xQtTM3GXzPcpIwQxX9dAgKb9VNWFsQGdcBo0IG8Ia17x4nDwTKS9oJkGR8KdyBoTWElgjxB15eKH6KNuKqKHQNm+QgQxYKwbHywJQycXftQYSV0V9cwN56jiVk0QIBV63LScNQyiTOKZhCOHy9bPzWU5lUYCmQSQXWzFknR40nffHZcarZUaW6AGnGqqUvgogxbgsIUbE5wT1Bc/84aD3SV3yqvv6vtdWU8749l8GSYPgDTYRpVecE9zc4QfU8Kyf9nY4H4VEpwUtKjeZl4IbQOoU4uFfKYUBR5Oi22MAadn1EPavywJ097F45OsVEuD3OsklGqJVyDcjuIc/tpq/AaIOdHrPP0QcwOiijsy7JC8EkcwGApWy5JTOZLib X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(396003)(39860400002)(136003)(346002)(366004)(52116002)(83380400001)(956004)(86362001)(2616005)(6506007)(66476007)(8676002)(66556008)(1076003)(2906002)(4326008)(16526019)(316002)(26005)(5660300002)(6512007)(186003)(8936002)(38350700002)(38100700002)(478600001)(6486002)(66946007)(32563001);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f4IlrShKZN/bPC4ydMUxgSrwJBDhmXrRZ5MxFLPFNnKjsfMB+zpbxnCztGqJRu9/Pfm0kYlYf007YbedlL64hXqpGx3bBHkVTlPJPr/zeU6FU0K8/xF+j3UN/rANJf5mMLTJxvSzcEq2GRzT/ow2SzOTfbxCnxxPoLDQVirTp0H40TLEb4py04WjOhe5IipyvcvuH60LOz8dDU91p7sq4pq2HZjqVDFTOfB704I7hGgK7qsynpd8Czii5DR/TQVPQoEDlweQFMxqdtmWjkkU7ggdVz+I5RTg62rRQ6uWIrDAYF X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fe46500-f21c-4f7c-4920-08d8fda7ef1a X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 11:41:38.7257 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zvndwu/TvWw29Kbe2YwnO5PRYgg8SXV1hfgSHB7mZMCC5SAmButCRiu/c2etZ8gvspkk4BV4aeCNrGChTiLvog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4233 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Peng Fan Add get reset cause function to show what triggerred reset. Signed-off-by: Peng Fan --- arch/arm/mach-imx/imx8ulp/soc.c | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) -- 2.30.0 diff --git a/arch/arm/mach-imx/imx8ulp/soc.c b/arch/arm/mach-imx/imx8ulp/soc.c index e6ac5f8d25..383dbe6000 100644 --- a/arch/arm/mach-imx/imx8ulp/soc.c +++ b/arch/arm/mach-imx/imx8ulp/soc.c @@ -32,6 +32,73 @@ enum bt_mode get_boot_mode(void) return LOW_POWER_BOOT; } +#define CMC_SRS_TAMPER BIT(31) +#define CMC_SRS_SECURITY BIT(30) +#define CMC_SRS_TZWDG BIT(29) +#define CMC_SRS_JTAG_RST BIT(28) +#define CMC_SRS_CORE1 BIT(16) +#define CMC_SRS_LOCKUP BIT(15) +#define CMC_SRS_SW BIT(14) +#define CMC_SRS_WDG BIT(13) +#define CMC_SRS_PIN_RESET BIT(8) +#define CMC_SRS_WARM BIT(4) +#define CMC_SRS_HVD BIT(3) +#define CMC_SRS_LVD BIT(2) +#define CMC_SRS_POR BIT(1) +#define CMC_SRS_WUP BIT(0) + +static u32 reset_cause = -1; + +static char *get_reset_cause(char *ret) +{ + u32 cause1, cause = 0, srs = 0; + void __iomem *reg_ssrs = (void __iomem *)(SRC_BASE_ADDR + 0x88); + void __iomem *reg_srs = (void __iomem *)(SRC_BASE_ADDR + 0x80); + + if (!ret) + return "null"; + + srs = readl(reg_srs); + cause1 = readl(reg_ssrs); + + reset_cause = cause1; + + cause = cause1 & (CMC_SRS_POR | CMC_SRS_WUP | CMC_SRS_WARM); + + switch (cause) { + case CMC_SRS_POR: + sprintf(ret, "%s", "POR"); + break; + case CMC_SRS_WUP: + sprintf(ret, "%s", "WUP"); + break; + case CMC_SRS_WARM: + cause = cause1 & (CMC_SRS_WDG | CMC_SRS_SW | + CMC_SRS_JTAG_RST); + switch (cause) { + case CMC_SRS_WDG: + sprintf(ret, "%s", "WARM-WDG"); + break; + case CMC_SRS_SW: + sprintf(ret, "%s", "WARM-SW"); + break; + case CMC_SRS_JTAG_RST: + sprintf(ret, "%s", "WARM-JTAG"); + break; + default: + sprintf(ret, "%s", "WARM-UNKN"); + break; + } + break; + default: + sprintf(ret, "%s-%X", "UNKN", cause1); + break; + } + + debug("[%X] SRS[%X] %X - ", cause1, srs, srs ^ cause1); + return ret; +} + #if defined(CONFIG_DISPLAY_CPUINFO) const char *get_imx_type(u32 imxtype) { @@ -50,6 +117,8 @@ int print_cpuinfo(void) (cpurev & 0x000F0) >> 4, (cpurev & 0x0000F) >> 0, mxc_get_clock(MXC_ARM_CLK) / 1000000); + printf("Reset cause: %s\n", get_reset_cause(cause)); + printf("Boot mode: "); switch (get_boot_mode()) { case LOW_POWER_BOOT: