Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932131AbbKYFmi (ORCPT ); Wed, 25 Nov 2015 00:42:38 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:13197 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752082AbbKYFme (ORCPT ); Wed, 25 Nov 2015 00:42:34 -0500 X-IronPort-AV: E=Sophos;i="5.20,341,1444662000"; d="scan'";a="199260496" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Message-ID: <87a8q28wsv.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH] thermal: rcar: add .set_trip_temp support User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Zhang Rui , Eduardo Valentin , Rob Herring , Pawel Moll , "Mark Rutland" , Ian Campbell , Kumar Gala CC: , , , Ryusuke Sakato , , "osd2@lm.renesas.com" MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Date: Wed, 25 Nov 2015 05:42:27 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0024.jpnprd01.prod.outlook.com (25.161.131.162) To SIXPR06MB1021.apcprd06.prod.outlook.com (25.160.238.156) X-Microsoft-Exchange-Diagnostics: 1;SIXPR06MB1021;2:v0uhZvwHZaFiZOqi+YdY2gCIkjvNAR9OrqBU9w8XPpgKVPEnIgHX5IptKlrZlKZ5kJcHZoA1W/lPE5Afc8oyxRSskUhtHg9D/Z4C7ctc17A+s0nZqFwYdHVm5LvPyK3yDQwCSDzUtIUwSoVHUF2Qbw==;3:TfKiTW4OW3PyVszXUGciLWcr34rO9bT5SSTxyDlnU/zcGBBTTkYrdd0mGib3ntuL97tZMhUE0Z6N8N6sOB2WWbD3dpZSfPx14NlauEYpkq2roqgSRs3HQl8GPotQpbH1;25:ThI8CvStcmN8zBZOHp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ThOqddfYdFL7k5Pd41LyqwndET1mQK8t/XSTFKSo1FxAwnP/9P3YQQnUu/2hrJ3EvUICxS9/LKeGbaZJE18CirSPUJ7qLjQHM9BZqGOPnimCJqImSe0PzZd580iUOwu3hzAOnEzoOCr65dFV0d3AlIbHvwbW/rP4Uoenju9ZUVSl3cqXmj+esZgT1COzG6gqk/CgBS+nh90YS4LimK66S27GnBzP5Q99vQwfUNNUwZwyuw0bSy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:SIXPR06MB1021;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB1021; X-Forefront-PRVS: 0771670921 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(189002)(5001960100002)(107886002)(42186005)(5007970100001)(189998001)(87976001)(54356999)(4001350100001)(83506001)(53416004)(229853001)(6116002)(586003)(5004730100002)(3846002)(69596002)(66066001)(19580395003)(19580405001)(36756003)(81156007)(97736004)(47776003)(77096005)(5001770100001)(50466002)(40100003)(46406003)(92566002)(86362001)(50986999)(4001430100002)(33646002)(5008740100001)(101416001)(106356001)(23726003)(105586002)(122386002)(142923001);DIR:OUT;SFP:1102;SCL:1;SRVR:SIXPR06MB1021;H:morimoto-PC.renesas.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SIXPR06MB1021;23:aGtaG5KN1lZN3pD1vGd/mtb0wrNsYcgfDh3Gh50QP?= =?us-ascii?Q?dXBswvhTeWcykFutZU3CD4h/MZy+BnhBwnmJll6+ZGwIUPF0hTCRVSh34c56?= =?us-ascii?Q?yhWbsi56fYS5GLOS4V1l4fPusYKyRtK/sbeN0+oUmWMPiguGtI8k2CHlGz5z?= =?us-ascii?Q?L1zZXDsUbpbo/QtUQ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?Q?GIUeoL5F8oLvmupr3oaI1lDFJOZWNXetsVsIvJp++DO5uvK1yDc9l2Y2JxJe?= =?us-ascii?Q?sCwF3TMN6cyyJ8ZR8gOcyIC+zCyNGnUIawEt9XqTr34OG4GVzlKTA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;SIXPR06MB1021;5:Qmbep9GEwnbn/aLSsOCycPYB5vHa/QsQvKE7syJ0XSUCMTg4p1NyyYiLM1fj1SpvfEimamGaEGYfiqQUFULgSQfJwrmTtB8TkUtnTzZH0GDieh7M+de1+xXpypF853imN39XyRR5KzRtV91+VaS2HA==;24:YRwiq7oOoDR6U6bbu3bjGFJDR5cqiGL4MkM7MQ9aNJzcEDtC6k2vVUmFrWzOKogYKa9Xj7hd6TzWh+3oNIFHPLnI3YAOOXA87TqD+beFpgY=;20:PCQ6mLPJgsJ9L+fON6LpQhl2xnXK7fZXGRZkSclB92SicB6xgKmZRLWtG5h1cbEEC+4mi09jCwISXmYATm68YHY3hR3IrI4OOdY4KFQnS6l/xy3wYYIhSUBsDPUTChS2+AkGS2X81h2qvmGWwkGzB9hHi3ojezbpnMhZzMBcz/0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2015 05:42:27.5813 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB1021 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3150 Lines: 106 From: Kuninori Morimoto You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp -45000 < $temp < 125000 is supported Default is 90000 Signed-off-by: Kuninori Morimoto --- This patch is v2 of "[PATCH] thermal: rcar: enable to set tripN-temp via DT" I think it will be full-DT feature if it uses of-thermal, but this driver is used from non-DT SoC too. We would like to keep non-DT support. And we would like to do is only exchange trip temp. .set_trip_temp is very enouth for it at this point. But, it can use of-thermal feature in the future. drivers/thermal/rcar_thermal.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 5d4ae7d..1eaa1be 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -63,6 +63,7 @@ struct rcar_thermal_priv { struct mutex lock; struct list_head list; int id; + int trip_temp; u32 ctemp; }; @@ -222,7 +223,7 @@ static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, /* see rcar_thermal_get_temp() */ switch (trip) { - case 0: /* +90 <= temp */ + case 0: *type = THERMAL_TRIP_CRITICAL; break; default: @@ -241,8 +242,8 @@ static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, /* see rcar_thermal_get_temp() */ switch (trip) { - case 0: /* +90 <= temp */ - *temp = MCELSIUS(90); + case 0: + *temp = priv->trip_temp; break; default: dev_err(dev, "rcar driver trip error\n"); @@ -270,10 +271,27 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone, return 0; } +static int rcar_thermal_set_trip_temp(struct thermal_zone_device *zone, + int trip, int temp) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + if (trip != 0) + return -EINVAL; + + if (temp < -45000 || temp > 125000) + return -EINVAL; + + priv->trip_temp = temp; + + return 0; +} + static struct thermal_zone_device_ops rcar_thermal_zone_ops = { .get_temp = rcar_thermal_get_temp, .get_trip_type = rcar_thermal_get_trip_type, .get_trip_temp = rcar_thermal_get_trip_temp, + .set_trip_temp = rcar_thermal_set_trip_temp, .notify = rcar_thermal_notify, }; @@ -418,13 +436,14 @@ static int rcar_thermal_probe(struct platform_device *pdev) priv->common = common; priv->id = i; + priv->trip_temp = MCELSIUS(90); /* default*/ mutex_init(&priv->lock); INIT_LIST_HEAD(&priv->list); INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); rcar_thermal_update_temp(priv); priv->zone = thermal_zone_device_register("rcar_thermal", - 1, 0, priv, + 1, 1, priv, &rcar_thermal_zone_ops, NULL, 0, idle); if (IS_ERR(priv->zone)) { -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/