From patchwork Tue Dec 8 05:28:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7794491 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 3C093BEEE1 for ; Tue, 8 Dec 2015 05:30:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 490122052C for ; Tue, 8 Dec 2015 05:30:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23C3B20515 for ; Tue, 8 Dec 2015 05:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932649AbbLHF3I (ORCPT ); Tue, 8 Dec 2015 00:29:08 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:63772 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932332AbbLHF3F (ORCPT ); Tue, 8 Dec 2015 00:29:05 -0500 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 08 Dec 2015 14:29:02 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 3A50245908; Tue, 8 Dec 2015 14:29:02 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 2D796480A3; Tue, 8 Dec 2015 14:29:02 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 263E248014; Tue, 8 Dec 2015 14:29:02 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id QAV26479; Tue, 8 Dec 2015 14:29:02 +0900 X-IronPort-AV: E=Sophos;i="5.20,397,1444662000"; d="scan'";a="201319709" Received: from mail-hk2apc01lp0207.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.207]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 08 Dec 2015 14:29:00 +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 SG2PR06MB1019.apcprd06.prod.outlook.com (10.161.9.27) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 8 Dec 2015 05:28:58 +0000 Message-ID: <87mvtl5x54.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/8 v4] 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: <87vb895x9d.wl%kuninori.morimoto.gx@renesas.com> References: <87vb895x9d.wl%kuninori.morimoto.gx@renesas.com> Date: Tue, 8 Dec 2015 05:28:58 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0019.jpnprd01.prod.outlook.com (25.161.24.29) To SG2PR06MB1019.apcprd06.prod.outlook.com (25.161.9.27) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1019; 2:+02/PN4j6hq+1bvv6BWF9iyozAKc8CtJgZBrgEmwZzXHvXTsVySdcyyA0G/J+vMTEyb2t77Dn3F1IVUT9+yH/oY7/kj5x7XVf+lqSkSgFi00oNfaBKyg81zM5LJ4P4OQjSbdt2y8k0+J6/vV1uNQLQ==; 3:rfY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mUCn7JkF9CrfHRPiK01JcN4UMtLQN7unbs8Irz5gNfU7RHtaBRss2Zo8PDtQOoQbb6S7nVz/h+1xJiwght5F1gb9/qZ82xaEnjuADXX2uBmBJLGdySj9HcNDsDZa6LiqypVhLrwWZAy9QtLdfE5ojui72XoLTd1XgiNiwBNaHgdP5EWOl4DTd/72zZcfai8pMUdVZkYZUHgRp1P43QCk7e69TocdJClUNGa2B5u3c2adt5NGUhwGrvG8MgQCWBIxJO+nEkQFMJgbpaTwcyAKIUmCKihWVQf3jZBs5P/oQIG9VvMsuqlJd634ExXN2xHEc7xepIlKuWEIIVpZfcwUpR6vkQkJdwy D9Lmf96Uk/aa+OHzVWBECwGWzJ 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:SG2PR06MB1019; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1019; X-Forefront-PRVS: 0784C803FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(5001770100001)(76176999)(36756003)(66066001)(229853001)(33646002)(86362001)(1096002)(189998001)(47776003)(23726003)(6116002)(46406003)(3846002)(5008740100001)(586003)(4001350100001)(97736004)(122386002)(40100003)(92566002)(5004730100002)(50986999)(69596002)(81156007)(83506001)(77096005)(106356001)(54356999)(53416004)(101416001)(42186005)(87976001)(50466002)(5001960100002)(19580395003)(105586002)(2950100001)(19580405001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1019; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1019; 23:7Vh4ESDQeVdwhJwfe3jtuXWYVrWifUT6p4my/nnHQ?= =?us-ascii?Q?Tt29gxx9w1jEvl83DgKtC+QFOvoMNG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=?us-ascii?Q?QfQS6iSNkfXdfKdgu3LvDZ2GFWqdSJnFhkdR1BGD8+vvwCHOM4Qikvg5lGS+?= =?us-ascii?Q?WNrcYbcSArnRglbW7e2KSHULPo91gtpbjeTLOIPZI38h7TDxdXnpo4zUX+8j?= =?us-ascii?Q?TMTwfc7FiDcJtmksvhTuANuiP/D/QAWTEG2xaSYZvw+eRf2MM82dAigs0yZT?= =?us-ascii?Q?61xkcGMaCg=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1019; 5:0NdSKTrEAQEyYsdh/AvxbEu5ZfYHAIXPtWEf1MmgQXWmdN74pgcWoNAd30dsPeCtRQWiUgOrs4jt70ch3Hyj8IHiwCzCHlcTldH4duMnx9/bLpu/eD/dPKc9Jux6UKasBqMVmS1xR4I5C+s/WiBfag==; 24:7wRWbPdfS2MCAUtjJcrkawdN7Vwv7ubbRYIo71W831mzYMuU8V0bIc7I1uvDLq57qt2yDt+c2uzmKbMSFzuc/iJzbI2yepysDH1YjmzB85g=; 20:37UkHxkravEeZsdCSaW56jZ8gUe20rnt7L8NACUi41TODcWkv77trqInEVVU8P5S/KS76MdMP6kY71N+AKqc6XUtg6wZim3kh4cDmVCnGKg5KF271NKbIRVOTodXl3TvvKVey26LaNEz4NWmRvmLInIoJbJHVDx2lJYZvvf/L/Q= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2015 05:28:58.8183 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1019 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-gen2-thermal". Previous style is still supported by "renesas,rcar-thermal". Signed-off-by: Kuninori Morimoto --- v3 -> v4 - no change .../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 40c3ba5..d4d2661 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)) { @@ -234,6 +236,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) { @@ -290,6 +306,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, @@ -326,14 +346,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); } @@ -394,6 +420,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; @@ -452,7 +480,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);