Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363355
b: refs/heads/master
c: 194a54f
h: refs/heads/master
i:
  363353: 31cd477
  363351: 09f015c
v: v3
  • Loading branch information
Eduardo Valentin authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent 37f7f6d commit 66db5f2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8c9e642fc87128d87cc773d042e2fdcd38a1a9e7
refs/heads/master: 194a54f0bd0adef2e6e61fea49ba4b9db81598f8
60 changes: 44 additions & 16 deletions trunk/drivers/staging/omap-thermal/omap-bandgap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/staging/omap-thermal/omap-bandgap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/staging/omap-thermal/omap5-thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 66db5f2

Please sign in to comment.