From patchwork Wed Jan 31 18:24:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 10194583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78DDE603EE for ; Wed, 31 Jan 2018 18:29:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D23F25223 for ; Wed, 31 Jan 2018 18:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 715F9286C8; Wed, 31 Jan 2018 18:29:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3716925223 for ; Wed, 31 Jan 2018 18:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3FoZCmtRNX6prl7xodiiCNCGCluk2Ioq9YCcwOKggj8=; b=Hohw8fkqjPQz+nCu724ng/3Vtu 3Nk5P2A54JmDnkS3NI02ac0xrOUOLdSbw4gp4gPkPspbz5q2QG92tMwJJDq5ngNQCvYIISAYYGfOM IPDZ88XqSO1pPQ8dlPDlFFZCMyv7MA3IZcm51/wwt/rIc+nBbEyubrg3okEc7ivG+8zE7EQDkUtfj tO7K0J6D4bUCOB1IbAzHJ80NnCQEmwL+1C/f4TAnyq71WCXVTW922pW8K8etDO0BvEOZNuxRJBW+o 12XgYiCCdSpNkTkScKIrRXyKzP13kSYDE3/+0YZCFTRx0XRynMmU4qSzxzUxZNRkyo/hFCj42rr+e dI454ikw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1egx8V-0003pc-Kz; Wed, 31 Jan 2018 18:29:31 +0000 Received: from relmlor3.renesas.com ([210.160.252.173] helo=relmlie2.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1egx5D-0000j3-26 for linux-arm-kernel@lists.infradead.org; Wed, 31 Jan 2018 18:26:30 +0000 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 01 Feb 2018 03:25:56 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 2E50D413D7; Thu, 1 Feb 2018 03:25:56 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.46,441,1511794800"; d="scan'208";a="271234848" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.37.88]) by relmlii2.idc.renesas.com with ESMTP; 01 Feb 2018 03:25:49 +0900 From: Fabrizio Castro To: Philipp Zabel , Rob Herring , Mark Rutland , Wim Van Sebroeck , Russell King , Catalin Marinas , Will Deacon , Michael Turquette , Stephen Boyd , Simon Horman , Magnus Damm , Geert Uytterhoeven , Wolfram Sang Subject: [RFC v4 12/26] watchdog: renesas_wdt: Add R-Car Gen2 support Date: Wed, 31 Jan 2018 18:24:16 +0000 Message-Id: <1517423070-24236-13-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabrizio Castro , devicetree@vger.kernel.org, Chris Paterson , linux-watchdog@vger.kernel.org, Biju Das , linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ramesh Shanmugasundaram , linux-clk@vger.kernel.org, Guenter Roeck MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Due to commits: * "ARM: shmobile: Add watchdog support", * "ARM: shmobile: rcar-gen2: Add watchdog support", and * "soc: renesas: rcar-rst: Enable watchdog as reset trigger for Gen2", we now have everything we needed for the watchdog to work on Gen2 and RZ/G1. This commit adds "renesas,rcar-gen2-wdt" as compatible string for R-Car Gen2 and RZ/G1, and since on those platforms the rwdt clock needs to be always ON, when suspending to RAM we need to explicitly disable the counting by clearing TME from RWTCSRA. Signed-off-by: Fabrizio Castro Signed-off-by: Ramesh Shanmugasundaram --- v3->4: * in this new version the changes to the driver have been splitted into two commits, this patch takes care of the basic Gen2 support, patch 13/26 takes care of the restart handler. drivers/watchdog/renesas_wdt.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index 831ef83..0a1a402 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c @@ -203,13 +203,42 @@ static int rwdt_remove(struct platform_device *pdev) return 0; } -/* - * This driver does also fit for R-Car Gen2 (r8a779[0-4]) WDT. However, for SMP - * to work there, one also needs a RESET (RST) driver which does not exist yet - * due to HW issues. This needs to be solved before adding compatibles here. - */ +#ifdef CONFIG_PM +static int rwdt_suspend(struct device *dev) +{ + struct platform_device *pdev; + struct rwdt_priv *priv; + + pdev = to_platform_device(dev); + priv = platform_get_drvdata(pdev); + if (watchdog_active(&priv->wdev)) { + rwdt_write(priv, priv->cks, RWTCSRA); + } + return 0; +} + +static int rwdt_resume(struct device *dev) +{ + struct platform_device *pdev; + struct rwdt_priv *priv; + + pdev = to_platform_device(dev); + priv = platform_get_drvdata(pdev); + if (watchdog_active(&priv->wdev)) { + rwdt_write(priv, priv->cks | RWTCSRA_TME, RWTCSRA); + } + return 0; +} + +static const struct dev_pm_ops rwdt_pm = { + .suspend = rwdt_suspend, + .resume = rwdt_resume, +}; +#endif + static const struct of_device_id rwdt_ids[] = { { .compatible = "renesas,rcar-gen3-wdt", }, + { .compatible = "renesas,rcar-gen2-wdt", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, rwdt_ids); @@ -218,6 +247,9 @@ static struct platform_driver rwdt_driver = { .driver = { .name = "renesas_wdt", .of_match_table = rwdt_ids, +#ifdef CONFIG_PM + .pm = &rwdt_pm, +#endif }, .probe = rwdt_probe, .remove = rwdt_remove,