From patchwork Fri Sep 22 09:42:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangtao \(Kevin, Kirin\)" X-Patchwork-Id: 114008 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp2888499edb; Fri, 22 Sep 2017 02:54:50 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBIC/MRU+ZMUDy8zk6WLjFrC6v1uHIg98G0n3L4YUOHdobTBheo8Yyzi5QXmRzntx4n8yus X-Received: by 10.99.1.81 with SMTP id 78mr8520542pgb.99.1506074089944; Fri, 22 Sep 2017 02:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506074089; cv=none; d=google.com; s=arc-20160816; b=NOGx6xLsStKmQiYSI3OFy8mcdIIhimF6RG2nSG4NxSfhD6qveZVKmP8yk4Ln4V14L/ oRlKETl7i/0rGbkz+nP60ARNCKjm3tTwu8sksgabCR9PF6BtHnGGhzAbtb8yaiBh640u Ns9wy0gBDxHyzdpSIywxiBu3JQa1WJ75UGM5yyAw+gOWg7d9dQIZxXapcn+cgjCI7CWU tCQX0L0T5+il08mpuvgvq2mWKlpJetazI4DDqu7LaNgCGFoZ+HY92ToavJOKd5/mgFnd Fmu9LDHT5YDEvNMnj7xjhcfzcfJ7LILO9m+W0Mt4+VV4hm+A8hgTXHzGHq/7UzjCcRp6 zMvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=MTlJldRY/yO87whmS7oKlnZpKbutKFepz6O0Y/q6i1E=; b=CniEWbqy14hie6fvrPD+O1AkLKqhUxkuFNu0fd9QASdQHZSrrnxDFQTbJ3I4t94QXY pdaYkO+MQO3lft7gGiI9PBVqEZTYmBC9wFGKWYtZv/ZmMTTcM0HUQEfBeXpcIsrYkZnn kc8STaYqQfo4GVcs1Hmv6/g+ylaRg9Ppq0u41PfXfKSyp0GrbD3XXyIEtROu4KHONOb4 6pyuXto+3nxBCh/vr0wxIY9BzroX1D6ns7P0vo3mhWZ+bw1ycf7ZqmI5FWatGkvfjh7e HZ8OK1BFnmyQ8zMIeFNapRUfzMNOaTwjh+8MS35iWsGQfKbb98vd19plWlE4fqHhMmLz Sr9w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si2617572ple.548.2017.09.22.02.54.49; Fri, 22 Sep 2017 02:54:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752156AbdIVJys (ORCPT + 26 others); Fri, 22 Sep 2017 05:54:48 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6554 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751826AbdIVJyq (ORCPT ); Fri, 22 Sep 2017 05:54:46 -0400 Received: from 172.30.72.58 (EHLO DGGEMS403-HUB.china.huawei.com) ([172.30.72.58]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DHV05249; Fri, 22 Sep 2017 17:49:26 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.301.0; Fri, 22 Sep 2017 17:49:16 +0800 From: Tao Wang To: , , , , , , CC: , , , , , , , , , , , Kevin Wangtao Subject: [PATCH 6/9] thermal/drivers/hisi: add support for multi temp threshold Date: Fri, 22 Sep 2017 17:42:09 +0800 Message-ID: <1506073332-92438-7-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1506073332-92438-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1506073332-92438-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.177.161.152] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.59C4DCA6.00E8, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 4d35f796d4f5e443e0243aa8851269ab Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Wangtao tsensor may have multi alarm levels, so we can support more trip point interrupt. Signed-off-by: Kevin Wangtao --- drivers/thermal/hisi_thermal.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) -- 2.8.1 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index f9d9fd6..718376b 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; } }