/**
* omap_bandgap_adc_to_mcelsius() - converts an ADC value to mCelsius scale
* @bg_ptr: struct omap_bandgap pointer
- * @id: sensor id
* @adc_val: value in ADC representation
* @t: address where to write the resulting temperature in mCelsius
*
* The conversion table is indexed by the ADC values.
*/
static
-int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
+int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr,
int adc_val, int *t)
{
- struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+ struct omap_bandgap_data *conf = bg_ptr->conf;
int ret = 0;
/* look up for temperature in the table and return the temperature */
- if (adc_val < ts_data->adc_start_val ||
- adc_val > ts_data->adc_end_val) {
+ if (adc_val < conf->adc_start_val || adc_val > conf->adc_end_val) {
ret = -ERANGE;
goto exit;
}
- *t = bg_ptr->conf->conv_table[adc_val - ts_data->adc_start_val];
+ *t = bg_ptr->conf->conv_table[adc_val - conf->adc_start_val];
exit:
return ret;
}
static
-int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
+int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, long temp,
int *adc)
{
- struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
+ struct omap_bandgap_data *conf = bg_ptr->conf;
const int *conv_table = bg_ptr->conf->conv_table;
int high, low, mid, ret = 0;
low = 0;
- high = ts_data->adc_end_val - ts_data->adc_start_val;
+ high = conf->adc_end_val - conf->adc_start_val;
mid = (high + low) / 2;
if (temp < conv_table[low] || temp > conv_table[high]) {
mid = (low + high) / 2;
}
- *adc = ts_data->adc_start_val + low;
+ *adc = conf->adc_start_val + low;
exit:
return ret;
}
static
-int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
- u32 *sum)
+int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum)
{
int temp, ret;
- ret = omap_bandgap_adc_to_mcelsius(bg_ptr, i, adc_val, &temp);
+ ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
if (ret < 0)
return ret;
temp += hyst_val;
- return omap_bandgap_mcelsius_to_adc(bg_ptr, i, temp, sum);
+ return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
}
/* Talert Thot threshold. Call it only if HAS(TALERT) is set */
__ffs(tsr->threshold_tcold_mask);
if (t_hot <= cold) {
/* change the t_cold to t_hot - 5000 millidegrees */
- err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, id, &cold);
+ err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold);
/* write the new t_cold value */
reg_val = thresh_val & (~tsr->threshold_tcold_mask);
reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
if (t_cold >= hot) {
/* change the t_hot to t_cold + 5000 millidegrees */
- err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, id, &hot);
+ err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot);
/* write the new t_hot value */
reg_val = thresh_val & (~tsr->threshold_thot_mask);
reg_val |= hot << __ffs(tsr->threshold_thot_mask);
temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
temp = (temp & tsr->threshold_thot_mask) >>
__ffs(tsr->threshold_thot_mask);
- ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+ ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
if (ret) {
dev_err(bg_ptr->dev, "failed to read thot\n");
return -EIO;
if (val < ts_data->min_temp + ts_data->hyst_val)
return -EINVAL;
- ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_hot);
+ ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_hot);
if (ret < 0)
return ret;
temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
temp = (temp & tsr->threshold_tcold_mask)
>> __ffs(tsr->threshold_tcold_mask);
- ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+ ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
if (ret)
return -EIO;
if (val > ts_data->max_temp + ts_data->hyst_val)
return -EINVAL;
- ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_cold);
+ ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_cold);
if (ret < 0)
return ret;
temp = omap_bandgap_read_temp(bg_ptr, id);
mutex_unlock(&bg_ptr->bg_mutex);
- ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+ ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
if (ret)
return -EIO;
.max_temp = OMAP4430_MAX_TEMP,
.min_temp = OMAP4430_MIN_TEMP,
.hyst_val = OMAP4430_HYST_VAL,
- .adc_start_val = OMAP4430_ADC_START_VALUE,
- .adc_end_val = OMAP4430_ADC_END_VALUE,
};
/*
.fclock_name = "bandgap_fclk",
.div_ck_name = "bandgap_fclk",
.conv_table = omap4430_adc_to_temp,
+ .adc_start_val = OMAP4430_ADC_START_VALUE,
+ .adc_end_val = OMAP4430_ADC_END_VALUE,
.expose_sensor = omap_thermal_expose_sensor,
.remove_sensor = omap_thermal_remove_sensor,
.sensors = {
.max_temp = OMAP4460_MAX_TEMP,
.min_temp = OMAP4460_MIN_TEMP,
.hyst_val = OMAP4460_HYST_VAL,
- .adc_start_val = OMAP4460_ADC_START_VALUE,
- .adc_end_val = OMAP4460_ADC_END_VALUE,
.update_int1 = 1000,
.update_int2 = 2000,
};
.fclock_name = "bandgap_ts_fclk",
.div_ck_name = "div_ts_ck",
.conv_table = omap4460_adc_to_temp,
+ .adc_start_val = OMAP4460_ADC_START_VALUE,
+ .adc_end_val = OMAP4460_ADC_END_VALUE,
.expose_sensor = omap_thermal_expose_sensor,
.remove_sensor = omap_thermal_remove_sensor,
.sensors = {
.fclock_name = "bandgap_ts_fclk",
.div_ck_name = "div_ts_ck",
.conv_table = omap4460_adc_to_temp,
+ .adc_start_val = OMAP4460_ADC_START_VALUE,
+ .adc_end_val = OMAP4460_ADC_END_VALUE,
.expose_sensor = omap_thermal_expose_sensor,
.remove_sensor = omap_thermal_remove_sensor,
.sensors = {
.max_temp = OMAP5430_MPU_MAX_TEMP,
.min_temp = OMAP5430_MPU_MIN_TEMP,
.hyst_val = OMAP5430_MPU_HYST_VAL,
- .adc_start_val = OMAP5430_ADC_START_VALUE,
- .adc_end_val = OMAP5430_ADC_END_VALUE,
.update_int1 = 1000,
.update_int2 = 2000,
};
.max_temp = OMAP5430_GPU_MAX_TEMP,
.min_temp = OMAP5430_GPU_MIN_TEMP,
.hyst_val = OMAP5430_GPU_HYST_VAL,
- .adc_start_val = OMAP5430_ADC_START_VALUE,
- .adc_end_val = OMAP5430_ADC_END_VALUE,
.update_int1 = 1000,
.update_int2 = 2000,
};
.max_temp = OMAP5430_CORE_MAX_TEMP,
.min_temp = OMAP5430_CORE_MIN_TEMP,
.hyst_val = OMAP5430_CORE_HYST_VAL,
- .adc_start_val = OMAP5430_ADC_START_VALUE,
- .adc_end_val = OMAP5430_ADC_END_VALUE,
.update_int1 = 1000,
.update_int2 = 2000,
};
.fclock_name = "l3instr_ts_gclk_div",
.div_ck_name = "l3instr_ts_gclk_div",
.conv_table = omap5430_adc_to_temp,
+ .adc_start_val = OMAP5430_ADC_START_VALUE,
+ .adc_end_val = OMAP5430_ADC_END_VALUE,
.expose_sensor = omap_thermal_expose_sensor,
.remove_sensor = omap_thermal_remove_sensor,
.sensors = {