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: 9449329 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 3C8456071C for ; Mon, 28 Nov 2016 11:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D7B32574A for ; Mon, 28 Nov 2016 11:13:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21ED826E64; Mon, 28 Nov 2016 11:13:33 +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 C9DF226598 for ; Mon, 28 Nov 2016 11:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932915AbcK1LNY (ORCPT ); Mon, 28 Nov 2016 06:13:24 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36321 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932783AbcK1LMy (ORCPT ); Mon, 28 Nov 2016 06:12:54 -0500 Received: by mail-pg0-f68.google.com with SMTP id x23so12896331pgx.3; Mon, 28 Nov 2016 03:12:53 -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=eWUlA0W06VAZlu4N2zU3ttjWW4efsIEpHU4QeHU/ssL+delb0PB5/fIZeEjXY4yC+H UBN9V7iNcKTD7NZDCO39affQiihLI0gguYRI7gsQ9fs+4PZAAe4NESPQw/C8h1DKm22X 0qc08WPPZDK3XK2UEuc4JWH8ArUNc63uP6IGEY+xa8QQzSJrWPO/U0kptJJggH2J5rSp HtDjghcSUXZS+Eh79j57ab/ztG9z3C5xKZj5xTKH8SOMLBzgUv1qVku4EAly2dWq5Vte NdMqy5JOus9mxMzFEKNTU75zps14xx44ga/IhiCTvFrRVhD9NHKF0VYfxxPFK0xTx66w e2+A== X-Gm-Message-State: AKaTC03msMLTHjvXi/HexzAseROo8Gar1vcPsNupNavkFX1erD0CHMUpwV0kp7JCYS/6dQ== 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 Cc: heiko@sntech.de, smbarber@chromium.org, briannorris@chromium.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, Caesar Wang 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> 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 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);