From patchwork Thu Sep 28 05:13:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 114388 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp314274qgf; Wed, 27 Sep 2017 22:16:01 -0700 (PDT) X-Received: by 10.98.58.25 with SMTP id h25mr3308428pfa.119.1506575761809; Wed, 27 Sep 2017 22:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506575761; cv=none; d=google.com; s=arc-20160816; b=t6x6UGMEl3PIAMquCqyGyiux3KaPIsQZK4Xa2BxDluQw7SrNcDytsgcGeWKFGseGW0 +gQtxRIgcwHlSpsegl47qhfN5Jx5H2RfofbJhgP4nI9IcttNE9yGwqJtQjuQePtsRrm0 rCr9TqhDU2rwf7CYpO2Nkt8JQc1OU8FpYl2mN1yHsu1YDYUfYeUt1lb666Y5Z7SCg5nU Y7bsPvzS1oXoDkFWSg4Cb/dhe4AUlpOOx0Ojbx2XOcwuRa34jDTZ2Xgk2XKKYrk7Yu3k S9gspMKLWKKIzeHbE85bSKLyrGB1f1jtO1dCnnZNMugrGjJO5bIHeiun6tTGTD/aHUbJ 20Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=bBiRoJdFCSsNQDAMpILCjEz3VSpEE3Sn3xl/chMuZag=; b=w9O/ad1K3aXsSR9NFP6kzlIzytS6XlalLdyjfm9ftN0l68G9+Hzejm0wjUDniCMzYh GWyCEN08RS6YfWg0PxysdJWuzE3kFl4yJtBED5uuBAUjP0XbAjwEyF7Qjs6pZ/W8JOUp ag726YeIXD2DFOKKd24ZG64XP9EGyZmkyryuD0mS5X6r89WBu4BEaVmbey1IfAFl4VI6 MSBj+1x4CegFQN4a12iqKVFTb4pqgd1BAfYZxB4b8QJIJ7sTorntGufW9BhilnQPJ1Ag bmcLtKvb80zXKIVfWltbBpmBd6/bqpUeifq78ZhkTIuNW2J7XfZP3Wob0QCTDxspb8E3 4a9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VjP0Atrl; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si678764pll.213.2017.09.27.22.16.01; Wed, 27 Sep 2017 22:16:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=@linaro.org header.s=google header.b=VjP0Atrl; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751046AbdI1FQA (ORCPT + 12 others); Thu, 28 Sep 2017 01:16:00 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:49551 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750943AbdI1FP7 (ORCPT ); Thu, 28 Sep 2017 01:15:59 -0400 Received: by mail-wr0-f170.google.com with SMTP id h16so595476wrf.6 for ; Wed, 27 Sep 2017 22:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bBiRoJdFCSsNQDAMpILCjEz3VSpEE3Sn3xl/chMuZag=; b=VjP0Atrlj7i/EeiINBY8p6Y2TW2m8cAYAiOQFE2j70b1ZitTF25Cp6ebnzdVsjdTGv H2UuwJ0Za0Q2D/z3C+z5H1ykiFucDDy7WZpjeFqM0QHsTG3Gkf69ZnQ/N2hl4kHp0h6X ES1Ei8bXGJSvp+40kMtG9G0AfOAviGRczfCxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bBiRoJdFCSsNQDAMpILCjEz3VSpEE3Sn3xl/chMuZag=; b=lR9wKxVfsUO790wkXV+MVSYTwGq2xkDXoOpz0TrszRxO/T+QYVtXsvgzmGwiNqsIsE 3MloldZaw2f0FqeGUng/jiWIgbuCj/ljJaD4sT4A80WofDBOCNTZfdX11vfLsGqwkDxe JnlbrZpkE7PoIC51WdCa2zbbCfnXwZdgyVSiRdPGpFFVLf3adz8CktAcjBH9zpLA//+T 0ojtAY/HY7OF9/sinjuCdLZ1sWg5CZzLCNznE0Y85p+HsDCM2SaqBnRGJ2ozAg4hnD9P Rytuaiw9iBoGJ7gxt/6y9wC4RsP7B4ETZs7FKY/+0esp1kcAVfk0SG5BLSlVunPfyx5e PWrw== X-Gm-Message-State: AHPjjUhOPKh2Kb2bMCebH7YZ37e89fxcU/PCNtqEphJTpp/llEepZOjB ZYPo4C8Q8PYa0Vkw791sOh44Mxo7iqk= X-Google-Smtp-Source: AOwi7QChEJ1NUUMf65A/L5XDWW6BeKAUJXqv7BmViBDAvV496JnifSM3RF5nFvtahTV439gpEPiAWg== X-Received: by 10.223.178.83 with SMTP id y19mr1111315wra.110.1506575757686; Wed, 27 Sep 2017 22:15:57 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:167:a1a9:ebe5:95ec]) by smtp.gmail.com with ESMTPSA id m64sm1044297wmb.0.2017.09.27.22.15.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 22:15:57 -0700 (PDT) From: Daniel Lezcano To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org Cc: jean.wangtao@linaro.org, Keerthy , Leo Yang , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2] thermal/drivers/hisi: Switch to interrupt mode Date: Thu, 28 Sep 2017 07:13:44 +0200 Message-Id: <1506575625-20388-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1bfd974e-3dc1-e99b-d0dd-50102cee762d@ti.com> References: <1bfd974e-3dc1-e99b-d0dd-50102cee762d@ti.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second. We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing. This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time. Cc: Keerthy Cc: Leo Yang Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 39f4627..74ea70d 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp) return 0; } +static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, + bool on) +{ + struct thermal_zone_device *tzd = sensor->tzd; + + tzd->ops->set_mode(tzd, + on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); +} + static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, }; @@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", temp, sensor->thres_temp); + hisi_thermal_toggle_sensor(&data->sensor, true); + thermal_zone_device_update(data->sensor.tzd, THERMAL_EVENT_UNSPECIFIED); } else if (temp < sensor->thres_temp) { dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", temp, sensor->thres_temp); + + hisi_thermal_toggle_sensor(&data->sensor, false); } return IRQ_HANDLED; @@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { }; MODULE_DEVICE_TABLE(of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, - bool on) -{ - struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode(tzd, - on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); -} - static int hisi_thermal_setup(struct hisi_thermal_data *data) { struct hisi_thermal_sensor *sensor; @@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - hisi_thermal_toggle_sensor(&data->sensor, true); + hisi_thermal_toggle_sensor(&data->sensor, false); return 0; }