From patchwork Mon Jul 19 07:46:55 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: 479810 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3867117jao; Mon, 19 Jul 2021 00:14:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSLiLMv1PgjRrJ3I0ySWeMsGVia5DPIP2TIywcvyAkBBYEU49f8sZfs9wBFN29Rly3MDI7 X-Received: by 2002:a17:907:7695:: with SMTP id jv21mr25339563ejc.243.1626678879246; Mon, 19 Jul 2021 00:14:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626678879; cv=pass; d=google.com; s=arc-20160816; b=tKGY6jPpYb/KPcP2h9aKMLDXEPcTVJiIPx8mVtqhkTb9fIlc2o6zxi295WKlHbwtM2 IqDnldSIKGaXzsqRb1qah3t4e8M/bE3/vBO3pWGDcCOTUcNjy+mm2FsFTCuDYMTrk7jF k0KfE3Cp0+BS9JF01wyqcBin5Jwo0qKqV6epU0HmfE2jROY9nFDIODeZt2u/poBhO0BG XGXGe1eN2QDVRWQJE8c+Ll8PfejFU7P4Tvcq89EAaNkWQzLIZFfYOEb2y3IwxcsBu1vS aQ2YOVfAO6B3WInhn7g1k0KHch/wg3V1UvA1dmHm6Oq5MJ4uRi4giQhmaxk5ylGfo4v/ IlFQ== 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=kSIoGvuT4R/QiP6uOjOLWOVuFPcwDohwIoVF4es2dhgC0GOAaU9Mi8XkY2vX7xlkMP r0XM+N6SDU6JLWJ0cCg1DjlyubPkCQQz0EFZbVJhQL7KHzI5ixu7yzBp0QkUuUlAq5U2 nRF5J74K8z8EXME+qIrX6nKAWyqivYO5rNqigvfE2Z0G4K338QjeMzyjIi4ZdqMv9kMh k0+Nx+ky7LYmvzfHnDrPGO2WXlutBlITJBgpq9FdUM5uE+/FAuBnB1jpRPweXmR1fByT xVCwgh3y++ZgFiThqHtxrocSJy0zpB22UamNBREbV4NznTvtfkPNgw5m/hq0EP3YiCqa yxuw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=iQsRot94; 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 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id lj26si16488187ejb.678.2021.07.19.00.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 00:14:39 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=iQsRot94; 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 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 942F982C26; Mon, 19 Jul 2021 09:14:08 +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="iQsRot94"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E26682B36; Mon, 19 Jul 2021 09:13:52 +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=-0.6 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 EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20607.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::607]) (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 7B41582BC4 for ; Mon, 19 Jul 2021 09:13:45 +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=DowGkuXe3ssPVyW6Z/w3vsaktkew+SUDfjk1hb3CygEbSUJMftwTbrzwIrP1zu4uMvTTz2RX9A6L+MjZT9ob5B9RXqeeqeadgbTKoMXkaC2CyxgCLES1EDF/MvvguuYbt0elzuTRG6AQibmyNexCnLHCgniSeBte7jfI/zDkpU4sfF3pATNO5DYKwUBHji5zUwcqGA/QpG1pdgV7lc7Cm2xf1vV9Ec4qN4Gw600Zxqt6+v+nlNZ7Tahb/NFuToJTDwzkyiAIsJXs+I4WYSbz1WHHXRoHB+HH2gLhZoAQB7eB0LqVghXFpTW8FQN3Nef2ZXvaBubRxODBLSrVzi/vEA== 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=EnvJ23O8sajoxrRX+eqlgsGMms77oa2WPrxTlDCNUvYyx5x73MIh090AjFwLA5j0Ms4ckbzW1cFUp+S+qGzhhXvenxHHkWw/DDxGbmE2u65eGnhuk0LFynqQKaMyXfl/XJ1Q7uAypRL0E3QxWnZWo+glx3BzGNZdTEZyOUa+Vs78brPLASPitcH+bgsWUI7kHINUawPXGQNm4Q8DVgVd9Rq1bFFK3sLckO+sf4aDC8rjthMGGnVpm+RZPv4zSlUAHMDJB5IcxLi+7I4dIMSrFFqXFovDQBaA/i8F4QooRXib4UWFAgypNVLjcOr4NKL0syNqRGOm0gdg8EWTwa6+0g== 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=iQsRot94+g5qR5WJXYvCwMFi7f0DagosxuyhD5Ynk+3W5v5O0fv8EUNDepHQ3Fb5ZFI3HA1NztEY3OaCPmmRmrxKQVmCFhrtVzuQzA2DR5hV8S4+FWYuW3ljGHZE2+3F6+S+hbzaBUXKed6PTZDEIgq57wIG7HDSDbULFGrFFd4= 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 DB6PR0402MB2933.eurprd04.prod.outlook.com (2603:10a6:4:9c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Mon, 19 Jul 2021 07:13:44 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c445:d742:eb76:86dd]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c445:d742:eb76:86dd%9]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 07:13:44 +0000 From: "Peng Fan (OSS)" To: sbabic@denx.de, festevam@gmail.com Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Peng Fan Subject: [Patch V3 05/44] imx: imx8ulp: add get reset cause Date: Mon, 19 Jul 2021 15:46:55 +0800 Message-Id: <20210719074734.29170-6-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210719074734.29170-1-peng.fan@oss.nxp.com> References: <20210719074734.29170-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SGAP274CA0006.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::18) 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 SGAP274CA0006.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 07:13:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b1efc2a-b202-4df6-09fb-08d94a84be40 X-MS-TrafficTypeDiagnostic: DB6PR0402MB2933: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: epT5fJJk3f83HbJaIANWydPRg1xaqw+moKOW8Fx7U+e2ZwEX+HS7jUSy3TzW4rlNyZhOptYX0DvAAKYBkGgXVgcLKq8DuQGic77fm7611A8bi34Z+7a9wavuNVdYEh9x7j17pbnUu4FuVTSQsEgblvSveFRWS9Gjd8EoTR+wD8GGnCkpjBWfTGPBaWlrY3xYHVCvO9yLmaw4d6vJwYOkBd2V+v4M3jNbvej8uF7jPicNTJZo84vhKmmAA/dpRm7bBBmZO7HeDuTo9irMlXNqfuhdHPbejpLk73anXgYAaM1KZU+eNmhFy3bl+Am98ijFl919krSYlJ+WjT/H+/N6BwKTWHfhJAFBeL39VW65uW/53aIc20QKuYKhzbXJtIWMY8N3HYh0nm3eBXOe577T8zTPDUvygf7qpWi84pv13IMDxfLet1Ggb9CJMsqLzWB9qg4ifSLcOnJrul9C2sYs+NeZj6sTmtJ0ebnCBFqXlg6hn7g5LnaXUFEeh2fAPZyppZVqfuCUHAB3t+MWfldRbwZ4CUhXMaP4vPdIRBtRIS/5iZvHNNVRd9eiEzHW6TIltcuV6EMa9wfgDD/ArUwlEL78M8mdved5LSg1Dfi4hwbJYeQmBkkVYzYV+PbQ9npWoyY3YiRzc1Qd5EWiNOwzCNZofHg9v8EqH3AsQve9a4zQGqOszfsoG2w/WacqvW94mCLapsyYXCtd5Jp7Ln0RRPy60/yB0oP64GpE/hPnbBg= 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)(366004)(5660300002)(508600001)(6666004)(316002)(956004)(83380400001)(8676002)(66946007)(6486002)(6512007)(66476007)(66556008)(8936002)(2616005)(1076003)(26005)(52116002)(4326008)(186003)(86362001)(38100700002)(6506007)(38350700002)(2906002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7qjQAb3oMa0mwKflUKQQEbiRA1arCq/S+9NYYoHm8/u4yI57G2/TOB2DS7fswBNDNRSfXjEHtrgX/Sgf31/FsIcvxPc1CYHyDfog3ntsZtVr0cYgJqKGvP6HPcNCW3Onp6pBXlrGnlEu2Tqmr/6FNU/1T0WzQbz7qtae6poJJnPzWLQ8+XECertrw0wLfu5SL0eUoZjzCtnOq8y1nn3qPxb7nAZn3kxcffjddoVlJvJh7qwFd1b50lNMiKz/CBucGlfllZnljpmd4/ZuWoLLy0GJvEGOs1JcehTtIf+qHX7els1kss9oJSFKtc3xWe8/SMLH/8m0nVo9Ixu6xCzGTrublUZtAohzNaKkn1CwaCplO+oeb2Qy6Mix9+tC78d7PMijNbwi+6kZm16Q/bum7rczOFXaXLFu5CaPlF4gGDjhUNHr4aT9JnpzREQGXzGJsvet5bOCHcECFaa39wGgQYfz2d7/UIGEK/28s7GfxJGdL7Em7H9xweMaaLa53LkiwkN6kmhkLzXNQzNUYJo/ypWGbRl6M5AsDp0tTM3i/WXHAsFnoePCsMk/Io2GPwrCudZgT2L65W+xQ8TilBIJTzpL2tCOnM60W7gg5oiC5Ahm6uZGzZTd3G14Unv/6HqUabs3tUXFKQ25+pbMLizDo494RTyBoBte4NpGjsNR+/7sBPRAbM1rljw8xrBJ+qF2o62C04EavLckHaWjyA72G3sxk+tMnwGaCxYohlWt0RDL/U7pTjDiwcEFc0U+AfcKSXW6XuF0BKDL54cOjvU4XNqlUSFUBrAV3pco8n7CouNdZOjQ63m8mrAbgQRKXjYo+o0vjw9svlGZqVq0VLSqyUHCCvS8mBNdqmYp1vPra2bDDHhOrrxHTWPGh4nH/CyGXNa/qgkBRuKTInz4oZimBBg4NLIMgKD+tFaIpwj4AUyuSEQOon+/GUzedfk5hfy0iY4FnxEJzuxMOYp65zbp2Ehcma3MLjOawyAdwDe8twe+0KSB1g+9ve6LQhhVgCzQz7T01Mik3rCjc/LYlZ8IucptXdntPc4pRpwtB0JB/snmW16YC5ygyHfmfvCVGwbnBWuhMxrw71dBQGaCIMbMWiJm2Y210vrvU3NoFRzKbvw12COmXgUwSZaDef+agmcOEsEWWOZgsaI2tsq/gqFVEjKmLT2We0rLp/hyRvrB4updFMHTDD6ZtvEf7WyO3W1SnYiPqKA/OoDlrlGKwj9VsWl23fWaTRw6S0GalJFn1TlePYqjRGRWPjkuGtLMRzaksWY6NwRalvg1hGQTb5xFBpjnk5MSMpjCD5F58ZUBctjhEwLsUidHrU0EFbYAelgy X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b1efc2a-b202-4df6-09fb-08d94a84be40 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 07:13:43.9961 (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: a4qU9sQV78HnjTh4hfaQeMWb1qjY+fFmZoouQxq+DqKcB61GNV8N6f1+H+UwBqBpS76jX6iyt6V3l/rUcOXDhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0402MB2933 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.103.2 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: