From: Eduardo Valentin <eduardo.valentin@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <devel@driverdev.osuosl.org>, <linux-omap@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Eduardo Valentin <eduardo.valentin@ti.com>
Subject: [PATCH 10/15] staging: omap-thermal: introduze FREEZE_BIT feature
Date: Tue, 26 Feb 2013 18:53:33 -0400 [thread overview]
Message-ID: <1361919218-9788-11-git-send-email-eduardo.valentin@ti.com> (raw)
In-Reply-To: <1361919218-9788-1-git-send-email-eduardo.valentin@ti.com>
For ES2.0 devices, it is not guaranteed that current DTEMP
or DTEMP0 from the history buffer are going to contain
correct values, due to desynchronization between BG clk
and OCP clk.
For this reason, this patch changes the driver to first:
a. consider a feature flag, FREEZE_BIT, in order to check
it is possible to freeze the history buffer or not.
b. whenever reading the temperature, it will fetch from
DTEMP1 instead of DTEMP or DTEMP0.
This WA is applicable only for OMAP5430 ES2.0.
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
drivers/staging/omap-thermal/omap-bandgap.c | 60 +++++++++++++++++++-------
drivers/staging/omap-thermal/omap-bandgap.h | 1 +
drivers/staging/omap-thermal/omap5-thermal.c | 1 +
3 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 80384ed..82ad5db 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -75,12 +75,44 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
return 0;
}
+static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp, ctrl, reg;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ reg = tsr->temp_sensor_ctrl;
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT)) {
+ ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
+ ctrl |= tsr->mask_freeze_mask;
+ omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
+ /*
+ * In case we cannot read from cur_dtemp / dtemp_0,
+ * then we read from the last valid temp read
+ */
+ reg = tsr->ctrl_dtemp_1;
+ }
+
+ /* read temperature */
+ temp = omap_bandgap_readl(bg_ptr, reg);
+ temp &= tsr->bgap_dtemp_mask;
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT)) {
+ ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
+ ctrl &= ~tsr->mask_freeze_mask;
+ omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
+ }
+
+ return temp;
+}
+
/* This is the Talert handler. Call it only if HAS(TALERT) is set */
static irqreturn_t talert_irq_handler(int irq, void *data)
{
struct omap_bandgap *bg_ptr = data;
struct temp_sensor_registers *tsr;
- u32 t_hot = 0, t_cold = 0, temp, ctrl;
+ u32 t_hot = 0, t_cold = 0, ctrl;
int i;
bg_ptr = data;
@@ -118,10 +150,6 @@ static irqreturn_t talert_irq_handler(int irq, void *data)
__func__, bg_ptr->conf->sensors[i].domain,
t_hot, t_cold);
- /* read temperature */
- temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
- temp &= tsr->bgap_dtemp_mask;
-
/* report temperature to whom may concern */
if (bg_ptr->conf->report_temperature)
bg_ptr->conf->report_temperature(bg_ptr, i);
@@ -190,11 +218,11 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
u32 temp, reg_val;
/* Read the current on die temperature */
- tsr = bg_ptr->conf->sensors[id].registers;
- temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
- temp &= tsr->bgap_dtemp_mask;
+ temp = omap_bandgap_read_temp(bg_ptr, id);
+ tsr = bg_ptr->conf->sensors[id].registers;
reg_val = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
+
if (temp < t_hot)
reg_val |= tsr->mask_hot_mask;
else
@@ -625,8 +653,9 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
return ret;
tsr = bg_ptr->conf->sensors[id].registers;
- temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
- temp &= tsr->bgap_dtemp_mask;
+ mutex_lock(&bg_ptr->bg_mutex);
+ temp = omap_bandgap_read_temp(bg_ptr, id);
+ mutex_unlock(&bg_ptr->bg_mutex);
ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
if (ret)
@@ -694,12 +723,11 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
temp |= 1 << __ffs(tsr->bgap_soc_mask);
omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
/* Wait until DTEMP is updated */
- temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
- temp &= (tsr->bgap_dtemp_mask);
- while ((temp == 0) && --counter) {
- temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
- temp &= (tsr->bgap_dtemp_mask);
- }
+ temp = omap_bandgap_read_temp(bg_ptr, id);
+
+ while ((temp == 0) && --counter)
+ temp = omap_bandgap_read_temp(bg_ptr, id);
+
/* Start of Conversion = 0 */
temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
temp &= ~(1 << __ffs(tsr->bgap_soc_mask));
diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index ef5503d..59c9ba2 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -442,6 +442,7 @@ struct omap_bandgap_data {
#define OMAP_BANDGAP_FEATURE_COUNTER (1 << 4)
#define OMAP_BANDGAP_FEATURE_POWER_SWITCH (1 << 5)
#define OMAP_BANDGAP_FEATURE_CLK_CTRL (1 << 6)
+#define OMAP_BANDGAP_FEATURE_FREEZE_BIT (1 << 7)
#define OMAP_BANDGAP_HAS(b, f) \
((b)->conf->features & OMAP_BANDGAP_FEATURE_ ## f)
unsigned int features;
diff --git a/drivers/staging/omap-thermal/omap5-thermal.c b/drivers/staging/omap-thermal/omap5-thermal.c
index c2bfc65..b20db0c 100644
--- a/drivers/staging/omap-thermal/omap5-thermal.c
+++ b/drivers/staging/omap-thermal/omap5-thermal.c
@@ -319,6 +319,7 @@ omap5430_adc_to_temp[
/* TODO : Need to update the slope/constant for ES2.0 silicon */
const struct omap_bandgap_data omap5430_data = {
.features = OMAP_BANDGAP_FEATURE_TSHUT_CONFIG |
+ OMAP_BANDGAP_FEATURE_FREEZE_BIT |
OMAP_BANDGAP_FEATURE_TALERT,
.fclock_name = "l3instr_ts_gclk_div",
.div_ck_name = "l3instr_ts_gclk_div",
--
1.7.7.1.488.ge8e1c
next prev parent reply other threads:[~2013-02-26 22:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-26 22:53 [PATCH 00/15] staging: omap-thermal fixes and ports Eduardo Valentin
2013-02-26 22:53 ` [PATCH 01/15] staging: omap-thermal: Add print when TSHUT temperature reached Eduardo Valentin
2013-02-26 22:53 ` [PATCH 02/15] staging: omap-thermal: introduce clock feature flag Eduardo Valentin
2013-02-26 22:53 ` [PATCH 03/15] staging: omap-thermal: update OMAP54xx conv_table Eduardo Valentin
2013-02-26 22:53 ` [PATCH 04/15] staging: omap-thermal: standardize register nomenclature to use 'GPU' Eduardo Valentin
2013-02-26 22:53 ` [PATCH 05/15] staging: omap-thermal: remove from register map soc and mode on OMAP5 Eduardo Valentin
2013-02-26 22:53 ` [PATCH 06/15] staging: omap-thermal: introduce new features of OMAP54xx Eduardo Valentin
2013-02-26 22:53 ` [PATCH 07/15] staging: omap-thermal: update OMAP54xx clock sources Eduardo Valentin
2013-02-26 22:53 ` [PATCH 08/15] staging: omap-thermal: update feature bitfield for OMAP54xx Eduardo Valentin
2013-02-26 22:53 ` [PATCH 09/15] staging: omap-thermal: remove dedicated counter register for OMAP5 Eduardo Valentin
2013-02-26 22:53 ` Eduardo Valentin [this message]
2013-02-26 22:53 ` [PATCH 11/15] staging: omap-thermal: update DT entry documentation Eduardo Valentin
2013-02-26 22:53 ` [PATCH 12/15] staging: omap-thermal: add DT example for OMAP54xx devices Eduardo Valentin
2013-02-26 22:53 ` [PATCH 13/15] staging: omap-thermal: Remove double conv_table reference Eduardo Valentin
2013-02-26 22:53 ` [PATCH 14/15] staging: omap-thermal: name data files accordingly Eduardo Valentin
2013-02-26 22:53 ` [PATCH 15/15] staging: omap-thermal: update clock prepare count Eduardo Valentin
2013-02-27 5:35 ` Mike Turquette
2013-02-27 10:51 ` 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=1361919218-9788-11-git-send-email-eduardo.valentin@ti.com \
--to=eduardo.valentin@ti.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.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®