From patchwork Thu Oct 5 15:56:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 13410240 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 CB959E92717 for ; Thu, 5 Oct 2023 15:58:45 +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=yYIcZgo4/48vMu9LsiOmuC/HLBljYyH9NLYaAN+TlNo=; b=rGq39wvd1xVnh8 UXqeWDtEENF6IciyBQCv/Q4vJ+yrTQJv8xm2hUOz+UP9hyT15mULcQWJiycsA10IRZTv+5I6g3E9z eUaQRfE15wFph9SQ3MbX25tHuiHGw2W1MJvv27zgTH/phMDjbZ4hPIlXsR6DeTtitcforv6mIroFg jyglhr9PRjXBZzoMP/MjOs/0+7jsNBPBGk9IKw6vU1z6bPZT22gzwk7xZjnsKDB74/0ZqLFfx5rFX vpWWMzzwaUrYniRal1dqdwcr7XKaoZ0/dkMFA03mqEoqnYZGtm7Mu8I5s+jLR3ethwJ39nzE9d7X5 CirZ0ydST9cfTQp2sKdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoQjw-003xpE-0O; Thu, 05 Oct 2023 15:58:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoQje-003xYq-1d for linux-arm-kernel@bombadil.infradead.org; Thu, 05 Oct 2023 15:57:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5xoonrjKWOZLwj8NrDcYCfH9KPmFeNjOTSTqB3hRNEM=; b=jOp+hAOrKBLpIar/jWf5tled0o TFCm7QimIXVv6dWR5o+OCIv1tksAR4E1OMh73J80rJCzwLLqG2JvZieunx8VHJ426rPZuD3XNGtgi LSYaVSzojUrRq3nFnFuuLGhNT8VxyuKviGXHDu32FtLQAabYUXCVEhFEsfkePcqNnKkw3Z4Rebqho fkXydy+i0YZ+F9qqrkY2NmT1ZShf1P4IOa4ZrcAsugSNCZESpLNOloD3VEKoeIGKs7ThpP5bmlrkU /vVVfq+wq5Fe6LXjFZ3XooIG/pJiRauZGltnSq3LzqEZYpePUG2j0DZaxWc1Qh0GDbMd2PrgaI+2k hXjtAoyw==; Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoQjZ-00BoI0-0Z for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 15:57:57 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-313e742a787so737984f8f.1 for ; Thu, 05 Oct 2023 08:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696521465; x=1697126265; 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=5xoonrjKWOZLwj8NrDcYCfH9KPmFeNjOTSTqB3hRNEM=; b=t+l4Fh0QvK4qOIBBZXYuSYU9cBmQY43PuJzl2poytFgx2v+b2PljDyOF4Bk9CNhpiR PvPqVguM/MKwlxoyAOlqzDpGnUqpCVneZmqPYXnMIF7Iq+LEBTonsrU8vsVu40nDhgw6 xYAbxpcduitkN8wd927fdpkpYgbeHmM9ACNvID7sSHMrlLLDM5TJWjhBy/e6hpAcHJ5b dLVJwmxj7N34eGIKyQVr4GyYD/D+1Qhb0kCUtT14E2ZvuSUV4Dj+l75KYzdQ9d2X2QMa HsrJgmZKx7MaYk9DxCsRkV8khEaICMibITksDBmhlZkWQPPL8Yujs/0A+VOv4bpGhc0g uXzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696521465; x=1697126265; 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=5xoonrjKWOZLwj8NrDcYCfH9KPmFeNjOTSTqB3hRNEM=; b=BM5VCszas6nGOhZPldGVEGK4Rp0c2w0X9QJPkBYF2cTB2tcu9g75XVJhQ7JGNbx201 a8Bi9QwntA7G0JeVqevUk4uc1ZO4AIaWeYEvyqw7YHpRWOLz+LiI6GidFM0BCAScUtk7 zVjml1UCzTP0mZd76EhNd9xF1rLY2sWCxrNmXhlNBJQhfOMFrtZef8PiW8AMsxjZ6AoO sSBIz9hFeJTrBMLc9lhkpjJCnqQ4qZj7M1P2qRRwALbN96qq0USf1Q8JSVKB+5KFHad4 fx2CI63CQWZDSVWvMPoBW9bisCu1Klj7hXbLoGt//qL9Ak28yTBxHGNrcBKs/6P20o3t 2pnQ== X-Gm-Message-State: AOJu0YwB2Ycd2gxE9CtE/2PbPK4usBAQUadtW3EVTXzoyYxua6l/0ckh bDaMc6a8hxzW+CZY17q4l9HZjw== X-Google-Smtp-Source: AGHT+IFsus89r1qsT+k05fF95QZF4pS6P/E6nTXHMzWyKE9+rdSlxCeuQHgoC4gC72Dl+9o8iTBpKw== X-Received: by 2002:adf:fece:0:b0:329:2306:91a7 with SMTP id q14-20020adffece000000b00329230691a7mr1798772wrs.2.1696521465209; Thu, 05 Oct 2023 08:57:45 -0700 (PDT) Received: from gpeter-l.lan (host-92-12-225-146.as13285.net. [92.12.225.146]) by smtp.gmail.com with ESMTPSA id t9-20020a5d4609000000b0031f8a59dbeasm2084336wrq.62.2023.10.05.08.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:57:44 -0700 (PDT) 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, cw00.choi@samsung.com Cc: peter.griffin@linaro.org, tudor.ambarus@linaro.org, andre.draszik@linaro.org, semen.protsenko@linaro.org, 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 Subject: [PATCH 17/21] watchdog: s3c2410_wdt: Add support for Google tensor SoCs Date: Thu, 5 Oct 2023 16:56:14 +0100 Message-ID: <20231005155618.700312-18-peter.griffin@linaro.org> X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog In-Reply-To: <20231005155618.700312-1-peter.griffin@linaro.org> References: <20231005155618.700312-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-20231005_165754_862835_310A8A01 X-CRM114-Status: GOOD ( 21.05 ) 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 This patch adds the compatibles and drvdata for the Google gs101 & gs201 SoCs found in Pixel 6 and Pixel 7 phones. Similar to Exynos850 it has two watchdog instances, one for each cluster and has some control bits in PMU registers. The watchdog IP found in gs101 SoCs also supports a few additional bits/features in the WTCON register which we add support for and an additional register detailed below. dbgack-mask - Enables masking WDT interrupt and reset request according to asserted DBGACK input windowed-mode - Enabled Windowed watchdog mode Windowed watchdog mode also has an additional register WTMINCNT. If windowed watchdog is enabled and you reload WTCNT when the value is greater than WTMINCNT, it prompts interrupt or reset request as if the watchdog time has expired. Signed-off-by: Peter Griffin --- drivers/watchdog/s3c2410_wdt.c | 116 +++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 11 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 0b4bd883ff28..4c23c7e6a3f1 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -31,12 +31,14 @@ #define S3C2410_WTDAT 0x04 #define S3C2410_WTCNT 0x08 #define S3C2410_WTCLRINT 0x0c - +#define S3C2410_WTMINCNT 0x10 #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 (1 << 0) +#define S3C2410_WTCON_INTEN (1 << 2) +#define S3C2410_WTCON_ENABLE (1 << 5) +#define S3C2410_WTCON_DBGACK_MASK (1 << 16) +#define S3C2410_WTCON_WINDOWED_WD (1 << 20) #define S3C2410_WTCON_DIV16 (0 << 3) #define S3C2410_WTCON_DIV32 (1 << 3) @@ -61,12 +63,16 @@ #define EXYNOS850_CLUSTER1_NONCPU_INT_EN 0x1644 #define EXYNOSAUTOV9_CLUSTER1_NONCPU_OUT 0x1520 #define EXYNOSAUTOV9_CLUSTER1_NONCPU_INT_EN 0x1544 - #define EXYNOS850_CLUSTER0_WDTRESET_BIT 24 #define EXYNOS850_CLUSTER1_WDTRESET_BIT 23 #define EXYNOSAUTOV9_CLUSTER0_WDTRESET_BIT 25 #define EXYNOSAUTOV9_CLUSTER1_WDTRESET_BIT 24 - +#define GS_CLUSTER0_NONCPU_OUT 0x1220 +#define GS_CLUSTER1_NONCPU_OUT 0x1420 +#define GS_CLUSTER0_NONCPU_INT_EN 0x1244 +#define GS_CLUSTER1_NONCPU_INT_EN 0x1444 +#define GS_CLUSTER2_NONCPU_INT_EN 0x1644 +#define GS_RST_STAT_REG_OFFSET 0x3B44 /** * DOC: Quirk flags for different Samsung watchdog IP-cores * @@ -106,6 +112,8 @@ #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 (1 << 5) +#define QUIRK_HAS_WTMINCNT_REG (1 << 6) /* These quirks require that we have a PMU register map */ #define QUIRKS_HAVE_PMUREG \ @@ -263,6 +271,54 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl1 = { QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN, }; +static const struct s3c2410_wdt_variant drv_data_gs101_cl0 = { + .mask_reset_reg = GS_CLUSTER0_NONCPU_INT_EN, + .mask_bit = 2, + .mask_reset_inv = true, + .rst_stat_reg = GS_RST_STAT_REG_OFFSET, + .rst_stat_bit = 0, + .cnt_en_reg = GS_CLUSTER0_NONCPU_OUT, + .cnt_en_bit = 8, + .quirks = QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_MASK_RESET | QUIRK_HAS_PMU_CNT_EN | + QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_WTMINCNT_REG, +}; + +static const struct s3c2410_wdt_variant drv_data_gs101_cl1 = { + .mask_reset_reg = GS_CLUSTER1_NONCPU_INT_EN, + .mask_bit = 2, + .mask_reset_inv = true, + .rst_stat_reg = GS_RST_STAT_REG_OFFSET, + .rst_stat_bit = 1, + .cnt_en_reg = GS_CLUSTER1_NONCPU_OUT, + .cnt_en_bit = 7, + .quirks = QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_MASK_RESET | QUIRK_HAS_PMU_CNT_EN | + QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_WTMINCNT_REG, +}; + +static const struct s3c2410_wdt_variant drv_data_gs201_cl0 = { + .mask_reset_reg = GS_CLUSTER0_NONCPU_INT_EN, + .mask_bit = 2, + .mask_reset_inv = true, + .rst_stat_reg = GS_RST_STAT_REG_OFFSET, + .rst_stat_bit = 0, + .cnt_en_reg = GS_CLUSTER0_NONCPU_OUT, + .cnt_en_bit = 8, + .quirks = QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_MASK_RESET | QUIRK_HAS_PMU_CNT_EN | + QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_WTMINCNT_REG, +}; + +static const struct s3c2410_wdt_variant drv_data_gs201_cl1 = { + .mask_reset_reg = GS_CLUSTER1_NONCPU_INT_EN, + .mask_bit = 2, + .mask_reset_inv = true, + .rst_stat_reg = GS_RST_STAT_REG_OFFSET, + .rst_stat_bit = 1, + .cnt_en_reg = GS_CLUSTER1_NONCPU_OUT, + .cnt_en_bit = 7, + .quirks = QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_MASK_RESET | QUIRK_HAS_PMU_CNT_EN | + QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_WTMINCNT_REG, +}; + static const struct of_device_id s3c2410_wdt_match[] = { { .compatible = "samsung,s3c2410-wdt", .data = &drv_data_s3c2410 }, @@ -278,6 +334,10 @@ static const struct of_device_id s3c2410_wdt_match[] = { .data = &drv_data_exynos850_cl0 }, { .compatible = "samsung,exynosautov9-wdt", .data = &drv_data_exynosautov9_cl0 }, + { .compatible = "google,gs101-wdt", + .data = &drv_data_gs101_cl0 }, + { .compatible = "google,gs201-wdt", + .data = &drv_data_gs201_cl0 }, {}, }; MODULE_DEVICE_TABLE(of, s3c2410_wdt_match); @@ -375,6 +435,21 @@ static int s3c2410wdt_enable(struct s3c2410_wdt *wdt, bool en) return 0; } +static void s3c2410wdt_mask_dbgack(struct s3c2410_wdt *wdt, bool mask) +{ + unsigned long wtcon; + + if (!(wdt->drv_data->quirks & QUIRK_HAS_DBGACK_BIT)) + return; + + wtcon = readl(wdt->reg_base + S3C2410_WTCON); + if (mask) + wtcon |= S3C2410_WTCON_DBGACK_MASK; + else + 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); @@ -585,9 +660,11 @@ s3c2410_get_wdt_drv_data(struct platform_device *pdev, struct s3c2410_wdt *wdt) } #ifdef CONFIG_OF - /* Choose Exynos850/ExynosAutov9 driver data w.r.t. cluster index */ + /* Choose Exynos850/ExynosAutov9/gsx01 driver data w.r.t. cluster index */ if (variant == &drv_data_exynos850_cl0 || - variant == &drv_data_exynosautov9_cl0) { + variant == &drv_data_exynosautov9_cl0 || + variant == &drv_data_gs101_cl0 || + variant == &drv_data_gs201_cl0) { u32 index; int err; @@ -600,9 +677,14 @@ s3c2410_get_wdt_drv_data(struct platform_device *pdev, struct s3c2410_wdt *wdt) case 0: break; case 1: - variant = (variant == &drv_data_exynos850_cl0) ? - &drv_data_exynos850_cl1 : - &drv_data_exynosautov9_cl1; + if (variant == &drv_data_exynos850_cl0) + variant = &drv_data_exynos850_cl1; + else if (variant == &drv_data_exynosautov9_cl0) + variant = &drv_data_exynosautov9_cl1; + else if (variant == &drv_data_gs101_cl0) + variant = &drv_data_gs101_cl1; + else if (variant == &drv_data_gs201_cl0) + variant = &drv_data_gs201_cl1; break; default: return dev_err_probe(dev, -EINVAL, "wrong cluster index: %u\n", index); @@ -700,6 +782,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, true); + /* * 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. @@ -712,6 +796,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) s3c2410wdt_start(&wdt->wdt_device); set_bit(WDOG_HW_RUNNING, &wdt->wdt_device.status); } else { + dev_info(dev, "stopping watchdog timer\n"); s3c2410wdt_stop(&wdt->wdt_device); } @@ -738,6 +823,15 @@ static int s3c2410wdt_probe(struct platform_device *pdev) (wtcon & S3C2410_WTCON_RSTEN) ? "en" : "dis", (wtcon & S3C2410_WTCON_INTEN) ? "en" : "dis"); + if (wdt->drv_data->quirks & QUIRK_HAS_DBGACK_BIT) + dev_info(dev, "DBGACK %sabled\n", + (wtcon & S3C2410_WTCON_DBGACK_MASK) ? "en" : "dis"); + + if (wdt->drv_data->quirks & QUIRK_HAS_WTMINCNT_REG) + dev_info(dev, "windowed watchdog %sabled, wtmincnt=%x\n", + (wtcon & S3C2410_WTCON_WINDOWED_WD) ? "en" : "dis", + readl(wdt->reg_base + S3C2410_WTMINCNT)); + return 0; }