From patchwork Mon Dec 12 11:05:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9470427 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 29AF460573 for ; Mon, 12 Dec 2016 11:06:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2512845A for ; Mon, 12 Dec 2016 11:06:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FD4028470; Mon, 12 Dec 2016 11:06:34 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 368C228473 for ; Mon, 12 Dec 2016 11:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932714AbcLLLGP (ORCPT ); Mon, 12 Dec 2016 06:06:15 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34778 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932181AbcLLLGN (ORCPT ); Mon, 12 Dec 2016 06:06:13 -0500 Received: by mail-pg0-f68.google.com with SMTP id e9so687201pgc.1; Mon, 12 Dec 2016 03:06:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KG5ceUK0S1S5IfJ8gLOWjDlNi3KyLaYjaTuePlJ8dfI=; b=EpmkydoBINDwTrdGXAIDY2aaOD082Pm9+e6QOU+jC0ikkDk7Uwdzm5IRZstykKU8wG /B3Q/firCCV+LPyifY7VMbW0IOO4EHrkggQsXm2fETlZxikXPtN/TjLT8b4JymZyk3bp 0GFFWuraW8CWdgHlTZWDScEVtxoW9sCTCF+4PWpm0EjEPMyeki8AsF42CKf7ZA5Zsr9o EWMVA7T56ShAoB1NYj/oN8MhWZ0zGnu7nydu1rqP5SK/cKrlIvV1oNuqwpD0Fdu/+mmi 4d2lwDDMf2g/wvi/6/gzgYqC/szZEUyxEo5TD46/eNZduBTuduGq4DEVfcBWlOHiX1/8 4BdA== X-Gm-Message-State: AKaTC00e/AqgBlrlxGpSmoWsq++UdAPW2t/B0l8cuG4+4hHEDJM9xEY5zlCfC0/N90oiCg== X-Received: by 10.84.218.136 with SMTP id r8mr185423419pli.23.1481540772739; Mon, 12 Dec 2016 03:06:12 -0800 (PST) Received: from localhost.localdomain ([47.89.33.70]) by smtp.gmail.com with ESMTPSA id i124sm76047411pgd.15.2016.12.12.03.06.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Dec 2016 03:06:12 -0800 (PST) From: Caesar Wang To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-rockchip@lists.infradead.org, linux-pm@vger.kernel.org, briannorris@chromium.org, linux-kernel@vger.kernel.org, smbarber@chromium.org, Caesar Wang Subject: [PATCH v4 5/5] thermal: rockchip: handle set_trips without the trip points Date: Mon, 12 Dec 2016 19:05:35 +0800 Message-Id: <1481540735-12710-6-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481540735-12710-1-git-send-email-wxt@rock-chips.com> References: <1481540735-12710-1-git-send-email-wxt@rock-chips.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases, some sensors didn't need the trip points, the set_trips will pass {-INT_MAX, INT_MAX} to trigger tsadc alarm in the end, ignore this case and disable the high temperature interrupt. Signed-off-by: Caesar Wang Reviewed-by: Brian Norris --- Changes in v4: None Changes in v3: - change the commit. - Fixes something as Brian comments on Changes in v2: - Fixes something as Brian comments on https://patchwork.kernel.org/patch/9440989. Changes in v1: None drivers/thermal/rockchip_thermal.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index cacc12b..cbbf0ce 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -674,7 +674,21 @@ static int rk_tsadcv2_get_temp(const struct chip_tsadc_table *table, static int rk_tsadcv2_alarm_temp(const struct chip_tsadc_table *table, int chn, void __iomem *regs, int temp) { - u32 alarm_value, int_en; + u32 alarm_value; + u32 int_en, int_clr; + + /* + * In some cases, some sensors didn't need the trip points, the + * set_trips will pass {-INT_MAX, INT_MAX} to trigger tsadc alarm + * in the end, ignore this case and disable the high temperature + * interrupt. + */ + if (temp == INT_MAX) { + int_clr = readl_relaxed(regs + TSADCV2_INT_EN); + int_clr &= ~TSADCV2_INT_SRC_EN(chn); + writel_relaxed(int_clr, regs + TSADCV2_INT_EN); + return 0; + } /* Make sure the value is valid */ alarm_value = rk_tsadcv2_temp_to_code(table, temp);