From patchwork Fri Dec 4 08:34:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 7766101 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 916ADBEEE1 for ; Fri, 4 Dec 2015 08:34:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2E3F204A2 for ; Fri, 4 Dec 2015 08:34:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2110C20498 for ; Fri, 4 Dec 2015 08:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755545AbbLDIem (ORCPT ); Fri, 4 Dec 2015 03:34:42 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:64678 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755442AbbLDIek (ORCPT ); Fri, 4 Dec 2015 03:34:40 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 04 Dec 2015 17:34:37 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id E59964640F; Fri, 4 Dec 2015 17:34:37 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id D6E38480A4; Fri, 4 Dec 2015 17:34:37 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id C555A480A3; Fri, 4 Dec 2015 17:34:37 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id TAE15378; Fri, 4 Dec 2015 17:34:37 +0900 X-IronPort-AV: E=Sophos;i="5.20,380,1444662000"; d="scan'";a="199892243" Received: from mail-sg2apc01lp0245.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.245]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 04 Dec 2015 17:34:36 +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 HKXPR06MB1014.apcprd06.prod.outlook.com (10.161.178.156) with Microsoft SMTP Server (TLS) id 15.1.331.20; Fri, 4 Dec 2015 08:34:33 +0000 Message-ID: <87a8pqfwci.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/8 v2] thermal: rcar: enable to use thermal-zone on DT User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Simon , Zhang Rui , Eduardo Valentin CC: Magnus , , , In-Reply-To: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com> References: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 4 Dec 2015 08:34:33 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0032.apcprd02.prod.outlook.com (25.163.104.170) To HKXPR06MB1014.apcprd06.prod.outlook.com (25.161.178.156) X-Microsoft-Exchange-Diagnostics: 1; HKXPR06MB1014; 2:2U7BPjr1DcVXq2UmnefpwXAY4x0+lr97/XHh2SKJPEEps+7FWvn68nUh+XaPoksN6JN+gGUqbCJxlYTN+EPOO3L6EZK4GQl6OQG862E3RdLLlmAF8dRjVHZ3svdKy2LuNoq7aVVZViAJJ4eycU6Dng==; 3:mmrPn5J7CnCgVDcsJ2W3A6GOkyzzk6w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3K0QqO0d70QW8C0FN9d3O17QZFJ3rhSpk5iGclcvU8lZdIBRpPLFl9q2Bbtn31ZVhapCGZX8Ex15ddy0aTVUPTvyZNlJt12HcaIjAnpKsvtRaoiOKTPhkCugljstcQqysJqQ1Zsj6pJvyUBHKMOx7pN9GZ/VOfjDlSL78ZHIzH8uODmhT0UVpzvyx1xRdMH/Por2u5L1tb9b5IxtYU35PFTwrwvne649h4yKiGblVcoAL5u0jrt9v6V6bSi/cnuX54jSz7cBzkSqEcoRBPDISmpLvS4kTvhYn0fhAhGwILZxhCDsk9OtrrqBfDoBVcBax2VMHP6lpw+6Nj0YdTudpn jB/U+7qnWTZYpZyDhuWliN6T0m X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:HKXPR06MB1014; BCL:0; PCL:0; RULEID:; SRVR:HKXPR06MB1014; X-Forefront-PRVS: 07807C55DC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(4001350100001)(66066001)(54356999)(36756003)(46406003)(97736004)(1096002)(5001770100001)(23726003)(47776003)(189998001)(81156007)(6116002)(3846002)(5001960100002)(50986999)(19580405001)(122386002)(69596002)(76176999)(19580395003)(50466002)(586003)(92566002)(83506001)(40100003)(33646002)(105586002)(101416001)(5004730100002)(53416004)(77096005)(2950100001)(5008740100001)(87976001)(229853001)(86362001)(106356001)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:HKXPR06MB1014; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HKXPR06MB1014; 23:8tmHknmGC5u7xEZLg6a4I7OjJcXBbVI/NBb0NsPyM?= =?us-ascii?Q?z5pCOXKZHui1shFfshCGtOn4c9KNabj5V/2/9HUO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SBoT5JOYyC0l8rce1l/6TttWIfLzdLvBR0mVFmLs?= =?us-ascii?Q?6mmAljlVnO7+IpzL2P430mNMzwrkzW0tgcuf2FtTQ87ntvlTg14/MS8O0W2c?= =?us-ascii?Q?dlOuPOjvbUs9izs2fTTTOEEUUkkImOnUJpQ6XnZtnaAVjGO2Q7xgZP8d/qjU?= =?us-ascii?Q?q3hpxcodYU=3D?= X-Microsoft-Exchange-Diagnostics: 1; HKXPR06MB1014; 5:ltSXj3ujYw+5MaTR/6uxPJN475Lms0pSZFoauCBlw5Zkllk/jfsuiu4pTwgaJrpuvLXdRCrOuI3mhPFnPqEyxYfwddI2L3ZxSRZeoVPv0mfyuSBuYTuK08wrAQdRJ/VpmHP4q3mA63jKN0wxomRufQ==; 24:QYaCvM7oa1eXs2dMQIwbOXVxBl6CpuBL4ULaUZ/pBEp0g7GU61lLACUdodks7oW9CqqCbi5zaFTkR4bZXvd4DDpmiHLpmQd/Bpot8pUeja8=; 20:FJA28zsrNTyyUe+m9EUhY48n0mcoevQjJF6YboEsPkbKf+Oza1Bkoh3iMRAPgo5yt69VC9iZBNE4n1+D+Tu0uXjncReu1MkzXDgPchWFbK85cPXjCh7cDlO9Vsw7kcp6GFKjx+9NP0kFi2rFN5JvEsLb5m4kEXTHeKaL0SDdaNc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2015 08:34:33.1748 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKXPR06MB1014 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 --- v1 -> v2 - get_temp cares return value .../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..904f204 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-thermal-gen2" (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-thermal-gen2", + "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..79ec26d 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-thermal-gen2", .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);