mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Caesar Wang <wxt@rock-chips.com>
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 <wxt@rock-chips.com>
Subject: [PATCH 5/5] thermal: rockchip: handle the set_trips without the trip points.
Date: Tue, 22 Nov 2016 20:34:48 +0800	[thread overview]
Message-ID: <1479818088-6007-6-git-send-email-wxt@rock-chips.com> (raw)
In-Reply-To: <1479818088-6007-1-git-send-email-wxt@rock-chips.com>

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 <wxt@rock-chips.com>
---

 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);
 
-- 
2.7.4

  parent reply	other threads:[~2016-11-22 12:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22 12:34 [PATCH 0/5] thermal: rockchip: optimization to improve the driver Caesar Wang
2016-11-22 12:34 ` [PATCH 1/5] thermal: rockchip: improve conversion error messages Caesar Wang
2016-11-22 12:34 ` [PATCH 2/5] thermal: rockchip: don't pass table structs by value Caesar Wang
2016-11-22 12:34 ` [PATCH 3/5] thermal: rockchip: fixes invalid temperature case Caesar Wang
2016-11-22 20:57   ` Brian Norris
2016-11-22 21:52     ` Brian Norris
2016-11-23  2:06       ` Caesar Wang
2016-11-23  2:33         ` Brian Norris
2016-11-23  3:03           ` Caesar Wang
2016-11-23  4:36             ` Brian Norris
2016-11-22 12:34 ` [PATCH 4/5] thermal: rockchip: optimize the conversion table Caesar Wang
2016-11-22 21:47   ` Brian Norris
2016-11-22 12:34 ` Caesar Wang [this message]
2016-11-22 20:51   ` [PATCH 5/5] thermal: rockchip: handle the set_trips without the trip points Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479818088-6007-6-git-send-email-wxt@rock-chips.com \
    --to=wxt@rock-chips.com \
    --cc=briannorris@chromium.org \
    --cc=edubezval@gmail.com \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=rui.zhang@intel.com \
    --cc=smbarber@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®