From patchwork Tue May 7 13:01:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 2533441 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 090A13FCA5 for ; Tue, 7 May 2013 13:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932560Ab3EGNCo (ORCPT ); Tue, 7 May 2013 09:02:44 -0400 Received: from mail-da0-f48.google.com ([209.85.210.48]:52506 "EHLO mail-da0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932393Ab3EGNCm (ORCPT ); Tue, 7 May 2013 09:02:42 -0400 Received: by mail-da0-f48.google.com with SMTP id h32so320027dak.21 for ; Tue, 07 May 2013 06:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=cQMUZgRFSzFU1B6HQ3zElMYLrX0tjthC1DicoKFSCSQ=; b=edubxEFyn+v6XtSXLmnMkD39D14413mCZ8QBWROf4IdftTRKvrOEyXNxQuBfiIQmIk h0DSXjjS71RtO5Y7lnDj67tZAKZFaUhuZFpFN/K4iGvM2xFPePCK+7kbb8/fCY50EGKK oqAyt4WatSgZLQeBMsSBHmOKAmR3n4o0t6TnXDkGwRp/ngS5fBSMjnTGT5sBA+fm6Z6F MsJFZq9/v5EIzD17y7U2a4M0nREoZGxPl+avYrC0c7oiOPC0wMr6Cs7navxuxkrNt4m4 Bjd6kkt12ghz1XkdeJkGK2FJKoR/WJZRmI4QQ/2nhyYAaNB8Uom/841oSjGT5WGqzhFg 3TpA== X-Received: by 10.66.149.170 with SMTP id ub10mr2793641pab.58.1367931761933; Tue, 07 May 2013 06:02:41 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPSA id l4sm28220809pbo.6.2013.05.07.06.02.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 07 May 2013 06:02:40 -0700 (PDT) From: Amit Daniel Kachhap To: linux-pm@vger.kernel.org Cc: Zhang Rui , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, Kukjin Kim , Eduardo Valentin Subject: [PATCH V3 14/21] thermal: exynos: Make the zone handling dependent on trip count Date: Tue, 7 May 2013 18:31:04 +0530 Message-Id: <1367931671-3906-15-git-send-email-amit.daniel@samsung.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1367931671-3906-1-git-send-email-amit.daniel@samsung.com> References: <1367931671-3906-1-git-send-email-amit.daniel@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This code simplifies the zone handling to use the trip count passed by the TMU driver. This also helps in adding more zone support. Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_thermal_common.c | 55 ++++++++++++----------- drivers/thermal/samsung/exynos_thermal_common.h | 2 - 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c index b7ca8a4..b0dc63e 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -83,17 +83,16 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, enum thermal_trip_type *type) { - switch (GET_ZONE(trip)) { - case MONITOR_ZONE: - case WARN_ZONE: - *type = THERMAL_TRIP_ACTIVE; - break; - case PANIC_ZONE: - *type = THERMAL_TRIP_CRITICAL; - break; - default: + struct exynos_thermal_zone *th_zone = thermal->devdata; + int max_trip = th_zone->sensor_conf->trip_data.trip_count; + + if (trip < 0 || trip >= max_trip) return -EINVAL; - } + else if (trip == (max_trip - 1)) + *type = THERMAL_TRIP_CRITICAL; + else + *type = THERMAL_TRIP_ACTIVE; + return 0; } @@ -102,8 +101,9 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, unsigned long *temp) { struct exynos_thermal_zone *th_zone = thermal->devdata; + int max_trip = th_zone->sensor_conf->trip_data.trip_count; - if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) + if (trip < 0 || trip >= max_trip) return -EINVAL; *temp = th_zone->sensor_conf->trip_data.trip_val[trip]; @@ -117,10 +117,10 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, static int exynos_get_crit_temp(struct thermal_zone_device *thermal, unsigned long *temp) { - int ret; - /* Panic zone */ - ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp); - return ret; + struct exynos_thermal_zone *th_zone = thermal->devdata; + int max_trip = th_zone->sensor_conf->trip_data.trip_count; + /* Get the temp of highest trip*/ + return exynos_get_trip_temp(thermal, max_trip - 1, temp); } /* Bind callback functions for thermal zone */ @@ -345,19 +345,22 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) return -ENOMEM; th_zone->sensor_conf = sensor_conf; - cpumask_set_cpu(0, &mask_val); - th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); - if (IS_ERR(th_zone->cool_dev[0])) { - pr_err("Failed to register cpufreq cooling device\n"); - ret = -EINVAL; - goto err_unregister; + if (sensor_conf->cooling_data.freq_clip_count > 0) { + cpumask_set_cpu(0, &mask_val); + th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); + if (IS_ERR(th_zone->cool_dev[0])) { + pr_err("Failed to register cpufreq cooling device\n"); + ret = -EINVAL; + goto err_unregister; + } + th_zone->cool_dev_size++; } - th_zone->cool_dev_size++; - th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, - EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0, - sensor_conf->trip_data.trigger_falling ? - 0 : IDLE_INTERVAL); + th_zone->therm_dev = thermal_zone_device_register( + sensor_conf->name, sensor_conf->trip_data.trip_count, + 0, th_zone, &exynos_dev_ops, NULL, 0, + sensor_conf->trip_data.trigger_falling ? 0 : + IDLE_INTERVAL); if (IS_ERR(th_zone->therm_dev)) { pr_err("Failed to register thermal zone device\n"); diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 0acde95..1dd1b9e 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -42,8 +42,6 @@ #define GET_ZONE(trip) (trip + 2) #define GET_TRIP(zone) (zone - 2) -#define EXYNOS_ZONE_COUNT 3 - /** * struct freq_clip_table * @freq_clip_max: maximum frequency allowed for this cooling state.