From patchwork Fri Nov 10 00:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 163694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp798589vqs; Thu, 9 Nov 2023 16:31:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGyOENkNpkvQEIDMlzHkEYEvVynBeT3Sn8Nxl3/hwA1HSzSb+2QdeV4K6xRxDjAcFKiaVT X-Received: by 2002:a05:6a20:8f29:b0:14c:d494:77c5 with SMTP id b41-20020a056a208f2900b0014cd49477c5mr7929370pzk.13.1699576261756; Thu, 09 Nov 2023 16:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699576261; cv=none; d=google.com; s=arc-20160816; b=PxEKxmWyWjVD8rDuNQ+ESb8j2xVXpKy06oXvD6XG+fV+Q1qTspruVf/palmcDonbsx ny8EdSLnIiyuDmu0tjN/46Eer+pqCYZOQl9+HWK6JBZHQDrvfAwqRoeRB9om5zSfgbHn VIwD0vqePEHPf7fq9309u0rF/OYGYRklJNjA7sE86k/FpL1nV5XYr2g9Um8TgfKAj6Bm Woyj7dov34OPiUNx7Dmns8XAEdhBRx48BciI0rrssksDy1uyp45TxvJl2TELNVqd+KJ2 Uajht5yGEySVKpQXMayZYjPZlf3GTZCG56KjeNCQbJYLUSh/sML3i0/02JCv4xKZyGYa o3rA== 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=3WUqgSmOsM1eJfUBDdoQFz2RuXcsIwBmdgmCwlrFW/c=; fh=+vr7x8OhcV8zhN29lKUOzBXxMgIfqPqi3CHIEOjKN2A=; b=GmM51MTP0Qy5tZmM8SURnly7ebTAAQmp/XhrHwymwvykKb2NxyzcMCc0YcLy7FO37u /k5gw6aZlMO/Ty8bqCu+oGZuQcVODuM4LtX28HG7xo2H0Hkd7oIc44IiARYLO68UwlIY pS5jwDJF/uGapvvPAM8QWXCiALqleaJ1LZGdB5gY3nnDk+fd8JxbMRvVDN0ulzK91kuV AcRJGjnhRW6usBmMEibDAYgwrQwnJd7fkxzmMUDo2wQRXFtxLLM89yvqOAsJnkg7eEAS hV8tHTLaEW1MBCmhaBmlXnrbPwQkV231X3UbwyHJG38pYS1igJVmEDqfZHEjlzyEYa3W h/2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id gk20-20020a17090b119400b00280c9b49738si2850652pjb.84.2023.11.09.16.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:31:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id AB7F18053641; Thu, 9 Nov 2023 16:30:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345483AbjKJAai (ORCPT + 30 others); Thu, 9 Nov 2023 19:30:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjKJAag (ORCPT ); Thu, 9 Nov 2023 19:30:36 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40E542D7C; Thu, 9 Nov 2023 16:30:34 -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 1r1FPd-00041W-2M; Fri, 10 Nov 2023 00:30:17 +0000 Date: Fri, 10 Nov 2023 00:30:13 +0000 From: Daniel Golle To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Philipp Zabel , 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 1/2] dt-bindings: watchdog: mediatek,mtk-wdt: add MT7988 watchdog and toprgu Message-ID: <6912f6f406bc45674020681184f3eeca2f2cb63f.1699576174.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline 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 (lipwig.vger.email [0.0.0.0]); Thu, 09 Nov 2023 16:30:59 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782134878414971629 X-GMAIL-MSGID: 1782134878414971629 Add binding description for mediatek,mt7988-wdt. Signed-off-by: Daniel Golle --- .../bindings/watchdog/mediatek,mtk-wdt.yaml | 1 + include/dt-bindings/reset/mediatek,mt7988-resets.h | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 include/dt-bindings/reset/mediatek,mt7988-resets.h 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 diff --git a/include/dt-bindings/reset/mediatek,mt7988-resets.h b/include/dt-bindings/reset/mediatek,mt7988-resets.h new file mode 100644 index 0000000000000..fa7c937505e08 --- /dev/null +++ b/include/dt-bindings/reset/mediatek,mt7988-resets.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +/* TOPRGU resets */ +#define MT7988_TOPRGU_SGMII0_GRST 1 +#define MT7988_TOPRGU_SGMII1_GRST 2 +#define MT7988_TOPRGU_XFI0_GRST 12 +#define MT7988_TOPRGU_XFI1_GRST 13 +#define MT7988_TOPRGU_XFI_PEXTP0_GRST 14 +#define MT7988_TOPRGU_XFI_PEXTP1_GRST 15 +#define MT7988_TOPRGU_XFI_PLL_GRST 16 + +#define MT7988_TOPRGU_SW_RST_NUM 24 From patchwork Fri Nov 10 00:30:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 163695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp798689vqs; Thu, 9 Nov 2023 16:31:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJNDwcyJ5QL8vHgb/oZWYGg8Oe3Q6hkZViNQ6/MbSysz2qKYe48SrkxHrlbMj26Spi0sV+ X-Received: by 2002:a17:903:244a:b0:1cc:467a:338f with SMTP id l10-20020a170903244a00b001cc467a338fmr1426566pls.4.1699576277547; Thu, 09 Nov 2023 16:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699576277; cv=none; d=google.com; s=arc-20160816; b=ndIoHjwHsoXUu1e6/AhJv+OD/3fyb5ONwcNAjHIeclWUibC6R5ifMidrHKvnaYpFFt PBpYvfcQqQlqQLjtoGAkrRt5plAE2oyer/+YScN2xpKiHNitV/GlhHFpameKAYtfEIgP gGiaa75zfyjxQVWo0mP5B8YslJoGSprYjcAHmkQOtikSS14RPX9myJtwsDN2z3UJ4a6P LkUzZjNUYnqsWl65E8S9kySB/AO9wxNWu1AFQU0YjotvMd0umSnlJXY6VnChRj589Yin Il79M22GY1+NyQkGFkAQmJKRADZNPJoBYGNRezHXUu2Y1lpOD+43obTKsf9G37sSitkU gUGA== 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=OTbpKvQmZvQRTB0xOPyvktBEEiwJFAjRng6FoiikXPQ=; fh=+vr7x8OhcV8zhN29lKUOzBXxMgIfqPqi3CHIEOjKN2A=; b=MCL7NGfrDxW96INMzxienA/wgwqY4icYWeafSX6fmYTgu49ss0ikfmzYJu1oRaQvW+ M9z92wt+E7NCuj6ntTkzRf6Uia7gSKHo5jrZgtZ8IgtKGGnQ/aH2vftkzry7HpJou8FZ gjIEUJWxQ0derDDZVGnuwNwJSDuyjp72GzzPYa8AUY9/q7mEGJYoE1cuPQ/Yx15068Kc ccu0aV/9yOZ6q+hpHMkkQPNkwJ/ShgQUzi15BcPHE6fUPMUnQrLv8wR6RF4yHEerTKnZ +9TaPpoFQXs4ejhF51q81R4tgj5IkZ+ukCWK3ys5Kp1VpN/vxstIbZ7S3LP0yLnVxCfX tXkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z13-20020a170902d54d00b001c32fe6cdf9si6966936plf.386.2023.11.09.16.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 0EC6E8303B2B; Thu, 9 Nov 2023 16:31:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345507AbjKJAav (ORCPT + 30 others); Thu, 9 Nov 2023 19:30:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjKJAau (ORCPT ); Thu, 9 Nov 2023 19:30:50 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3921F2590; Thu, 9 Nov 2023 16:30:48 -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 1r1FPz-00041m-2U; Fri, 10 Nov 2023 00:30:39 +0000 Date: Fri, 10 Nov 2023 00:30:36 +0000 From: Daniel Golle To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Philipp Zabel , 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 2/2] watchdog: mediatek: mt7988: add wdt support Message-ID: References: <6912f6f406bc45674020681184f3eeca2f2cb63f.1699576174.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6912f6f406bc45674020681184f3eeca2f2cb63f.1699576174.git.daniel@makrotopia.org> 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 (groat.vger.email [0.0.0.0]); Thu, 09 Nov 2023 16:31:06 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782134895032557472 X-GMAIL-MSGID: 1782134895032557472 Add support for watchdog and reset generator unit of the MediaTek MT7988 SoC. Signed-off-by: Daniel Golle --- drivers/watchdog/mtk_wdt.c | 56 +++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c index b2330b16b497a..b98b8c29735aa 100644 --- a/drivers/watchdog/mtk_wdt.c +++ b/drivers/watchdog/mtk_wdt.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,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,44 +74,85 @@ 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 = { .toprgu_sw_rst_num = MT2712_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; static const struct mtk_wdt_data mt6795_data = { .toprgu_sw_rst_num = MT6795_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; static const struct mtk_wdt_data mt7986_data = { .toprgu_sw_rst_num = MT7986_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, +}; + +static const struct mtk_wdt_data mt7988_data = { + .toprgu_sw_rst_num = MT7988_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = true, }; static const struct mtk_wdt_data mt8183_data = { .toprgu_sw_rst_num = MT8183_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; static const struct mtk_wdt_data mt8186_data = { .toprgu_sw_rst_num = MT8186_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; static const struct mtk_wdt_data mt8188_data = { .toprgu_sw_rst_num = MT8188_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; static const struct mtk_wdt_data mt8192_data = { .toprgu_sw_rst_num = MT8192_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; static const struct mtk_wdt_data mt8195_data = { .toprgu_sw_rst_num = MT8195_TOPRGU_SW_RST_NUM, + .has_swsysrst_en = false, }; +static int toprgu_reset_sw_enable(struct reset_controller_dev *rcdev, + unsigned long id, bool enable) +{ + unsigned int tmp; + unsigned long flags; + struct mtk_wdt_dev *data = + container_of(rcdev, struct mtk_wdt_dev, rcdev); + + if (!data->has_swsysrst_en) + return 0; + + spin_lock_irqsave(&data->lock, flags); + + 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); + + spin_unlock_irqrestore(&data->lock, flags); + + return 0; +} + static int toprgu_reset_update(struct reset_controller_dev *rcdev, unsigned long id, bool assert) { @@ -135,13 +179,20 @@ static int toprgu_reset_update(struct reset_controller_dev *rcdev, static int toprgu_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) { + int ret; + + ret = toprgu_reset_sw_enable(rcdev, id, true); + if (ret) + return ret; + return toprgu_reset_update(rcdev, id, true); } static int toprgu_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id) { - return toprgu_reset_update(rcdev, id, false); + toprgu_reset_update(rcdev, id, false); + return toprgu_reset_sw_enable(rcdev, id, false); } static int toprgu_reset(struct reset_controller_dev *rcdev, @@ -406,6 +457,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 +497,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 },