From patchwork Wed Mar 30 00:41:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikar Srimath Tirumala X-Patchwork-Id: 8691801 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 71F589F30C for ; Wed, 30 Mar 2016 00:41:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B01820351 for ; Wed, 30 Mar 2016 00:41:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C53EC2035B for ; Wed, 30 Mar 2016 00:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757806AbcC3Alb (ORCPT ); Tue, 29 Mar 2016 20:41:31 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:15263 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757182AbcC3Alb (ORCPT ); Tue, 29 Mar 2016 20:41:31 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Tue, 29 Mar 2016 17:41:15 -0700 Received: from hqemhub02.nvidia.com ([172.20.150.31]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 29 Mar 2016 17:39:45 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 29 Mar 2016 17:39:45 -0700 Received: from srikars-mint.nvidia.com (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server id 8.3.406.0; Tue, 29 Mar 2016 17:41:30 -0700 From: Srikar Srimath Tirumala To: edubezval@gmail.com, rui.zhang@intel.com, srinivas.pandruvada@intel.com, linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org CC: mlongnecker@nvidia.com, Srikar Srimath Tirumala Subject: [PATCH v3 3/4] thermal: of: enable temperature notifications Date: Tue, 29 Mar 2016 17:41:36 -0700 Message-ID: <1459298497-29481-4-git-send-email-srikars@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459298497-29481-1-git-send-email-srikars@nvidia.com> References: <1459298497-29481-1-git-send-email-srikars@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 * Add a state variable to track if trip point is triggered. * Enable trip events only when the state of the tirp point changes. * Implement the get\set callbacks for trip state. Change-Id: I1bd6a7b0e5e520d8ee678b83111d23cada7a580c Signed-off-by: Srikar Srimath Tirumala --- drivers/thermal/of-thermal.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 49ac23d..f6d9d3d 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -379,6 +379,43 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, return -EINVAL; } +static bool of_thermal_enb_temp_notify(struct thermal_zone_device *tz, int trip) +{ + bool ret = true; + struct __thermal_zone *data = tz->devdata; + + if (trip >= data->ntrips || trip < 0) + ret = false; + + return ret; +} + +static int of_thermal_get_trip_state(struct thermal_zone_device *tz, int trip, + enum thermal_trip_state *state) +{ + struct __thermal_zone *data = tz->devdata; + + if (trip >= data->ntrips || trip < 0) + return -EDOM; + + *state = data->trips[trip].state; + + return 0; +} + +static int of_thermal_set_trip_state(struct thermal_zone_device *tz, int trip, + enum thermal_trip_state state) +{ + struct __thermal_zone *data = tz->devdata; + + if (trip >= data->ntrips || trip < 0) + return -EDOM; + + data->trips[trip].state = state; + + return 0; +} + static struct thermal_zone_device_ops of_thermal_ops = { .get_mode = of_thermal_get_mode, .set_mode = of_thermal_set_mode, @@ -392,6 +429,10 @@ static struct thermal_zone_device_ops of_thermal_ops = { .bind = of_thermal_bind, .unbind = of_thermal_unbind, + + .get_trip_state = of_thermal_get_trip_state, + .set_trip_state = of_thermal_set_trip_state, + .enb_temp_notify = of_thermal_enb_temp_notify, }; /*** sensor API ***/ @@ -782,6 +823,8 @@ static int thermal_of_populate_trip(struct device_node *np, return ret; } + trip->state = THERMAL_TRIP_NOT_TRIPPED; + /* Required for cooling map matching */ trip->np = np; of_node_get(np);