From patchwork Tue Dec 24 14:43:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 3400011 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 DCBEC9F314 for ; Tue, 24 Dec 2013 02:45:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0933C207A0 for ; Tue, 24 Dec 2013 02:45:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2075B20610 for ; Tue, 24 Dec 2013 02:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758072Ab3LXCpb (ORCPT ); Mon, 23 Dec 2013 21:45:31 -0500 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:29162 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757912Ab3LXCpa (ORCPT ); Mon, 23 Dec 2013 21:45:30 -0500 Received: from mail97-va3-R.bigfish.com (10.7.14.252) by VA3EHSOBE012.bigfish.com (10.7.40.62) with Microsoft SMTP Server id 14.1.225.22; Tue, 24 Dec 2013 02:45:29 +0000 Received: from mail97-va3 (localhost [127.0.0.1]) by mail97-va3-R.bigfish.com (Postfix) with ESMTP id 2482D1C00AA; Tue, 24 Dec 2013 02:45:29 +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 mail97-va3 (localhost.localdomain [127.0.0.1]) by mail97-va3 (MessageSwitch) id 1387853127342341_18187; Tue, 24 Dec 2013 02:45:27 +0000 (UTC) Received: from VA3EHSMHS007.bigfish.com (unknown [10.7.14.225]) by mail97-va3.bigfish.com (Postfix) with ESMTP id 441A4300047; Tue, 24 Dec 2013 02:45:27 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS007.bigfish.com (10.7.99.17) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 24 Dec 2013 02:45:26 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 24 Dec 2013 02:45:26 +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 rBO2jMrY029694; Mon, 23 Dec 2013 19:45:24 -0700 From: Anson Huang To: , , CC: , Subject: [PATCH V2] thermal: imx: correct suspend/resume flow Date: Tue, 24 Dec 2013 09:43:24 -0500 Message-ID: <1387896204-31754-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 Fixes regression introduced by: commit 37713a1e8e4c1a1067ad4c99296f78d3c82ed9c4 Author: Philipp Zabel Date: Thu Aug 1 18:33:12 2013 +0200 thermal: imx: implement thermal alarm interrupt handling The commit 37713a1e8e4 makes imx thermal sensor always powered up as alarm function is enabled, but the suspend callback of imx thermal returns success only if thermal sensor is powered down, so it will always returns fail hence break system's suspend, this patch disables imx thermal sensor before suspend and re-enable it after resume. Signed-off-by: Anson Huang Acked-by: Shawn Guo --- drivers/thermal/imx_thermal.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index cbb16f3..9a9a6c2 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -510,27 +510,30 @@ static int imx_thermal_suspend(struct device *dev) { struct imx_thermal_data *data = dev_get_drvdata(dev); struct regmap *map = data->tempmon; - u32 val; - regmap_read(map, TEMPSENSE0, &val); - if ((val & TEMPSENSE0_POWER_DOWN) == 0) { - /* - * If a measurement is taking place, wait for a long enough - * time for it to finish, and then check again. If it still - * does not finish, something must go wrong. - */ - udelay(50); - regmap_read(map, TEMPSENSE0, &val); - if ((val & TEMPSENSE0_POWER_DOWN) == 0) - return -ETIMEDOUT; - } + /* + * Need to disable thermal sensor, otherwise, when thermal core + * try to get temperature before thermal sensor resume, a wrong + * temperature will be read as the thermal sensor is powered + * down. + */ + regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP); + regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN); + data->mode = THERMAL_DEVICE_DISABLED; return 0; } static int imx_thermal_resume(struct device *dev) { - /* Nothing to do for now */ + struct imx_thermal_data *data = dev_get_drvdata(dev); + struct regmap *map = data->tempmon; + + /* Enabled thermal sensor after resume */ + regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN); + regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP); + data->mode = THERMAL_DEVICE_ENABLED; + return 0; } #endif