Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp678059imm; Wed, 11 Jul 2018 09:07:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpceDQRcWa5ENyJwX0V2dctm/VcHbTG6B+70QNVqJc8ip1bIY+6VIXpuwRmXIu4BFJKqpfBa X-Received: by 2002:a63:6986:: with SMTP id e128-v6mr5303945pgc.294.1531325254324; Wed, 11 Jul 2018 09:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531325254; cv=none; d=google.com; s=arc-20160816; b=lSXi/YMkYmQdtQ5CzCjcAyrENR1HZTfdrSVT6BUHHwPfUhMdwu73s9cRbpXCEo7qHd hsH7IiZ5lS2DzDN6vrqwgipo5DNBZ46CXk0TgBR7q8kGbdG3xd24rc/6Nlt4VQfKJigN AxowpKeZJ/WksSIg5jfw9qi7BvETSy7+qwijMg+YmXeE74wYtAxFE7rANqz5cyN86Gh7 AvnnwgrplocDLwbXG5RUIGiZlimfk0qsSXY5ybxJESUggI9uweLoxXGwzb7Eh5OHPubP KEXTSSCbeR1OyGeGw2brxw18Y3Zpts0XCPuCtS8atvfnGsvcTpOnbi6KIJI8eHQM+M0T XfuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=QhVTkzbwCT3RtWFB8UdfVw5N/go9nXIBH3n1C2C3Zi8=; b=zFH13WEp2jLqs42YTsMracCSbJg5BWIPJHFpaF8HzYDPYjeO3OGUGugp41KbqRbevd 1BG0ZgpIEywi+fFdT9T6htPYmDasA0HQyJl+KLjLT86wZM8y4+TFyaYg83nNNKMhyjzM l/19AS0F8gY7X+u2hyHHwn0rQPIKEPgApCgj0XYpIBjoEegWT/ezPUZS6mgUKaI7iFtM +QTC27dVsBZ8wTIPZkJRQvlcJSNN7Ti4DbmJIzv7bUF2z4shQ7R4WKo+CdOf3ntiQdJa X1RZKNcgnfTmUNoASEX19kSh5qlKrENAN+eTDrwREWmxmB0ngZbnlxqv7UHZ8E77zMZ8 yLgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=WE++S9oh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o189-v6si18463115pga.577.2018.07.11.09.07.18; Wed, 11 Jul 2018 09:07:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=WE++S9oh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387765AbeGKN1M (ORCPT + 99 others); Wed, 11 Jul 2018 09:27:12 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:37601 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732530AbeGKN1M (ORCPT ); Wed, 11 Jul 2018 09:27:12 -0400 Received: by mail-oi0-f67.google.com with SMTP id k81-v6so49175249oib.4 for ; Wed, 11 Jul 2018 06:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QhVTkzbwCT3RtWFB8UdfVw5N/go9nXIBH3n1C2C3Zi8=; b=WE++S9ohXoWtyo/RMv13Ey5ZkxaHtFJl+1k/75JUx1uhSV79CwdCOb8Gvd7h5oGQ+K IT71xf6Vmyy4udSjdL/693RP/ErTvRjC2hO6g69c5H/+gqMdr36s6AdvuWDwbe/YTluB sc8VGbjPE1raPZrbJgzXF/N11yEL5q05QmBWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QhVTkzbwCT3RtWFB8UdfVw5N/go9nXIBH3n1C2C3Zi8=; b=AFah2inO412ISaXniCvv2rcZ3k5KdPCwJihRpGI2SKZyTiIEUbuI1iBmZCOVQBDMpp x+o/Ga7DYH/z2auxTviwouKEP2pcAdl3xfsbZLDrjFf2z+HMHkrxB/muDt0L4zjZijOr Zm62eGOOgEZC2C1h1oBecJcgxZHhQEZDN28/PtJsra2nAmyAHG7A3x8Opvo+QO8iP56H ZFi8enf/3GvB7mVuGogsN8cALo7Jo1M6IYPmRl9tacp/hEaD4toeC5Lw90gL3uAV1n+k SqxPknnY2JaPdmvgULRiXJeIkJ2ggd5QOOD2JlerTrM4giMLo6gHkY+S1OsesOiCmIEc fOcg== X-Gm-Message-State: APt69E1lkak1SDe645yaJc54zgpk44gBbuwKoh3THf2aUixqyLYAAg/d SPYLTqQ2+GlzcI+CqpvbUdG+HP+A8ittph54Nvk1YA== X-Received: by 2002:aca:afcc:: with SMTP id y195-v6mr33866249oie.322.1531315372148; Wed, 11 Jul 2018 06:22:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:6043:0:0:0:0:0 with HTTP; Wed, 11 Jul 2018 06:22:51 -0700 (PDT) In-Reply-To: <20180710213557.GC27827@roeck-us.net> References: <1531212279-24953-1-git-send-email-srinath.mannam@broadcom.com> <20180710213557.GC27827@roeck-us.net> From: Srinath Mannam Date: Wed, 11 Jul 2018 18:52:51 +0530 Message-ID: Subject: Re: [RFC PATCH v3] watchdog: sp805: Add clock-frequency property To: Guenter Roeck Cc: wim@linux-watchdog.org, Ray Jui , Vladimir Olovyannikov , Vikram Prakash , Scott Branden , Sudeep Holla , linux-watchdog@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, Thank you very much for all the help with your feedback and review comments to complete the changes very fast. About the documentation.. I have gone through few similar patches available in the kernel are listed in the mail of previous version. No documentation available in Linux for the properties used in those patches also. For example, 1: "src-clock-hz" property added in the part of ACPI support with the below patch. Patch details: commit 515da746983bc6382e380ba8b1ce9345a9550ffe Author: Naveen Kaje Date: Tue Oct 11 10:27:56 2016 -0600 i2c: qup: add ACPI support 2: "amd,dma-freq" property added in the part of ACPI support with the below patch commit 82a19035d000c8b4fd7d6f61b614f63dec75d389 Author: Lendacky, Thomas Date: Fri Jan 16 12:47:16 2015 -0600 amd-xgbe: Add ACPI support Regards, Srinath. On Wed, Jul 11, 2018 at 3:05 AM, Guenter Roeck wrote: > On Tue, Jul 10, 2018 at 02:14:39PM +0530, Srinath Mannam wrote: >> When using ACPI node, binding clock devices are >> not available as device tree, So clock-frequency >> property given in _DSD object of ACPI device is >> used to calculate Watchdog rate. >> >> Signed-off-by: Srinath Mannam > > I am ok with the patch itself. All that is missing now is a > reference to the _DSD property documentation. Is that published > somewhere or is it all wild-wild-west ? > > Thanks, > Guenter > >> --- >> drivers/watchdog/sp805_wdt.c | 35 +++++++++++++++++++++++++---------- >> 1 file changed, 25 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c >> index 9849db0..a896b1c 100644 >> --- a/drivers/watchdog/sp805_wdt.c >> +++ b/drivers/watchdog/sp805_wdt.c >> @@ -11,6 +11,7 @@ >> * warranty of any kind, whether express or implied. >> */ >> >> +#include >> #include >> #include >> #include >> @@ -22,6 +23,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -65,6 +67,7 @@ struct sp805_wdt { >> spinlock_t lock; >> void __iomem *base; >> struct clk *clk; >> + u64 rate; >> struct amba_device *adev; >> unsigned int load_val; >> }; >> @@ -80,7 +83,7 @@ static int wdt_setload(struct watchdog_device *wdd, unsigned int timeout) >> struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); >> u64 load, rate; >> >> - rate = clk_get_rate(wdt->clk); >> + rate = wdt->rate; >> >> /* >> * sp805 runs counter with given value twice, after the end of first >> @@ -106,9 +109,7 @@ static int wdt_setload(struct watchdog_device *wdd, unsigned int timeout) >> static unsigned int wdt_timeleft(struct watchdog_device *wdd) >> { >> struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); >> - u64 load, rate; >> - >> - rate = clk_get_rate(wdt->clk); >> + u64 load; >> >> spin_lock(&wdt->lock); >> load = readl_relaxed(wdt->base + WDTVALUE); >> @@ -118,7 +119,7 @@ static unsigned int wdt_timeleft(struct watchdog_device *wdd) >> load += wdt->load_val + 1; >> spin_unlock(&wdt->lock); >> >> - return div_u64(load, rate); >> + return div_u64(load, wdt->rate); >> } >> >> static int >> @@ -228,11 +229,25 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) >> if (IS_ERR(wdt->base)) >> return PTR_ERR(wdt->base); >> >> - wdt->clk = devm_clk_get(&adev->dev, NULL); >> - if (IS_ERR(wdt->clk)) { >> - dev_warn(&adev->dev, "Clock not found\n"); >> - ret = PTR_ERR(wdt->clk); >> - goto err; >> + if (adev->dev.of_node) { >> + wdt->clk = devm_clk_get(&adev->dev, NULL); >> + if (IS_ERR(wdt->clk)) { >> + dev_err(&adev->dev, "Clock not found\n"); >> + return PTR_ERR(wdt->clk); >> + } >> + wdt->rate = clk_get_rate(wdt->clk); >> + } else if (has_acpi_companion(&adev->dev)) { >> + /* >> + * When Driver probe with ACPI device, clock devices >> + * are not available, so watchdog rate get from >> + * clock-frequency property given in _DSD object. >> + */ >> + device_property_read_u64(&adev->dev, "clock-frequency", >> + &wdt->rate); >> + if (!wdt->rate) { >> + dev_err(&adev->dev, "no clock-frequency property\n"); >> + return -ENODEV; >> + } >> } >> >> wdt->adev = adev; >> -- >> 2.7.4 >>