From patchwork Tue May 12 03:04:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 6383861 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 117DBBEEE1 for ; Mon, 11 May 2015 20:05:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18E7E20BE0 for ; Mon, 11 May 2015 20:05:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 505B720C1F for ; Mon, 11 May 2015 20:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932078AbbEKUEo (ORCPT ); Mon, 11 May 2015 16:04:44 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35893 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754689AbbEKUE1 (ORCPT ); Mon, 11 May 2015 16:04:27 -0400 Received: by pabsx10 with SMTP id sx10so117974832pab.3; Mon, 11 May 2015 13:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Srp91Q7KdMhyDISMvG5HduNemjqlut7vlWxfw330pgA=; b=PfmHDCsJ5FHuCB3TpR4PRLZb8O/w+NouH3Qsp97gppd498s5VUvCif7e7swShY7cen bCILhXe8EYAaujHYHjxoEyJtMtPWTQgfeIwVuDuXkrJbvk4x6FnpJUtJT1TuzISOqftX xT23ePvIrjPymHSksJxx1eNm5eurE8mMB77NGoOdBbcNZWNOU6O988R41KVM2Jq5N2ZX guHacu63mEsGLgI2D99vk9SBZbwd1vTQdCreR0J+iMB4TZsSCmXAMiQRXNF/L7Q4enaW dB1Xm/LjahRcfRKEag7n686VxaoeokptF/mLPaHZrqyiQQzqK21NDw+AZu2XRs+FpETV nFvw== X-Received: by 10.68.94.193 with SMTP id de1mr21645977pbb.153.1431374666409; Mon, 11 May 2015 13:04:26 -0700 (PDT) Received: from localhost (amazon.gigabitethernet4-0-6.asr1.snv2.gblx.net. [64.211.110.86]) by mx.google.com with ESMTPSA id ki3sm13922939pdb.74.2015.05.11.13.04.25 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 13:04:25 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang , hongtao.jia@freescale.com, kong.kongxinwei@hisilicon.com Cc: Linux PM , LKML , Linux ACPI , Eduardo Valentin Subject: [PATCH 2/2] thermal: of-thermal: add support for reading coefficients property Date: Mon, 11 May 2015 20:04:17 -0700 Message-Id: <1431399857-13943-3-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.3.4 In-Reply-To: <1431399857-13943-1-git-send-email-edubezval@gmail.com> References: <1431399857-13943-1-git-send-email-edubezval@gmail.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 In order to avoid having each driver adding their own specific DT property to specify slope and offset, this patch adds a basic coefficient reading from DT thermal zone node. Right now, as the thermal framework does not support multiple sensors, the current coefficients apply only to the only sensor in the thermal zone. The supported equation is a simple linear model: slope * + offset. slope and offset are read from the coefficients DT property. In the same way as it is described in the DT thermal binding. So, as of today, the thermal framework will support only cases like: /* hotspot = 1 * adc + 6000 */ coefficients = <1 6000>; Signed-off-by: Eduardo Valentin --- drivers/thermal/of-thermal.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 9e8c614..b295b2b 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -58,6 +58,8 @@ struct __thermal_bind_params { * @mode: current thermal zone device mode (enabled/disabled) * @passive_delay: polling interval while passive cooling is activated * @polling_delay: zone polling interval + * @slope: slope of the temperature adjustment curve + * @offset: offset of the temperature adjustment curve * @ntrips: number of trip points * @trips: an array of trip points (0..ntrips - 1) * @num_tbps: number of thermal bind params @@ -70,6 +72,8 @@ struct __thermal_zone { enum thermal_device_mode mode; int passive_delay; int polling_delay; + int slope; + int offset; /* trip data */ int ntrips; @@ -716,7 +720,7 @@ static int thermal_of_populate_trip(struct device_node *np, * @np parameter and fills the read data into a __thermal_zone data structure * and return this pointer. * - * TODO: Missing properties to parse: thermal-sensor-names and coefficients + * TODO: Missing properties to parse: thermal-sensor-names * * Return: On success returns a valid struct __thermal_zone, * otherwise, it returns a corresponding ERR_PTR(). Caller must @@ -728,7 +732,7 @@ thermal_of_build_thermal_zone(struct device_node *np) struct device_node *child = NULL, *gchild; struct __thermal_zone *tz; int ret, i; - u32 prop; + u32 prop, coef[2]; if (!np) { pr_err("no thermal zone np\n"); @@ -753,6 +757,20 @@ thermal_of_build_thermal_zone(struct device_node *np) } tz->polling_delay = prop; + /* + * REVIST: for now, the thermal framework supports only + * one sensor per thermal zone. Thus, we are considering + * only the first two values as slope and offset. + */ + ret = of_property_read_u32_array(np, "coefficients", coef, 2); + if (ret == 0) { + tz->slope = coef[0]; + tz->offset = coef[1]; + } else { + tz->slope = 1; + tz->offset = 0; + } + /* trips */ child = of_get_child_by_name(np, "trips"); @@ -900,6 +918,10 @@ int __init of_parse_thermal_zones(void) for (i = 0; i < tz->ntrips; i++) mask |= 1 << i; + /* these two are left for temperature drivers to use */ + tzp->slope = tz->slope; + tzp->offset = tz->offset; + zone = thermal_zone_device_register(child->name, tz->ntrips, mask, tz, ops, tzp,