Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755266AbbLDDRx (ORCPT ); Thu, 3 Dec 2015 22:17:53 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:31433 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755102AbbLDDRu (ORCPT ); Thu, 3 Dec 2015 22:17:50 -0500 X-IronPort-AV: E=Sophos;i="5.20,378,1444662000"; d="scan'";a="199869502" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Message-ID: <87y4dagb0i.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/4] 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: <871tb2hpn2.wl%kuninori.morimoto.gx@renesas.com> References: <871tb2hpn2.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Date: Fri, 4 Dec 2015 03:17:43 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HKXPR02CA0052.apcprd02.prod.outlook.com (25.161.48.37) To HKXPR06MB1016.apcprd06.prod.outlook.com (25.161.181.156) X-Microsoft-Exchange-Diagnostics: 1;HKXPR06MB1016;2:04km38btlMFISmtgpySj1uMjy2RNOItw0d76v4UI/bqcy4+N6WBCf8pr/1u0IYZrP33QUac7HzpC2OnaTFkGSBVGfDRv+R64bxpkBxTFFz8y9xso0dsuCuWCUgaNon6t/rjsQmEIBFslAleVOqZ2gw==;3:kCxFobU5C5wHhxJ9QJbcjZBPSEE9vQOGmBUlf0pgrqGFBCRJay31zskDsEaS/PZIVrssn+uZzPIYNzxmnEUMU8VScbvjFGvlNzC91JZXpF22CCjBJJaJRP9dSGA5ViMw;25:Fhq8sT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SaHFnYtk4XIu+CwJYuURgh5+7d79DlbKFEkdSTQzD19CIh0tYUpGISnBojk6gnLYVWsiOtUqC4QbQPn8OghiAAQdNzi5/Pb75O57A/UE1AHJmrpjKxlWSb2PcrlebFBTD1XlCCBk5pEH4pLhOexs+tLlvqHjr1zWas6ekpArar0d7FOs3eWLEdhxpMDQYVzCNLXTlcCW2NjsF2VeKvbwFOJswUKGEpynKl4MIEgvebf9tgobDoTtFeYlgf 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:HKXPR06MB1016;BCL:0;PCL:0;RULEID:;SRVR:HKXPR06MB1016; X-Forefront-PRVS: 07807C55DC X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(33646002)(69596002)(106356001)(83506001)(19580405001)(40100003)(19580395003)(77096005)(229853001)(53416004)(86362001)(42186005)(586003)(92566002)(36756003)(46406003)(105586002)(5004730100002)(81156007)(4001350100001)(6116002)(97736004)(1096002)(5001770100001)(66066001)(76176999)(50986999)(54356999)(50466002)(2950100001)(3846002)(23726003)(47776003)(101416001)(189998001)(87976001)(5008740100001)(122386002)(5001960100002);DIR:OUT;SFP:1102;SCL:1;SRVR:HKXPR06MB1016;H:morimoto-PC.renesas.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HKXPR06MB1016;23:NvF3kFkTJCJlu0enabyAqwDLOdcYoq7SSS3fQh9jz?= =?us-ascii?Q?Kdhyp1QCwPUNeuSz6WxNJFy5dee7UDg7AspQVrYcbaD7dpU+bU3963kDsJgt?= =?us-ascii?Q?UPNel/zT/qgT8gUIxHSdV8km5UAi9uggXb7/e8ZjRhrSyFnq2/yIU7esso0y?= =?us-ascii?Q?+lKK1W3rFRrc1O7uI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?us-ascii?Q?TfxoWI4PuZCWOeuv2UgVhr3eSHv+f+XwU82Z1VqX44ByFEi5N2P1TSbXvEeT?= =?us-ascii?Q?fS+X8Jcysc=3D?= X-Microsoft-Exchange-Diagnostics: 1;HKXPR06MB1016;5:X6r/E4BrosqXEM05ArUR38dcAJSPUH/Vru4gpnJkMXGRF4vA+K78hZVq+DSutLitL3eh4QF0bOhoubAWJGK7d5mgAXGJu4fp5XfOS+oyJItZxpLAaIomhOdtnM6a2APl44sSc0WJ1Os26rWN7+H11A==;24:jB+X5bB1MwRGB3IHnj4OYjl55NEfSnUMz4CZeBxOK1Kt7lpRjeaz8E9omN1xswP+CgxfMP6At/fq9MF61eH2Fprt6bHFSbDAEtIuTsyGXGM=;20:EvewOYOtEgUwoFwoHk2q48+LGzhk3NAHp4AXnlFBBmaO/AF/5raKQXi6l3W4q39dWoAiSS2n2HiBr/sctv/Bf3odWNmAwwvbh7A0TjiCPgryKwzC198W0ur314ozgRYzkn2Hmsn1X0lrQhNYj0Vz3ril9Aeem1m9E3nhAyGZhrQ= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2015 03:17:43.8506 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKXPR06MB1016 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5723 Lines: 184 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 --- .../devicetree/bindings/thermal/rcar-thermal.txt | 37 +++++++++++++++++- drivers/thermal/rcar_thermal.c | 45 +++++++++++++++++++--- 2 files changed, 74 insertions(+), 8 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 96707a6..9c9e38b 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,17 +209,35 @@ 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) { - struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + int temp; if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) rcar_thermal_update_temp(priv); mutex_lock(&priv->lock); - *temp = MCELSIUS((priv->ctemp * 5) - 65); + temp = MCELSIUS((priv->ctemp * 5) - 65); mutex_unlock(&priv->lock); + return temp; +} + +static int rcar_thermal_of_get_temp(void *data, int *temp) +{ + struct rcar_thermal_priv *priv = data; + + *temp = rcar_thermal_get_current_temp(priv); + + return 0; +} + +static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) +{ + struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + + *temp = rcar_thermal_get_current_temp(priv); + return 0; } @@ -276,6 +297,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, @@ -308,11 +333,11 @@ 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); + cctemp = rcar_thermal_get_current_temp(priv); rcar_thermal_update_temp(priv); rcar_thermal_irq_enable(priv); - rcar_thermal_get_temp(priv->zone, &nctemp); + nctemp = rcar_thermal_get_current_temp(priv); if (nctemp != cctemp) thermal_zone_device_update(priv->zone); } @@ -391,6 +416,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; @@ -449,7 +476,13 @@ static int rcar_thermal_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); rcar_thermal_update_temp(priv); - 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); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/