From patchwork Thu Aug 1 16:33:11 2013
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 2837146
X-Patchwork-Delegate: rui.zhang@intel.com
Return-Path:
X-Original-To: patchwork-linux-pm@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.19.201])
by patchwork2.web.kernel.org (Postfix) with ESMTP id A5B16C0319
for ;
Thu, 1 Aug 2013 16:33:30 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 519C920357
for ;
Thu, 1 Aug 2013 16:33:29 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
by mail.kernel.org (Postfix) with ESMTP id 3E1DC20349
for ;
Thu, 1 Aug 2013 16:33:27 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1753278Ab3HAQd0 (ORCPT
);
Thu, 1 Aug 2013 12:33:26 -0400
Received: from metis.ext.pengutronix.de ([92.198.50.35]:59797 "EHLO
metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1752842Ab3HAQd0 (ORCPT
); Thu, 1 Aug 2013 12:33:26 -0400
Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de)
by metis.ext.pengutronix.de with esmtp (Exim 4.72)
(envelope-from )
id 1V4voV-0000C0-HW; Thu, 01 Aug 2013 18:33:19 +0200
From: Philipp Zabel
To: linux-pm@vger.kernel.org
Cc: Shawn Guo , Zhang Rui ,
Eduardo Valentin ,
kernel@pengutronix.de, Philipp Zabel
Subject: [PATCH 1/2] thermal: imx: dynamic passive and SoC specific critical
trip points
Date: Thu, 1 Aug 2013 18:33:11 +0200
Message-Id: <1375374792-32326-2-git-send-email-p.zabel@pengutronix.de>
X-Mailer: git-send-email 1.8.4.rc0
In-Reply-To: <1375374792-32326-1-git-send-email-p.zabel@pengutronix.de>
References: <1375374792-32326-1-git-send-email-p.zabel@pengutronix.de>
MIME-Version: 1.0
X-SA-Exim-Connect-IP: 10.1.0.7
X-SA-Exim-Mail-From: p.zabel@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de);
SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-pm@vger.kernel.org
Sender: linux-pm-owner@vger.kernel.org
Precedence: bulk
List-ID:
X-Mailing-List: linux-pm@vger.kernel.org
X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI,
RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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
Set passive and critical trip point values depending on the maximum die
temperature stored in the OCOTP fuses. This allows higher trip points
for industrial and automotive rated i.MX6 SoCs.
Also allow to configure the passive trip point from userspace.
Signed-off-by: Philipp Zabel
Acked-by: Shawn Guo
---
drivers/thermal/imx_thermal.c | 50 ++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index d16c33c..9387e47 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -55,12 +55,6 @@ enum imx_thermal_trip {
*/
#define IMX_TEMP_PASSIVE 85000
-/*
- * The maximum die temperature on imx parts is 105C, let's give some cushion
- * for noise and possible temperature rise between measurements.
- */
-#define IMX_TEMP_CRITICAL 100000
-
#define IMX_POLLING_DELAY 2000 /* millisecond */
#define IMX_PASSIVE_DELAY 1000
@@ -70,6 +64,8 @@ struct imx_thermal_data {
enum thermal_device_mode mode;
struct regmap *tempmon;
int c1, c2; /* See formula in imx_get_sensor_data() */
+ unsigned long temp_passive;
+ unsigned long temp_critical;
};
static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp)
@@ -156,15 +152,35 @@ static int imx_get_trip_type(struct thermal_zone_device *tz, int trip,
static int imx_get_crit_temp(struct thermal_zone_device *tz,
unsigned long *temp)
{
- *temp = IMX_TEMP_CRITICAL;
+ struct imx_thermal_data *data = tz->devdata;
+
+ *temp = data->temp_critical;
return 0;
}
static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip,
unsigned long *temp)
{
- *temp = (trip == IMX_TRIP_PASSIVE) ? IMX_TEMP_PASSIVE :
- IMX_TEMP_CRITICAL;
+ struct imx_thermal_data *data = tz->devdata;
+
+ *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive :
+ data->temp_critical;
+ return 0;
+}
+
+static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
+ unsigned long temp)
+{
+ struct imx_thermal_data *data = tz->devdata;
+
+ if (trip == IMX_TRIP_CRITICAL)
+ return -EPERM;
+
+ if (temp > IMX_TEMP_PASSIVE)
+ return -EINVAL;
+
+ data->temp_passive = temp;
+
return 0;
}
@@ -211,6 +227,7 @@ static const struct thermal_zone_device_ops imx_tz_ops = {
.get_trip_type = imx_get_trip_type,
.get_trip_temp = imx_get_trip_temp,
.get_crit_temp = imx_get_crit_temp,
+ .set_trip_temp = imx_set_trip_temp,
};
static int imx_get_sensor_data(struct platform_device *pdev)
@@ -267,6 +284,18 @@ static int imx_get_sensor_data(struct platform_device *pdev)
data->c1 = 1000 * (t1 - t2) / (n1 - n2);
data->c2 = 1000 * t2 - data->c1 * n2;
+ /*
+ * Set the default passive cooling trip point to 20 °C below the
+ * maximum die temperature. Can be changed from userspace.
+ */
+ data->temp_passive = 1000 * (t2 - 20);
+
+ /*
+ * The maximum die temperature is t2, let's give 5 °C cushion
+ * for noise and possible temperature rise between measurements.
+ */
+ data->temp_critical = 1000 * (t2 - 5);
+
return 0;
}
@@ -314,7 +343,8 @@ static int imx_thermal_probe(struct platform_device *pdev)
}
data->tz = thermal_zone_device_register("imx_thermal_zone",
- IMX_TRIP_NUM, 0, data,
+ IMX_TRIP_NUM,
+ BIT(IMX_TRIP_PASSIVE), data,
&imx_tz_ops, NULL,
IMX_PASSIVE_DELAY,
IMX_POLLING_DELAY);