From patchwork Fri Aug 12 06:42:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 658534 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3s9b0d1qCFz9sXy for ; Fri, 12 Aug 2016 16:42:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=kBcMmQMl; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750964AbcHLGmX convert rfc822-to-8bit (ORCPT ); Fri, 12 Aug 2016 02:42:23 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:32921 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbcHLGmX (ORCPT ); Fri, 12 Aug 2016 02:42:23 -0400 Received: by mail-qk0-f196.google.com with SMTP id x189so1397321qkd.0; Thu, 11 Aug 2016 23:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=HqCi0fv6gX7qs4VRR/j7Ez66Q3Ckr0FFAAEAbpVX+kI=; b=kBcMmQMloDogHD7y3SSz/ylh54SDgdt/+cD5WOEvc80AXIrSpm7oIe8/6Wekol+UHr Jh04pNRch+C1W7oXdX2bRJvTo0wT4XMqGpQuYqfCaFFS5KHJqMe6R0HZkqWTCnr6jZMm 1Z4ag73F1W/pCDJL8vtqFh1YCk82hq77DEmLxnmDndWx7DRiGWZYm9Z1v/8bsIT1y1oq JracXZa/zKcved9o6Y8U9w3gRdot6/XSnTCv9KE2Y2jFhr3HYofxPNxXXx1mj344EQ/I hmvMhD3qGxVCRmZCC+juGy8DEUlx0weOqlNzqWCtD/otGoF5bOu87Gejx859Gf5iYBwL ikbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=HqCi0fv6gX7qs4VRR/j7Ez66Q3Ckr0FFAAEAbpVX+kI=; b=JVciocEKFEdn9zjyJ5lEWQDlUARtgMk23giziKY7QCQ4ZbtZHLH0sFFKX7vX9axjUc ZonAL1n9c2OPnhjfw45dnJNiXyxfVsnJNY8uUNPMUGjrYTpTMjzfbs4RkRw7Vkk9JsJV tiEKP+d8gjd1uwlnUsvHxdDEc3yDXd1Env2ur76NABhpwSZDgL9/Bk2P2vAlqyISaNFF rOGuApUXyjQMocozhe3PZ9IdlpiZnoFv76bOq89+y5efTwBbU+Q7m/MxBuDkHyMESULB Jhf2o+i4UsivVf6q2kqJh4MxymsC+wtSztaWO7nmI4LZpsIzsMFpPGzDR0ZfyDcIZ9aE 9jyw== X-Gm-Message-State: AEkoout0GGfJRxlfD+siyLXyb2LaJR/Et2wOS+2duIwEmd3D3P5pvHU5WrveB/mu/gzVMk4uX+WM5oQgWNRPCQ== X-Received: by 10.55.122.4 with SMTP id v4mr15000657qkc.136.1470984142073; Thu, 11 Aug 2016 23:42:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.34.135 with HTTP; Thu, 11 Aug 2016 23:42:21 -0700 (PDT) In-Reply-To: <1a86f6d6-fc92-81ec-eb07-669c2bda8b38@roeck-us.net> References: <1470982664-13228-1-git-send-email-shubhrajyoti.datta@xilinx.com> <1a86f6d6-fc92-81ec-eb07-669c2bda8b38@roeck-us.net> From: Shubhrajyoti Datta Date: Fri, 12 Aug 2016 12:12:21 +0530 Message-ID: Subject: Re: [PATCHv4] watchdog: xilinx: Add clock support To: Guenter Roeck Cc: Shubhrajyoti Datta , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, =?UTF-8?Q?S=C3=B6ren_Brinkmann?= , Michal Simek , wim@iguana.be Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org [...] > > > The clock is optional. Why print anything ? > > I am not a friend of logging noise, and I think this is just noise. > Would you want such a message printed for each optional property ? > > Guenter > sure patch below From: Shubhrajyoti Datta Subject: [PATCH] watchdog: xilinx: Add clock support Add support for the clock. Currently we enable at probe and relinquish at remove. Reviewed-by: Guenter Roeck Acked-by: Sören Brinkmann Signed-off-by: Shubhrajyoti Datta --- v2: fix spaces and error path. v3 do not fail existing dts v4: fix the error prints as the clock is optional .../devicetree/bindings/watchdog/of-xilinx-wdt.txt | 3 +++ drivers/watchdog/of_xilinx_wdt.c | 25 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/watchdog/of-xilinx-wdt.txt b/Documentation/devicetree/bindings/watchdog/of-xilinx-wdt.txt index 6d63782..c6ae9c9 100644 --- a/Documentation/devicetree/bindings/watchdog/of-xilinx-wdt.txt +++ b/Documentation/devicetree/bindings/watchdog/of-xilinx-wdt.txt @@ -7,6 +7,8 @@ Required properties: - reg : Physical base address and size Optional properties: +- clocks : Input clock specifier. Refer to common clock + bindings. - clock-frequency : Frequency of clock in Hz - xlnx,wdt-enable-once : 0 - Watchdog can be restarted 1 - Watchdog can be enabled just once @@ -17,6 +19,7 @@ Example: axi-timebase-wdt@40100000 { clock-frequency = <50000000>; compatible = "xlnx,xps-timebase-wdt-1.00.a"; + clocks = <&clkc 15>; reg = <0x40100000 0x10000>; xlnx,wdt-enable-once = <0x0>; xlnx,wdt-interval = <0x1b>; diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index b2e1b4c..fae7fe9 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -10,6 +10,7 @@ * 2 of the License, or (at your option) any later version. */ +#include #include #include #include @@ -45,6 +46,7 @@ struct xwdt_device { u32 wdt_interval; spinlock_t spinlock; struct watchdog_device xilinx_wdt_wdd; + struct clk *clk; }; static int xilinx_wdt_start(struct watchdog_device *wdd) @@ -195,16 +197,30 @@ static int xwdt_probe(struct platform_device *pdev) spin_lock_init(&xdev->spinlock); watchdog_set_drvdata(xilinx_wdt_wdd, xdev); + xdev->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(xdev->clk)) { + if (PTR_ERR(xdev->clk) == -ENOENT) + xdev->clk = NULL; + else + return PTR_ERR(xdev->clk); + } + + rc = clk_prepare_enable(xdev->clk); + if (rc) { + dev_err(&pdev->dev, "unable to enable clock\n"); + return rc; + } + rc = xwdt_selftest(xdev); if (rc == XWT_TIMER_FAILED) { dev_err(&pdev->dev, "SelfTest routine error\n"); - return rc; + goto err_clk_disable; } rc = watchdog_register_device(xilinx_wdt_wdd); if (rc) { dev_err(&pdev->dev, "Cannot register watchdog (err=%d)\n", rc); - return rc; + goto err_clk_disable; } dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", @@ -213,6 +229,10 @@ static int xwdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, xdev); return 0; +err_clk_disable: + clk_disable_unprepare(xdev->clk); + + return rc; } static int xwdt_remove(struct platform_device *pdev) @@ -220,6 +240,7 @@ static int xwdt_remove(struct platform_device *pdev) struct xwdt_device *xdev = platform_get_drvdata(pdev); watchdog_unregister_device(&xdev->xilinx_wdt_wdd); + clk_disable_unprepare(xdev->clk); return 0; }