Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1444124imm; Tue, 10 Jul 2018 01:46:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpffiagwSYz2r681DbGj4QaQNqwF3dcf1khQo2j8r6o78ZW+zCkMNL41azvO48v5hs+fVuA+ X-Received: by 2002:a65:510c:: with SMTP id f12-v6mr21279225pgq.288.1531212373777; Tue, 10 Jul 2018 01:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531212373; cv=none; d=google.com; s=arc-20160816; b=uzBPo9sXOzheA0t2ROYFl3KqSAX29smPS7myYYcX9806St8voVDUrnt/EHIns/HH18 eJKc8twc8jloohJOxvdfbsCvy04R0ROeoQZpZYoGjkRcal+4PC3iQyALRVqJKlos6Ki9 RYpShNNpDc6JKnBDmcGCsygSbQ7yW7Bj7uGeVe3DY5xqXEpESi9OoFrWwHULpRQg5NSM JtV0IY+SD3bY2DM5h0QPChow1VmRPXQYfzOsVF2bv1dvZ1Y0vCJPeFI6/lYtQY8159HH HByvTpvo8VUFSL9MrPBL3j1YPWaIL9wbBwvoe/AnUX139hUVKdFqI4VNwhwcugNzfPNq qgaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=+GIAKQDQFSFQztEFMaVeioL3lzy9BxfSG2/K3Fqo07E=; b=UOCs+CXtAXq7O+ca6TQVxsQaAg097tOpW5kw2PBzrUQlBvZJ7GFG7kfWQ4/tFfl3Qa qFXnsKQkBmErAV92gPWkbf17NMjFj5PAs1vtkoDsg69Zm75+7zWfGkAMv8ic3Y/Hvjsi GIir1A2pk/oQ1OEyeOmm83wcPQwIXCsQBjOuajd2TEZK63LLFfUAtxvARzjiI0Z7P8O/ 4v0cZIV1Y3YKrvCOZbzW8d6NlqSN9h9smtjlwAgJPuuGCiO9F6N5lg7FWGrz9AyOzlAr 4wAmPeyU8x9UlYjZYHoezzdVWuiNgau+mOWOC4y0rhA245maJmoPVevSABH4FbqzokDC bf2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=YBEGkGit; 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 d11-v6si7471778pgh.564.2018.07.10.01.45.59; Tue, 10 Jul 2018 01:46:13 -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=YBEGkGit; 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 S933166AbeGJIo4 (ORCPT + 99 others); Tue, 10 Jul 2018 04:44:56 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:45229 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751432AbeGJIoy (ORCPT ); Tue, 10 Jul 2018 04:44:54 -0400 Received: by mail-qt0-f196.google.com with SMTP id y5-v6so17641973qti.12 for ; Tue, 10 Jul 2018 01:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=+GIAKQDQFSFQztEFMaVeioL3lzy9BxfSG2/K3Fqo07E=; b=YBEGkGitM+tKnduN/qc3hKn+WfJnPZM3oOYcvwV8fqm0GRbbGFaFgf2pWpUU+m7+oD Lrcd7qf8VP62kNRoEvb+3C35rn3+k87m4SnAYuZdq7028GkuI4gXaG7bANqkQTk4jZE0 PhIUom0Cop5oiO8jYP+CabtfnanSibFrXthhM= 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; bh=+GIAKQDQFSFQztEFMaVeioL3lzy9BxfSG2/K3Fqo07E=; b=D49ViDKCRx3MOCFxu+XOfR0fhZ0619/vVI3bm+h2KV97Wns6WOsrUBjEvy6vbygiZJ fLUAm+JA8YV9po5Rjfw1s51TbUJBJ0CdRbNRDp8LBgfnxVrpB6oJ5HFtpt/ovQLLVUVK THwi1psCbw89caFiqDynWuNaON1Q2CZAgJsC0YMGmzOs/qgIpMVOVEm+y/S6Qk5+LwpF AYUl314GgxrqektDj+X5SeHMVBooOdWBgRQByWByag8vuDMqPKuj8sFxUBftCtQLPQsu subKA+uEAbZR1tA186h9Tkuff2sPicpjtdN/mr70qtK3gQHs2Bgncd+rVG/Qu2GeoDbi sQfw== X-Gm-Message-State: APt69E0Bp5ZHTVE+EsfhXeH4yh+IWs6Ummmcr/3XAyE1Emz6jWRhJLuZ uu0xCW0U7nx2S/SrvapIMfaVhw== X-Received: by 2002:a0c:aa06:: with SMTP id d6-v6mr20436334qvb.26.1531212293826; Tue, 10 Jul 2018 01:44:53 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id j20-v6sm13893422qtc.71.2018.07.10.01.44.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jul 2018 01:44:52 -0700 (PDT) From: Srinath Mannam To: wim@linux-watchdog.org, linux@roeck-us.net Cc: 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, Srinath Mannam Subject: [RFC PATCH v3] watchdog: sp805: Add clock-frequency property Date: Tue, 10 Jul 2018 14:14:39 +0530 Message-Id: <1531212279-24953-1-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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