Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp152613imm; Wed, 4 Jul 2018 20:25:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfw8JevaB2dGUhQuZwi5ELyizgojc8lA4AZA+XxYH8GxnAkL07gj/zMSx+Yl+HscmW9ifBx X-Received: by 2002:a62:9042:: with SMTP id a63-v6mr4593502pfe.52.1530761139574; Wed, 04 Jul 2018 20:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530761139; cv=none; d=google.com; s=arc-20160816; b=YuXnad70OeHMpK1v+F3vYDHC2WbgU6dc3uCq8wzNfmWcp22hgVqY3G5lUkZkg6ir1x UDf58/FHBApN5Qxvn/fJv0VnpGLsekanFVy4Dv6dpwerOa8eHI/afHni1naBkjlOx83S i1KkxK6Y7fwVjeiFrnDnzgKfuUG2XG5/modmCHYUBxpFNShiCEC84mXlLCAL+WZjVoCW S3/9bT+kGbEEDzOGlObZ9H6lRcKwvjZfDkpie/D3JOduMz1YcC0APKKOAjteDPJeaUxX Xm+2S9M8NvYtAO+EeYl71kklmyHwbst3gQ3sRGA+1URa2a76/9N3tz9qqrZStUsU9p0p ytWQ== 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=1zGeJmpHvN4U00B3Qq0ng4BrDyeUhUnaBHoYOE9z8FM=; b=sCCETae7VurffGzzlCbyYOzMMXSzBnNqGeciFRAtejBTSNL73Y5wDA5yHV+By8TyTs JoAN0DdHnViRrX+C+C0BhP1XJ9sXdJXf9kJb6Wt0Xu7/BbWqPMB1ASgZIgUptqKpccWx K1hZhDKRFNoAEpsexG9Z9OzH/WXBXMf/ljOQTSCY7X1C8afU2roK9AQhtr18uEpeSMhX mc/esgR5pQppBLYM3gDrHUV0SSdhfSRMEwYshMx/Tx7Pk08Lg1+TNeCfbi3EmBnwYJyO 1tj4GMumsbyXSDUWPa9zxfBK5SDa2BZiGrIGEXL6nAwHBptMx+XOP7GBvN+xZJ40r73K mwBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=KTJ9peRK; 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 n11-v6si5059885plg.230.2018.07.04.20.24.55; Wed, 04 Jul 2018 20:25:39 -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=KTJ9peRK; 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 S1753096AbeGEDXR (ORCPT + 99 others); Wed, 4 Jul 2018 23:23:17 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39898 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753000AbeGEDXP (ORCPT ); Wed, 4 Jul 2018 23:23:15 -0400 Received: by mail-ed1-f67.google.com with SMTP id w14-v6so5265906eds.6 for ; Wed, 04 Jul 2018 20:23:14 -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=1zGeJmpHvN4U00B3Qq0ng4BrDyeUhUnaBHoYOE9z8FM=; b=KTJ9peRKNE57X+kX9l07GC7vKkGOrlGzqY/nZk7jbhZ0idVO6Oggq4KYymc0Kmujlr jeLbpueC0upqBozH1b1X1s+YqaN+UU09411sHW1ILpEmcJ4aMAY/ekmCAkl+RFFw5pXF hF2nYKbaUZx8Di2V1ME8gIlXgsC7Fj0U4vy0k= 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=1zGeJmpHvN4U00B3Qq0ng4BrDyeUhUnaBHoYOE9z8FM=; b=jvMisrHSd69Wcc8xSSb8utS4e6pcWHvM/Ef3IlEKuI5zxM0giTTxRgAFWeIxrIcHyn WIh3CkcMqozVb5AFnjXr1xNNfdEpFhWV9tcJ9lXSDx1orivmNI2aW3USKUM46JGI2GN8 TWvNrbMlZCsqrKwskIxnl2eYqpTzOZGzML3xJIVf6+WVdQFSbomheLzQ0jICvjCfWr8d MeGdnBqDqBP7GkFFdoXWG5J5wO1c2GmfEru4gZapss+9pYnjhZh3IRjwaTDqVyNeRXJo B7AlPqXWNAOXyYVA0iOm4DB0luUS0RpFgAEL8blVVxE3Tsvs0ZrQk8wJ1lPD58KQsRJ+ CaBA== X-Gm-Message-State: APt69E1/D10IPAMivOiJ3X3VS3s/UdAR71vlWshWYG0aRthIJP1bI3lN V/utjGTGanlqrLdpacxziI6b/A== X-Received: by 2002:a50:cb4c:: with SMTP id h12-v6mr4912467edi.158.1530760994032; Wed, 04 Jul 2018 20:23:14 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id z4-v6sm2501828edi.90.2018.07.04.20.23.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Jul 2018 20:23:13 -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] watchdog: sp805: Add clock-frequency property Date: Thu, 5 Jul 2018 08:52:48 +0530 Message-Id: <1530760968-13104-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 | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 9849db0..d830dbc 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,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 +82,10 @@ 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); + if (wdt->rate) + rate = wdt->rate; + else + rate = clk_get_rate(wdt->clk); /* * sp805 runs counter with given value twice, after the end of first @@ -108,7 +113,10 @@ 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); + if (wdt->rate) + rate = wdt->rate; + else + rate = clk_get_rate(wdt->clk); spin_lock(&wdt->lock); load = readl_relaxed(wdt->base + WDTVALUE); @@ -230,11 +238,22 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) 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; + dev_warn(&adev->dev, "Clock device not found\n"); + wdt->clk = NULL; + /* + * 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; + goto err; + } } + wdt->adev = adev; wdt->wdd.info = &wdt_info; wdt->wdd.ops = &wdt_ops; -- 2.7.4