From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Date: Tue, 05 Jan 2016 08:08:45 +0000 Subject: Re: [PATCH 5/8 v6] thermal: rcar: enable to use thermal-zone on DT Message-Id: <87lh841mev.wl%kuninori.morimoto.gx@renesas.com> List-Id: References: <87d1u8qzsy.wl%kuninori.morimoto.gx@renesas.com> <876100qzp6.wl%kuninori.morimoto.gx@renesas.com> <20151217203707.GD7999@localhost.localdomain> <87wpsctxjv.wl%kuninori.morimoto.gx@renesas.com> In-Reply-To: <87wpsctxjv.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Kuninori Morimoto Cc: Eduardo Valentin , Simon , Zhang Rui , Geert Uytterhoeven , Magnus , linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "devicetree@vger.kernel.org" Hi ping ? > 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 > --- > v5 -> v6 > > - "was call" -> "was called" > - add reason why it keeps previous style > > .../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 30602f2..e92f29b 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); > } > @@ -386,6 +413,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; > @@ -444,7 +473,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); > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-sh" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751679AbcAEIIy (ORCPT ); Tue, 5 Jan 2016 03:08:54 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:11144 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750904AbcAEIIu (ORCPT ); Tue, 5 Jan 2016 03:08:50 -0500 X-IronPort-AV: E=Sophos;i="5.20,524,1444662000"; d="scan'";a="201629910" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Message-ID: <87lh841mev.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Kuninori Morimoto CC: Eduardo Valentin , Simon , Zhang Rui , "Geert Uytterhoeven" , Magnus , , , , "devicetree@vger.kernel.org" Subject: Re: [PATCH 5/8 v6] thermal: rcar: enable to use thermal-zone on DT In-Reply-To: <87wpsctxjv.wl%kuninori.morimoto.gx@renesas.com> References: <87d1u8qzsy.wl%kuninori.morimoto.gx@renesas.com> <876100qzp6.wl%kuninori.morimoto.gx@renesas.com> <20151217203707.GD7999@localhost.localdomain> <87wpsctxjv.wl%kuninori.morimoto.gx@renesas.com> User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Date: Tue, 5 Jan 2016 08:08:45 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS1PR01CA0047.jpnprd01.prod.outlook.com (25.164.162.29) To HKXPR06MB1016.apcprd06.prod.outlook.com (25.161.181.156) X-Microsoft-Exchange-Diagnostics: 1;HKXPR06MB1016;2:fWVmZToLBINtcpNSQGFv7wOuth7VNYzr2o2505Rz4tZ2oI8lhx8sCS4YYMQY9PTntjClsv8YKYB4Dr+Z4xBiGSORymI9syOa5DlpR6P1ACt+/q7zhfNuXUUqjA/cL0uaywLQbF5gLowe/MG9nGLkDQ==;3:qHeJzUKsYXRso8mvZH1JBrqzAWz84ERbZkm0x3a8o7pD/0sNFOrfT9vNdiuzwGWaWUocrz+7oRRuz6vMrl3GyevQBMc1f1q5abRBYyIUn25rfob97kMmKiKLzQ+hRiIe2d9KxqcT14Y2wlxxUaZ79VFbbgNjrrTryttGu6BkXTlhrKlfCKgkVfsE2bzSPLMJ;25:bRIvOh8Nhmy+mngUL7xnOAg90g2JwHju8t+Yw5+fNy3VTBV8wuOssgljF/zrPiyVgk7Or+O2c7ZTOac9ns/NtpOhpG9G7ROEpvkq6OKMmDUW7BHnD3c7Tt4cZ+Nfzj2VwjxPIR+nc+jdJYA5Ep4F7MyfcpabqXskIqF4xJWG3A2Nc+IWEywibBUo2WQWS5ICDtyqVtosDeDXgAkrIAfU3kUr4P+TH5+eZWTDH47L1hzJS3AYXwhmi83AAS/i5GEvIP6iEPUwVdqxnakpaREVTA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(42134001)(42139001);SRVR:HKXPR06MB1016; X-Microsoft-Exchange-Diagnostics: 1;HKXPR06MB1016;20:KqkfcJK6wck2xwLI10HHnMWKNZFKXi30lOBdC6Z/kXlH3+nuyf2G39dRPGtptrETV1o7oXYHT4EKNpwhMJuYiYMBryr3jllwCaPvM6WXpUeuHB2GD4/5ScHpwc8BrEFse8KLdDmNLjxbhVyZWDT0EvyCVHrgtYE1WugBVuY3T3pCq5m9bb566gyN9qTxxemy0zilFKoB4P1C+BODcR2lMflOUNOPVxqMwMokdV0YDeecB9m2H5Q9MT0+Uq/Tcog5QNgdgYR3M997wQ3LExdlQrmaLF5urh7s5oqv1Vkr72H1wH5Xigo63fSIqNhtvKndjnm/Tli6tf/QutXxBu2X5z0SwT+2WjI+4d7e/z65JdXvbpy2iEhq4PrOpFRl/oFrGrupQUqY/WUk4l9MOOAcQY2NBuS4uvMNEdFoL8HJoVvEpYiKvqc0bHHs3luUuCAgzsQZirYNx3HF/fDuZwRRbYEUGvTVkI3FJU9EMneUJcThGcy259qCpywXAaDZ3rXA;4:nUrSrP6XN3M7bnwpApne6Gw1v2K/fai1SsFXMEUzt2aAe0recdL51nhiH9s6GvqwA5ZcMpiljoJPAWflBvY3T6GWGemjj54/5RdbObOIk3HOxGeOZlW7ggvjziOnGy6V+wvffc3SWpx0KRUSpxisNG2fiI08djohMHcry81grng1i+EccKLQi6VeWMUO9lrgLuBv8BV/Szlq56Yo3v+Pm1hR3Mx+olhZ8EzJUizq/StmYeF8/d0rrwtReqBv2J0C4WK7OYaBO9IZHpjME0+jvp4ZjnEcHCkTCnNSVwe99Lp+UAh1U7plr3umvWj+w4Wl5G18mjUVesno6yDDK6VrkeoOZ6YdGywGWfTBitTbYuoIqyo9ZzNa1UNb7jGMXE+snxg5WrxmawEzDqm5v0a+PMaG1XNg/+ORjHwKRAL9gYdGDB1Uzl6InfhQbxKpXxci 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)(8121501046)(5005006)(3002001)(10201501046);SRVR:HKXPR06MB1016;BCL:0;PCL:0;RULEID:;SRVR:HKXPR06MB1016; X-Forefront-PRVS: 0812095267 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(189998001)(4001350100001)(23726003)(6116002)(81156007)(19580405001)(3846002)(101416001)(47776003)(42186005)(36756003)(4326007)(69596002)(4001450100002)(76176999)(83506001)(87976001)(586003)(86362001)(110136002)(19580395003)(5001960100002)(105586002)(2950100001)(50466002)(7049001)(97736004)(6200100001)(50986999)(54356999)(53416004)(5008740100001)(46406003)(122386002)(77096005)(40100003)(106356001)(93886004)(15975445007)(92566002)(33646002)(66066001)(5004730100002)(1096002)(422495003);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:IxZOmau7CHiroHBnuITVFs2X+0hHdznVyS+8nD/or?= =?us-ascii?Q?7Rso5Gkf2ylPIln/D0wLvvLIleU3qKU6p9bYyczZ83MgvcsIyu8AG7TlLR4P?= =?us-ascii?Q?V7HaVanEfkQXYUB26Nd44kRmioiyuNm/qjvYAApc81TPPX2rOOrq8tgvSdVW?= =?us-ascii?Q?1vX+2l6gD3xLhpJ8xphtJBrgRXNiAH7PA1oQhK8E3upMpzFnO0V4woTjel1z?= =?us-ascii?Q?wyc4QtL+DGWso6Ba0STXdgMeuRqTiShsxGBndLcaKq8iISFpZbLbFNIEH0M/?= =?us-ascii?Q?iPKDb3gIdkTKl8N9dQswfWKjHVJXdE2D3EqtUMNF6FK84rtcd0GaQxNtBHTr?= =?us-ascii?Q?QBIa6/UViQRn4fsxBKURoIkjZTFmfjOekC45WSRylRE03suYJ8dsrDpinqEL?= =?us-ascii?Q?ZgzA3/Vhue/q2kJr9zHCmnyLxEuECBhOtE65o9diT3ikh27SvFRy305O6yTW?= =?us-ascii?Q?vwztjdI8saemH4b1oPbjLNIUD4+xH2H6dUGY99NbR2dNqgMOfAIYUNhkmtwx?= =?us-ascii?Q?OsKgIUEGonSqEk1yVp4rOqRh3BKoS0FAmE75yotfI0JJNJpGIA1u4eY6iCxi?= =?us-ascii?Q?67ZoE+nfouwHDikSdaM0+e8eFtkxCBLdyuzPpdcRW9MeC2GQDA9+oz34Ul7/?= =?us-ascii?Q?ov1AHehN5NAkqfwuqaQxbQS9DXXN3VJn2T7ud4tpZngv06NvUKQ5chlhtoX7?= =?us-ascii?Q?Vch0QaC01f4cqizXCBy24Z0RlN05cVc7d07RrZN1SXPxBV8bld2bar4hLHhN?= =?us-ascii?Q?5p9soWuHPJN93NDE3oHyrTnMHthK97EmNXJXHQkNxWFT96SQ0X58/C/7Dwj+?= =?us-ascii?Q?zjdpGi2z/JTlXL7WPd5WWMFOQCrBk1G/mSexJTZsWGipFMnSdHB0ND7he8h8?= =?us-ascii?Q?2n+uZHG0RoKSAiiuP5Xzs1icrx0c4KE9MGVMMW3H3AyP4hZoKGEhXbILDPN/?= =?us-ascii?Q?tkCnYHT7/3NKOQpo0UXaTyiPipYs8rK1XCmgvfv4zpuAKjGQbc1uVG7qkNPS?= =?us-ascii?Q?qptxCsqF1BANBZmVpfjRTKrqFEYoD12CFFUltSNGUtF8zW2OcHrpTvLQD2FG?= =?us-ascii?Q?v7RZAxHOSB9HxoVA1NwmlSv6DQsBfsQEa7YGUa9+rpoWPKrVW/uuaMjKITDl?= =?us-ascii?Q?wPBs7A4fkF11fxnrCvXFwAMQkavX3rlWb7AQqYf0S8cF9iNEGW+rQxunGFpk?= =?us-ascii?Q?gGugkD3aPIo4pMuxvsED9zupFYbIr7pzYB+9wopMmLoIISx6U0Eyzxn3TNR5?= =?us-ascii?Q?eJwNk9gfNln3WR7Hyc=3D?= X-Microsoft-Exchange-Diagnostics: 1;HKXPR06MB1016;5:MYNAJhWj4gHZAmDEQW89lvRGECFelIkj56bl/6ujSCvLOgfFUSFqCwYdfwJ6Hsv5dbUMp+uwRcqQ1kEzBjrc1YgrMuZ8bqviV5PgnhtpV/sshvVmc1xchMR1xK0NPXQVzarlgeTb3NNg9VJNSVLbdg==;24:imnsJ1WsGkPcW9gdDPvUCGo/QJwMhdRfYYEN2CkRQgsRQYnDYX4tf8uBiIT2tgThqtTuKGb6E0bZm30+sf8C3kP4kFFAuOkJJAq0osE3TXY=;20:inRGCDUx+pFKe+Z9+02shlyfwOFFMjphd6fexARV8gl2obzSglRrq76EBMkG/hOoWpzJo+66AB6Y1ARlewVxqGZhbqE1mzrAcnnW1QRKzsT5Il1kWD9XVHtEC/lF3+A06f8lWVnP2KEb7qWx8bbkKwEsQO5bznDGVC337zTCmnc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2016 08:08:45.7985 (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 Hi ping ? > 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 > --- > v5 -> v6 > > - "was call" -> "was called" > - add reason why it keeps previous style > > .../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 30602f2..e92f29b 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); > } > @@ -386,6 +413,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; > @@ -444,7 +473,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); > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-sh" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: Re: [PATCH 5/8 v6] thermal: rcar: enable to use thermal-zone on DT Date: Tue, 5 Jan 2016 08:08:45 +0000 Message-ID: <87lh841mev.wl%kuninori.morimoto.gx@renesas.com> References: <87d1u8qzsy.wl%kuninori.morimoto.gx@renesas.com> <876100qzp6.wl%kuninori.morimoto.gx@renesas.com> <20151217203707.GD7999@localhost.localdomain> <87wpsctxjv.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" Return-path: In-Reply-To: <87wpsctxjv.wl%kuninori.morimoto.gx@renesas.com> Sender: linux-sh-owner@vger.kernel.org To: Kuninori Morimoto Cc: Eduardo Valentin , Simon , Zhang Rui , Geert Uytterhoeven , Magnus , linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "devicetree@vger.kernel.org" List-Id: devicetree@vger.kernel.org Hi ping ? > 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 > --- > v5 -> v6 > > - "was call" -> "was called" > - add reason why it keeps previous style > > .../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 30602f2..e92f29b 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); > } > @@ -386,6 +413,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; > @@ -444,7 +473,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); > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-sh" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html