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: Tao Wang X-Patchwork-Id: 9965739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D292600C5 for ; Fri, 22 Sep 2017 09:54:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CBD72982C for ; Fri, 22 Sep 2017 09:54:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2163329844; Fri, 22 Sep 2017 09:54:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A2222982C for ; Fri, 22 Sep 2017 09:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=r4Ndso9lbOcsf4fjgL6IFAJe/a83qldskINeBDhJUEA=; b=jGcPImCV6Z0hKg iCAatZ7DqZTOFSAN8EXkC54bk4mLYH9udJkm6XLacZ7jJoGH3BBFJPbrG0EQ1YqOX/bRwCUa4yPwW 8yOXzd3gsXkKqVDTNVQGlQ6l+jnNRlWTQHO5e1LMzi2YiB3qzS1yGIPtBcoFq6yCQi3qGLx32RQe9 oJgZxhZiNqd0W2iPtAOi2bFdTG2UZpEGhc3OKrIJu0A5KMoTE8MqGkEJkrPWwNhbStM3YpiAUTQeh 3lZ9VlN0ajzhhlpJOq6o5qUcPE7OlekLpTBpPnxk2sPhngW7erxtz9IPi+zDW+U9fSpUfRmFG4iB4 p9ErAb4q6dl3kKB0b4pA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dvKfB-0000JW-4d; Fri, 22 Sep 2017 09:54:25 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dvKdu-0007dK-7y for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2017 09:53:30 +0000 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: , , , , , , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170922_025307_465342_A49AB64F X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, vincent.guittot@linaro.org, gengyanping@hisilicon.com, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, lonela.Voinescu@arm.com, linux-kernel@vger.kernel.org, Kevin Wangtao , leo.yan@linaro.org, sunzhaosheng@hisilicon.com, Valentin.Schneider@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; } }