From patchwork Tue Dec 15 01:18:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7850411 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 195569F1C2 for ; Tue, 15 Dec 2015 01:19:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15B0420374 for ; Tue, 15 Dec 2015 01:19:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBCB120357 for ; Tue, 15 Dec 2015 01:19:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932932AbbLOBSr (ORCPT ); Mon, 14 Dec 2015 20:18:47 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:33179 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753739AbbLOBSp (ORCPT ); Mon, 14 Dec 2015 20:18:45 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 15 Dec 2015 10:18:43 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 3C1EC49EF7; Tue, 15 Dec 2015 10:18:43 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 35A452806E; Tue, 15 Dec 2015 10:18:43 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 316262806D; Tue, 15 Dec 2015 10:18:43 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id LAA28313; Tue, 15 Dec 2015 10:18:43 +0900 X-IronPort-AV: E=Sophos;i="5.20,429,1444662000"; d="scan'";a="201809473" Received: from mail-hk2apc01lp0209.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.209]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 15 Dec 2015 10:18:41 +0900 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by SG2PR06MB1020.apcprd06.prod.outlook.com (10.161.9.28) with Microsoft SMTP Server (TLS) id 15.1.355.16; Tue, 15 Dec 2015 01:18:39 +0000 Message-ID: <876100qzp6.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/8 v5] thermal: rcar: enable to use thermal-zone on DT User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Simon , Zhang Rui , Eduardo Valentin CC: Geert Uytterhoeven , Magnus , , , , "devicetree@vger.kernel.org" In-Reply-To: <87d1u8qzsy.wl%kuninori.morimoto.gx@renesas.com> References: <87d1u8qzsy.wl%kuninori.morimoto.gx@renesas.com> Date: Tue, 15 Dec 2015 01:18:39 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0007.jpnprd01.prod.outlook.com (25.161.131.145) To SG2PR06MB1020.apcprd06.prod.outlook.com (25.161.9.28) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 2:zVBBSxIIlG9xKKzr6ppIfLIT12Ehe+CsTzkDz6xSQs8uBBXcOmX/+V/ZXjR+RsockVUqsThYbx6TkhD3i48qcxY28BAI4zYWoCQdh+94tHVe+zoSCxaxWOUKBl8M57v516o7/dE2nF2GFbYbMc2JQQ==; 3:Dp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FSJ9EttMo163Ge3PRVAbn1OlL2jEZQSCcNNN7wqB4lpCN4sGLl8VXDnYbeH2tzX8UXb/+abU9l6etiUai4uOrC1XxzPeBJYxWY9bIbSvgoD3gdX1wSUvaD4yhI8vkFXe3N4w9lFwmi430PbXIJ7fgDsmGH10IYReyXTRsd7WfJMmt6EGzY+JwYqRTUma7CrpVu4pspW+VKsTBCUJX7FAuPgJTgn8IG4w5gE5WFDhaDVNuYq+Va1xMXO0AhM0D2oSJ41an+kktqUndufH9sBH9VYh7SlaZdNffG3jeCswNezPn+3AbZSge/egsctnFMeW/9ine4YMAytt8QXD8efWEFTONC3chm2Q6 9Gq6N8Zwh/60ETImtoO0QVxSxf 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:SG2PR06MB1020; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1020; X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(50466002)(5004730100002)(6116002)(229853001)(54356999)(92566002)(101416001)(76176999)(33646002)(53416004)(69596002)(77096005)(19580395003)(42186005)(23726003)(83506001)(87976001)(106356001)(105586002)(2950100001)(50986999)(86362001)(3846002)(36756003)(47776003)(81156007)(5001770100001)(122386002)(40100003)(66066001)(19580405001)(4001350100001)(97736004)(5001960100002)(586003)(189998001)(5008740100001)(1096002)(46406003); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1020; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1020; 23:ZAJ5or6AL1HIG+cBh/Uye/j7vRB4/hG8Yyic9wb/J?= =?us-ascii?Q?KykkaawjvN12BKXbqSeUzZg7Yc8ResrgC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hlOxF6/N70IfWA5WLZYrYwPYEWl9i8j7XvFqAT9K+9onwWD6dHfj7eNxMU?= =?us-ascii?Q?aaEsQeljx+HCUCE/L8hUZIpjxbbARaVndWAqjm5PAI077vVFZF+Ku8LMWgaa?= =?us-ascii?Q?Jb1lfIFFh5c1+N8tEpCcv1cdnj5ICgJMyPV8vluh/g7eQ9uEL2AI9Af0eXo8?= =?us-ascii?Q?O49stTkYs0=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 5:k3/rQtHguKmuEKJ0kdyolLP3QFIqEZIjwadjNtoANBiBREDbFo/q9tnM0K+1t5qqEHx6qAq49qG8iNA3jo8bREy8/clkqG7UXUpXno0GC4VF2o3P6nCU1LFJ7P7pP2xWkUQyXy6mNHJA8SiwxDbC5w==; 24:oIKwxQkfHge2/H1GIwqFT/ZXgBI+Yc+APuTSHn2m4JFiCxCYQrcZlbcXYUPjzFqqPHw8veQMbvU/p+tRn4CrhqtirYaypXWUZ/VWlv78sfM=; 20:6MdT/Qd0t9hd++ZM1VY5aIJtqto6AU7Ep3T4uhrXfcRRc9eXXJmKpGrJhyRqGDxGldZ31P2k8pz5mfibMZ2JumSZHleQ4fxGsmZeYfV3ZK5u16vxGUdPNcO44oiK3OD3ZY9IDEEwCfTZTslp/eAJ3pJyG3qyyOJEG0bQuXv6tbc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2015 01:18:39.1290 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1020 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Kuninori Morimoto This patch enables to use thermal-zone on DT if it was call as "renesas,rcar-thermal-gen2". Previous style is still supported by "renesas,rcar-thermal". Signed-off-by: Kuninori Morimoto --- v4 -> v5 - "1150000" -> "115000" on rcar-thermal.txt .../devicetree/bindings/thermal/rcar-thermal.txt | 37 +++++++++++++++++- drivers/thermal/rcar_thermal.c | 45 +++++++++++++++++++--- 2 files changed, 75 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt index 332e625..e5ee3f1 100644 --- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt @@ -1,8 +1,9 @@ * Renesas R-Car Thermal Required properties: -- compatible : "renesas,thermal-", "renesas,rcar-thermal" - as fallback. +- compatible : "renesas,thermal-", + "renesas,rcar-gen2-thermal" (with thermal-zone) or + "renesas,rcar-thermal" (without thermal-zone) as fallback. Examples with soctypes are: - "renesas,thermal-r8a73a4" (R-Mobile APE6) - "renesas,thermal-r8a7779" (R-Car H1) @@ -36,3 +37,35 @@ thermal@e61f0000 { 0xe61f0300 0x38>; interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>; }; + +Example (with thermal-zone): + +thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <1000>; + polling-delay = <5000>; + + thermal-sensors = <&thermal>; + + trips { + cpu-crit { + temperature = <115000>; + hysteresis = <0>; + type = "critical"; + }; + }; + cooling-maps { + }; + }; +}; + +thermal: thermal@e61f0000 { + compatible = "renesas,thermal-r8a7790", + "renesas,rcar-gen2-thermal", + "renesas,rcar-thermal"; + reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>; + interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp5_clks R8A7790_CLK_THERMAL>; + power-domains = <&cpg_clocks>; + #thermal-sensor-cells = <0>; +}; diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 30602f2..e92f29b 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -75,8 +76,10 @@ struct rcar_thermal_priv { #define rcar_has_irq_support(priv) ((priv)->common->base) #define rcar_id_to_shift(priv) ((priv)->id * 8) +#define USE_OF_THERMAL 1 static const struct of_device_id rcar_thermal_dt_ids[] = { { .compatible = "renesas,rcar-thermal", }, + { .compatible = "renesas,rcar-gen2-thermal", .data = (void *)USE_OF_THERMAL }, {}, }; MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids); @@ -200,9 +203,9 @@ err_out_unlock: return ret; } -static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) +static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv, + int *temp) { - struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); int tmp; int ret; @@ -226,6 +229,20 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) return 0; } +static int rcar_thermal_of_get_temp(void *data, int *temp) +{ + struct rcar_thermal_priv *priv = data; + + return rcar_thermal_get_current_temp(priv, temp); +} + +static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + return rcar_thermal_get_current_temp(priv, temp); +} + static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, int trip, enum thermal_trip_type *type) { @@ -282,6 +299,10 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone, return 0; } +static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = { + .get_temp = rcar_thermal_of_get_temp, +}; + static struct thermal_zone_device_ops rcar_thermal_zone_ops = { .get_temp = rcar_thermal_get_temp, .get_trip_type = rcar_thermal_get_trip_type, @@ -318,14 +339,20 @@ static void rcar_thermal_work(struct work_struct *work) priv = container_of(work, struct rcar_thermal_priv, work.work); - rcar_thermal_get_temp(priv->zone, &cctemp); + ret = rcar_thermal_get_current_temp(priv, &cctemp); + if (ret < 0) + return; + ret = rcar_thermal_update_temp(priv); if (ret < 0) return; rcar_thermal_irq_enable(priv); - rcar_thermal_get_temp(priv->zone, &nctemp); + ret = rcar_thermal_get_current_temp(priv, &nctemp); + if (ret < 0) + return; + if (nctemp != cctemp) thermal_zone_device_update(priv->zone); } @@ -386,6 +413,8 @@ static int rcar_thermal_probe(struct platform_device *pdev) struct rcar_thermal_priv *priv; struct device *dev = &pdev->dev; struct resource *res, *irq; + const struct of_device_id *of_id = of_match_device(rcar_thermal_dt_ids, dev); + unsigned long of_data = (unsigned long)of_id->data; int mres = 0; int i; int ret = -ENODEV; @@ -444,7 +473,13 @@ static int rcar_thermal_probe(struct platform_device *pdev) if (ret < 0) goto error_unregister; - priv->zone = thermal_zone_device_register("rcar_thermal", + if (of_data == USE_OF_THERMAL) + priv->zone = thermal_zone_of_sensor_register( + dev, i, priv, + &rcar_thermal_zone_of_ops); + else + priv->zone = thermal_zone_device_register( + "rcar_thermal", 1, 0, priv, &rcar_thermal_zone_ops, NULL, 0, idle);