From patchwork Mon Dec 7 07:44:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7781311 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B426FBEEE1 for ; Mon, 7 Dec 2015 07:46:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7E6520382 for ; Mon, 7 Dec 2015 07:46:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B4862037C for ; Mon, 7 Dec 2015 07:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754218AbbLGHoW (ORCPT ); Mon, 7 Dec 2015 02:44:22 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:22462 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753016AbbLGHoQ (ORCPT ); Mon, 7 Dec 2015 02:44:16 -0500 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 07 Dec 2015 16:44:14 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 5650E4D87D; Mon, 7 Dec 2015 16:44:14 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 3688E1806F; Mon, 7 Dec 2015 16:44:14 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 30D381800A; Mon, 7 Dec 2015 16:44:14 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id SAM27515; Mon, 7 Dec 2015 16:44:14 +0900 X-IronPort-AV: E=Sophos;i="5.20,393,1444662000"; d="scan'";a="201249715" Received: from mail-pu1apc01lp0020.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.20]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 07 Dec 2015 16:44:11 +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 SIXPR06MB1024.apcprd06.prod.outlook.com (10.160.242.28) with Microsoft SMTP Server (TLS) id 15.1.337.19; Mon, 7 Dec 2015 07:44:09 +0000 Message-ID: <87r3iy66za.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/8 v3] 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 , Geert Uytterhoeven CC: Magnus , , , , "devicetree@vger.kernel.org" In-Reply-To: <87y4d6672t.wl%kuninori.morimoto.gx@renesas.com> References: <87y4d6672t.wl%kuninori.morimoto.gx@renesas.com> Date: Mon, 7 Dec 2015 07:44:09 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HKXPR03CA0034.apcprd03.prod.outlook.com (10.141.129.24) To SIXPR06MB1024.apcprd06.prod.outlook.com (25.160.242.28) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1024; 2:NV78to/WIHnP3KwGKb9gII1NAGbFN7+216/wYjbTnLCTgupnGDyS7np7XKAF8u+7yrPj1qwvCT0byhiIW66t3vX+whYvYhu8r7vvrPpjEg0Nm8A+2FNwp4ueaBfXrAitPEUAvx9etaxkAfiqGzBZ/w==; 3:Hlo1z+2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Ec0ZNbRDNyS39ioQHk1fqDAdlbUdjIOArww0KxLgkFRvqg2YVbXqttJ6ST4DW6jZ3pqGZrwKdim1pdDXjJUHD+NKDU7a+ekfiQujWW9ycw8fDNGr/i4vQ+X6nD2lyMafV/K7T//GpRNHqD67JZjkvcFT5m/G+m5qc88lgfSgW4mxRnqvdODX7sY0nBd/I/vOjmVEZG4CWvUqbhFLGy+XNkowx1MYqGPzkQJg8NL1wwb/CnP/276BJ4qbsY6l6asc32yGU00AEQZoqy3vENMRvAJme+GVnF97B3MD4jk83ztr4/6u93jb8hszglQV9fuGskQzFpnQDwOrERQDnXHvOUJraEd21ZLwATTWfBb3L2ZuEDfC YOHO4NxErAigRDD7dSX5nviOaf X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046); SRVR:SIXPR06MB1024; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB1024; X-Forefront-PRVS: 078310077C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(1096002)(5004730100002)(83506001)(97736004)(5001770100001)(4001350100001)(19580405001)(6116002)(86362001)(19580395003)(50466002)(42186005)(50986999)(76176999)(69596002)(81156007)(101416001)(77096005)(53416004)(3846002)(5008740100001)(33646002)(46406003)(66066001)(40100003)(2950100001)(23726003)(47776003)(36756003)(106356001)(54356999)(5001960100002)(229853001)(586003)(87976001)(189998001)(105586002)(92566002)(122386002); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB1024; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB1024; 23:QX00ZA3g8SoLPlkfOY6Mipc6M4cm5twOBDSDV7AZq?= =?us-ascii?Q?Gy/OrBK2+pfTa7Zu5Nz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G/x/z?= =?us-ascii?Q?I2AOP5xQSPLkh6ytEUzt7bz3UyTDD7sDOKI5w0T4O4DWshqJLUrwve6a8Il0?= =?us-ascii?Q?884gy2svTh5QpcVnchna3UpL3JzZY7JoGIv4Hc2eCfsqtb78NzLIpFCA7pZt?= =?us-ascii?Q?lbZKLEhatHG4puknV3k+UZcfpIxkSNSFbiysUBOYFXGDZINuw+OSmJXs0W6y?= =?us-ascii?Q?2cs7G5g8qg=3D?= X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1024; 5:GE5ycAHCq+zWmSrRg9rewKr5hPJrKWK1O+XBKiamXn2V/6E9gMbk7DqBdnyN8Ku/FqdfPuexZP6koJJqx0Gu9iiPj1qV0S6AMd/h6JUHdriewc/04DOS/k/pkusRLCCRO2N3Xv6793I7y1U56Yn+yQ==; 24:uGIVoE+9prmg5AEGK+c2WTkhn5jzAhlGUDUd0NytYUUCDnpzDPE/ZbBSqzAUE8Tl3sMiA0Lf003v9caIs4U3Afk60pjxzO8jssjmd9/EVvA=; 20:+xSsS5OxJHSF/HFHWRPiVg3GlqIZCRELKPH899iIz/AUObylsu9Z28jMBqaTw2ariYsavn/80cxozQrjezC+v2A7O5KjqX19+u7xvjsF3pF5gVOP+OFy6WlKBSH45UmSxnhZp5AwUzKCarNbBee6xGX9cxgb1HoFKXxzZX20XZA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2015 07:44:09.2545 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB1024 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@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 Acked-by: Rob Herring --- v2 -> v3 - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal" .../devicetree/bindings/thermal/rcar-thermal.txt | 37 +++++++++++++++++- drivers/thermal/rcar_thermal.c | 44 +++++++++++++++++++--- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt index 332e625..601a54d 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 = <1150000>; + 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 52493b4..a8c88f4 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -81,8 +82,10 @@ struct rcar_thermal_priv { # define rcar_force_update_temp(priv) 0 #endif +#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); @@ -206,9 +209,8 @@ 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; if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) { @@ -233,6 +235,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) { @@ -289,6 +305,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, @@ -325,14 +345,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); } @@ -410,6 +436,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; @@ -470,7 +498,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);