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: 603196 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qZTNX1ZwTz9sBc for ; Wed, 30 Mar 2016 11:41:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757551AbcC3Alb (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-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org * 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);