From patchwork Wed Jul 21 14:16:46 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: 483286 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp6209024jao; Wed, 21 Jul 2021 06:44:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz35dQPp/wlmYNmwKOXCJndPDLbnaljhID+IIz5Q3hdMYP7v0DIjDAKZ30G9Dk8gHnT8AbI X-Received: by 2002:a17:906:a391:: with SMTP id k17mr39087080ejz.516.1626875044915; Wed, 21 Jul 2021 06:44:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626875044; cv=pass; d=google.com; s=arc-20160816; b=vLR7PwvvIe1eH0kw9gC0x80hMcdEk7Tw2Pdi2/tnQKXG35rO+XUSmk6faNoEmt7qyN jDsg9zW7RwmktmD2D1a8xk1mVxrGsaercPZbjBJ0dBCdX+aECkCCi9Id7+vongekqJBs GKkMKsX/XjPXJEqggLS8twmtmv3VgBmpm4iarUXG5ttK/6ypgZY9l3abQwZTMUBieRgh YV1+oYnOrvMYMQZmyTt20h4XxmCbMGBPaMS/vmE7SNKWsxTWA1ifZPEpGlsX09rhQTpn j23Lm18GKYwX8MBuK+X0gHFL0sVRYy/UklFJLRTSmXtRJLwnxDzu/VtHt6THhVSB69f8 j7nA== 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=OVLNxGITJxxjla9+sbll+iSOf3XaXO0uN9xyWhn6E5yQc+f6AawiKvM9jogr25SmYt aqefB5stGHmQlIYPl5YGqJlqFe1Qj06pvN7lnF8LaHOl6Qoa9E4jtF/TMtYeucx1cLbS 4kIYXcbyuAA0PsTI/rZC17iybdU6hmtJvoHkfD15L7gSyC/bxK9xFCwXpDWYf9QTkW0y d2DHOSzoz/9FJLag0mCmBpDXCGaxeJX5reoAE0GO8Y8OmIWkw+Y5EHy5O76+cwWgIXs5 8dcIS1M+jAX96Ctl8yYwyZ2hvCaWbQmQD1O45ObpgKtNaMqF/fVzaZ4RBX5CCjvml629 0K/g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b="YgEQE/+g"; 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 hx26si28134247ejc.494.2021.07.21.06.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 06:44:04 -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="YgEQE/+g"; 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 56F5E82C4D; Wed, 21 Jul 2021 15:43:56 +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="YgEQE/+g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5FCE482C08; Wed, 21 Jul 2021 15:43:36 +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.9 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 EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0614.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::614]) (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 4DE5682BEE for ; Wed, 21 Jul 2021 15:43:30 +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=ma/Yw+9QPVb+HptWlnjXf46HyL361//4F8coXs4tx2O+so3HVYKjRZLsDmqP5ey2EGjCJgD97VF4bAnlQq7vW2d328shLuqvb58ZGczO9IRbzEgJoZ2+LlAJ0tFmMraMG2KLd/gBegDp7y3c8hCQjbLjRGLqyE4fzco0BprldE9VksJ8C6cJOuV2ano51KSp5faGqj1P8vMELB4IpSoUfqtW+rzNwOi5H64obpwkh6S2wArIi9pWkAjkuQoLGaiJr+AAVXBnDlwSuDS7BDrpNwhshEyDAkQoKUgnTxVr13H/Rjb0CbN6+lIXkAQgGcSdLV/sl7k66teZx0OrK8iPAQ== 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=QLmd3K4ro2Uw3VY1GLraW/HKAD284RyyVrSAVDIbgdhnHSLTVJJJc5IytXyvFpgG4LFST43/+BVv0CqxWzyZZbDOGCbZPRtRuh3tEsRuqqCbbkQgm7uH8DQWu+nwGfFHp+4enia4wxw9xXFu8sThd+7QOD+vLD7qKPEfodVYH7itLW8dVQ0A2Lw8BkJWH3pAjqxYM63ulBx74P+2Csic6q91TUOob35WSQKIh2u2k3033VIyFnAsvqZ+CrLr4drs91IRqHF641xqSeVznFUwlZRqfeT0isZ8Wz1a2ugYA7dIB3JM2rt4z/2tW5QIcO7fup2alENzfCJcGm34z+N4/w== 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=YgEQE/+gCNBVyertN+H/9fduVVELWmpHYywqJk23Y0LJx0ERLKCKLaBVghbANUzDJHToOjTqAFEPhN4bfyCaCSp3E24XPKYN6YxbuubbK9+33Oun4Jwsdz/ihnOI+5rL5bVHySJxpFwwn0FIpvKcX7dj4mZ8NtyvRE+J81NtxKM= 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 DB8PR04MB5802.eurprd04.prod.outlook.com (2603:10a6:10:a4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Wed, 21 Jul 2021 13:43:28 +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.034; Wed, 21 Jul 2021 13:43:28 +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 V4 05/44] imx: imx8ulp: add get reset cause Date: Wed, 21 Jul 2021 22:16:46 +0800 Message-Id: <20210721141725.23346-6-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210721141725.23346-1-peng.fan@oss.nxp.com> References: <20210721141725.23346-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR0401CA0015.apcprd04.prod.outlook.com (2603:1096:3:1::25) 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 SG2PR0401CA0015.apcprd04.prod.outlook.com (2603:1096:3:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Wed, 21 Jul 2021 13:43:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1e28050-0e3a-4f93-4bf9-08d94c4d8563 X-MS-TrafficTypeDiagnostic: DB8PR04MB5802: 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: f4EwMr2aKwGHIfmrcM6/ZMvMlsC2bB1MRCFuVLFHLNPj+a9Onn6KqvsWBKdkzlWDo4PVacGe05G4gH5Q+Otx6XwvzkUt6io8rmu7ng5mKxk6TBRwoIQlPuXKLH0AkrHRugG7mhMYh4323Vaq7w1J2xFtWjB9mELR+nKuuNxDs1yAElHIWx3Yrcm+951gTiXe9yGPlH5vo7IA23AqsGNeoorwFE39BPXnq7Ktaz+I7CznQWFHqEYXx19q1hM6nbsNslMgVBvwnR8FiCHXRp1812F51Mg9dIy17D36CWdniMxHGEMh5IOyhQ+N7GYft9zqR0a7dvKbc8aj6Qy1INAu7JiU6oA1DRx665WEeEkXP5+85UMhdxAjLYLvk1Pgi2iQxblG2yVnw+Jot2BWTRKdAnVCHsFmtwqzN5aEtdGNTUNy8ap2gp8VROgf1NnQ5rW9+TgC29/Boq++5Ibd3afMF2TzIgIGK0LNjXQ6Mb92m5dMHgBcfUfJPISmYjFGEcx7ZhrId4NIjx982z9PIIEIIDs7XAZq7lXYMk57phsHI98tmciKl2EXQ/C5wN0+4fk+hT1wMlA4qXnmahJzVbha/iDC+9jD87O/l+puV5P6KbszN67yP8+x5RpQv1hAjZeaLLFTThHFqiyH4KtVuC17TDEPEX5ebLr8RdllvI8ZNldPrmyfcdJw5zD2kf8YE6tkFemk4lgnA3Wxr3E9X1OhGnslPf/LYenBRSLUCqnVJY8= 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)(376002)(39860400002)(396003)(346002)(136003)(6666004)(8936002)(6512007)(4326008)(5660300002)(8676002)(2906002)(1076003)(38350700002)(38100700002)(956004)(66556008)(66476007)(66946007)(316002)(86362001)(6486002)(26005)(83380400001)(52116002)(2616005)(186003)(6506007)(478600001)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ps76EqsmHdOSslTLoiE1+Hm9I4RbCfEbFIJUEP/p3d5/mkMmwTWTwadGCXL1EfLorQLaM6iHZFvy1s5YqsMaSh0ieflmF04IbHnXkweK6pvXJEA9X8DnbcIVrQPDKtlmQ0KxGrY/3Nr7RXtOL040FrcURHtAd4+rGYk60rqzIcIGMyTJxXhybY9+lnwu2SeyDeW1fOjfrhlcvuP9RRMfgRDbsB6fWTQ0X5/pRYc5de9VYX+VOX5W+xP9Cry9i2Y2vGXDtRsU66IE/rMe+tdIMOJkAKdWkc7o8CFf5OsqfqWHlgd9EB2LgaO+de7c6vYtU11A/VfNtRFOV/9OLUPybHTv084L26YqgFKXjgpoYEeZL4LWlp4iMd5xRlKJ3RhnOuiSgs3xmit3kh35/ptxMuJcQ/vtOx1WFjkerMg7grsxM7yEPcFUIilmw/zwJ+HSLSV2NCjxEIhXXdxqxeSaduObyASunHQpbQU8u0/Ye8qzF+WMxQFWP5SoWdXmx9+LNxNyXMLRWegXfXHuRzWSScCy4ARHfuHDibyXBI8ZwnjYw8nMLA8Ht9FsNj99gh8blag7lp9fY4d8Yuzzanv8s6Tc7K0FaFTkXuQ2rkxIK6zT6DgmyQKMJG9a/SqgsybklW+e7IsccdNZzfCN/qwJJ0yCD2m/1Nt7lHXazwLAE9kwGNpbiNzUTheXM48eQLT8rFKCSwbSlUgvvfAH55p/cEEoasGdxShtRZtaxyTazpjDnOmen0jfPXHzZm5uTq/r+SKT29oCubOxBhvfRuZtUzjkMrYIzfGzpZIOAN/fBkSVKY+NhEUID4jsCZfptvTeR620ZU0tYVASu087wRVLHXZtQ6KL9OPTP5zqGENXtRHtDV80VGfrnTn0H5a8PSzEWPG5ZKm26xy4MpPBjCq7pvOMbejCAmC8raHrx8fMH11T25umsZpNUs9eUffk14VznXl17dsgJQXknHhtM7mTeIyO7ej3/MnQmpgbxIY+ZHXHCj9XpI4fbHO6F4/pYQdXcSCUsoL/0EnpRMUzvjAozjm8NTM5sIEcfrMPG7p9JS8EiiLNhvggVnyErTSQncaoekXKKcUXqQI3z/ncwYKeL2jbYm23ICTDE/DkzugtRMC64nGQxVHdR13BXpBM0EvX89EWIRgCkY+e6VS3JDfWayi5Ae+D4DWnjzEGhZsdyggo6hoGrN6+m4BB0SFSUeeak/6tYCioqbHbkVOVB41ibfkvwgM9JmJ1bkY3UIL69QitgFejrJ+ICXqGZ7TrYCvfvTrF9ua4iMi/qjM40+bkhTeSCpVl3p5MoSbboa8ogy8xq0gxHoy1OF7XaWN8GRRk X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1e28050-0e3a-4f93-4bf9-08d94c4d8563 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 13:43:28.5964 (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: ImsQn9yltGAUf6z0UzrgwSKpV9GGM51CWRI0mePS4s/yeGhr2OvS+cplbS2Oj/8Ce9VFZ/0AoSK9MnSMBA1q6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5802 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: