Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2167467imm; Tue, 10 Jul 2018 14:36:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd+agnSD9YTlq6H87zJOjeCoShbBp+kin9eINR4gAjqLsOUzxLX00L4esi2tUzrRvzYQD9f X-Received: by 2002:a17:902:8f86:: with SMTP id z6-v6mr26163289plo.38.1531258610697; Tue, 10 Jul 2018 14:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531258610; cv=none; d=google.com; s=arc-20160816; b=ccS4gTMehsK7U9icQEJNj+sfiWE0Ljq/WUhtovu1RyMryrEuyqKatC3ADoSPoam0cd GLXS9o4OLROt5K/pa0esawYq7FpW/bQ3JSlI1WbwKnxm3BlpzTCDpcqO5Oig1yXlImnh 6UuCYbeiJ2oKqKE5b4ivThIKVayOZ/DuGIT2llBHDbusQCcQb9oHiwL2CDKE/iEmr9gi 2fi5yatQM0xfRUXPh+6fuP9cvFTKvrNrwgS9Lxs3d2oVaz6vwT16u8WgwWulXjG/sdJS gNOL+fzAEJb33YO6XFumShHkFlvXpzR+aCx/qrV9Y/Hen53Vyh/ZcyeKraYfohw34Jdz VO9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=LKV21Fl+v2nZYQzvxZIvkHBSN4bgL0UNTBs2GR0iKmU=; b=tPOkMzS82WInClJlttrzygawMfyiijlVvZDsq5JDPT2r6tviMoVsYNW8mRZdH8fkEL jFnfqg9khjMJfkT3o5f0YfTHhTvPijY5eLX69yb1H65719vTjSjrJhXtLiqMriOWgjMf 4NI1UbgEnidRjMMdqhfgpIuP2/wLxVjNSZ6iFXxtvF8eby1ve2oQLDiuXGDjAqwcN0RX fHIWAutbfk+pl7R8EwUl/iE/wa2xRT8WHYLApDYY1AI4Uc15MVbBj/H3XfpPqTYAW0EG PWVVDz0Pz+7TRhy3sUFevsml0+qN/rR2Iu1b2qkSzPdwkPOB11OVcBHfaUjDu7wE1jbd +a/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CBOmhhjs; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3-v6si16565517pgr.44.2018.07.10.14.36.34; Tue, 10 Jul 2018 14:36:50 -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=fail header.i=@gmail.com header.s=20161025 header.b=CBOmhhjs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732314AbeGJVg7 (ORCPT + 99 others); Tue, 10 Jul 2018 17:36:59 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33710 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732242AbeGJVg7 (ORCPT ); Tue, 10 Jul 2018 17:36:59 -0400 Received: by mail-pg1-f193.google.com with SMTP id r5-v6so2289147pgv.0; Tue, 10 Jul 2018 14:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LKV21Fl+v2nZYQzvxZIvkHBSN4bgL0UNTBs2GR0iKmU=; b=CBOmhhjsGWT6I6FlB3NaIYkT/BpP4aKmyPSpgGfe7sF+AksjCUsGBWh+L47BgROJn6 bxVi8vQRKx8Vmz6AzMtONNQAA1kgbjlJVFc3N88Vc1SRtiNa/tyiDSLnhRXm7qs2WsgM yXiqiwi7Bps/+6ez45367WCJb9hbtfQ6wGVyLx3DQMwFe/BlgBGtT5X6eDMIHkJgpEtG a6U+tz0RvXRrmr3a3BQLfQLsjfuZd9UGfjgCEp9eCc7WthNh/WsJSj8yo6/kK602xuEm xOYsLfci6N6qcLdjR57tSHl71/GvVTv6yiuPMFu7hsTr3dqgjN60eEGmQlawVzSpQcnr e+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=LKV21Fl+v2nZYQzvxZIvkHBSN4bgL0UNTBs2GR0iKmU=; b=G6ZXctQ2hq93vQTTqlsNbIhPFhlSxGZJyAidVnAwl5lP+JDQL66/lNS261azSgrGjQ WymbnB6msbJ9eJTEDhW6VTLCNcUpS9Sr8rgWsKp/a6U9BSUrMLm2oLsymp1jYOYEUK5+ xveHCfXNNKux1RqQVcEyvnp3CaEJn4/1FoYcXlxRXLtcX0++zYb+no5z18pLN+C1khT6 4G5a28H+Le2t6UyH+ffNuRpGgO2azBeI3StPx14mGZlB5RvC3KNr9g1ZN2PDdZSMZXct wTQQHYZpNDh0YDQs+6ePQZ8cYhKRBl1Bu+0PBnDPmvZeVAPJ/yDSSUfjs2J51qXYphz9 SA4g== X-Gm-Message-State: APt69E1otRJzOCXwA002EQMwPeSsRDoOMiEg1tNi/33lCJgnNbt3z/4y Rrvr3VW5jQ/llavqo+pkcRM= X-Received: by 2002:a62:129a:: with SMTP id 26-v6mr27450041pfs.102.1531258559612; Tue, 10 Jul 2018 14:35:59 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id d11-v6sm28927544pfo.135.2018.07.10.14.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 14:35:58 -0700 (PDT) Date: Tue, 10 Jul 2018 14:35:57 -0700 From: Guenter Roeck To: Srinath Mannam Cc: wim@linux-watchdog.org, ray.jui@broadcom.com, vladimir.olovyannikov@broadcom.com, vikram.prakash@broadcom.com, scott.branden@broadcom.com, sudeep.holla@arm.com, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3] watchdog: sp805: Add clock-frequency property Message-ID: <20180710213557.GC27827@roeck-us.net> References: <1531212279-24953-1-git-send-email-srinath.mannam@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1531212279-24953-1-git-send-email-srinath.mannam@broadcom.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >