From patchwork Wed Nov 23 14:29:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9443501 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 8A83060779 for ; Wed, 23 Nov 2016 14:30:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D12A26C9B for ; Wed, 23 Nov 2016 14:30:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7021E26CFF; Wed, 23 Nov 2016 14:30:26 +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, RCVD_IN_DNSWL_MED 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 334A126D05 for ; Wed, 23 Nov 2016 14:30:26 +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 1c9YZ7-0006rQ-Kr; Wed, 23 Nov 2016 14:30:25 +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 1c9YZ1-0005ht-Vr for linux-rockchip@lists.infradead.org; Wed, 23 Nov 2016 14:30:23 +0000 Received: by mail-pg0-f66.google.com with SMTP id 3so1228842pgd.0 for ; Wed, 23 Nov 2016 06:29:59 -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=a0YPRSnnmxx9b8VZSEdfcL+gRVPpMCiRbuwpwJhrfXM=; b=IY++MrSMF+IZZqnSal/rC4/U0x8Mfzo0teGaxrh6hNYDiWi54y9z+3vO1+MqIgNbyk LkZeIXVGsMGA+xKqxL6U22jPevY9n75tIAv8+ArjcFImiYMsRon29g3GoS9kuJk0cZvf 9sVSgFvsoiGpACrpIitUGIXkTUl9yVlEd5OgDe9XkHRLiY9mGlNXwDKG+oBXFFj4B4Eb 5qP3PPdmOIFmWavm/P3m4T+M7yEH9Nd/27X0wyFT5x8MyYjzzwOuOPigAWr6uM+OPS+w und44wsLGdJK9brRVcCQT1bULw2xIFQIlQ0rudxunRxfMp0vTUKYIL2iiX9hxCB5qAip AHsw== X-Gm-Message-State: AKaTC020AmN3NBlxNBGB8cvkc8xodhZXb17VK35sTDYhux5UP4FdLnKepZ7dtnBylZO5Zw== X-Received: by 10.99.97.15 with SMTP id v15mr5773022pgb.10.1479911399018; Wed, 23 Nov 2016 06:29:59 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id y29sm53385351pfd.63.2016.11.23.06.29.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Nov 2016 06:29:58 -0800 (PST) From: Caesar Wang To: edubezval@gmail.com, rui.zhang@intel.com Subject: [PATCH v2 5/5] thermal: rockchip: handle set_trips without the trip points Date: Wed, 23 Nov 2016 22:29:34 +0800 Message-Id: <1479911374-22006-6-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479911374-22006-1-git-send-email-wxt@rock-chips.com> References: <1479911374-22006-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161123_063020_493601_F8E856D2 X-CRM114-Status: GOOD ( 11.71 ) 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: 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 return {-INT_MAX, INT_MAX} to trigger thermal alarm. Signed-off-by: Caesar Wang Reviewed-by: Brian Norris --- 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 0d50df7..f873053 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);