From patchwork Mon Nov 28 11:12:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9449319 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 9DC876071C for ; Mon, 28 Nov 2016 11:13:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DEA520410 for ; Mon, 28 Nov 2016 11:13:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8225B26598; Mon, 28 Nov 2016 11:13:27 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0C78220410 for ; Mon, 28 Nov 2016 11:13:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBJsE-0006Vt-E4; Mon, 28 Nov 2016 11:13:26 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBJrv-0006HV-F9 for linux-rockchip@lists.infradead.org; Mon, 28 Nov 2016 11:13:08 +0000 Received: by mail-pg0-f66.google.com with SMTP id p66so12899519pga.2 for ; Mon, 28 Nov 2016 03:12:48 -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=eeYohCZwLG0OgonArdar7I8WECxIBfmCoc7yPW4PDP4=; b=RS1dl2n6NdeNHCOTpFntVnAFAvXAM4EeH7O7X9gVHDFOSxoornOGHflcdWbIcTC7AN 8AXUvjaN5duWslelcF1NGC7boGLhZFTxUShEn3zWkTlubMFM+FpXRRZEhhfVklv6onx0 Yb4vn1kgyTw0Hsssb+PgYJsMVU7FfmQH+lq195Gqnn7tZOApgFlQVNn5b5pNzODZhjUn iEQ33e9HyqaYOKf9xIn0OPknTyV5r56gMqAbhYUC+r6/0W7iaDlmsVVEZ8Pi8PbMT81x BklQSQcsNrsbXeQbieEkgj0qsnLRGSxEn5JCdvZKlRfAGgrt9IBJn1Y9DhE/YIuf7q8i dF9g== X-Gm-Message-State: AKaTC008+GgeiGhWtl4Pw5OfkpcHZwWXUWfffOkuj26p5NMEoPnCwVERzDJdfrHsQ0+YlQ== X-Received: by 10.98.41.3 with SMTP id p3mr21482728pfp.22.1480331567853; Mon, 28 Nov 2016 03:12:47 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id y20sm86586905pfj.26.2016.11.28.03.12.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 03:12:47 -0800 (PST) From: Caesar Wang To: rui.zhang@intel.com, edubezval@gmail.com Subject: [PATCH v3 5/5] thermal: rockchip: handle set_trips without the trip points Date: Mon, 28 Nov 2016 19:12:04 +0800 Message-Id: <1480331524-18741-6-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480331524-18741-1-git-send-email-wxt@rock-chips.com> References: <1480331524-18741-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_031307_649380_33686423 X-CRM114-Status: GOOD ( 11.49 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, linux-pm@vger.kernel.org, briannorris@chromium.org, linux-kernel@vger.kernel.org, smbarber@chromium.org, linux-rockchip@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.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 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 660ed3b..56c663c 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -675,7 +675,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);