From patchwork Mon Nov 13 15:43:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 164552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1289784vqg; Mon, 13 Nov 2023 07:44:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJu2K7LlMEshC8z8aKS5ShHWaAiCJMcv1ZIr/dq1f/+UNxnhPDlIqwxb0abg/YS7DT33Up X-Received: by 2002:a05:6a20:72a7:b0:161:2bed:6b3a with SMTP id o39-20020a056a2072a700b001612bed6b3amr5150068pzk.17.1699890241567; Mon, 13 Nov 2023 07:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699890241; cv=none; d=google.com; s=arc-20160816; b=qb0RBVLxkehzimlkZhQDXWjjfys2nOzcM0wFjAQk/VsaiwwWPMwADYMhwkbGNaN+dm yrFPC8Q3dZlRweMHcwRrFaEsuuZZSlOp2RiLfGrrpTuJrT0i9IhDe75UnwkcoX1VkuOf GqfejGtlJYCkio+YpoecGvGCHTqSaOUWt5NnNfcxBgVRL+Mk8BVNX0or6fiajUizjw4m aEHSDpe3DXN4d1zpQDfkOUXQHzpxDYdYBN2LQhDj2ebR5VTFHR6sx+zMf7C87GDjxvU8 Vg/PSsG3w81CWm+MgMJcYpxI4y1YhzEhiHbchMza3nkEpAQntsethmaIGBprxexx7ksl dWRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=/KbYEvSfBc+Lv72CpyXpDVOfBPoD+ZL7mDv3LWOV9bQ=; fh=xEaS6JsnxjZX8pVPVpj87OJgkNID0y6bqQ3crE1r+UM=; b=PJgQV23X8MNWQXJ7SioSzyRVNWsC5e9suYpF4NZRru9pLOmcy/N2Nlt7RatQ8Xmdk2 MLCGDwmmBcLXlrhRu8AoLZNwimoUGofFzHe+wFGzfD691BT08O/BvtDW8RelYjvuNIje do3sktM0UbddFbcTIoCLmp91FD/x0ApKmIysRisl9QBzozzhylgunaTyjVJyAB3xNpnB lzmQC5VENJ4I7aqn13Agp1z7hCmgaTBqRf2EgDKfezctZ0MUn/2f3JlIVVnFexXASz2r b4PAHUrEuasJ4ruXCNMz7YaEtX1CdQpVcqIwmixD/raE4gKsCL4crK4Sdrr7wZY6FiSW pPDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q1-20020a056a00150100b006c346de97b0si6147708pfu.336.2023.11.13.07.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 07:44:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 71C77802FA7A; Mon, 13 Nov 2023 07:43:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231687AbjKMPnx (ORCPT + 29 others); Mon, 13 Nov 2023 10:43:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbjKMPnu (ORCPT ); Mon, 13 Nov 2023 10:43:50 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08198D5E; Mon, 13 Nov 2023 07:43:47 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1r2Z63-0003Mw-1X; Mon, 13 Nov 2023 15:43:31 +0000 Date: Mon, 13 Nov 2023 15:43:24 +0000 From: Daniel Golle To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 1/2] dt-bindings: watchdog: mediatek,mtk-wdt: add MT7988 watchdog and toprgu Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 07:43:59 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782464110165467495 X-GMAIL-MSGID: 1782464110165467495 Add compatible mediatek,mt7988-wdt. Signed-off-by: Daniel Golle Acked-by: Conor Dooley Reviewed-by: Guenter Roeck --- v2: Drop adding include/dt-binding/mt7988-resets.h as that header is not actually a binding header. Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml index cc502838bc398..8d2520241e37f 100644 --- a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml +++ b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml @@ -25,6 +25,7 @@ properties: - mediatek,mt6735-wdt - mediatek,mt6795-wdt - mediatek,mt7986-wdt + - mediatek,mt7988-wdt - mediatek,mt8183-wdt - mediatek,mt8186-wdt - mediatek,mt8188-wdt From patchwork Mon Nov 13 15:43:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 164553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1289850vqg; Mon, 13 Nov 2023 07:44:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnuKmJDDJT7bCOSLcrS22T3Nzhswi9ZqY1lx2xrKbEHXAmDkRm5twZ92X+DfwxKtmDiHOY X-Received: by 2002:a05:6a21:1a4:b0:181:10ee:20d5 with SMTP id le36-20020a056a2101a400b0018110ee20d5mr9697409pzb.12.1699890248466; Mon, 13 Nov 2023 07:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699890248; cv=none; d=google.com; s=arc-20160816; b=oYKYYJ9YWgq1lpeyg1Xm4lof22uzydquQVQeaSw3A24NGmCDOG/8GHEdsnORzqQXNa Kn09pot+dj7crSjvx4xELqxoZVMuSuiRmxykanoNuAjbhScpYaDbinVztaljnD1bxapt RRX8+3qy/1/aPi8ZNawfxilm6n0sR8VDz7hk4er48uhOi6UVWYL7QfGWmR6l+irNW0t2 3WubU1auoAyY3GlLdlfoR4C/4YiVvURgioORwhLdoF3jVzyHMPrHM8wlq/y86SZ+pNUd 70shhSSq6+HNTJku+D2qlp1oGXOUbRuoNMEgRFCX6d6LRNaenVdcn8ZcJ/i4AUwo7KWs hSQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=OyQ8BjYHjQMQhpzuppCFeKGNCUaBi+JzVoIeEnA0pj8=; fh=xEaS6JsnxjZX8pVPVpj87OJgkNID0y6bqQ3crE1r+UM=; b=j3FLEYvXRtcxkHP7yjVC8B9kssPYL5qI47TYfYIeRIKVhEbRQBgGWVI16ujhqpScHe nTDFj4PdyOXoW9mEYePC2ZpDSkkEDWWnJX2IDDLbDZoBhIWBUwebgU4ZsZa5bQnwqtcS 0TBR+m0Vqw/1w/WXrCSU0jJ0QK1tl/7qOf1PJsHYKqlUl+7HKDj+IDQl8amCf6y+uYr5 72ip3RlzrTrdXOj/ARCCjBXuEpUgjtXFvW50eS0amD0Iykz/rljbJZ11QqfclBddOPqF kfJfTj7/fDk0yd0Y0Qnc6NgvY+nmNoF9fJPHD8fjYQbCtynu3oUFrv0EyNkE/+0wdoI0 XUXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w22-20020a056a0014d600b006bcde830350si6252819pfu.290.2023.11.13.07.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 07:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9D9F4802AD28; Mon, 13 Nov 2023 07:44:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjKMPoB (ORCPT + 29 others); Mon, 13 Nov 2023 10:44:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231697AbjKMPoA (ORCPT ); Mon, 13 Nov 2023 10:44:00 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A41172B; Mon, 13 Nov 2023 07:43:56 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1r2Z6M-0003NH-02; Mon, 13 Nov 2023 15:43:50 +0000 Date: Mon, 13 Nov 2023 15:43:47 +0000 From: Daniel Golle To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 2/2] watchdog: mediatek: mt7988: add wdt support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 07:44:07 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782464117416524235 X-GMAIL-MSGID: 1782464117416524235 Add support for watchdog and reset generator unit of the MediaTek MT7988 SoC. Signed-off-by: Daniel Golle Reviewed-by: Guenter Roeck --- v2: call new toprgu_reset_sw_en_unlocked from toprgu_reset_update while holding lock. drivers/watchdog/mtk_wdt.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c index b2330b16b497a..5a31a8746e954 100644 --- a/drivers/watchdog/mtk_wdt.c +++ b/drivers/watchdog/mtk_wdt.c @@ -58,6 +58,8 @@ #define WDT_SWSYSRST 0x18U #define WDT_SWSYS_RST_KEY 0x88000000 +#define WDT_SWSYSRST_EN 0xfc + #define DRV_NAME "mtk-wdt" #define DRV_VERSION "1.0" @@ -71,10 +73,12 @@ struct mtk_wdt_dev { struct reset_controller_dev rcdev; bool disable_wdt_extrst; bool reset_by_toprgu; + bool has_swsysrst_en; }; struct mtk_wdt_data { int toprgu_sw_rst_num; + bool has_swsysrst_en; }; static const struct mtk_wdt_data mt2712_data = { @@ -89,6 +93,11 @@ static const struct mtk_wdt_data mt7986_data = { .toprgu_sw_rst_num = MT7986_TOPRGU_SW_RST_NUM, }; +static const struct mtk_wdt_data mt7988_data = { + .toprgu_sw_rst_num = 24, + .has_swsysrst_en = true, +}; + static const struct mtk_wdt_data mt8183_data = { .toprgu_sw_rst_num = MT8183_TOPRGU_SW_RST_NUM, }; @@ -109,6 +118,28 @@ static const struct mtk_wdt_data mt8195_data = { .toprgu_sw_rst_num = MT8195_TOPRGU_SW_RST_NUM, }; +/** + * toprgu_reset_sw_en_unlocked() - enable/disable software control for reset bit + * @mtk_wdt: Pointer to instance of struct mtk_wdt_dev. + * @id: Bit number identifying the reset to be enabled or disabled. + * @enable: If true, enable software control for that bit, disable otherwise. + * + * Context: The caller must hold lock of struct mtk_wdt_dev. + */ +static void toprgu_reset_sw_en_unlocked(struct mtk_wdt_dev *data, + unsigned long id, bool enable) +{ + u32 tmp; + + tmp = readl(data->wdt_base + WDT_SWSYSRST_EN); + if (enable) + tmp |= BIT(id); + else + tmp &= ~BIT(id); + + writel(tmp, data->wdt_base + WDT_SWSYSRST_EN); +} + static int toprgu_reset_update(struct reset_controller_dev *rcdev, unsigned long id, bool assert) { @@ -119,6 +150,9 @@ static int toprgu_reset_update(struct reset_controller_dev *rcdev, spin_lock_irqsave(&data->lock, flags); + if (assert && data->has_swsysrst_en) + toprgu_reset_sw_en_unlocked(data, id, true); + tmp = readl(data->wdt_base + WDT_SWSYSRST); if (assert) tmp |= BIT(id); @@ -127,6 +161,9 @@ static int toprgu_reset_update(struct reset_controller_dev *rcdev, tmp |= WDT_SWSYS_RST_KEY; writel(tmp, data->wdt_base + WDT_SWSYSRST); + if (!assert && data->has_swsysrst_en) + toprgu_reset_sw_en_unlocked(data, id, false); + spin_unlock_irqrestore(&data->lock, flags); return 0; @@ -406,6 +443,8 @@ static int mtk_wdt_probe(struct platform_device *pdev) wdt_data->toprgu_sw_rst_num); if (err) return err; + + mtk_wdt->has_swsysrst_en = wdt_data->has_swsysrst_en; } mtk_wdt->disable_wdt_extrst = @@ -444,6 +483,7 @@ static const struct of_device_id mtk_wdt_dt_ids[] = { { .compatible = "mediatek,mt6589-wdt" }, { .compatible = "mediatek,mt6795-wdt", .data = &mt6795_data }, { .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data }, + { .compatible = "mediatek,mt7988-wdt", .data = &mt7988_data }, { .compatible = "mediatek,mt8183-wdt", .data = &mt8183_data }, { .compatible = "mediatek,mt8186-wdt", .data = &mt8186_data }, { .compatible = "mediatek,mt8188-wdt", .data = &mt8188_data },