From patchwork Tue May 6 16:59:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 4123231 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 EC89F9F1E1 for ; Tue, 6 May 2014 17:00:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B48C20251 for ; Tue, 6 May 2014 17:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E80B20212 for ; Tue, 6 May 2014 17:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbaEFRAr (ORCPT ); Tue, 6 May 2014 13:00:47 -0400 Received: from top.free-electrons.com ([176.31.233.9]:53312 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750821AbaEFRAr (ORCPT ); Tue, 6 May 2014 13:00:47 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id B460B1242; Tue, 6 May 2014 19:00:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost.localdomain (unknown [190.2.108.30]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3FD95535; Tue, 6 May 2014 19:00:41 +0200 (CEST) From: Ezequiel Garcia To: Zhang Rui , Cc: Jason Cooper , Thomas Petazzoni , Gregory Clement , Tawfik Bayouk , Lior Amsalem , Andrew Lunn , Sebastian Hesselbarth , Ezequiel Garcia Subject: [PATCH v3 5/7] thermal: armada: Allow to specify an 'inverted readout' sensor Date: Tue, 6 May 2014 13:59:49 -0300 Message-Id: <1399395591-5713-6-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399395591-5713-1-git-send-email-ezequiel.garcia@free-electrons.com> References: <1399395591-5713-1-git-send-email-ezequiel.garcia@free-electrons.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support inverted-formula thermal sensor readout, this commit introduces an 'inverted' field in the SoC-specific structure which allows to specify an inversion of the temperature formula. Acked-by: Jason Cooper Signed-off-by: Ezequiel Garcia --- drivers/thermal/armada_thermal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index 6fd6483..f84d9f0 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -56,6 +56,7 @@ struct armada_thermal_data { unsigned long coef_b; unsigned long coef_m; unsigned long coef_div; + bool inverted; /* Register shift and mask to access the sensor temperature */ unsigned int temp_shift; @@ -138,7 +139,10 @@ static int armada_get_temp(struct thermal_zone_device *thermal, m = priv->data->coef_m; div = priv->data->coef_div; - *temp = (b - (m * reg)) / div; + if (priv->data->inverted) + *temp = ((m * reg) - b) / div; + else + *temp = (b - (m * reg)) / div; return 0; }