From patchwork Tue May 25 18:44:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 12279987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34005C2B9F8 for ; Tue, 25 May 2021 19:06:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E925161378 for ; Tue, 25 May 2021 19:06:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E925161378 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=EEFxP12y7KRgFxqrJe0NiqbghLqEzGXxAhD1BpIVt3Q=; b=LLhG0d2FUraNzn X+xtWKfEea1wZDX35wd1AvW7PP5kZNhbVka2AFZlEe+Te4fWAwV/oAPvxGitFkbC/+LTHY/HBgVSV bHiKhn1zTsuKSZOGbWD8toawTVILeEl2ZnwZ7UzX6K6K4rILA/pZnOj4AK5mUQorzy0xX5O4YAAxY LSa+Fy88lsIAY+sDCJS8KeNx4sxpCxq/8ENh9OjURExZFDlepSEgc3BTxhY9fzg3q60HkQku6jDmu 9HzkHYIGEeTtPlcwEflc2kXxtV2yg6DSG7V3i6iiac6Y/KXOVatXF0YYcneTUZSgQUvByXsqQEaJu T/BV4H4IyPqeTGHC6+kA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llcKy-007WjX-34; Tue, 25 May 2021 19:03:33 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llc2z-007OLU-AT for linux-arm-kernel@lists.infradead.org; Tue, 25 May 2021 18:44:58 +0000 Received: by mail-wm1-x32b.google.com with SMTP id u133so17295776wmg.1 for ; Tue, 25 May 2021 11:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VR1JWU4nW1DmUrTHeiF6/6cj0vIS4fC0uA+HnyAg+8M=; b=e6tF+Gl+FBuOY9vs30nyw10JSUU778grJ2DshnLVoJi7XMeIkEtvMld0nDrcad4fT9 V20yAwHapYpk4SHi7DForbIx0E/QbeG3Y/8Li4QH/fxbAj/ZW2Ik2Y7GZeHwB3AsPSSX tOvSUibxh7LZi1EI4ag9OpG/vh6b7Q5FWvdQd5gerkBhoSYrFZGplxpIqmA6RARFp8CW yj6+YWRQNgs+wJFIdlrk8WsS74FZltab1dYBcpTFdaJ2GRWua3NXJLGWcDDNukgZ3nPy 1mKkGORDjfzUsI30TRzX3zTVM3yCJks2/2fYc7n6JizDXT6NRYPKrJoONsdqdS8Ce3Cq auRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VR1JWU4nW1DmUrTHeiF6/6cj0vIS4fC0uA+HnyAg+8M=; b=tAcOILcY66Mxt8jFPBCuzjBV+Vb+o0Qt+WEuX+31j8d3Bztez13MgoLk2sWojyl7Lj 8C/OknS+cHWooSHHpcYjqnHx6i+M2WMUwlo1SYszPz9heZ/Vmy4pL4s7Q2HfM6rb2MHd z+S/ruPgMxCcEeoIExEzM5qgTnV2A6wP5/kEvCCJ4jbFYZDdLsPnYPhPwlaVef73HMsv a2NXxdLz5cpfEtcgs6Yn0dzcQl5JE8kyBYx1jB0hT2S8lmuaXAhQumMbOuXH4Ex6NI1K u8lIZZ41ru3K5lKaONtziyRCjN/YQb1aHdG8xT3HbgicH6Z1ZDqm9brp9hyQlp5+B+f1 tP9A== X-Gm-Message-State: AOAM532a4kwEfmyLIRcOfDwHOm31fkmUbPsgygT0pHvOLep0wYgodh1j fuZZ0sYD9MGbeEviH7yYg/zEGcXT5k8= X-Google-Smtp-Source: ABdhPJxwo/trUdxbAPyfQNNO5rDy7YF9eIaqrWZ30hV4W8ZzFeOaO+Dt2gXGW5+3b4TiQSl/i5IQrQ== X-Received: by 2002:a1c:80d0:: with SMTP id b199mr5048916wmd.6.1621968295417; Tue, 25 May 2021 11:44:55 -0700 (PDT) Received: from debby (176-141-241-253.abo.bbox.fr. [176.141.241.253]) by smtp.gmail.com with ESMTPSA id u17sm7292456wrt.61.2021.05.25.11.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 11:44:55 -0700 (PDT) From: Romain Perier To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: Daniel Palmer , Mohammed Billoo , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] Documentation: watchdog: Add Mstar MSC313e WDT devicetree bindings documentation Date: Tue, 25 May 2021 20:44:47 +0200 Message-Id: <20210525184449.57703-2-romain.perier@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210525184449.57703-1-romain.perier@gmail.com> References: <20210525184449.57703-1-romain.perier@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_114457_404220_A8696B77 X-CRM114-Status: GOOD ( 13.93 ) 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 adds the documentation for the devicetree bindings of the Mstar MSC313e watchdog driver, found from MSC313e SoCs and newer. Signed-off-by: Romain Perier --- .../bindings/watchdog/msc313e-wdt.yaml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/msc313e-wdt.yaml diff --git a/Documentation/devicetree/bindings/watchdog/msc313e-wdt.yaml b/Documentation/devicetree/bindings/watchdog/msc313e-wdt.yaml new file mode 100644 index 000000000000..70b8e1be5e8e --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/msc313e-wdt.yaml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/watchdog/msc313e-wdt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MStar Watchdog Device Tree Bindings + +maintainers: + - Daniel Palmer + - Romain Perier + +allOf: + - $ref: watchdog.yaml# + +properties: + compatible: + enum: + - mstar,msc313e-wdt + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + +required: + - compatible + - clocks + - reg + +unevaluatedProperties: false + +examples: + - | + watchdog: watchdog@6000 { + compatible = "mstar,msc313e-wdt"; + reg = <0x6000 0x1f>; + clocks = <&xtal_div2>; + }; From patchwork Tue May 25 18:44:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 12279989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 356A9C2B9F8 for ; Tue, 25 May 2021 19:06:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E5E6860FDA for ; Tue, 25 May 2021 19:06:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5E6860FDA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=tKHZhYYovuLXfmNavyHuCO/SaTjX/ErINC00BUsGhME=; b=asEaiL+L8nr7Ap Usf05zjp88E2LWjeIhuT4snwme4znNAymYMWX6SSoK0gje/X8ZEXHngQ49WWJsAS+2b70BRMdte/3 tkqzN0EKxJrJ0FP8sLBc2ZBUV9RNTu5OqBL6v9pbFXPD6DiJUGvwBsTXNR83YtF8PLGeLR/focYSC /q8uIp2V52G+i9mx36Wqr+ewQB52xSRU1zrJmF7lDNzcu7d10fVTVaXoGJam1uEEWdqSWJ7aOSl6d nbn4sb1j9QpuZotT9v2aSNMkwmo1+JEERNVuAa3mn9bnZ1ov4VzwKApcpwRK5FOge31mL9prZ9ZI6 RmjLO/1gwIiADirtclmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llcMF-007XMV-52; Tue, 25 May 2021 19:04:52 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llc30-007OLy-H3 for linux-arm-kernel@lists.infradead.org; Tue, 25 May 2021 18:45:00 +0000 Received: by mail-wm1-x331.google.com with SMTP id h3so4554090wmq.3 for ; Tue, 25 May 2021 11:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8hOl9Yrw9Tmm8G5l9sOtbitxhPz2DOH0BvkorS/HrdE=; b=f7rc+YsrOYxl3TiXJuHDoriBJ6QtSAWE0t2ooOChHm09aixv+IGtdzGE5+WyIYvWjX Fv4/VjHtDEeSz5zHeWNNEePDS0CBc8tgK62Hlw/rQ4PM8jVMPPo0qg8Ifdp51q/vHydl 8Vw6h/dE+jammrfmFrwc5y/gb2Ifl2Rac+Yi5wtoSkCvrZr9m7TiwC3S42K1erxtJSQM /j+4aW8p48wH8wVLjeu2EFDIxbnc/oE+1SILZuHxB64t1wQFaMe0Q8RgMUB3Tzb0bpvo XMrPzTvdeg98RZRfhxMPfYY5W18EvthjutwBLIAGhOrK4hul8t+uEHseJ6WpCpraktSn /zPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8hOl9Yrw9Tmm8G5l9sOtbitxhPz2DOH0BvkorS/HrdE=; b=BWV+MfkQlLJepz9stR4PwXDnAdVugRROO7BrfiUZlfb/eFbzvrj6A7ZKmXOdm3rWTJ 535CRRa56c4jXl3Oz/LmEi+qi+btgY+JlzokOvVVXB84OuH+F0oXoKj3gMkRy6QWn/wt TqDPTkynmhYw4UEXm6OJFgfjRupS+fKMQq46/AuuZZPIyeHlKNUy90occJDCCStpnSsO aam4D/51kZOzqsgcC22xogc8KQ0OSCEas6q6lu2g0BFUmPpSecLpEwiaOHFij5CBA/kB xd4+DViBzTpnKu/hG6VrjOYt4v7YJQGCp2vbrBXTZbGQpEz3dyWPWl/+DNPq8xp29HAF LFIQ== X-Gm-Message-State: AOAM532FWmttQE9KCVv1WztVeOn9ufSJvXRl4p1Uw50FtA3e2hzkr64K DZH+NpPtfxU7zyfTo5eDvO4= X-Google-Smtp-Source: ABdhPJyrJMDULk7xK0nzKkEOEb84T1OKykQHTw5YHKeQlzRG8XStJFDNTy9SnjLuMadZRwXpUnPrLg== X-Received: by 2002:a1c:cc05:: with SMTP id h5mr5169753wmb.92.1621968296598; Tue, 25 May 2021 11:44:56 -0700 (PDT) Received: from debby (176-141-241-253.abo.bbox.fr. [176.141.241.253]) by smtp.gmail.com with ESMTPSA id o8sm17171135wrx.4.2021.05.25.11.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 11:44:56 -0700 (PDT) From: Romain Perier To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: Daniel Palmer , Mohammed Billoo , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] watchdog: Add Mstar MSC313e WDT driver Date: Tue, 25 May 2021 20:44:48 +0200 Message-Id: <20210525184449.57703-3-romain.perier@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210525184449.57703-1-romain.perier@gmail.com> References: <20210525184449.57703-1-romain.perier@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_114458_625385_420BFB3E X-CRM114-Status: GOOD ( 26.39 ) 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 From: Daniel Palmer It adds a driver for the IP block handling the watchdog timer found for Mstar MSC313e SoCs and newer. Signed-off-by: Daniel Palmer Co-developed-by: Romain Perier Signed-off-by: Romain Perier --- MAINTAINERS | 1 + drivers/watchdog/Kconfig | 13 +++ drivers/watchdog/Makefile | 1 + drivers/watchdog/msc313e_wdt.c | 173 +++++++++++++++++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 drivers/watchdog/msc313e_wdt.c diff --git a/MAINTAINERS b/MAINTAINERS index a0f37adb9e64..fcc10c57298c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2177,6 +2177,7 @@ F: arch/arm/mach-mstar/ F: drivers/clk/mstar/ F: drivers/gpio/gpio-msc313.c F: drivers/pinctrl/pinctrl-msc313.c +F: drivers/watchdog/msc313e_wdt.c F: include/dt-bindings/clock/mstar-* F: include/dt-bindings/gpio/msc313-gpio.h F: include/soc/mstar/ diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 355100dad60a..f53634ea0de6 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -980,6 +980,19 @@ config VISCONTI_WATCHDOG Say Y here to include support for the watchdog timer in Toshiba Visconti SoCs. +config MSC313E_WATCHDOG + tristate "MStar MSC313e watchdog" + depends on ARCH_MSTARV7 || COMPILE_TEST + depends on OF + select WATCHDOG_CORE + help + Say Y here to include support for the Watchdog timer embedded + into MStar MSC313e chips. This will reboot your system when the + timeout is reached. + + To compile this driver as a module, choose M here: the + module will be called msc313e_wdt. + # X86 (i386 + ia64 + x86_64) Architecture config ACQUIRE_WDT diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index a7eade8b4d45..7fa392ae3000 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -92,6 +92,7 @@ obj-$(CONFIG_SPRD_WATCHDOG) += sprd_wdt.o obj-$(CONFIG_PM8916_WATCHDOG) += pm8916_wdt.o obj-$(CONFIG_ARM_SMC_WATCHDOG) += arm_smc_wdt.o obj-$(CONFIG_VISCONTI_WATCHDOG) += visconti_wdt.o +obj-$(CONFIG_MSC313E_WATCHDOG) += msc313e_wdt.o # X86 (i386 + ia64 + x86_64) Architecture obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o diff --git a/drivers/watchdog/msc313e_wdt.c b/drivers/watchdog/msc313e_wdt.c new file mode 100644 index 000000000000..434259256967 --- /dev/null +++ b/drivers/watchdog/msc313e_wdt.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * MStar WDT driver + * + * Copyright (C) 2019 - 2021 Daniel Palmer + * Copyright (C) 2021 Romain Perier + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define REG_WDT_CLR 0x0 +#define REG_WDT_MAX_PRD_L 0x10 +#define REG_WDT_MAX_PRD_H 0x14 + +#define MSC313E_WDT_DEFAULT_TIMEOUT 30 +/* Supports 1 - 350 sec */ +#define MSC313E_WDT_MIN_TIMEOUT 1 +#define MSC313E_WDT_MAX_TIMEOUT 350 + +static unsigned int timeout; + +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds"); + +struct msc313e_wdt_priv { + void __iomem *base; + struct device *dev; + struct watchdog_device wdev; + struct clk *clk; +}; + +static int msc313e_wdt_start(struct watchdog_device *wdev) +{ + struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev); + u32 timeout; + int err; + + err = clk_prepare_enable(priv->clk); + if (err) { + dev_err(priv->dev, "failed to enable clock\n"); + return err; + } + timeout = wdev->timeout * clk_get_rate(priv->clk); + writew(timeout & 0xffff, priv->base + REG_WDT_MAX_PRD_L); + writew((timeout >> 16) & 0xffff, priv->base + REG_WDT_MAX_PRD_H); + writew(1, priv->base + REG_WDT_CLR); + return 0; +} + +static int msc313e_wdt_ping(struct watchdog_device *wdev) +{ + struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev); + + writew(1, priv->base + REG_WDT_CLR); + return 0; +} + +static int msc313e_wdt_stop(struct watchdog_device *wdev) +{ + struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev); + + writew(0, priv->base + REG_WDT_MAX_PRD_L); + writew(0, priv->base + REG_WDT_MAX_PRD_H); + writew(0, priv->base + REG_WDT_CLR); + clk_disable_unprepare(priv->clk); + return 0; +} + +static int msc313e_wdt_settimeout(struct watchdog_device *wdev, unsigned int new_time) +{ + wdev->timeout = new_time; + + return msc313e_wdt_start(wdev); +} + +static const struct watchdog_info msc313e_wdt_ident = { + .identity = "MSC313e watchdog", + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, +}; + +static const struct watchdog_ops msc313e_wdt_ops = { + .owner = THIS_MODULE, + .start = msc313e_wdt_start, + .stop = msc313e_wdt_stop, + .ping = msc313e_wdt_ping, + .set_timeout = msc313e_wdt_settimeout, +}; + +static const struct of_device_id msc313e_wdt_of_match[] = { + { .compatible = "mstar,msc313e-wdt", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, msc313e_wdt_of_match); + +static int msc313e_wdt_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct msc313e_wdt_priv *priv; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + priv->clk = devm_clk_get(dev, NULL); + if (IS_ERR(priv->clk)) { + dev_err(dev, "No input clock\n"); + return PTR_ERR(priv->clk); + } + + priv->dev = dev; + priv->wdev.info = &msc313e_wdt_ident, + priv->wdev.ops = &msc313e_wdt_ops, + priv->wdev.parent = dev; + priv->wdev.min_timeout = MSC313E_WDT_MIN_TIMEOUT; + priv->wdev.max_timeout = MSC313E_WDT_MAX_TIMEOUT; + priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT; + + watchdog_set_drvdata(&priv->wdev, priv); + + watchdog_init_timeout(&priv->wdev, timeout, dev); + watchdog_stop_on_reboot(&priv->wdev); + watchdog_stop_on_unregister(&priv->wdev); + + return devm_watchdog_register_device(dev, &priv->wdev); +} + +static int __maybe_unused msc313e_wdt_suspend(struct device *dev) +{ + struct msc313e_wdt_priv *priv = dev_get_drvdata(dev); + + if (watchdog_active(&priv->wdev)) + msc313e_wdt_stop(&priv->wdev); + + return 0; +} + +static int __maybe_unused msc313e_wdt_resume(struct device *dev) +{ + struct msc313e_wdt_priv *priv = dev_get_drvdata(dev); + + if (watchdog_active(&priv->wdev)) + msc313e_wdt_start(&priv->wdev); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(msc313e_wdt_pm_ops, msc313e_wdt_suspend, msc313e_wdt_resume); + +static struct platform_driver msc313e_wdt_driver = { + .driver = { + .name = "msc313e-wdt", + .of_match_table = msc313e_wdt_of_match, + .pm = &msc313e_wdt_pm_ops, + }, + .probe = msc313e_wdt_probe, +}; +module_platform_driver(msc313e_wdt_driver); + +MODULE_AUTHOR("Daniel Palmer "); +MODULE_DESCRIPTION("Watchdog driver for MStar MSC313e"); +MODULE_LICENSE("GPL v2"); From patchwork Tue May 25 18:44:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 12279991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46D78C2B9F8 for ; Tue, 25 May 2021 19:07:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0C862613A9 for ; Tue, 25 May 2021 19:07:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C862613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=V/SZ43pb/Vp/pCT5BhYOcVX13K2/rmdEq0oSpiwPq40=; b=1CO9b9LTRBBR5Q 5lZtLAl7Krvxw0TllOgGiozknj59ZA4HcEw/KYhWbXKO8ymwgWhRc/AgSSmuJadQ/fbPrAsQC7z/U jwSET3VkxKj+8Lc5aoc58DaV9RYbRbfLUzMVdyen9+EwCdHX3X2X7FOTb25UBJM1EHf4SZm8LFiMr xpOhUJi8aqOcZUIZvhdaftca/qsNowKegJpd4qNoNiHaTSqmigZF/ILDugGY47qTnVF+X5z0to6yB RpTixCa7vOGNDzkefwLtYxV4OfF68qlwuF9lyvx4XCs+TS8Wyw8lS5b+zbyM/Z3kneU2WzTHvYV5w LUGS7NpBs6xVI4ZB2A+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llcNC-007XqG-Bl; Tue, 25 May 2021 19:05:51 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llc32-007OMy-1y for linux-arm-kernel@lists.infradead.org; Tue, 25 May 2021 18:45:01 +0000 Received: by mail-wr1-x435.google.com with SMTP id i17so33272058wrq.11 for ; Tue, 25 May 2021 11:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bqTv+TFAOMBiEQMLXRI7rx6F3LpfuebvVaCG8zYT/N8=; b=hLav2Q7or125o0zrBzNf5u+ACFiioB2IxHdwFxQ4yGd2FIPHV+8AoIrrXv0y0Am+uR bcXLjdplJ2iz+DIYOkYUlJPj7paVRPy+HceZQXevvK+coIGow13KR08oLVkZ8ykJF85P pyhfmFa1rbU/CCUiAfam8CjjMqioRvEmRiWexQcwh427lx2WmR2y29sRkz6XwwzQrHR7 BVDka9IYtZtYiWixr1gwDlr/MN8M/RcYAOVTil4yn5EBreLr1Uxnn/9qz9qv4fwVXCK6 uxx73F3lKbVj3hkKKJTx6smZW8m8CFPaXdQ7L5q8Eko60kKhAxgTO8eZfZX2vhQIlimV JzvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bqTv+TFAOMBiEQMLXRI7rx6F3LpfuebvVaCG8zYT/N8=; b=QHXx+NOG2pyKEmeZMBhl+67AMb+zzlwFxtKiwxbIc9IrN35MbTZVvigEeiF+31Oct9 jQkBd59xTCDbKtEkezdMN/Ny3bmT16NqOlDj+RIdYxcXEaMe1RiSA6PsSj/kuJCXhvJ8 Pl8hNh6sDnh9AfsxXxQDHZHl1dBhTXwxeqw+RrDW3e7uQDht+JVp1S48cozCj/ojul7p krELPGEuuVWBkqJXuR8TV8NdCHBXLcr51ZGOyQ8qZBPENmeRlB6zLB4QhjFs3UHLPwvo Ga/eRfyYGI4qfwjM3fFS3eCEpCAGrlDWT/bcwNFTRHNUreeEckpCbsXk93vHSO9Gl26S RKXw== X-Gm-Message-State: AOAM533ifA4GIpEU72JKbmk4brqBmbGVollC+1bRdeTS/SaWAojgba7w qakx3fd8JLETzhM6uZyXqZQ= X-Google-Smtp-Source: ABdhPJwor9nnK+rwJRHqFbttHr3fZpGo8vUcaPhHIaSN5bwKEj7DzM7qdy8y/YeHMvQF+EXoQy5PhQ== X-Received: by 2002:a5d:6d83:: with SMTP id l3mr28938777wrs.241.1621968297955; Tue, 25 May 2021 11:44:57 -0700 (PDT) Received: from debby (176-141-241-253.abo.bbox.fr. [176.141.241.253]) by smtp.gmail.com with ESMTPSA id u14sm3595732wmc.41.2021.05.25.11.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 11:44:57 -0700 (PDT) From: Romain Perier To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: Daniel Palmer , Mohammed Billoo , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] ARM: dts: mstar: Add watchdog device_node definition Date: Tue, 25 May 2021 20:44:49 +0200 Message-Id: <20210525184449.57703-4-romain.perier@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210525184449.57703-1-romain.perier@gmail.com> References: <20210525184449.57703-1-romain.perier@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_114500_128404_6192A85D X-CRM114-Status: GOOD ( 11.41 ) 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 adds the definition of both an oscillator at 12Mhz required by the the watchdog and the watchdog device_node. Signed-off-by: Romain Perier --- arch/arm/boot/dts/mstar-v7.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/mstar-v7.dtsi b/arch/arm/boot/dts/mstar-v7.dtsi index 3d5d8c634de3..23dff8fe4731 100644 --- a/arch/arm/boot/dts/mstar-v7.dtsi +++ b/arch/arm/boot/dts/mstar-v7.dtsi @@ -62,6 +62,14 @@ rtc_xtal: rtc_xtal { clock-frequency = <32768>; status = "disabled"; }; + + xtal_div2: xtal_div2 { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&xtal>; + clock-div = <2>; + clock-mult = <1>; + }; }; soc: soc { @@ -119,6 +127,12 @@ pm_irin_pins: pm_irin { }; }; + watchdog: watchdog@6000 { + compatible = "mstar,msc313e-wdt"; + reg = <0x6000 0x1f>; + clocks = <&xtal_div2>; + }; + intc_fiq: interrupt-controller@201310 { compatible = "mstar,mst-intc"; reg = <0x201310 0x40>;