From patchwork Thu Mar 28 02:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PeterYin X-Patchwork-Id: 13607922 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 9E924C54E67 for ; Thu, 28 Mar 2024 02:23:14 +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=9KIJcniTzyYF/MmSwa7Yex8bz5kHEPArcD39unNQsEI=; b=kRUtWr3QxdHndT Xk/REejjWYNAALq591tsO72/eR8TBtfV+8TugZuTflwowLy+VU0iWdBwHlIY1WHZHbivGcqC7y9cd edgoFWZN05RGaEagAXicYBr0rS2hgKpBsWa/84X4YuGTEhwtmvqOzjP4aJU4C5Li8edqVapsD8T5r SN1Qvyq2S/P0Auzsyi2N+Dtdbxl6cOb867O52147WNX98sSY8SCW2W9a6MJoquM4RrzQEYy4ZL842 Dd3Pr+jzk02JbxdnKbmyFPyUr/4Pf/1Bp0fxTX/6/R7jbWSdxLoNy39LojqfqoNJlCDCYHvC2jIdq LT2mGKAMgLUvLjnjVqNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpfPx-0000000C5E4-3dsc; Thu, 28 Mar 2024 02:23:01 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpfPr-0000000C5BR-0rly for linux-arm-kernel@lists.infradead.org; Thu, 28 Mar 2024 02:22:56 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e6ca2ac094so511400b3a.0 for ; Wed, 27 Mar 2024 19:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711592573; x=1712197373; 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=pTnAwOa2uvPcM/ekFIY9I6q6Jkplpwwz1KPt6Wpm9+I=; b=FNMW8agABORxlqbyqF4VWOXgndvqkPTPPXRs6Zhxcrr1PjVu7ug4H/+s9ZYsf54Wj7 twGaR1QkVrB4AXibYSBXD5+u9bXQDtlveByEyrhJXGDpUjnw66O/hCyRPIJa7hlWw0+O 1hWI7ONzy1ccvhEn4OtXDGTidb4orMKEaPJlYN10hJbY84R5yk8NhKlGyN+G5dmlhsPp 9xmWW7KSm/5uQJay2ug0tQIRT+81O0s2smZS6RuaLZgQarDZWP69NCE1z1UiqHE8zq5f +F5HoLKPUH6wn/a5FdhYiXuFB8m/xppn1JIkQZS7VDO7GUHHXo1knjINzEnvpX9Ik4v5 KusA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711592573; x=1712197373; 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=pTnAwOa2uvPcM/ekFIY9I6q6Jkplpwwz1KPt6Wpm9+I=; b=PYv3JhXaoF0QIJ6B3BtmKCqpelMFHOeGinXbZnDH8w6vyz15z2WP5/Cdb9WwHhf3qR Fnk1wUH5A0kr0CR96rxopp9q5dSGKuhUqMsR3RmkzTYUehgJn0YDL1BwNQHqCaMaEsPl 0R2XdWVq+GwK8K23+DXkXpyftazWCUdJtzHpEFsZT4h0FQcOsJFohO158+MsfUEah+io rBKK3CVO9patO/w2R6nJc6ZsXe78TPXm2AVoWxRxzddxFBUgtoRyhi3gaT70qncX5DP9 Eolr2U97k2nQwMsBSDK6eT391xRA0DfDqSYu44QIuVmWoFBPAghd/wC6+ZI5qu/QtOay gFEw== X-Forwarded-Encrypted: i=1; AJvYcCVfADTPU+a86DrGyCbOTgnfnDuYr+MHF56NcDK57DLvf3jsSjdeCpiITzsZ9UJs2GWoL4MeD+TUK/cnpY8VLiSs3vVuV9TP4thrhmHPkdRme9SFRl4= X-Gm-Message-State: AOJu0YwnA2JVcSqlCjZ37X6U9XY/Y2mBRiAAL81oN6f6oURxvavQnE3K rOMuVG9ZGOdSYxuFMr7dKUrF/zywZePmy2e6pm7f6ZZ3GRxV7c32 X-Google-Smtp-Source: AGHT+IHyluQj3/cCpsmHi5qOqzz/QMCSs1jG33c9hrW1m6MP1TsWwfE6CQM9fOkeDUivtVwLq6k/8A== X-Received: by 2002:a05:6a00:4b4a:b0:6ea:c634:ca0f with SMTP id kr10-20020a056a004b4a00b006eac634ca0fmr1790243pfb.21.1711592573087; Wed, 27 Mar 2024 19:22:53 -0700 (PDT) Received: from peter-bmc.dhcpserver.bu9bmc.local (2001-b400-e355-7eb0-17c6-c47d-d4ee-f9e8.emome-ip6.hinet.net. [2001:b400:e355:7eb0:17c6:c47d:d4ee:f9e8]) by smtp.gmail.com with ESMTPSA id d25-20020aa78699000000b006ea858ea901sm229256pfo.210.2024.03.27.19.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 19:22:52 -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 v6 4/4] drivers: watchdog: ast2500 and ast2600 support bootstatus Date: Thu, 28 Mar 2024 10:22:31 +0800 Message-Id: <20240328022231.3649741-5-peteryin.openbmc@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240328022231.3649741-1-peteryin.openbmc@gmail.com> References: <20240328022231.3649741-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_192255_294259_27F371C0 X-CRM114-Status: GOOD ( 19.61 ) 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 | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index b4773a6aaf8c..0e7ef860cbdc 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; @@ -77,11 +79,19 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table); #define WDT_TIMEOUT_STATUS 0x10 #define WDT_TIMEOUT_STATUS_IRQ BIT(2) #define WDT_TIMEOUT_STATUS_BOOT_SECONDARY BIT(1) +#define WDT_TIMEOUT_STATUS_EVENT BIT(0) #define WDT_CLEAR_TIMEOUT_STATUS 0x14 #define WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION BIT(0) #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 +340,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 +474,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);