From patchwork Thu Dec 19 21:16:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 3376121 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@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 77CBA9F384 for ; Thu, 19 Dec 2013 09:18:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52B4F20639 for ; Thu, 19 Dec 2013 09:18:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F35E720634 for ; Thu, 19 Dec 2013 09:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752168Ab3LSJSp (ORCPT ); Thu, 19 Dec 2013 04:18:45 -0500 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:38659 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751689Ab3LSJSk (ORCPT ); Thu, 19 Dec 2013 04:18:40 -0500 Received: from mail222-va3-R.bigfish.com (10.7.14.252) by VA3EHSOBE009.bigfish.com (10.7.40.29) with Microsoft SMTP Server id 14.1.225.22; Thu, 19 Dec 2013 09:18:38 +0000 Received: from mail222-va3 (localhost [127.0.0.1]) by mail222-va3-R.bigfish.com (Postfix) with ESMTP id 886307C02AA; Thu, 19 Dec 2013 09:18:38 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah1fc6h1082kzz1de098h8275bh1de097hz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h2327h2336h1155h) Received: from mail222-va3 (localhost.localdomain [127.0.0.1]) by mail222-va3 (MessageSwitch) id 1387444716691619_6687; Thu, 19 Dec 2013 09:18:36 +0000 (UTC) Received: from VA3EHSMHS043.bigfish.com (unknown [10.7.14.249]) by mail222-va3.bigfish.com (Postfix) with ESMTP id 9A79A7800A1; Thu, 19 Dec 2013 09:18:36 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS043.bigfish.com (10.7.99.53) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 19 Dec 2013 09:18:28 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.158.2; Thu, 19 Dec 2013 09:18:27 +0000 Received: from ubuntu.ap.freescale.net (ubuntu-010192242118.ap.freescale.net [10.192.242.118]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id rBJ9INe5003455; Thu, 19 Dec 2013 02:18:24 -0700 From: Anson Huang To: , , , CC: , , , Subject: [PATCH V3 2/2] thermal: imx: add necessary clk operation Date: Thu, 19 Dec 2013 16:16:31 -0500 Message-ID: <1387487791-3259-1-git-send-email-b20788@freescale.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Thermal sensor needs pll3_usb_otg when measuring temperature, otherwise the temperature read will be incorrect, so need to enable this clk before sensor working, for alarm function, as hardware will take measurement periodically, so we should keep this clk always on once alarm function is enabled. Signed-off-by: Anson Huang --- .../devicetree/bindings/thermal/imx-thermal.txt | 4 ++++ drivers/thermal/imx_thermal.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.txt b/Documentation/devicetree/bindings/thermal/imx-thermal.txt index 541c25e..1f0f672 100644 --- a/Documentation/devicetree/bindings/thermal/imx-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/imx-thermal.txt @@ -8,10 +8,14 @@ Required properties: calibration data, e.g. OCOTP on imx6q. The details about calibration data can be found in SoC Reference Manual. +Optional properties: +- clocks : thermal sensor's clock source. + Example: tempmon { compatible = "fsl,imx6q-tempmon"; fsl,tempmon = <&anatop>; fsl,tempmon-data = <&ocotp>; + clocks = <&clks 172>; }; diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 1d6c801..c2b8173 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -7,6 +7,7 @@ * */ +#include #include #include #include @@ -73,6 +74,7 @@ struct imx_thermal_data { unsigned long last_temp; bool irq_enabled; int irq; + struct clk *thermal_clk; }; static void imx_set_alarm_temp(struct imx_thermal_data *data, @@ -457,6 +459,22 @@ static int imx_thermal_probe(struct platform_device *pdev) 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"); + } else { + /* + * Thermal sensor needs clk on to get correct value, normally + * we should enable its clk before taking measurement and disable + * clk after measurement is done, but if alarm function is enabled, + * hardware will auto measure the temperature periodically, so we + * need to keep the clk always on for alarm function. + */ + ret = clk_prepare_enable(data->thermal_clk); + if (ret) + dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret); + } + /* Enable measurements at ~ 10 Hz */ regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ); measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */