All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: pali.rohar@gmail.com, sre@debian.org, sre@ring0.de,
	kernel list <linux-kernel@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-omap@vger.kernel.org, tony@atomide.com, khilman@kernel.org,
	aaro.koskinen@iki.fi, ivo.g.dimitrov.75@gmail.com,
	edubezval@gmail.com, rui.zhang@intel.com,
	linux-pm@vger.kernel.org
Subject: [PATCHv2] ti-soc-thermal: implement eocz bit to make driver useful on omap3
Date: Sun, 18 Jan 2015 21:20:51 +0100	[thread overview]
Message-ID: <20150118202051.GB27800@amd> (raw)
In-Reply-To: <20150103114632.GA21883@amd>

For omap3, proper implementation of eocz bit is needed. It was
actually a TODO in the driver.

Signed-off-by: Pavel Machek <pavel@ucw.cz>

---

No longer includes forced reading in single conversion mode; that will
be done as a separate patch.

diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 634b6ce..2fde78c 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -917,7 +903,8 @@ void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id)
 static int
 ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
 {
-	u32 temp = 0, counter = 1000;
+	u32 counter = 1000;
+	struct temp_sensor_registers *tsr;
 
 	/* Select single conversion mode */
 	if (TI_BANDGAP_HAS(bgp, MODE_CONFIG))
@@ -925,16 +912,27 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
 
 	/* Start of Conversion = 1 */
 	RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1);
-	/* Wait until DTEMP is updated */
-	temp = ti_bandgap_read_temp(bgp, id);
 
-	while ((temp == 0) && --counter)
-		temp = ti_bandgap_read_temp(bgp, id);
-	/* REVISIT: Check correct condition for end of conversion */
+	/* Wait for EOCZ going up */
+	tsr = bgp->conf->sensors[id].registers;
+
+	while (--counter) {
+		if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &
+		    tsr->bgap_eocz_mask)
+			break;
+	}
 
 	/* Start of Conversion = 0 */
 	RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0);
 
+	/* Wait for EOCZ going down */
+	counter = 1000;
+	while (--counter) {
+		if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &
+		      tsr->bgap_eocz_mask))
+			break;
+	}
+
 	return 0;
 }
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

WARNING: multiple messages have this Message-ID (diff)
From: pavel@ucw.cz (Pavel Machek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2] ti-soc-thermal: implement eocz bit to make driver useful on omap3
Date: Sun, 18 Jan 2015 21:20:51 +0100	[thread overview]
Message-ID: <20150118202051.GB27800@amd> (raw)
In-Reply-To: <20150103114632.GA21883@amd>

For omap3, proper implementation of eocz bit is needed. It was
actually a TODO in the driver.

Signed-off-by: Pavel Machek <pavel@ucw.cz>

---

No longer includes forced reading in single conversion mode; that will
be done as a separate patch.

diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 634b6ce..2fde78c 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -917,7 +903,8 @@ void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id)
 static int
 ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
 {
-	u32 temp = 0, counter = 1000;
+	u32 counter = 1000;
+	struct temp_sensor_registers *tsr;
 
 	/* Select single conversion mode */
 	if (TI_BANDGAP_HAS(bgp, MODE_CONFIG))
@@ -925,16 +912,27 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id)
 
 	/* Start of Conversion = 1 */
 	RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1);
-	/* Wait until DTEMP is updated */
-	temp = ti_bandgap_read_temp(bgp, id);
 
-	while ((temp == 0) && --counter)
-		temp = ti_bandgap_read_temp(bgp, id);
-	/* REVISIT: Check correct condition for end of conversion */
+	/* Wait for EOCZ going up */
+	tsr = bgp->conf->sensors[id].registers;
+
+	while (--counter) {
+		if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &
+		    tsr->bgap_eocz_mask)
+			break;
+	}
 
 	/* Start of Conversion = 0 */
 	RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0);
 
+	/* Wait for EOCZ going down */
+	counter = 1000;
+	while (--counter) {
+		if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) &
+		      tsr->bgap_eocz_mask))
+			break;
+	}
+
 	return 0;
 }
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  parent reply	other threads:[~2015-01-18 20:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-03 11:46 [PATCH] ti-soc-thermal: implement eocz bit to make driver useful on omap3 Pavel Machek
2015-01-03 11:46 ` Pavel Machek
2015-01-03 12:26 ` Eduardo Valentin
2015-01-03 12:26   ` Eduardo Valentin
2015-01-03 16:22   ` Pavel Machek
2015-01-03 16:22     ` Pavel Machek
2015-01-05 21:35     ` Eduardo Valentin
2015-01-05 21:35       ` Eduardo Valentin
2015-01-18 20:18       ` Pavel Machek
2015-01-18 20:18         ` Pavel Machek
2015-01-21  5:21         ` Eduardo Valentin
2015-01-21  5:21           ` Eduardo Valentin
2015-01-18 20:20 ` Pavel Machek [this message]
2015-01-18 20:20   ` [PATCHv2] " Pavel Machek
2015-01-18 20:24 ` [PATCHv2] ti-soc-thermal: request temperature periodically if hw can't do that itself Pavel Machek
2015-01-18 20:24   ` Pavel Machek
2015-03-24 16:30   ` Eduardo Valentin
2015-03-24 16:30     ` Eduardo Valentin
2015-03-24 22:27     ` Pavel Machek
2015-03-24 22:27       ` Pavel Machek
2015-03-24 22:20   ` [PATCHv3] " Pavel Machek
2015-03-24 22:20     ` Pavel Machek
2015-03-31  8:42   ` [PATCH] ti-soc-thermal: implement omap3 support Pavel Machek
2015-03-31  8:42     ` Pavel Machek
2015-03-31 15:02     ` Grazvydas Ignotas
2015-03-31 15:02       ` Grazvydas Ignotas
2015-03-31 15:02       ` Grazvydas Ignotas
2015-04-02 14:49       ` Pavel Machek
2015-04-02 14:49         ` Pavel Machek
2015-04-02 14:49     ` [PATCHv2] " Pavel Machek
2015-04-02 14:49       ` Pavel Machek
2015-04-07 18:57       ` Eduardo Valentin
2015-04-07 18:57         ` Eduardo Valentin
2015-04-07 19:09       ` Eduardo Valentin
2015-04-07 19:09         ` Eduardo Valentin

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=20150118202051.GB27800@amd \
    --to=pavel@ucw.cz \
    --cc=aaro.koskinen@iki.fi \
    --cc=edubezval@gmail.com \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=rui.zhang@intel.com \
    --cc=sre@debian.org \
    --cc=sre@ring0.de \
    --cc=tony@atomide.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.