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: 9440991 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 028EF60237 for ; Tue, 22 Nov 2016 12:35:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E73E928476 for ; Tue, 22 Nov 2016 12:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC28328520; 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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 7B93728476 for ; Tue, 22 Nov 2016 12:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932748AbcKVMff (ORCPT ); Tue, 22 Nov 2016 07:35:35 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34261 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932816AbcKVMf3 (ORCPT ); Tue, 22 Nov 2016 07:35:29 -0500 Received: by mail-pg0-f66.google.com with SMTP id e9so2041343pgc.1; 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=Hoa0jVEWoC1IXD2kp8/T2qy3d2TWmTyDd25nNQ4zvmjCu9YEoLW6ypL+NhDoYLMpkU Ve1srmLZvFENxYkW7GYeveHeHXni5dqY0LR65JUNHjDOZzcfMPTmW+BWVmbKOuyGxqWI gNYKDA+kynPfKG+OZTDLC/+JawHHeFwnDLyCiMJenY+b7uouwqx1rhWYAgYPsXIdggoM u1u6RZlVFP0VS52jyZuR9p+X7QLnFdhMsVlI2+ibhyIF/9aBwqlMbytUc9JJvwyKpSrU k+b2WGArd/UrBxA8NWEi2hCQSSV7qAQ4BUYrJJqCOLYPGR2UM51dOHPyVDkDAysJPDzQ lwGg== X-Gm-Message-State: AKaTC03xdJ2F18JTqzgOQbmlm+yt2Sx+iRlhnRKMholBsaYUid9YbQ8hGhP8mm3rPwwV7Q== 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 Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, briannorris@chromium.org, heiko@sntech.de, smbarber@chromium.org, Caesar Wang 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> 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 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);