From patchwork Thu Jan 28 02:45:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8145771 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 B079DBEEE5 for ; Thu, 28 Jan 2016 02:45:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1F92202FF for ; Thu, 28 Jan 2016 02:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A42B6202FE for ; Thu, 28 Jan 2016 02:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967388AbcA1CpQ (ORCPT ); Wed, 27 Jan 2016 21:45:16 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:10090 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965155AbcA1CpO (ORCPT ); Wed, 27 Jan 2016 21:45:14 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 28 Jan 2016 11:45:11 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 10F504BFA0; Thu, 28 Jan 2016 11:45:12 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id D29A8480A3; Thu, 28 Jan 2016 11:45:11 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id B801F480A5; Thu, 28 Jan 2016 11:45:11 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id MBH06651; Thu, 28 Jan 2016 11:45:11 +0900 X-IronPort-AV: E=Sophos;i="5.22,356,1449500400"; d="scan'";a="203170136" Received: from mail-hk2apc01lp0213.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.213]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 28 Jan 2016 11:45:10 +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.390.13; Thu, 28 Jan 2016 02:45:08 +0000 Message-ID: <877fiu2zos.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/4][RESEND] thermal: rcar: enable to use thermal-zone on DT User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Eduardo Valentin , Zhang Rui CC: Linux-Renesas , Wolfram Sang , Simon , Magnus , Linux-Kernel In-Reply-To: <878u3a2zqt.wl%kuninori.morimoto.gx@renesas.com> References: <878u3a2zqt.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 28 Jan 2016 02:45:08 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0037.jpnprd01.prod.outlook.com (25.165.48.147) To SG2PR06MB1020.apcprd06.prod.outlook.com (25.161.9.28) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 2:7uj9BBkPtIs+RD/rVRDsOu4BckpXabh5FIYLTAKY92UJqh57RyIbEUMyVRwHE+1/7KmO9qJLRGNwrwTq9bn41UB8QVNPfIvHxBNoCbkZVR2l4ECaco0pDR5nQVTb9W3dBV9cP0wtRxQVtcy+gM3S1Q==; 3:srNYi2553FWwbZTgATOlPZWmfx9hkHArVfeDasysBFgkdZ+qaBdhBG+YRqoZiT+DN37XI35iP7rM3hWxkCDHsgjfrDR5e3ojrD4iW7Q1Eq267Xas/emdow/VT572YV/1; 25:c0mA3II1hM4cfLugtY2ei8nM7ommns7ienkZW/2bPeNxxgDlZ/EcZFZ02gCBuIKQi4drXH6mLucqcJPaHr1PfTE2YVCV0D1QrEQa7OLvd16G+FOOzAs7pkxKAHrGogdnngk1jGdLoB78+25kWOJvf3FK73DJDCrK8q8f6KFz3MhZpbPpR0cfRjjGFmYTQC7ynAF9N+cVLlNsGXmBa3m6/Xb6IuoZbQgFnSDttB26pLS9IflGt2dSMC63i2s0IOD8 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB1020; X-MS-Office365-Filtering-Correlation-Id: 4d39c389-c7f3-44bc-7474-08d3278d096b X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 20:MY/iVq6Pm423qimN8dmCtthUr71VD9oTzAdqqIrLiTAYfb/59ABe+z9WgSQuX6chxJwtJ6am16yHcIMyWchyJI2JjsIyKYxdbW6/7HaNKHgU7irlBZNd5mcb/Om2HuxRn1tFEDo5xBmw8KIizjZYv9/Qsdm0UzuJqSgoc/sZiCZr8z3e08T1Rw0Z8xYSbUBLOVduzRj7vcmI7qbyTUqOwaOnn0FaryCUjnkt7w83GX9KkSvWTQw0o7Cy/ZfeTUoLoOq78rSKayPqVHi6g47Kg/xHe/eeUJfXRmDrr63YgWxWJwwhA3YXS2+yY5CoX1cMa4Uveyf0z8gZUXAg6XZ6ErKMEK/zmk4+iKCqPMIiGqO5Oc85qL02eX9xUGpZ+ipIdQAKuXx1+75u9Ubxxi1b06jiQRryjBJJJvHg524ZTL+yPQfaEt8Shsnqdbp+S3vQCYJrHTCufkuubBmFTwU89UjPUT6wlyKAEigJWr/8kNXJKmkrgvmSaAxS3FthGlU0; 4:p6YW7yUCxWL/uFepxEcA/b9OXXMQkikvpO1wWEyeX7RiqpHks5raMtFx7uyKfnvqapi0wudbXG1uUXbmbqZp6CFEV8Zodef9PzbFtNhIwnoYA5spzeFcPwc0aRsHYJ5PJWtdML/Zk7ZcCRbQNtAb7j08mWb9ATZasx8tMsVuUKn1mFtSXBEnZBy3PFW1g0q0iH4nGrmkmJetcWMVB3V/8lkBrEY3wh9rnsiSQOZx/lJP+VBPMCo/SWNXKaunamH+lIx66LaexVzzCue2nke3ZmzRNTRwSFPM7z1YQ1zo9Jh9l04vemsKDKuaop1gYKMahT+ATcw61j+Zq+QDjP3TqfxQuyYJmsxgKoJ+4morGncZ9fxC74+teT/wjIH9wDgZZVNsJHKbX6e9NrgBfsXwwQdSW8qGTZYCH//xSI dvw6I= 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)(5005006)(3002001)(10201501046); SRVR:SG2PR06MB1020; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1020; X-Forefront-PRVS: 083526BF8A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(50466002)(54356999)(5001960100002)(2950100001)(3846002)(36756003)(23726003)(189998001)(77096005)(50986999)(106356001)(6116002)(97736004)(1096002)(229853001)(586003)(105586002)(5008740100001)(4001350100001)(3470700001)(76176999)(19580395003)(5001770100001)(66066001)(101416001)(81156007)(47776003)(46406003)(53416004)(19580405001)(122386002)(83506001)(4326007)(86362001)(87976001)(5004730100002)(42186005)(92566002)(33646002)(40100003)(69596002)(2906002); 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:G2qubxVus6kGvJdt9bLFjhCR/7VU0EQbxmPd0U7wM?= =?us-ascii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Ty6GxLjROenTEHl2OZsPdnf?= =?us-ascii?Q?fqQLF/0F+7FfrfrZj1wV4046T1mPEksVzRVl7xyTkRNAuolPBASG9uvmrjGZ?= =?us-ascii?Q?kc0a1tZ9S6ozRiIabc11l61QLYylo102CQ2/AXVLJ6BwnuyoHoZDo003LkiK?= =?us-ascii?Q?H9BxwiXtbXI0+n+3u9MVFQXtOki2I9J8UATowVi0tKVJ0i8qaqZH/3cubKcl?= =?us-ascii?Q?0bqGRrDd4QhubGS2gFyiNqDmDyzTljkn6gwF/05cDoXjQdhRXx7HHVaOrGWW?= =?us-ascii?Q?Btxo3xzu1kt3FY=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 5:4gKmGT7y1tYliUmQwci/emya992V40ZVvd+6++uzHUDLdT4SXYU2yvDe0XCvE83hlOGyZcDTeXkCfewjSIyWCt04R89RADDpJ+zXySjtLsqYXZy8dJi1Mnih5UQfqBY/YQar1PFzKcBHxMrLloITUA==; 24:iQLjziW2VyhxyLqlbORvgdCaywyvyeNKFbY1xG9xEBfhD0IAlHdAMaNB/40DeO6G2PU7og4B+TWRF6jKJOvsucjw4s2z61DPxzN7KRa+cHg=; 20:uyTG2uovwRyDyisksOBdYQ9ti3ePueERLJ2LHBuVbCpfN1K5TSdIDpDMim+4sEFq+xXWmj3OnQkScGXF6hK14+SZ3Cez5qxsMdf4xnle0belHq28HP9aYs5Jt2ZFOfvzBR+YtuVFhZyJPgZTIjATbJQDDpAvjRMBix7A+8FRC1M= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2016 02:45:08.0658 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1020 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 --- .../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 44b9c48..0e735ac 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); } @@ -403,6 +430,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; @@ -463,7 +492,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);