From patchwork Wed Jan 20 05:56:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8068421 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 B9D1FBEEE5 for ; Wed, 20 Jan 2016 05:56:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F74820340 for ; Wed, 20 Jan 2016 05:56:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 767E1202FF for ; Wed, 20 Jan 2016 05:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751300AbcATF4y (ORCPT ); Wed, 20 Jan 2016 00:56:54 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:28180 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752242AbcATF4w (ORCPT ); Wed, 20 Jan 2016 00:56:52 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 20 Jan 2016 14:56:51 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 73B1E4722F; Wed, 20 Jan 2016 14:56:51 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 5567C8002E; Wed, 20 Jan 2016 14:56:51 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 508DC8002D; Wed, 20 Jan 2016 14:56:51 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id QAK06235; Wed, 20 Jan 2016 14:56:51 +0900 X-IronPort-AV: E=Sophos;i="5.22,319,1449500400"; d="scan'";a="202621918" Received: from mail-sg2apc01lp0241.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.241]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 20 Jan 2016 14:56:50 +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 SIXPR06MB1023.apcprd06.prod.outlook.com (10.160.240.28) with Microsoft SMTP Server (TLS) id 15.1.365.19; Wed, 20 Jan 2016 05:56:48 +0000 Message-ID: <8737ts4x13.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/4] 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: Zhang Rui , Simon , Magnus , Linux-Kernel , In-Reply-To: <874me84x3p.wl%kuninori.morimoto.gx@renesas.com> References: <874me84x3p.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Wed, 20 Jan 2016 05:56:48 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0016.jpnprd01.prod.outlook.com (25.161.131.154) To SIXPR06MB1023.apcprd06.prod.outlook.com (25.160.240.28) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1023; 2:vQZpH+/05vkiCXlAqNes69Bds5ISW3CuUqVPZ49zwlWtCAUDlpMke0vfgVTKSShZWS9wsGeDiJV4vp0Rai0EkDX+xZzF4x7JdqBsxgK13Klcb1ZEzyF2OCizSEHwz+TfWSaNuHSiT8zEhCjlPKzV0w==; 3:d8/fl6utVjCRmLoVRL/mAqcX/Xg/N2zFUXccsCTpmfYjkP//+0vPl0UAYxEBkPDMjEqSYEFDCOSB00R+Pz3yzUpvdPxFF2ZeAJTySxJUxF/t1awghaC6lVsQzF7ZwbKl; 25:IdUqZuvgMrjQvjar9LLaU41q2028NTV8I9GE3ri0qiUEEgcfQ07TVXMLoENtcwsRaeOyoVeG01fBuRXHCzw1NIecp2H0H2xHKt+qeeD6sWoTlPZpdCI5l+Mm2PiL4bm49hERBJ4a3KJAm+LyXgm4FSsAuv8+E9nsFPOrI0Ryqdp6a99/wXBgIcX1DuSbsku2fFTb9d+u6dxbS2jqY59w7tA9bXeoUu/Ew04tW97Zh/F5rEnJFHNTrTBdOb4SIiSV X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB1023; X-MS-Office365-Filtering-Correlation-Id: 1450050d-24cd-4abb-daa5-08d3215e7cba X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1023; 20:Sp02E7Xq3pFRpRvIDjMpVI+aGRBf67lPLghU3N4A6KuEp0N5zKB4RGHqaifBZor2za+nlD/nQYJBso+K1d8oWW08z6eewJqQkPxc4tuleiBV13Ee8E/iUhdxRO3SiiWRhf/IcUwcZClrk5MOUbUlIFJKxWKLFYtwZL2FWcI0l6yAgkv8kaxLiN2w6cdFAb4wXr7v/8w+2exGyr8ZMvNN+6IDBGmSPDr/HQ9WcV6B7M2dioemY5Uu3p6YAOQ6WuQB9iNV9/24DClywAUiWm6jn6Z1sT46YO104pjq2VTNliey6E2M/vy4LJTOINYU8RENIxgeilS3NFUPDG6i2wXDQ1jImt4kZQzd9ZP9WIBBnha0wg7/XBX0o2M3rEq9d6dfWSSDCRR79X/Z/scMxzrzoKOqdB+k7gwKScODHhlaAZTqjthl8Sns34oY2w9XdbeaOd6nWdBsd8m+O3e2P3X3KUqS5P1ItdAd1CochqRkVBH5x40hDEWKUC4PsDm8hlR8; 4:zrxhdUtTJdlf2zEzBof8jEcL/xgboGR8plmEtINqQuuu26EDaux3Xm1tQMTaJhe/hJ5jd+JuHEZOlMLKuk5AfO99dGAW/q1gX3UafKkf+1UYnz0ywhX/bV5CWUJfnosboqycjOg91SDHqbIq2UKFKTCjkVjaRJAsRgYVq5nNnNsE2tMtb/AqNvCg/gAdTvPsbqDGdHA/v1TomqEHHgyk9/JhAK3T4Rr08AzgajjjrkIi1oc/UfvAlTwWZcEaj1TcPkYESl64N7v/AVefwfyZUuPQHYnqQGvSGAHO8MrVrJa0+WT/O+iqjZQ2iSGeyO4RjIptJepw20vhHrzA497bcytRwF5Gj84aDrp2AezcVJ8Eimr3oFf0ReKw+VCSrzDF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:SIXPR06MB1023; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB1023; X-Forefront-PRVS: 0827D7ACB9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(83506001)(105586002)(77096005)(5001960100002)(3846002)(23726003)(6116002)(4001350100001)(5008740100001)(19580405001)(122386002)(106356001)(69596002)(229853001)(97736004)(5004730100002)(47776003)(1096002)(101416001)(40100003)(1411001)(586003)(110136002)(2906002)(189998001)(87976001)(66066001)(36756003)(54356999)(86362001)(76176999)(19580395003)(4326007)(50466002)(92566002)(50986999)(33646002)(81156007)(53416004)(42186005)(46406003)(2950100001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB1023; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB1023; 23:PHGBM9hzj3lQIzAsX/Zll2S+SGBeYuC5JcoEg6dcE?= =?us-ascii?Q?aRQo8UurkhgZLomwe83XFxJ4pp0Bi3X4eOi5Woe5PXSHLokm8PVy6vJb80KR?= =?us-ascii?Q?FW+PCZRk8B5gNOtn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= =?us-ascii?Q?RiAe2pmrrBkRo8nzLWZfwVYBU/S7cvyIfP9KVPIpXQSZRclvv5hUncIBGCmp?= =?us-ascii?Q?HEN8dZslXL56t+RjW8FFNpad/vr7oNlpmWsL/RoLizCIom4r/Lc5bBJt+ZnG?= =?us-ascii?Q?qY9DV2t2lqRcxhzGk5S+M+Rpc9mb1DK1kq9aUB+J7vZQbNGpvWm0w=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1023; 5:D2E4kbytfiDI+V8wjJLfhamNojYgC0bVQcdq3I+Z4JinUMLu+uzrJR/mvFDFgpix8iNVk092c+mlxi0SnJKdhP03EHy7vLFGtTdDkVR8gtCBGRvDmFcNdIAal5XlKnnXXqII6QoJ2oraal0PG+WDug==; 24:HGRmr2/MBWWFp5wGWiNAZOJ06HGHZvskIeXWd93jJx4Hyr2Zqf8KQP9IDkAMrhgYtuNUkY95lYhFMRB4puicQmTxLxynGOctU8/XRti5AdM=; 20:reWGiv7hW94CAHn2oqLebls2kJIZu5YAp0L7tVazXq+QqBUmCOC3m27y2Iif+h5y8lurwrzEUWfbxuRswJF6ZpHoy1eFbjfUYvZrbDzOVnNQLpuf0/J4w+ZPS65iwFJ8IdLHGNj2o3Dggv1+4u+R9Q0J2Elt1RR9mIdlos6vvUU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2016 05:56:48.5134 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB1023 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, 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 a18a732..27764ae 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, THERMAL_DEVICE_EVENT_NONE); @@ -404,6 +431,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; @@ -464,7 +493,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);