From patchwork Tue Oct 10 18:02:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 115429 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4039370qgn; Tue, 10 Oct 2017 11:05:29 -0700 (PDT) X-Received: by 10.101.72.132 with SMTP id n4mr5977689pgs.245.1507658728964; Tue, 10 Oct 2017 11:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507658728; cv=none; d=google.com; s=arc-20160816; b=YFdamOKP2IQisji6XdPymLcdM6JqXvffQv4vAdsE1yjQ2C3TuKvunSyqmmZM31Nkv3 zd+3LGt3DKmOt8cEvU4sF4NpRVRc/Dojvu3iLV9lvqohvodulXW4JbhJKblXhK/BXXZw vjfWjnqazzMna5mcNSNZUxtPhCMsjON/2VwCzM1nDh8z8az5fAqW4n8lUyEJzI8PHdrj RkKZ+fgbPPniOQ5P55eN17BoEBjedi2Zfe017fUbSe6GaDwtsvgCVKVuaYGDPIQZ2VsM w95Ir9x8Q667APIUod6EUcAHYLwJjXOjnK6sbXT4+h1Vw4ke50a1SJ51O12EYuNG7L8X 8vQw== 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=VNfithlJaR7JHlG4OPXBnwSU7MRKMhDCwL88J7IUMVQ=; b=VVxlewXXntyicLtNQtRyLWl0alMQMBH4NmCcP4zwJ0whk/y0yqOEI/D8kNlaKaOvK7 YGOjanZ7kJlmYW19e1sLPCRXqxWkxqXey7I7sMdz3OEDqfZBDEzgyBaXtucoUFsfl2gt FShrIH8288Zv+glQhC5bm3H30hwW95nVxtaEGCsmesUytYPf1i7uAWmBut5PfBvNUo1o aHVxq3UmD9fxj8R2Ai5AcAXoRBgPmtBAUBVLY5VHnSWcXOyJnjwR5HvzPF+7Q/VWEcp1 FLaai80v0leO7Yt9WiPIXSYcQ5Uaq7YkCrH99Im0S9H/f6gnbbtJgjK7M/6wjH0+6+5i rheg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yohx14x/; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si8828206plp.584.2017.10.10.11.05.28; Tue, 10 Oct 2017 11:05:28 -0700 (PDT) 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=@linaro.org header.s=google header.b=Yohx14x/; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932728AbdJJSF1 (ORCPT + 26 others); Tue, 10 Oct 2017 14:05:27 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:54110 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932689AbdJJSFX (ORCPT ); Tue, 10 Oct 2017 14:05:23 -0400 Received: by mail-wm0-f47.google.com with SMTP id q132so7698575wmd.2 for ; Tue, 10 Oct 2017 11:05:22 -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=VNfithlJaR7JHlG4OPXBnwSU7MRKMhDCwL88J7IUMVQ=; b=Yohx14x/r/D7VrtTKJtbceUyy54rKzOoQg6wrwZJH8cOGqRg6r/ZI8XM2VBNXG5L5O E94wpPJ3GrjBjvBrmWeHlCoKQy/mN7PEcV0BaGP36acuF/7yOO+lFPQ29jbBs+9NTWHe cW1h0fNJk3lt94OYZ2f0ZjziiirtUcG5sYrOo= 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=VNfithlJaR7JHlG4OPXBnwSU7MRKMhDCwL88J7IUMVQ=; b=sqQCBF6myHh5w7ri86hfGWsPZJQnggaR5XFPdIEh1m4+fPv1jT6QvZ1YPysM65rmcu +1fmFT836M13Y2Mb3D3bK7yloDWHvGwfArF3oTIB46QxvBbF+cpRVBytm8G9fJJ6T9j8 aIMiuARFqBqJ+5r1qfDpUvLqqXFjUvH1CmEQ+1uvlzIuD66hJ3VUGxfpDlel/8fI1BaG DFDdz6hAXrBq6WQDoADNGp8eyf4AYkT1k02X6xjLVi/76A+vtzpEAS5wwbisbvoKbSXM cno4WluM4VJBdfhceI65wNRvsG1E2xJGHpDS68iL4P6jlBvdcIdT/mQBhylEv+Nypu+A cVKA== X-Gm-Message-State: AMCzsaX6xzTo5Mus/kg37h8Q1czkMNqmbgbV0uJHgg4rCyJBN+GvrTHM /q8t5WMoHNqjY2dfdsJy99/2hw== X-Google-Smtp-Source: AOwi7QAdWjoyEAVbgXwVYFy+HTbc2csVngQc4tI4gYMioQFIY1fTEER1kF/mw/VFWKjcRdw2Irg0GA== X-Received: by 10.28.36.212 with SMTP id k203mr10565455wmk.127.1507658721816; Tue, 10 Oct 2017 11:05:21 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:4f9:3ae1:43d2:31ae]) by smtp.gmail.com with ESMTPSA id l73sm12513428wmd.47.2017.10.10.11.05.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:05:21 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kevin.wangtao@linaro.org Subject: [PATCH 22/25] thermal/drivers/hisi: Add support for multi temp threshold Date: Tue, 10 Oct 2017 20:02:47 +0200 Message-Id: <1507658570-32675-22-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> References: <79a5f10c-0fb7-3e4f-caac-c1625904b137@linaro.org> <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Wangtao The next patches will provide the support for the hi3660 where the temperature sensor can have multiple alarm levels. In order to set the scene to support it, we have to convert the current code to be able to support multiple threshold values. [Daniel Lezcano: Restated the log] Signed-off-by: Kevin Wangtao Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index b5a7159..e87ca6c 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -46,10 +46,12 @@ #define HI6220_DEFAULT_SENSOR 2 +#define MAX_THRES_NUM 2 + struct hisi_thermal_sensor { struct thermal_zone_device *tzd; uint32_t id; - uint32_t thres_temp; + uint32_t thres_temp[MAX_THRES_NUM]; }; struct hisi_thermal_data { @@ -244,7 +246,7 @@ static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data) hi6220_thermal_set_lag(data->regs, HI6220_TEMP_LAG); /* enable for interrupt */ - hi6220_thermal_alarm_set(data->regs, sensor->thres_temp); + hi6220_thermal_alarm_set(data->regs, sensor->thres_temp[0]); hi6220_thermal_reset_set(data->regs, HI6220_TEMP_RESET); @@ -303,7 +305,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp) *temp = data->get_temp(data); dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", - sensor->id, *temp, sensor->thres_temp); + sensor->id, *temp, sensor->thres_temp[0]); return 0; } @@ -322,16 +324,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) hisi_thermal_get_temp(data, &temp); - if (temp >= sensor->thres_temp) { + if (temp >= sensor->thres_temp[0]) { dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", - temp, sensor->thres_temp); + temp, sensor->thres_temp[0]); thermal_zone_device_update(data->sensor.tzd, THERMAL_EVENT_UNSPECIFIED); } else { dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", - temp, sensor->thres_temp); + temp, sensor->thres_temp[0]); } return IRQ_HANDLED; @@ -341,7 +343,7 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, struct hisi_thermal_data *data, struct hisi_thermal_sensor *sensor) { - int ret, i; + int ret, i, thres_idx = 0; const struct thermal_trip *trip; sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, @@ -359,8 +361,9 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, for (i = 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { if (trip[i].type == THERMAL_TRIP_PASSIVE) { - sensor->thres_temp = trip[i].temperature; - break; + sensor->thres_temp[thres_idx++] = trip[i].temperature; + if (thres_idx >= MAX_THRES_NUM) + break; } }