Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp425395imu; Tue, 20 Nov 2018 01:13:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VVbf7kBelJ0I2hDT1pmd3aI0FGtAWw0Yi5NLSEZ2JMpsbOXCDHUXOWnDZ3Alc1wKnMYtri X-Received: by 2002:a17:902:b48b:: with SMTP id y11-v6mr1371795plr.135.1542705214920; Tue, 20 Nov 2018 01:13:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542705214; cv=none; d=google.com; s=arc-20160816; b=SgfKOQHjJN4EBJM2y6ACnkv6AfJpJ07bC6iIvStLNPosk/aJE9D4idpIM4OSpJP56c XZYVMazmIAzv2bu7o4RyPQZeifndhp/7MNV0LA1B0eOpvMZHTgmaUNZfF/JoC30RGhBB XzuZNyi23klcY0UT072TCTMZTGeCPFCowZJavxRS8TozYadrLuUh0QoNu9ejKFmswwWt STOJZg1atwgG1P6BcPYBXb2Smi9SuvCCooe65v7ZqEPm4YWZBsMfhpSEG6LwwjPzNpmN OPG+dhIlZUk8BFmi7AjsYXgYvyziKFnDUaihx3vM3GVaUWHqs4+UHu6hNuogz/o45fK8 wLgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:message-id :date:subject:cc:to:from; bh=+E1NbiGuq4oVI9X/GrWNd7E/FXlVxO/Ck8VXurrSRwA=; b=IiyXRdXTeAtr87QLfXODWAKdRHQGpoZEAyo0X69cQfbSCGaAmyr5tEX/22rTQYTvLN SLmbFlhqfMpfebWppmpiYunfsit7ng+pvqWgytgl37v3+QRmlTzbrjIBcQfiox/kkYnV Iig5PN6M6294Fov8gE+cyzG27koVjRf/zKN38EEylUkL7q0XthGZ8/z3f37T27fNCnOL RL+94m71FKey7IROTGqeH515dIXWX0QbIvw3d3878gHTFIUMEw1S923cTYiqaSIfoW3R +/2IFoktZ7tsxhK/8JoBQfOcOULRWUx8V7Aomho+je1byVNcnSC134/ZB6EiooGBCbVm 3X6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=FJcpC09A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89-v6si603512plb.405.2018.11.20.01.13.19; Tue, 20 Nov 2018 01:13:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=FJcpC09A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbeKTTjz (ORCPT + 99 others); Tue, 20 Nov 2018 14:39:55 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:9259 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbeKTTjy (ORCPT ); Tue, 20 Nov 2018 14:39:54 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 20 Nov 2018 01:11:50 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 20 Nov 2018 01:11:49 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 20 Nov 2018 01:11:49 -0800 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 20 Nov 2018 09:11:44 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Tue, 20 Nov 2018 09:11:44 +0000 Received: from niwei-ubuntu.nvidia.com (Not Verified[10.19.225.182]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 20 Nov 2018 01:11:44 -0800 From: Wei Ni To: , , CC: , , , Wei Ni Subject: [PATCH] thermal: tegra: add get_trend ops Date: Tue, 20 Nov 2018 17:11:17 +0800 Message-ID: <1542705077-29697-1-git-send-email-wni@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1542705110; bh=+E1NbiGuq4oVI9X/GrWNd7E/FXlVxO/Ck8VXurrSRwA=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=FJcpC09AuvBSNO3rFEkHCeZ/COeU3HE63eRddHOyTs+Toi9VunPUtkzIaDfoOg9eL 0H9FmqMwDmxgJ7mwq6ex+Ln4n2tZawo0t4RRXPYHFy9WABVGAbTG2+e0ZUKuVUh7+f FNc7NceYmdHUYOxrEM3CQ0sSWGa8eeWTgTBSV1oWKm+amAzcdFzpYCw7EQdOHPVTUe FAq3POAp1Y3jh7WyXJguJ9ayAzY0oAsJZgwa6o7jHxlCPiq19GQd+TUDcgpBPCKzLD QjLmC7IgE1+kSTkQkFvjS+JOIqyP7TzpJkG9/37IsIdTiMJATKmSylz4IcQRtLiauo g2bWr5GfBpCfA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for get_trend ops that allows soctherm sensors to be used with the step-wise governor. Signed-off-by: Wei Ni --- drivers/thermal/tegra/soctherm.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index ed28110a3535..d2951fbe2b7c 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -488,9 +488,43 @@ static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp) return 0; } +static int tegra_thermctl_get_trend(void *data, int trip, + enum thermal_trend *trend) +{ + struct tegra_thermctl_zone *zone = data; + struct thermal_zone_device *tz = zone->tz; + int trip_temp, temp, last_temp, ret; + + if (!tz) + return -EINVAL; + + ret = tz->ops->get_trip_temp(zone->tz, trip, &trip_temp); + if (ret) + return ret; + + mutex_lock(&tz->lock); + temp = tz->temperature; + last_temp = tz->last_temperature; + mutex_unlock(&tz->lock); + + if (temp > trip_temp) { + if (temp >= last_temp) + *trend = THERMAL_TREND_RAISING; + else + *trend = THERMAL_TREND_STABLE; + } else if (temp < trip_temp) { + *trend = THERMAL_TREND_DROPPING; + } else { + *trend = THERMAL_TREND_STABLE; + } + + return 0; +} + static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = { .get_temp = tegra_thermctl_get_temp, .set_trip_temp = tegra_thermctl_set_trip_temp, + .get_trend = tegra_thermctl_get_trend, }; static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp) -- 2.7.4