Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp367804imm; Mon, 9 Jul 2018 03:21:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeimJ/uhvr86DU9OJtBKTEQh3SkV9BE+PsKdZxJis/OlRJJGeI5mZMhhgNeevh9MVm3opRv X-Received: by 2002:a62:d75b:: with SMTP id v27-v6mr11256182pfl.79.1531131680193; Mon, 09 Jul 2018 03:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531131680; cv=none; d=google.com; s=arc-20160816; b=xt6fSQ5Vjw6v9vUyg52PRkHxqjtkVvpwvRYNHGIugapE7GALFIU1ix4vnteuWcgpr1 fDHWMtfVuhr1KoClsiSQg3AbaTeaIGLL84qiYqC6A7Kdy2xDHC+K13/xg9BKSfMXmMa/ UkcHJmtQjHc/o56R/Z6sgDVgIEo4waCbZC2ptFrwpSVET9XpEhr0A872I6B1R+aHVVVL uQROaHmbWnk9MrEYMIkPnR+xgMqMYIjvfJT4Bv2JlwTorhTw53EC0r9rU2n80vx4C+aB dkQacQCERyvJGfdGCBcfO2cexLZN5x6g+RsVylmyJqlHQJM9W83/q3btaqxOp58TyOkU QdyA== 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=uRl31Yg0nZV+m4wDWq8yuor2sBkVQZYUU89idLCaUOM=; b=BZEpKiOc48TDwaVsbbI29aCti9VxoElANwhkjpWJmCdZI5jJDZaovquRW+19D+oa6G /KcZc+HUoXXQXYuK3nfSJWnYC4Lgt6qXf9RRR1fe7km6zALxMDmVzZ9nHdILYTpqnqVn WlwJB/7/X0hfQeIqKoJv4NBQO1nu0KlYajphiN2tp49PevkOGhcrZgod8xadMBVT1+zB bGWtClfJsCb1o/mw2KSAIzpWLRDpjpu7NhveXYzqBrZEdMuVvAzZIyw5cvqi+d1Mc82M I300ahalD1J94bzff1q5exBD4yM3HV6qvMs8T2fr35WLhuX/U2GsZccyOMfpiKWbYEco 3yIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="V/w8ll1l"; 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 j30-v6si7884255pgm.26.2018.07.09.03.21.05; Mon, 09 Jul 2018 03:21:20 -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="V/w8ll1l"; 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 S932514AbeGIKT4 (ORCPT + 99 others); Mon, 9 Jul 2018 06:19:56 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:36763 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932415AbeGIKTz (ORCPT ); Mon, 9 Jul 2018 06:19:55 -0400 Received: by mail-qt0-f195.google.com with SMTP id f1-v6so14927801qti.3 for ; Mon, 09 Jul 2018 03:19:55 -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=uRl31Yg0nZV+m4wDWq8yuor2sBkVQZYUU89idLCaUOM=; b=V/w8ll1lS5o+B4fGHmjGV4hRZWyg9NfYoLgVS/qpTL6RadNa1nlZvWod0YRvGERnEp bi0aFaH5FJH15inZ/e9TdnXggh3yKhGF2UP4zCujLRxozPZkEI6HEJN4MXKeeGElbJdP s50fLLKMeJgAOl4Tvoltyf/sDKbWovcVxGYS8= 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=uRl31Yg0nZV+m4wDWq8yuor2sBkVQZYUU89idLCaUOM=; b=MA5kESZLk5mzg01sDCC56H3OgKEBFNW+ehzCUFTq3ownRQHIciB8Dz9g8W+a75ph5q va5WqaGS35+6mP4Zp8C2N2QUziVaL79h7iDCYevL8zHIPByDRDXcCipiGEbGV4nVRD84 Tyly2VHwsYj8zURqwJEy7xqGG8RA1pr+/vjTPzk3xMEPIdlndpiHApfVMEiC56oJk6Gb sUtJv7wOZ1s2TecpRjuhn5nYsguIiv8Jeo6S1YXhGmzGeqDrmqUZPRrYqkCPhtaC8/bK 1ABhpgRBdtoU27U/L4MZQfv7EdnPMjmN3dzlW4rUUFB5PM8Z8HWvyFzyzNOJLbUxaU7n VxOA== X-Gm-Message-State: APt69E1s/Z+TCCZRXcaZTKcHuZ3+Kaorc6WknxPDvbyyXepUNxjEShCI KJ+AF6L9+SLyd2JMUjV3UOhzzw== X-Received: by 2002:a0c:9259:: with SMTP id 25-v6mr16969506qvz.239.1531131594478; Mon, 09 Jul 2018 03:19:54 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y49-v6sm12687507qty.91.2018.07.09.03.19.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jul 2018 03:19:53 -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 v2] watchdog: sp805: Add clock-frequency property Date: Mon, 9 Jul 2018 15:49:29 +0530 Message-Id: <1531131569-13727-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 | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 9849db0..ad5ed64 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,10 +229,27 @@ 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)) { + if (adev->dev.of_node) { + wdt->clk = devm_clk_get(&adev->dev, NULL); + if (IS_ERR(wdt->clk)) { + ret = PTR_ERR(wdt->clk); + wdt->clk = NULL; + } else + 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) + ret = -ENODEV; + } + + if (ret) { dev_warn(&adev->dev, "Clock not found\n"); - ret = PTR_ERR(wdt->clk); goto err; } -- 2.7.4