From patchwork Mon Dec 11 16:23:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 13487568 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 A9693C4167B for ; Mon, 11 Dec 2023 16:25:39 +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:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NbOeom6g6Py+9yHDyIvhvPPIyWkB1spj9s5i0HXk8dQ=; b=u+UsTdPpyoYZql /cZlXQpWCQHXIU1A2ENudih2CwLjuT+JQKEMRTFYZoFZb+gwAXn/eFih2iCF6vCbFqrsPTa8PBw1P 302Z0eLDTRkzhlM6G24+P5yFaAA4uTo5ybTPs83N6CrHD40ChCrg6IGrpBdF+nddXeqvJ0les0UDX N+RMZ0VOaLnGra3ArsfeiLkO+ytG9+AG05yK3rR1O8PCx378Ho0kq3WYm5reTs1jTTSsrrZSCW3fZ bBg8RkAJf7gZFj1xFYQy/e0oh9rVAL++P4s2g40S//PpGqgkDpPOG8rLh5c3rjupfr518K4IHsnLJ Ru3z4g7rLBA4NWSgL+Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCj5g-005mm9-2i; Mon, 11 Dec 2023 16:25:08 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rCj56-005mPw-10 for linux-arm-kernel@lists.infradead.org; Mon, 11 Dec 2023 16:24:43 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3332f1512e8so4429515f8f.2 for ; Mon, 11 Dec 2023 08:24:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702311868; x=1702916668; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OY3NZW1VVkhHi97yDb7wuKAvdZxLolGu7v09v2ECEzA=; b=l9ffd6dO6eA/iQD3Z8F0VgHNOg9KeXZ2/Cgitsiw0Wa3wa7yQUDN52tgW0P7cwvJIz VTjXqE6YaDVLx626fsonrrbGk5qM59OrecYP1oNqjbOtygsMneeNGrfIObAu4wvVwoIC LQFLpiHI1u8/ZJeJq7uJUXSdtel0oJJ/JUBC3Y44B+KP9n8nGFNVZT18EhS/yXS9P4fp VJyk9I9XNJz8qlOcgZcFwTjSZDPbG6VERTQ2galAMDSUZbHZ7RhMKpMK60tg1xUurOcD Qnoaj16GOu2TtgPNwO1eINPGymhuhK/Rjx6ZBj/tTmyP8GrKZDJ7zqMYPumEttY20zZ1 Ro9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702311868; x=1702916668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OY3NZW1VVkhHi97yDb7wuKAvdZxLolGu7v09v2ECEzA=; b=rmSncilEi5pDp1SYlYqxFHrQ7xPumUOMJVegAbWtlvWAcbkSUUDDL6sFYhXz09+cJz oejOeOkCHOx+xFCes3BqvxogFl0c6YOxkYhqYOSysJb97JlX3hSxPtE2aA1RqaAIV3ro i4sJ6LYrvuyyrAGkT9NimcNBmNc7AyPOU3+JgZUXWFkV66QCC6qejOkc8rDLzWgaymo0 YUctsp5oZVcM7Gaex7V5nnd8+JfEjm6dAqF3qnNARLqDsGrPyjUmSrWPdZztbg2obOg+ y7oyrJCLaiLFM/geO3k4eQkUc2arDz42VQwD1szrccwUbZH3PRgaAa4OcaN5xeeEnMfM 08qA== X-Gm-Message-State: AOJu0Yyk0q/cnZ+OIE+8n6EtQ/whrkRHl9LmpFy5WBuZtbE1ppvB6EoO 0EjjNvSoP8Xqte0fEWxeXhUpaQ== X-Google-Smtp-Source: AGHT+IGh34RehzA4y7NRakQmyNCO0bWLmbphPvVU+MIJpWn33vd04o6AuYfkSllgaMbS9psWhNoYfQ== X-Received: by 2002:adf:ee0f:0:b0:336:1a2d:2f35 with SMTP id y15-20020adfee0f000000b003361a2d2f35mr1584505wrn.130.1702311868567; Mon, 11 Dec 2023 08:24:28 -0800 (PST) Received: from gpeter-l.lan (host-92-29-28-58.as13285.net. [92.29.28.58]) by smtp.gmail.com with ESMTPSA id o4-20020a5d58c4000000b0033333bee379sm8923103wrf.107.2023.12.11.08.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 08:24:28 -0800 (PST) From: Peter Griffin To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, mturquette@baylibre.com, conor+dt@kernel.org, sboyd@kernel.org, tomasz.figa@gmail.com, s.nawrocki@samsung.com, linus.walleij@linaro.org, wim@linux-watchdog.org, linux@roeck-us.net, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, olof@lixom.net, gregkh@linuxfoundation.org, jirislaby@kernel.org, cw00.choi@samsung.com, alim.akhtar@samsung.com Cc: peter.griffin@linaro.org, tudor.ambarus@linaro.org, andre.draszik@linaro.org, semen.protsenko@linaro.org, saravanak@google.com, willmcvicker@google.com, soc@kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-watchdog@vger.kernel.org, kernel-team@android.com, linux-serial@vger.kernel.org Subject: [PATCH v7 10/16] watchdog: s3c2410_wdt: Add support for WTCON register DBGACK_MASK bit Date: Mon, 11 Dec 2023 16:23:25 +0000 Message-ID: <20231211162331.435900-11-peter.griffin@linaro.org> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231211162331.435900-1-peter.griffin@linaro.org> References: <20231211162331.435900-1-peter.griffin@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_082433_449632_2E067BF7 X-CRM114-Status: GOOD ( 17.34 ) 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 The WDT uses the CPU core signal DBGACK to determine whether the SoC is running in debug mode or not. If the DBGACK signal is asserted and DBGACK_MASK bit is enabled, then WDT output and interrupt is masked (disabled). Presence of the DBGACK_MASK bit is determined by adding a new QUIRK_HAS_DBGACK_BIT quirk. Also update to use BIT macro to avoid checkpatch --strict warnings. Tested-by: Will McVicker Reviewed-by: Sam Protsenko Signed-off-by: Peter Griffin --- drivers/watchdog/s3c2410_wdt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 0b4bd883ff28..7ecb762a371d 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -9,6 +9,7 @@ * (c) Copyright 1996 Alan Cox */ +#include #include #include #include @@ -34,9 +35,10 @@ #define S3C2410_WTCNT_MAXCNT 0xffff -#define S3C2410_WTCON_RSTEN (1 << 0) -#define S3C2410_WTCON_INTEN (1 << 2) -#define S3C2410_WTCON_ENABLE (1 << 5) +#define S3C2410_WTCON_RSTEN BIT(0) +#define S3C2410_WTCON_INTEN BIT(2) +#define S3C2410_WTCON_ENABLE BIT(5) +#define S3C2410_WTCON_DBGACK_MASK BIT(16) #define S3C2410_WTCON_DIV16 (0 << 3) #define S3C2410_WTCON_DIV32 (1 << 3) @@ -100,12 +102,17 @@ * %QUIRK_HAS_PMU_CNT_EN: PMU block has some register (e.g. CLUSTERx_NONCPU_OUT) * with "watchdog counter enable" bit. That bit should be set to make watchdog * counter running. + * + * %QUIRK_HAS_DBGACK_BIT: WTCON register has DBGACK_MASK bit. Setting the + * DBGACK_MASK bit disables the watchdog outputs when the SoC is in debug mode. + * Debug mode is determined by the DBGACK CPU signal. */ #define QUIRK_HAS_WTCLRINT_REG (1 << 0) #define QUIRK_HAS_PMU_MASK_RESET (1 << 1) #define QUIRK_HAS_PMU_RST_STAT (1 << 2) #define QUIRK_HAS_PMU_AUTO_DISABLE (1 << 3) #define QUIRK_HAS_PMU_CNT_EN (1 << 4) +#define QUIRK_HAS_DBGACK_BIT BIT(5) /* These quirks require that we have a PMU register map */ #define QUIRKS_HAVE_PMUREG \ @@ -375,6 +382,19 @@ static int s3c2410wdt_enable(struct s3c2410_wdt *wdt, bool en) return 0; } +/* Disable watchdog outputs if CPU is in debug mode */ +static void s3c2410wdt_mask_dbgack(struct s3c2410_wdt *wdt) +{ + unsigned long wtcon; + + if (!(wdt->drv_data->quirks & QUIRK_HAS_DBGACK_BIT)) + return; + + wtcon = readl(wdt->reg_base + S3C2410_WTCON); + wtcon |= S3C2410_WTCON_DBGACK_MASK; + writel(wtcon, wdt->reg_base + S3C2410_WTCON); +} + static int s3c2410wdt_keepalive(struct watchdog_device *wdd) { struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd); @@ -700,6 +720,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev) wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt); wdt->wdt_device.parent = dev; + s3c2410wdt_mask_dbgack(wdt); + /* * If "tmr_atboot" param is non-zero, start the watchdog right now. Also * set WDOG_HW_RUNNING bit, so that watchdog core can kick the watchdog.