From patchwork Mon Nov 26 02:32:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 1799971 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 16434DF264 for ; Mon, 26 Nov 2012 02:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753767Ab2KZCcq (ORCPT ); Sun, 25 Nov 2012 21:32:46 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:54065 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753344Ab2KZCcq (ORCPT ); Sun, 25 Nov 2012 21:32:46 -0500 Received: by mail-pa0-f46.google.com with SMTP id bh2so4666790pad.19 for ; Sun, 25 Nov 2012 18:32:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:from:to:cc:in-reply-to:references:from :subject:mime-version:content-type; bh=CaIdOUuUZYicdgICr2753w5C6ONVCc507VRJTfyiIxg=; b=pobUPKcVMLUwxFtInikXAIZhpGDSle4s767Z4NB1WA0Za1zbG5ILRAKNdVHTf3TVL+ 9zLEH6hMX/gvUZEdG8rQM4/+3iRZa9hHcmmhnurER0afs75BJCsWb9jIenxFjRB38qYx Qt7FlwVLkBznVdXOSYuAW9DLzVHJbR9Zvvm7pTj/jx6xEVvzTNlmhve69XnllsVBW32t OIYlTtyIH4/lGW0UevpQU714cjp5BEgU6h3TfUzcpJMnx7YHFmmFjCJIgcMToXt8kSf1 jXY904qsZ+tiaMgkXFcYBIysiH5HGP1/vzbP/FkFj8IlYHoeQ4okts5VGfnVYoWU6O58 N0Dg== Received: by 10.66.73.227 with SMTP id o3mr28635704pav.78.1353897165680; Sun, 25 Nov 2012 18:32:45 -0800 (PST) Received: from morimoto-Dell-XPS420.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPS id u5sm3978407pax.6.2012.11.25.18.32.43 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Nov 2012 18:32:44 -0800 (PST) Date: Sun, 25 Nov 2012 18:32:44 -0800 (PST) Message-ID: <87ehjhw0ty.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Zhang Rui Cc: Simon , Magnus , linux-pm@vger.kernel.org, Kuninori Morimoto In-Reply-To: <87ip8tw0x1.wl%kuninori.morimoto.gx@renesas.com> References: <87sj82uo7o.wl%kuninori.morimoto.gx@renesas.com> <87pq36uo5v.wl%kuninori.morimoto.gx@renesas.com> <1353652189.2111.7.camel@rzhang1-mobl4> <87k3t9w39m.wl%kuninori.morimoto.gx@renesas.com> <1353894734.2299.16.camel@rzhang1-mobl4> <87ip8tw0x1.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch adds .get_trip_type(), .get_trip_temp(), and .notify() on rcar_thermal_zone_ops. Driver will try platform power OFF if it reached to critical temperature. Signed-off-by: Kuninori Morimoto --- drivers/thermal/rcar_thermal.c | 68 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 90db951..e1aedcc 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -22,10 +22,13 @@ #include #include #include +#include #include #include #include +#define IDLE_INTERVAL 5000 + #define THSCR 0x2c #define THSSR 0x30 @@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, return 0; } +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, + int trip, enum thermal_trip_type *type) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + /* see rcar_thermal_get_temp() */ + switch (trip) { + case 0: /* +90 <= temp < +135 */ + *type = THERMAL_TRIP_CRITICAL; + break; + default: + dev_err(priv->dev, "rcar driver trip error\n"); + return -EINVAL; + } + + return 0; +} + +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, + int trip, unsigned long *temp) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + /* see rcar_thermal_get_temp() */ + switch (trip) { + case 0: /* +90 <= temp < +135 */ + *temp = MCELSIUS(90 - 1); + break; + default: + dev_err(priv->dev, "rcar driver trip error\n"); + return -EINVAL; + } + + return 0; +} + +static int rcar_thermal_notify(struct thermal_zone_device *zone, + int trip, enum thermal_trip_type type) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + switch (type) { + case THERMAL_TRIP_CRITICAL: + /* FIXME */ + dev_warn(priv->dev, + "Thermal reached to critical temperature\n"); + machine_power_off(); + break; + default: + break; + } + + return 0; +} + static struct thermal_zone_device_ops rcar_thermal_zone_ops = { - .get_temp = rcar_thermal_get_temp, + .get_temp = rcar_thermal_get_temp, + .get_trip_type = rcar_thermal_get_trip_type, + .get_trip_temp = rcar_thermal_get_trip_temp, + .notify = rcar_thermal_notify, }; /* @@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev) return -ENOMEM; } - zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv, - &rcar_thermal_zone_ops, NULL, 0, 0); + zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv, + &rcar_thermal_zone_ops, NULL, 0, + IDLE_INTERVAL); if (IS_ERR(zone)) { dev_err(&pdev->dev, "thermal zone device is NULL\n"); return PTR_ERR(zone);