Esempio n. 1
0
/**
 * omap_bandgap_write_thot() - sets sensor current thot
 * @bg_ptr - pointer to bandgap instance
 * @id - sensor id
 * @val - desired thot value
 *
 * returns 0 on success or the proper error code
 */
int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
{
	struct temp_sensor_data *ts_data;
	struct temp_sensor_registers *tsr;
	u32 t_hot;
	int ret;

	ret = omap_bandgap_validate(bg_ptr, id);
	if (ret)
		return ret;

	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
		return -ENOTSUPP;

	ts_data = bg_ptr->conf->sensors[id].ts_data;
	tsr = bg_ptr->conf->sensors[id].registers;

	if (val < ts_data->min_temp + ts_data->hyst_val)
		return -EINVAL;
	ret = temp_to_adc_conversion(val, bg_ptr, id, &t_hot);
	if (ret < 0)
		return ret;

	mutex_lock(&bg_ptr->bg_mutex);
	temp_sensor_configure_thot(bg_ptr, id, t_hot);
	mutex_unlock(&bg_ptr->bg_mutex);

	return 0;
}
int omap4460plus_scm_set_temp_max(struct scm *scm_ptr, int id, int val)
{
	struct omap4460plus_temp_sensor_registers *tsr;
	u32 t_hot;
	tsr = scm_ptr->registers[id];

	if (val < scm_ptr->ts_data[id]->min_temp +
	    scm_ptr->ts_data[id]->hyst_val)
		return -EINVAL;
	t_hot = temp_to_adc_conversion(val, scm_ptr, id);
	if (t_hot < 0)
		return t_hot;

	mutex_lock(&scm_ptr->scm_mutex);
	temp_sensor_configure_thot(scm_ptr, id, t_hot);
	mutex_unlock(&scm_ptr->scm_mutex);

	return 0;
}