From patchwork Thu Mar 28 01:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PeterYin X-Patchwork-Id: 13607886 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F08FC47DD9 for ; Thu, 28 Mar 2024 01:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KB/MQQw0kxfBT9nfESJ+wM7s1pQzJrIjxf2lghZIbSg=; b=E60vRynjBmFNAs T7xGCjqg3vLz0ACwFcjTUAkoHs6etpjp4Dh9QRGM5PI5Eetpqxml1vLpgJ6v3Av4b6lPlppv8NQq/ QYWdIUzPwzf9GsAT+Vrd+zQdtvwuI9c9WVQmmQieRratVysiV42rbYJcC/YCyc0j70TZPp+87mj90 d/J/KMYVyulYvEGG6k2qekd7ck2ejcDwOhWE9mcwlA0znxPwWvDgJjNjX/WPLGtrZ6z0QaFBQr55W /W3K9hHQA2qI4eHP+0X2DaeSTkxVeRZTWGbFHVqHE53fuzo5F7CuoeB3SwL5+QMuaB2r0QvmCh2he Ar9PBB8P/rREsXDsGC5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpee7-0000000Bx0Z-36ms; Thu, 28 Mar 2024 01:33:35 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpedw-0000000Bwul-2aBU for linux-arm-kernel@lists.infradead.org; Thu, 28 Mar 2024 01:33:26 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1def2a1aafaso3843665ad.3 for ; Wed, 27 Mar 2024 18:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711589604; x=1712194404; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=G0IynxA3JbozA3TAjnZstACddkpz8hoX6OU7xoU+2fw=; b=RHkzDm6zqGd6kYs44UgaarSLMORHpprPklQd1y4P1VZD2SsAM/Uu68huWp3D8EtQsq gpVJ7+TtMOGBL4nzEKXyHXYXPwxBbeQClAX2uZl3gNPxcnrx1VxInULTozNkD6H74QnC mJTOBa6FOSPRCvkF838ZH17B8F+IutPY8iC0KJq7kOt2YQoSAnuBaJTHZMlR2TB7iuLt ZyoL9O6/evN59ilHYlTwlTg3dZZZIhCEna5dkIqbMU1oTuSem7Shcf3uYHcxp7dTuSjR /ZBDOyd6/EPKHYFpA575Ku5qUJIEc6y5C0seoLgOEsdw2aL2bI5K01lCRqQGA/Dfwrwb BKog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711589604; x=1712194404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G0IynxA3JbozA3TAjnZstACddkpz8hoX6OU7xoU+2fw=; b=H3E0wyJZ3lPLzOyQDORMse8Vv6jUqFil/ads2F4LGaId0gM54VKO1qluNR7iuTcd6m m/UlaeX5wiL7VXFZTq9sAL0wsNpCNoxl5a79Uo+UFdh1G708/mQ/gJJFRc/w+Uwvrk29 sLsZjLFFMnDiHeODfFFGWgH9v02DprBemEpRxpOs/6qOLmT3Z5jOMJCMosGouVt4DT4H o4XlGtMb1//+gnHLvfYcnEzrJU5pdXA2caw1gyG90QJ4zQdoVeDBnyY5jPTgm0UvrSpU 2ynM3IjTlmmxytTCTfD8GoUmwV0td+cDT2yPaOb6U5Ut8ZQoPO2iw3Y9yXB32lP8tbQy lNRg== X-Forwarded-Encrypted: i=1; AJvYcCXm1wbtto4obhjhD9GU9QvKbZ8A/D2AyqwEqV8/ld3370MLTvWSYM52ZM0lTcgEj/k1VrFk0ihj2weI0I3NSoI+0FiaPSPJdh/T57jlEHuRgFN/JZ4= X-Gm-Message-State: AOJu0YxlZcq1GDcHC2UruWAWex6RjXlpqtsQ6/5YZB+Ka98HitlUigJy drIpuZZIRTiCmYB0vKgi7YD61G+y1BA6L6okFRq+VVeOaTzMUYpI X-Google-Smtp-Source: AGHT+IErqe1JgPY/tC+iEEwyWTtpp/xy7QUKcZTy0vIiStxw4d/K5SUR+QGLZAGX83Ujl4LUNDIuFw== X-Received: by 2002:a17:903:8cc:b0:1e0:a2cf:62f2 with SMTP id lk12-20020a17090308cc00b001e0a2cf62f2mr1579482plb.23.1711589604023; Wed, 27 Mar 2024 18:33:24 -0700 (PDT) Received: from peter-bmc.dhcpserver.bu9bmc.local (2001-b400-e355-7eb0-b4d0-66d2-2269-ef6c.emome-ip6.hinet.net. [2001:b400:e355:7eb0:b4d0:66d2:2269:ef6c]) by smtp.gmail.com with ESMTPSA id g5-20020a170902c38500b001e0e85a21f5sm201338plg.32.2024.03.27.18.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 18:33:23 -0700 (PDT) From: Peter Yin To: patrick@stwcx.xyz, Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/4] drivers: watchdog: ast2500 and ast2600 support bootstatus Date: Thu, 28 Mar 2024 09:33:02 +0800 Message-Id: <20240328013303.3609385-5-peteryin.openbmc@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240328013303.3609385-1-peteryin.openbmc@gmail.com> References: <20240328013303.3609385-1-peteryin.openbmc@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_183324_693682_A3CD3D50 X-CRM114-Status: GOOD ( 19.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add WDIOF_EXTERN1 and WDIOF_CARDRESET bootstatus in ast2600 Regarding the AST2600 specification, the WDTn Timeout Status Register (WDT10) has bit 1 reserved. Bit 1 of the status register indicates on ast2500 if the boot was from the second boot source. It does not indicate that the most recent reset was triggered by the watchdog. The code should just be changed to set WDIOF_CARDRESET if bit 0 of the status register is set. Include SCU register to veriy WDIOF_EXTERN1 in ast2600 SCU74 or ast2500 SCU3C when bit1 is set. Signed-off-by: Peter Yin --- drivers/watchdog/aspeed_wdt.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index b4773a6aaf8c..c3c8098c035d 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -11,10 +11,12 @@ #include #include #include +#include #include #include #include #include +#include #include static bool nowayout = WATCHDOG_NOWAYOUT; @@ -82,6 +84,13 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table); #define WDT_RESET_MASK1 0x1c #define WDT_RESET_MASK2 0x20 +/* + * Ast2600 SCU74 bit1 is External reset flag + * Ast2500 SCU3C bit1 is External reset flag + */ +#define AST2500_SYSTEM_RESET_EVENT 0x3C +#define AST2600_SYSTEM_RESET_EVENT 0x74 +#define EXTERN_RESET_FLAG BIT(1) /* * WDT_RESET_WIDTH controls the characteristics of the external pulse (if * enabled), specifically: @@ -330,6 +339,11 @@ static int aspeed_wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); + struct regmap *scu_base = syscon_regmap_lookup_by_phandle(dev->of_node, + "aspeed,scu"); + if (IS_ERR(scu_base)) + return PTR_ERR(scu_base); + wdt->wdd.info = &aspeed_wdt_info; if (wdt->cfg->irq_mask) { @@ -459,14 +473,26 @@ static int aspeed_wdt_probe(struct platform_device *pdev) } status = readl(wdt->base + WDT_TIMEOUT_STATUS); - if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY) { + if (status & WDT_TIMEOUT_STATUS_EVENT) wdt->wdd.bootstatus = WDIOF_CARDRESET; - if (of_device_is_compatible(np, "aspeed,ast2400-wdt") || - of_device_is_compatible(np, "aspeed,ast2500-wdt")) - wdt->wdd.groups = bswitch_groups; + if (of_device_is_compatible(np, "aspeed,ast2600-wdt")) { + ret = regmap_read(scu_base, + AST2600_SYSTEM_RESET_EVENT, + &status); + } else { + ret = regmap_read(scu_base, + AST2500_SYSTEM_RESET_EVENT, + &status); + wdt->wdd.groups = bswitch_groups; } + /* + * Reset cause by Extern Reset + */ + if (status & EXTERN_RESET_FLAG && !ret) + wdt->wdd.bootstatus |= WDIOF_EXTERN1; + dev_set_drvdata(dev, wdt); return devm_watchdog_register_device(dev, &wdt->wdd);