From patchwork Mon Oct 6 18:34:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 5039101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECC8F9F30B for ; Mon, 6 Oct 2014 18:38:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2118A2014A for ; Mon, 6 Oct 2014 18:38:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 2284320145 for ; Mon, 6 Oct 2014 18:38:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XbD8W-0004Fz-Nl; Mon, 06 Oct 2014 18:35:56 +0000 Received: from mout.web.de ([212.227.17.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XbD8T-0004DP-0M for linux-arm-kernel@lists.infradead.org; Mon, 06 Oct 2014 18:35:53 +0000 Received: from [192.168.178.137] ([217.86.79.198]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0M4IAh-1YRWpi2bsh-00rqrm; Mon, 06 Oct 2014 20:35:25 +0200 Message-ID: <5432E0CA.4050807@web.de> Date: Mon, 06 Oct 2014 20:34:50 +0200 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: linux-arm-kernel@lists.infradead.org Subject: [Patch] imx: thermal: imx_get_temp might be called before the sensor clock ist prepared X-Provags-ID: V03:K0:0+wKNvu71+HucEsw6RgyhuXVVrsyyC2WzxjFDLUX6gPA8NJf0HY lPqPQACQm/h2L3POAmGvf7mJW091eMI0AObF0t38B03bklzy2GNIyWUN/YkKRa9pJUbSx4H JyaVNUUUW176B6qdn6B2He0k+3pnlGwLlblD5iqsD6lLN9i8yuZlKdMSyzG17D6LStfW6/F XKfVZPNWPsDwXY97jba0A== X-UI-Out-Filterresults: notjunk:1; X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141006_113553_385735_D3C013C5 X-CRM114-Status: GOOD ( 10.72 ) X-Spam-Score: -0.0 (/) Cc: "Zhang Rui ; Eduardo Valentin ; Shawn Guo ; Sascha Hauer" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_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 imx_get_temp might be called before the sensor clock ist prepared thus resulting in a timeout of the first attempt to read temp: thermal thermal_zone0: failed to read out thermal zone 0 Happened to me on a Utilite Standard with IMX6 Dual SoC. Reason is that in imx_thermal_probe thermal_zone_device_register is called before the sensor clock is prepared. thermal_zone_device_register however calls thermal_zone_device_update which eventually calls imx_get_temp. Fix this by preparing the clock before calling thermal_zone_device_register. Signed-off-by: Heiner Kallweit --- drivers/thermal/imx_thermal.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) -- 2.1.2 diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 461bf3d..ef50df6 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -521,20 +521,6 @@ static int imx_thermal_probe(struct platform_device *pdev) return ret; } - data->tz = thermal_zone_device_register("imx_thermal_zone", - IMX_TRIP_NUM, - BIT(IMX_TRIP_PASSIVE), data, - &imx_tz_ops, NULL, - IMX_PASSIVE_DELAY, - IMX_POLLING_DELAY); - if (IS_ERR(data->tz)) { - ret = PTR_ERR(data->tz); - dev_err(&pdev->dev, - "failed to register thermal zone device %d\n", ret); - cpufreq_cooling_unregister(data->cdev); - return ret; - } - data->thermal_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(data->thermal_clk)) { dev_warn(&pdev->dev, "failed to get thermal clk!\n"); @@ -551,6 +537,20 @@ static int imx_thermal_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret); } + data->tz = thermal_zone_device_register("imx_thermal_zone", + IMX_TRIP_NUM, + BIT(IMX_TRIP_PASSIVE), data, + &imx_tz_ops, NULL, + IMX_PASSIVE_DELAY, + IMX_POLLING_DELAY); + if (IS_ERR(data->tz)) { + ret = PTR_ERR(data->tz); + dev_err(&pdev->dev, + "failed to register thermal zone device %d\n", ret); + cpufreq_cooling_unregister(data->cdev); + return ret; + } + /* Enable measurements at ~ 10 Hz */ regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ); measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */