From patchwork Tue Nov 22 12:34:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9440989 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 620F460237 for ; Tue, 22 Nov 2016 12:35:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52D2528476 for ; Tue, 22 Nov 2016 12:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 477AB28520; Tue, 22 Nov 2016 12:35:53 +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 9B9FD28476 for ; Tue, 22 Nov 2016 12:35:52 +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 1c9AIi-0006Ic-6t; Tue, 22 Nov 2016 12:35:52 +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 1c9AIf-0006AH-EH for linux-rockchip@lists.infradead.org; Tue, 22 Nov 2016 12:35:50 +0000 Received: by mail-pg0-f66.google.com with SMTP id p66so2046841pga.2 for ; Tue, 22 Nov 2016 04:35:29 -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=Bp6pFi2dkwzUMtQ1lX9qLy1E9cHTxJA/wOTE130f+gM=; b=F50mqbjRXOctaSSd3ZTXyRkPTmugcGuiD/juqC3m3x2oJUvyCQtdf07N2IYrxz1/MJ JjNTOBcn9e9CORkLrN3o2iH6nz1i5v/DGi6pDx9U+1ZXlBhFkc/7w9/cK770yG1jb5Dr cSnQX/grjre0FtWxSdyfEna/tWcRK90DvpOuyHQ1hii3xvqIk7YoYTs/mRubtcIbGs+B EQrbad/1nt//as+uQBdVMU6MKdxC8ulZNxuhnBzkyOVePP6we8vTrRuX6G2YlsB0Jwwe I4ImlOepWkzg3TdPXFHkg80w+p6y6/WOLLjRzTsc4l1wV6bpMo2DQIv5tGzVdHLI0Kzi Uw2g== X-Gm-Message-State: AKaTC01+P5kXE0XCpXkMh/CGXMTThv+xPVAQWaThNMlNP/osVe+S0D4na5CFz3n9JUHNlQ== X-Received: by 10.99.39.132 with SMTP id n126mr43733487pgn.85.1479818128568; Tue, 22 Nov 2016 04:35:28 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id m5sm27140335pgn.42.2016.11.22.04.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 04:35:27 -0800 (PST) From: Caesar Wang To: edubezval@gmail.com, rui.zhang@intel.com Subject: [PATCH 5/5] thermal: rockchip: handle the set_trips without the trip points. Date: Tue, 22 Nov 2016 20:34:48 +0800 Message-Id: <1479818088-6007-6-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479818088-6007-1-git-send-email-wxt@rock-chips.com> References: <1479818088-6007-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161122_043549_699258_D5FCA702 X-CRM114-Status: GOOD ( 10.17 ) 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 return {-INT_MAX, INT_MAX} to trigger thermal alarm. Signed-off-by: Caesar Wang --- drivers/thermal/rockchip_thermal.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index f4d4be9..5b9c346 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -200,6 +200,7 @@ struct rockchip_thermal_data { #define TSADCV3_AUTO_Q_SEL_EN BIT(1) #define TSADCV2_INT_SRC_EN(chn) BIT(chn) +#define TSADCV2_INT_SRC_SHIFT(chn) chn #define TSADCV2_SHUT_2GPIO_SRC_EN(chn) BIT(4 + (chn)) #define TSADCV2_SHUT_2CRU_SRC_EN(chn) BIT(8 + (chn)) @@ -903,10 +904,22 @@ static int rockchip_thermal_set_trips(void *_sensor, int low, int high) struct rockchip_thermal_sensor *sensor = _sensor; struct rockchip_thermal_data *thermal = sensor->thermal; const struct rockchip_tsadc_chip *tsadc = thermal->chip; + u32 int_clr; dev_dbg(&thermal->pdev->dev, "%s: sensor %d: low: %d, high %d\n", __func__, sensor->id, low, high); + /* + * In some cases, some sensors didn't need the trip points, the + * set_trips will return {-INT_MAX, INT_MAX} to trigger thermal alarm. + */ + if (high == INT_MAX) { + int_clr = readl_relaxed(thermal->regs + TSADCV2_INT_EN); + int_clr |= 0 << TSADCV2_INT_SRC_SHIFT(sensor->id); + writel_relaxed(int_clr, thermal->regs + TSADCV2_INT_EN); + return 0; + } + tsadc->set_alarm_temp(&tsadc->table, sensor->id, thermal->regs, high);