From patchwork Fri Dec 18 00:25:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7878101 X-Patchwork-Delegate: eduardo.valentin@ti.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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C5E26BEEE5 for ; Fri, 18 Dec 2015 00:26:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A02020450 for ; Fri, 18 Dec 2015 00:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB68720445 for ; Fri, 18 Dec 2015 00:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932265AbbLRA0A (ORCPT ); Thu, 17 Dec 2015 19:26:00 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:42563 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753512AbbLRAZ6 (ORCPT ); Thu, 17 Dec 2015 19:25:58 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 18 Dec 2015 09:25:56 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 29FAB46859; Fri, 18 Dec 2015 09:25:56 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 1EF368002E; Fri, 18 Dec 2015 09:25:56 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 19A798002D; Fri, 18 Dec 2015 09:25:56 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id KBA20091; Fri, 18 Dec 2015 09:25:55 +0900 X-IronPort-AV: E=Sophos;i="5.20,443,1444662000"; d="scan'";a="200811097" Received: from mail-sg2apc01lp0247.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.247]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 18 Dec 2015 09:25:54 +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 SIXPR06MB1022.apcprd06.prod.outlook.com (10.160.239.156) with Microsoft SMTP Server (TLS) id 15.1.355.16; Fri, 18 Dec 2015 00:25:51 +0000 Message-ID: <87wpsctxjv.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/8 v6] thermal: rcar: enable to use thermal-zone on DT User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Eduardo Valentin CC: Simon , Zhang Rui , Geert Uytterhoeven , Magnus , , , , "devicetree@vger.kernel.org" In-Reply-To: <20151217203707.GD7999@localhost.localdomain> References: <87d1u8qzsy.wl%kuninori.morimoto.gx@renesas.com> <876100qzp6.wl%kuninori.morimoto.gx@renesas.com> <20151217203707.GD7999@localhost.localdomain> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 18 Dec 2015 00:25:51 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0019.apcprd02.prod.outlook.com (25.163.104.157) To SIXPR06MB1022.apcprd06.prod.outlook.com (25.160.239.156) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1022; 2:0R5ZcDOLO2r1E6uy6uHlq7ezdfZUNsmJzH/kEngnps99Vhud6au/5QANEUlW8wZymnACzvoMQE5WBNm8MGox0wObHYwkTUVE7SRFlBw3EykfqPXx06No/a5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/uVLDWcFdq/jmDMUcewFE4hSgdwEQTltH8l7hu6VkympPlUt0kNaB1+C541Edm9t6YPtZAOxEixplde7+LkNHjNeKx4xdPxZMeX9sQdPKsEKYJCeDEK5CM7U9a2vSpI1fiQOpvIYzUvQdr6OoI4o+uBtlfFlQpoXxHLOL9TBo7EdCJRFkd2EF4VWCV4QxuNqpMnJUvZ/aIRayxTFWb8zWgFxWnrWx8l94pViB8JrgyMa1iPNuSo3U0l/WP7WDQdkxBJnRiOQCXFYf7QWPnjrdHaD+vWg6l21ppB0tSamKKX4Eeda/Ap/8FK1IPKPpYnVm4zjNkCPHMn7k/GtA1RfAKa9oKSA8jNA0QMVFc6uIwy6jedrIbnwMUBw7mjwuNkhsg+NceBKMSzt5R+J1VsK3n C4YH6oJhERP6aBoPxTL77enlUm 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:SIXPR06MB1022; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB1022; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(19580405001)(47776003)(66066001)(5004730100002)(105586002)(50986999)(87976001)(54356999)(76176999)(1411001)(101416001)(106356001)(92566002)(83506001)(53416004)(42186005)(86362001)(33646002)(229853001)(19580395003)(189998001)(5008740100001)(110136002)(50466002)(2950100001)(23726003)(46406003)(5001960100002)(3846002)(6116002)(40100003)(586003)(81156007)(122386002)(69596002)(97736004)(4001350100001)(1096002)(36756003)(77096005); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB1022; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB1022; 23:UVc1Nse776YOdqEhbRct/vdgmI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JOk9n5Hd8Uo0AIT1KIHD941TGzQpUG?= =?us-ascii?Q?03lENUcZed4WFBQES48ULq5tDcCTdlt5fwsvmPxCT2A1OU0OYYjCoKk81i3N?= =?us-ascii?Q?vAHjkQY6m1YkPgUoMvKeVvmCGXrPR5prgHA02RedHzCjOZAXqv+sICFd8J1W?= =?us-ascii?Q?Kd9shrrGGTvl/UlRAHqlE5mkeX6My5CHi9XVo9RGGuS5rwftIlXvZ80mFdoq?= =?us-ascii?Q?0+qX53qnkY=3D?= X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1022; 5:2dr5RdSy/blPgvYewgbCiAFxmIogd7JRJ+t0uW2k7hk82yl0VKfqRAX8WDyNjoL5vEvNkqeq+nTwsdzqoxdrVsLOTO5cyF9OWNHZki5Kt/qRWkig6Z2TGYDbuyDGSDHHy/JUClTcwea3OZxyx9IxKQ==; 24:YP5Hz1FMkWJIs6cuIbV6LVT7WYH8UM1tyPjyZjlQMPrtM7hR4jAC90u5Htn+W8sCcbazuwajpQsqmL7aZrPxihE6YF7BHPgYLkX/ZeWSvA0=; 20:pztl6mutfBRZsh3nlcmMeDF80Uwpo1HH7e5MwyPiE1TGojPpHMEKp3oB/z36yGsTcP6IyS+QD87lUl34N6/Z9BSElxXbzju4zSxEFJibSI6TEk0W34Tw9gWHt95fYTrPf3fdRKL7AYqYTUwIt7zEcyTEupaHFh1dZDBqyyqujoI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2015 00:25:51.9345 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB1022 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 calles as "renesas,rcar-thermal-gen2". Previous style (= non thermal-zone) is still supported by "renesas,rcar-thermal" to keep compatibility for "git bisect". Signed-off-by: Kuninori Morimoto --- v5 -> v6 - "was call" -> "was called" - add reason why it keeps previous style .../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);