From patchwork Tue May 12 03:04:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 6383891 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BD43A9F374 for ; Mon, 11 May 2015 20:05:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC6A020C26 for ; Mon, 11 May 2015 20:05:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E476220C1D for ; Mon, 11 May 2015 20:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754689AbbEKUFK (ORCPT ); Mon, 11 May 2015 16:05:10 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:32930 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754459AbbEKUEZ (ORCPT ); Mon, 11 May 2015 16:04:25 -0400 Received: by pdbnk13 with SMTP id nk13so154400179pdb.0; Mon, 11 May 2015 13:04:24 -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=0dbfJiaPInDTqTBmhDFKE7snyVMAJwoqLgqmUeslG58=; b=ue7cWlcwwtdt9KwlBLizZhkeVUcUbpfobqAkX7nFwtgJn47teoZK72lDj+w4OcOjDQ 9xS9adfk7bhL5gjjfTJ9nH13gMO/66AH9Qlhx/ZVEaKQgIY0LlQ4bnlT7TGdJTqUQZ1j WHzos65PDBwArJgM1F/Va5gaAK0AmSjIm9owa/Oaf7e2Yjvk4trZAUgtRzeRtmm16l0y K7rtvUyNCSZPbPSfewElKeKr5t1wI+2OQHBKd4gGVgaGLBjTkVk4zfSjGVbEw4RdqY+z u7FH5WtXNyhs+wpFu5AnJXS/AUw1kpe+e/puA9jbthTeXB81ekgChOsJ7B+FaY4tzrRh n9ZQ== X-Received: by 10.66.249.168 with SMTP id yv8mr22033978pac.49.1431374664513; Mon, 11 May 2015 13:04:24 -0700 (PDT) Received: from localhost (amazon.gigabitethernet4-0-6.asr1.snv2.gblx.net. [64.211.110.86]) by mx.google.com with ESMTPSA id qe9sm13899402pbc.62.2015.05.11.13.04.23 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 13:04:23 -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 1/2] thermal: support slope and offset coefficients Date: Mon, 11 May 2015 20:04:16 -0700 Message-Id: <1431399857-13943-2-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 It is common to have a linear extrapolation from the current sensor readings and the actual temperature value. This is specially the case when the sensor is in use to extrapolate hotspots. This patch adds slope and offset constants for single sensor linear extrapolation equation. Because the same sensor can be use in different locations, from board to board, these constants are added as part of thermal_zone_params. The constants are available through sysfs. It is up to the device driver to determine the usage of these values. Signed-off-by: Eduardo Valentin --- Documentation/thermal/sysfs-api.txt | 16 ++++++++++++++++ drivers/thermal/thermal_core.c | 4 ++++ include/linux/thermal.h | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt index 7d44d7f..c1f6864 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.txt @@ -190,6 +190,8 @@ Thermal zone device sys I/F, created once it's registered: |---k_i: PID's integral term in the power allocator gov |---k_d: PID's derivative term in the power allocator |---integral_cutoff: Offset above which errors are accumulated + |---slope: Slope constant applied as linear extrapolation + |---offset: Offset constant applied as linear extrapolation Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]: @@ -359,6 +361,20 @@ integral_cutoff Documentation/thermal/power_allocator.txt RW, Optional +slope + The slope constant used in a linear extrapolation model + to determine a hotspot temperature based off the sensor's + raw readings. It is up to the device driver to determine + the usage of these values. + RW, Optional + +offset + The offset constant used in a linear extrapolation model + to determine a hotspot temperature based off the sensor's + raw readings. It is up to the device driver to determine + the usage of these values. + RW, Optional + ***************************** * Cooling device attributes * ***************************** diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 962de18..04659bf 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -944,6 +944,8 @@ create_s32_tzp_attr(k_pu); create_s32_tzp_attr(k_i); create_s32_tzp_attr(k_d); create_s32_tzp_attr(integral_cutoff); +create_s32_tzp_attr(slope); +create_s32_tzp_attr(offset); #undef create_s32_tzp_attr static struct device_attribute *dev_tzp_attrs[] = { @@ -953,6 +955,8 @@ static struct device_attribute *dev_tzp_attrs[] = { &dev_attr_k_i, &dev_attr_k_d, &dev_attr_integral_cutoff, + &dev_attr_slope, + &dev_attr_offset, }; static int create_tzp_attrs(struct device *dev) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 6bbe11c..037e9df 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -302,6 +302,17 @@ struct thermal_zone_params { /* threshold below which the error is no longer accumulated */ s32 integral_cutoff; + + /* + * @slope: slope of a linear temperature adjustment curve. + * Used by thermal zone drivers. + */ + int slope; + /* + * @offset: offset of a linear temperature adjustment curve. + * Used by thermal zone drivers (default 0). + */ + int offset; }; struct thermal_genl_event {