From patchwork Thu Nov 8 04:26:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 1713801 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 127D23FC8F for ; Thu, 8 Nov 2012 04:27:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753258Ab2KHE0q (ORCPT ); Wed, 7 Nov 2012 23:26:46 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:44677 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753233Ab2KHE0n (ORCPT ); Wed, 7 Nov 2012 23:26:43 -0500 Received: by mail-pa0-f46.google.com with SMTP id hz1so1678219pad.19 for ; Wed, 07 Nov 2012 20:26:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=+BY/Cy43WR6MI8iXUQzjHRtj3Y5gw5j7VMVr4hwPfcs=; b=XHlzc6lhwBqjODjBEDEC6+ka3Fb/40pZ1XyLO4wvDy7c+vWKk6SqABItvadc8ZzeKc l/sk8CouQ04I1y+JMK37aJ6Khkv7Hf16VpktTFxZ6UFNtgZXOBq0UTneBHo0RkIAAnyh Sgt4Rk5vOiYf8i4LFrftfVdpdiVmcR3KqFmwBh1Ll4u6OSTGjIkrJwZ7+08f2WTBk6nN dpm4bHVxElfu6xh3jIdJl/5Hr42hkMIYhucx+stL8BzXrC3GIjPfBRxpnmAYDSWArqTp VLXlnD6U+Pf110EIt3IFQaJars9owpR54AfAkntDIrRYuvpnB6lhmkej4HGzi808jPS8 HUQA== Received: by 10.66.77.74 with SMTP id q10mr18597847paw.81.1352348802691; Wed, 07 Nov 2012 20:26:42 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id t1sm15413839paw.11.2012.11.07.20.26.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 20:26:41 -0800 (PST) From: Amit Daniel Kachhap To: linux-pm@lists.linux-foundation.org Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, durgadoss.r@intel.com, lenb@kernel.org, rui.zhang@intel.com, linux-acpi@vger.kernel.org, amit.kachhap@linaro.org, jonghwa3.lee@samsung.com Subject: [PATCH 1/4] thermal: Add new thermal trend type to support quick cooling Date: Thu, 8 Nov 2012 09:56:24 +0530 Message-Id: <1352348786-24255-2-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1352348786-24255-1-git-send-email-amit.kachhap@linaro.org> References: <1352348786-24255-1-git-send-email-amit.kachhap@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This modification adds 2 new thermal trend type THERMAL_TREND_RAISE_FULL and THERMAL_TREND_DROP_FULL. This thermal trend can be used to quickly jump to the upper or lower cooling level instead of incremental increase or decrease. This is needed for temperature sensors which support rising/falling threshold interrupts and polling can be totally avoided. Signed-off-by: Amit Daniel Kachhap Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/step_wise.c | 19 +++++++++++++++---- include/linux/thermal.h | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 1242cff..0d2d8d6 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -35,6 +35,10 @@ * state for this trip point * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling * state for this trip point + * c. if the trend is THERMAL_TREND_RAISE_FULL, use highest cooling + * state for this trip point + * d. if the trend is THERMAL_TREND_DROP_FULL, use lowest cooling + * state for this trip point */ static unsigned long get_target_state(struct thermal_instance *instance, enum thermal_trend trend) @@ -50,7 +54,10 @@ static unsigned long get_target_state(struct thermal_instance *instance, } else if (trend == THERMAL_TREND_DROPPING) { cur_state = cur_state > instance->lower ? (cur_state - 1) : instance->lower; - } + } else if (trend == THERMAL_TREND_RAISE_FULL) + cur_state = instance->upper; + else if (trend == THERMAL_TREND_DROP_FULL) + cur_state = instance->lower; return cur_state; } @@ -87,7 +94,8 @@ static void update_instance_for_throttle(struct thermal_zone_device *tz, } static void update_instance_for_dethrottle(struct thermal_zone_device *tz, - int trip, enum thermal_trip_type trip_type) + int trip, enum thermal_trip_type trip_type, + enum thermal_trend trend) { struct thermal_instance *instance; struct thermal_cooling_device *cdev; @@ -101,7 +109,10 @@ static void update_instance_for_dethrottle(struct thermal_zone_device *tz, cdev = instance->cdev; cdev->ops->get_cur_state(cdev, &cur_state); - instance->target = cur_state > instance->lower ? + if (trend == THERMAL_TREND_DROP_FULL) + instance->target = instance->lower; + else + instance->target = cur_state > instance->lower ? (cur_state - 1) : THERMAL_NO_TARGET; /* Deactivate a passive thermal instance */ @@ -133,7 +144,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) if (tz->temperature >= trip_temp) update_instance_for_throttle(tz, trip, trip_type, trend); else - update_instance_for_dethrottle(tz, trip, trip_type); + update_instance_for_dethrottle(tz, trip, trip_type, trend); mutex_unlock(&tz->lock); } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 807f214..8bce3ec 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -68,6 +68,8 @@ enum thermal_trend { THERMAL_TREND_STABLE, /* temperature is stable */ THERMAL_TREND_RAISING, /* temperature is raising */ THERMAL_TREND_DROPPING, /* temperature is dropping */ + THERMAL_TREND_RAISE_FULL, /* Apply highest cooling action*/ + THERMAL_TREND_DROP_FULL, /* Apply lowest cooling action*/ }; /* Events supported by Thermal Netlink */