Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1867285imu; Fri, 14 Dec 2018 01:51:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/V4hIO5KgSk+1CFG8aVeMGVQ8Dw/1fJk8NZHIZmB0qhdVCDgxRiNo4xvOH8L2O+1NnNpB7J X-Received: by 2002:a17:902:8607:: with SMTP id f7mr2164477plo.123.1544781078708; Fri, 14 Dec 2018 01:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544781078; cv=none; d=google.com; s=arc-20160816; b=H05ZOn4t8u0gomIakTVKHMgrWpf7W88hOyRX9U2VMpWRzCQnCv9PCwS+2Vd+Z9AHRN VfDxgVvdBj2EGu1S66oxlg4hDULyvSLCFT57pe8N+Qmn2OJ+ZG4AHDlmkpKxaBig1+AS 79EvOJBXHDbrNOSKEpVqSenAh7GQ+RuO+CcBW+yuXyow/TmPQH3Rd+bZ4KzVfdOw88Gz OEOnVdh+mB5nOMq+9DYTcVFKQmg++edRiB1/fBP6ynrGBvVv3w3MD/gIWDM0JVBgB6n7 iTXNErmX9piLJAjwiOYmo/3vK3aFsafMkfSweXam8m8Ix3NjAMKRqA/CUtVRYNwK5ysy CkLA== 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:references :in-reply-to:message-id:date:subject:cc:to:from; bh=qgc9OiWJ+azan6W/2X7/HJEt1+FS33W/FwXeDUxQfE8=; b=xo6Kh1LDt2FqMrqnP1Ra/cUrHrud+JMowkEfiNcVAGTURa4+8cgIZOrnUXTPn8AbQD G3KnTnURLhHVsi58OiJI1vx6/SRYEYgScLOYGsKBW+uM/paqk8MpL7yQLcOdedZ02wo7 jW6Mk/huKTkF+ZhjOMyw8Rfs527K0Avg0zCER8XwXqm9NbzqQSN/y5sVanK+0OPyISfm WLwy/hRi4EMrkCqZMZ6r4V+YC7431zvKX07VV6hoUKGTIP5NEZxnzZ+eCRxjAC9Gs395 QMM0B7eMDBis4xPpKTvGazw80hv7s34+bR4qqD0lHxWnY/mMJvBKcknGDqhU12lSFlc3 xJug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="GRdAji/V"; 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 w12si3583049ply.404.2018.12.14.01.51.04; Fri, 14 Dec 2018 01:51:18 -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="GRdAji/V"; 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 S1729380AbeLNJuK (ORCPT + 99 others); Fri, 14 Dec 2018 04:50:10 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:16072 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729322AbeLNJuI (ORCPT ); Fri, 14 Dec 2018 04:50:08 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 14 Dec 2018 01:50:03 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 14 Dec 2018 01:50:07 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 14 Dec 2018 01:50:07 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 14 Dec 2018 09:50:07 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 14 Dec 2018 09:50:07 +0000 Received: from niwei-ubuntu.nvidia.com (Not Verified[10.19.225.182]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 14 Dec 2018 01:50:06 -0800 From: Wei Ni To: , CC: , , , , , Wei Ni Subject: [PATCH v6 4/4] thermal: tegra: add get_trend ops Date: Fri, 14 Dec 2018 17:49:53 +0800 Message-ID: <1544780993-20744-5-git-send-email-wni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544780993-20744-1-git-send-email-wni@nvidia.com> References: <1544780993-20744-1-git-send-email-wni@nvidia.com> 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=1544781003; bh=qgc9OiWJ+azan6W/2X7/HJEt1+FS33W/FwXeDUxQfE8=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=GRdAji/VXAIK4aSJZeEVevkBmoOBkRT0PjJvc9PraSV6cw5Ya6WX6aayXdne/y+p6 2YZukZgHf+/pz0AsM0go9tEIzynDNhH29MQ9bhG0UhlebYhK75a6m2LhK9EZEcKzkK 9eBT+JSMLFRZ5780tbUDBQHah2urOpUTxym0nPsdq1ZyKUhic3yefPTaHRT47SQhH3 CapyWiEe9lxpiAU+GyC4xaytbD6j9AqvK8ukfphOxATmBGRingwFlCM+G+Q2NWEMnx 78CpRWjc5HGUs6O9KAndsvAW6Wl1/zctJK7B2w5NChuaUwscg45Ionvk7toAb+QEdP IETt18DHyHYyg== 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 6bee31cd4621..330bffd38fdd 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