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 27F6AC678D5 for ; Wed, 8 Mar 2023 15:18:07 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6/dctB8ERLqrH+wFsn5OgcQDRfXMYecEMX/UjL9pJCI=; b=XxvLpGoI57zu2l zZaH+ay8xshok9Y50a8JKrwLmnDoGq9g/T1NO/0L2ShS150Aqr0jh30igQoaCABuxozaRo6e9yM/i 9tR1WMg8qHod9RS6HnQ5e9PjZcCZWIZCOVr00DjBIHH8tJVZTJ7lV7do1rByBPRrTD5NMPUn8Yj7g th+y0LaFcSQXK/9VIbpsU36ReUAz2eSQqg3s4BobgyP3h9FqjHbJTnJzNFjIkV+SsN8YSfgySMu4U cbKQSegOdDM8lIOC10ukl5FRMbHcHiX7wMBG8fJ3uWp4O0vd0Z/q9TF3tB79Tg5Q/QZFAPQreGCR8 iZkcXVS2HX8dfv5kLtcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZvYC-005fXT-TZ; Wed, 08 Mar 2023 15:17:56 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZvY6-005fVi-US for linux-riscv@lists.infradead.org; Wed, 08 Mar 2023 15:17:55 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 32-20020a9d0323000000b0069426a71d79so9143851otv.10 for ; Wed, 08 Mar 2023 07:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678288669; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=rCEf+NQ+Pc1ncYD3djIGD+iYastMQpss3chPBnkt7Ig=; b=AOvv9WB4IQmxykMtzq2277on7e0CPR51Ry/Rl6JUraFHKAEczYdKlV3ZDAkpMwV7pX kqJzDKu/EiuahfwOKicycBXDJMcZYSXAj7wh6JHiliFpDRLaqaWuVx/pFOGnMGTWIdpi rxkHnmI9vyyUbqmUIY3Ya+7VRZhZSoKYOCGwO1uD/BhvekSjGkMANNNneYDAODXQ8VcQ FCCO8oovrLlGGM49MUqzEp29tc3p2d11z6Vo1HFCcBNu6fdOFRnrDY6ScHn9RB4HJONj mOzhAVITUapgFfjUO/TZDv1Hb9nMNiUJB9DNr26LiMcUk+A0K3xFmzg0m40cljLJBoCt 2nqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678288669; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rCEf+NQ+Pc1ncYD3djIGD+iYastMQpss3chPBnkt7Ig=; b=CJv6lpAAGH/mwmnV290661hJbayyX/wtMSIrY+M+CHg2T72xUSXZKqS0CrVC3llctE OFpxwgFCtepvRJnVIcQm5jBBCNdM1BZdvBr9xHUuaAN2bioFGkazAqn+hHhbtKD+kBJ0 Pbrrgo41FTV8+DNEqIlOtFuTvfXEscCYaqNIv3ZOeb3AdBMnLVXeb9X0aUE5DPG7CRZ8 1objDrOgLkjINdAmCznSbr6Txi4saZqDlm03jlDlsFWjoG3nxl63frvAGoO8wf0GIit7 +9J3brUc2NdkTCLkpOfxLTd7HsCRpowxh3Bg0BbpasMyGRXy1sZYb0dqehxgzWFYXvyu yPLg== X-Gm-Message-State: AO0yUKWuOJ4HI2N+UGdjoTDELdQ5mtbHy0QeGi7fxdljwexBVwShnHz0 0UOtRBJn1xnE7Yb08P5o9S0= X-Google-Smtp-Source: AK7set9aolhusX/PmFaEseHKB8tfkbfJcx/8fA5YeZ0OaHKrPcRid0K89cnxM2/CLstuGYynD1rjhA== X-Received: by 2002:a9d:5f9d:0:b0:694:2f51:129b with SMTP id g29-20020a9d5f9d000000b006942f51129bmr7769218oti.24.1678288669514; Wed, 08 Mar 2023 07:17:49 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a16-20020a9d3e10000000b0068d752f1870sm6539288otd.5.2023.03.08.07.17.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Mar 2023 07:17:48 -0800 (PST) Message-ID: <0b467896-17d4-c355-da86-437b45f089d4@roeck-us.net> Date: Wed, 8 Mar 2023 07:17:45 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v4 2/3] drivers: watchdog: Add StarFive Watchdog driver Content-Language: en-US To: Emil Renner Berthing , Xingyu Wu Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org, Wim Van Sebroeck , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Samin Guo , linux-kernel@vger.kernel.org References: <20230308034036.99213-1-xingyu.wu@starfivetech.com> <20230308034036.99213-3-xingyu.wu@starfivetech.com> From: Guenter Roeck In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_071751_018084_91A54DC4 X-CRM114-Status: GOOD ( 29.25 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On 3/8/23 07:07, Emil Renner Berthing wrote: > On Wed, 8 Mar 2023 at 04:43, Xingyu Wu wrote: >> >> Add watchdog driver for the StarFive JH7100 and JH7110 SoC. >> >> Signed-off-by: Xingyu Wu > > Hi Xingyu, > > Thanks for adding the JH7100 support. I tried it on my Starlight board > and it seems to work fine except systemd complains about not being > able to set a 10min timeout on reboot: > systemd-shutdown[1]: Using hardware watchdog 'StarFive Watchdog', > version 0, device /dev/watchdog0 > systemd-shutdown[1]: Failed to set timeout to 10min: Invalid argument > systemd-shutdown[1]: Syncing filesystems and block devices. > systemd-shutdown[1]: Sending SIGTERM to remaining processes... > > The systemd runtime watchdog seems to work, so I guess this is just > because 10min is too long a timeout for the StarFive watchdog. > Correct, the driver would have to be implemented slightly differently for the watchdog subsystem to accept larger timeout values. > More comments below. > >> --- >> MAINTAINERS | 7 + >> drivers/watchdog/Kconfig | 9 + >> drivers/watchdog/Makefile | 2 + >> drivers/watchdog/starfive-wdt.c | 675 ++++++++++++++++++++++++++++++++ >> 4 files changed, 693 insertions(+) >> create mode 100644 drivers/watchdog/starfive-wdt.c >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 8d5bc223f305..721d0e4e8a0d 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -19962,6 +19962,13 @@ S: Supported >> F: Documentation/devicetree/bindings/rng/starfive* >> F: drivers/char/hw_random/jh7110-trng.c >> >> +STARFIVE WATCHDOG DRIVER >> +M: Xingyu Wu >> +M: Samin Guo >> +S: Supported >> +F: Documentation/devicetree/bindings/watchdog/starfive* >> +F: drivers/watchdog/starfive-wdt.c >> + >> STATIC BRANCH/CALL >> M: Peter Zijlstra >> M: Josh Poimboeuf >> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig >> index f0872970daf9..9d825ffaf292 100644 >> --- a/drivers/watchdog/Kconfig >> +++ b/drivers/watchdog/Kconfig >> @@ -2090,6 +2090,15 @@ config UML_WATCHDOG >> tristate "UML watchdog" >> depends on UML || COMPILE_TEST >> >> +config STARFIVE_WATCHDOG >> + tristate "StarFive Watchdog support" >> + depends on ARCH_STARFIVE || COMPILE_TEST >> + select WATCHDOG_CORE >> + default ARCH_STARFIVE >> + help >> + Say Y here to support the watchdog of StarFive JH7100 and JH7110 >> + SoC. This driver can also be built as a module if choose M. > > This file seems to be sorted by architecture, so you probably want to > add something like this at the appropriate place > > # RISC-V Architecture > > config STARFIVE_WATCHDOG > ... > > >> # >> # ISA-based Watchdog Cards >> # >> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile >> index 9cbf6580f16c..4c0bd377e92a 100644 >> --- a/drivers/watchdog/Makefile >> +++ b/drivers/watchdog/Makefile >> @@ -211,6 +211,8 @@ obj-$(CONFIG_WATCHDOG_SUN4V) += sun4v_wdt.o >> # Xen >> obj-$(CONFIG_XEN_WDT) += xen_wdt.o >> >> +obj-$(CONFIG_STARFIVE_WATCHDOG) += starfive-wdt.o > > Again please follow the layout of the file. Eg. something like this at > the appropriate place > > # RISC-V Architecture > obj-$(CONFIG_STARFIVE_WATCHDOG) += starfive-wdt.o > >> # Architecture Independent >> obj-$(CONFIG_BD957XMUF_WATCHDOG) += bd9576_wdt.o >> obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o >> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c >> new file mode 100644 >> index 000000000000..8ce9f985f068 >> --- /dev/null >> +++ b/drivers/watchdog/starfive-wdt.c >> @@ -0,0 +1,675 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Starfive Watchdog driver >> + * >> + * Copyright (C) 2022 StarFive Technology Co., Ltd. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +/* JH7100 Watchdog register define */ >> +#define STARFIVE_WDT_JH7100_INTSTAUS 0x000 /* RO: [4]: Watchdog Interrupt status */ >> +#define STARFIVE_WDT_JH7100_CONTROL 0x104 /* RW: reset enable */ >> +#define STARFIVE_WDT_JH7100_LOAD 0x108 /* RW: Watchdog Load register */ >> +#define STARFIVE_WDT_JH7100_EN 0x110 /* RW: Watchdog Enable Register */ >> +#define STARFIVE_WDT_JH7100_RELOAD 0x114 /* RW: Write 0 or 1 to reload preset value */ >> +#define STARFIVE_WDT_JH7100_VALUE 0x118 /* RO: The current value for watchdog counter */ >> +#define STARFIVE_WDT_JH7100_INTCLR 0x120 /* >> + * RW: Watchdog Clear Interrupt Register >> + * [0]: Write 1 to clear interrupt >> + * [1]: 1 mean clearing and 0 mean complete >> + */ >> +#define STARFIVE_WDT_JH7100_LOCK 0x13c /* RW: Lock Register, write 0x378f0765 to unlock */ >> + >> +/* JH7110 Watchdog register define */ >> +#define STARFIVE_WDT_JH7110_LOAD 0x000 /* RW: Watchdog Load register */ >> +#define STARFIVE_WDT_JH7110_VALUE 0x004 /* RO: The current value for watchdog counter */ >> +#define STARFIVE_WDT_JH7110_CONTROL 0x008 /* >> + * RW: >> + * [0]: reset enable; >> + * [1]: int enable/wdt enable/reload counter; >> + * [31:2]: reserved. >> + */ >> +#define STARFIVE_WDT_JH7110_INTCLR 0x00c /* WO: clear intterupt && reload the counter */ >> +#define STARFIVE_WDT_JH7110_IMS 0x014 /* RO: Enabled interrupt status from the counter */ >> +#define STARFIVE_WDT_JH7110_LOCK 0xc00 /* RW: Lock Register, write 0x1ACCE551 to unlock */ > > Since these register offsets are only used to fill in the > starfive_wdt_variant structures, consider just adding them directly > there with the comments. > As maintainer, I prefer defines, even if only used oonce. Guenter _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv