From patchwork Tue Jan 7 18:57:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 3449701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2D199C02DC for ; Tue, 7 Jan 2014 18:59:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 589E120125 for ; Tue, 7 Jan 2014 18:59:57 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 71E9D200ED for ; Tue, 7 Jan 2014 18:59:56 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0brG-0006QC-AW; Tue, 07 Jan 2014 18:58:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0br1-0000CZ-Br; Tue, 07 Jan 2014 18:58:19 +0000 Received: from jacques.telenet-ops.be ([195.130.132.50]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0bqZ-00008u-Bg for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2014 18:57:52 +0000 Received: from ayla.of.borg ([84.193.72.141]) by jacques.telenet-ops.be with bizsmtp id B6xU1n01B32ts5g0J6xUSH; Tue, 07 Jan 2014 19:57:29 +0100 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1W0bqC-0001dI-ED; Tue, 07 Jan 2014 19:57:28 +0100 From: Geert Uytterhoeven To: Zhang Rui , Eduardo Valentin , Simon Horman , Magnus Damm , Kuninori Morimoto Subject: [PATCH 3/4] thermal: rcar: Add missing clock handling Date: Tue, 7 Jan 2014 19:57:15 +0100 Message-Id: <1389121036-3555-4-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389121036-3555-1-git-send-email-geert@linux-m68k.org> References: <1389121036-3555-1-git-send-email-geert@linux-m68k.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140107_135751_745171_A693D0BF X-CRM114-Status: GOOD ( 14.85 ) X-Spam-Score: -1.9 (-) Cc: Geert Uytterhoeven , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Geert Uytterhoeven When using DT to instantiate the rcar-thermal device, it prints the following error: rcar_thermal e61f0000.thermal: thermal sensor was broken Explicitly request and enable the thermal clock to fix this. Signed-off-by: Geert Uytterhoeven --- drivers/thermal/rcar_thermal.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 88f92e1a9944..a5629500723a 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -17,6 +17,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include #include @@ -53,6 +54,7 @@ struct rcar_thermal_common { struct device *dev; struct list_head head; spinlock_t lock; + struct clk *clk; }; struct rcar_thermal_priv { @@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device *pdev) spin_lock_init(&common->lock); common->dev = dev; + common->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(common->clk)) { + dev_err(&pdev->dev, "cannot get clock\n"); + return PTR_ERR(common->clk); + } + + ret = clk_prepare(common->clk); + if (ret < 0) { + dev_err(&pdev->dev, "unable to prepare clock\n"); + return ret; + } + + clk_enable(common->clk); + pm_runtime_enable(dev); pm_runtime_get_sync(dev); irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (irq) { - int ret; + int ret2; /* * platform has IRQ support. * Then, drier use common register */ - ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0, - dev_name(dev), common); - if (ret) { + ret2 = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0, + dev_name(dev), common); + if (ret2) { dev_err(dev, "irq request failed\n "); - return ret; + ret = ret2; + goto error_unpm; } /* @@ -402,8 +419,10 @@ static int rcar_thermal_probe(struct platform_device *pdev) */ res = platform_get_resource(pdev, IORESOURCE_MEM, mres++); common->base = devm_ioremap_resource(dev, res); - if (IS_ERR(common->base)) - return PTR_ERR(common->base); + if (IS_ERR(common->base)) { + ret = PTR_ERR(common->base); + goto error_unpm; + } /* enable temperature comparation */ rcar_thermal_common_write(common, ENR, 0x00030303); @@ -465,9 +484,13 @@ error_unregister: rcar_thermal_irq_disable(priv); } +error_unpm: pm_runtime_put_sync(dev); pm_runtime_disable(dev); + clk_disable(common->clk); + clk_unprepare(common->clk); + return ret; } @@ -486,6 +509,9 @@ static int rcar_thermal_remove(struct platform_device *pdev) pm_runtime_put_sync(dev); pm_runtime_disable(dev); + clk_disable(common->clk); + clk_unprepare(common->clk); + return 0; }