linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ti-soc-thermal: implement eocz bit to make driver useful on omap3
@ 2015-01-03 11:46 Pavel Machek
  2015-01-03 12:26 ` Eduardo Valentin
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Pavel Machek @ 2015-01-03 11:46 UTC (permalink / raw)
  To: pali.rohar, sre, sre, kernel list, linux-arm-kernel, linux-omap,
	tony, khilman, aaro.koskinen, ivo.g.dimitrov.75, edubezval,
	rui.zhang, linux-pm

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

When periodic mode is not enabled, it is neccessary to force reads.

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

diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 634b6ce..ee63d08 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -43,6 +43,8 @@
 
 #include "ti-bandgap.h"
 
+static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id);
+
 /***   Helper functions to access registers and their bitfields   ***/
 
 /**
@@ -852,14 +831,20 @@ int ti_bandgap_read_temperature(struct ti_bandgap *bgp, int id,
 	if (ret)
 		return ret;
 
+	if (!TI_BANDGAP_HAS(bgp, MODE_CONFIG)) {
+		ret = ti_bandgap_force_single_read(bgp, id);
+		if (ret)
+			return ret;
+	}
+
 	spin_lock(&bgp->lock);
 	temp = ti_bandgap_read_temp(bgp, id);
 	spin_unlock(&bgp->lock);
 
-	ret |= ti_bandgap_adc_to_mcelsius(bgp, temp, &temp);
+	ret = ti_bandgap_adc_to_mcelsius(bgp, temp, &temp);
 	if (ret)
 		return -EIO;
 
 	*temperature = temp;
 
 	return 0;
@@ -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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-04-07 19:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-03 11:46 [PATCH] ti-soc-thermal: implement eocz bit to make driver useful on omap3 Pavel Machek
2015-01-03 12:26 ` Eduardo Valentin
2015-01-03 16:22   ` Pavel Machek
2015-01-05 21:35     ` Eduardo Valentin
2015-01-18 20:18       ` Pavel Machek
2015-01-21  5:21         ` Eduardo Valentin
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-03-24 16:30   ` Eduardo Valentin
2015-03-24 22:27     ` Pavel Machek
2015-03-24 22:20   ` [PATCHv3] " Pavel Machek
2015-03-31  8:42   ` [PATCH] ti-soc-thermal: implement omap3 support Pavel Machek
2015-03-31 15:02     ` Grazvydas Ignotas
2015-04-02 14:49       ` Pavel Machek
2015-04-02 14:49     ` [PATCHv2] " Pavel Machek
2015-04-07 18:57       ` Eduardo Valentin
2015-04-07 19:09       ` Eduardo Valentin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).