diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-06-07 19:13:13 +0000 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-08-08 14:37:08 +0900 |
commit | d968ad80adac38bd8c76baaccdaa426dc3a9ce2f (patch) | |
tree | d776c405c29d062a27289af7ae7fde9e21883444 /drivers | |
parent | 7d8e0771e78c00350b5b13fd1abb699ae96a494a (diff) | |
download | linux-3.10-d968ad80adac38bd8c76baaccdaa426dc3a9ce2f.tar.gz linux-3.10-d968ad80adac38bd8c76baaccdaa426dc3a9ce2f.tar.bz2 linux-3.10-d968ad80adac38bd8c76baaccdaa426dc3a9ce2f.zip |
thermal: ti-soc-thermal: freeze FSM while computing trend
In order to read the history buffer, it is required to
freeze BG FSM. This patch adds the missing piece of code
to freeze the FSM and also a contention area to avoid
other parts of the code to access the DTEMPs.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/ti-soc-thermal/ti-bandgap.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index f20c1cfe980..219c051d2e6 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -992,9 +992,12 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend) goto exit; } + spin_lock(&bgp->lock); + tsr = bgp->conf->sensors[id].registers; /* Freeze and read the last 2 valid readings */ + RMW_BITS(bgp, id, bgap_mask_ctrl, mask_freeze_mask, 1); reg1 = tsr->ctrl_dtemp_1; reg2 = tsr->ctrl_dtemp_2; @@ -1008,22 +1011,25 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend) /* Convert from adc values to mCelsius temperature */ ret = ti_bandgap_adc_to_mcelsius(bgp, temp1, &t1); if (ret) - goto exit; + goto unfreeze; ret = ti_bandgap_adc_to_mcelsius(bgp, temp2, &t2); if (ret) - goto exit; + goto unfreeze; /* Fetch the update interval */ ret = ti_bandgap_read_update_interval(bgp, id, &interval); if (ret || !interval) - goto exit; + goto unfreeze; *trend = (t1 - t2) / interval; dev_dbg(bgp->dev, "The temperatures are t1 = %d and t2 = %d and trend =%d\n", t1, t2, *trend); +unfreeze: + RMW_BITS(bgp, id, bgap_mask_ctrl, mask_freeze_mask, 0); + spin_unlock(&bgp->lock); exit: return ret; } |