static void decrease_mpu_freq_fn(struct work_struct *work)
{
	struct omap_die_governor *omap_gov;

	omap_gov = container_of(work, struct omap_die_governor,
				decrease_mpu_freq_work.work);

	omap_gov->sensor_temp = thermal_request_temp(omap_gov->temp_sensor);
	thermal_sensor_set_temp(omap_gov->temp_sensor);
}
static int omap_report_temp(struct thermal_dev *tdev)
{
	struct platform_device *pdev = to_platform_device(tdev->dev);
	struct scm *scm_ptr = platform_get_drvdata(pdev);
	int id = tdev->sen_id;

	scm_ptr->therm_fw[id]->current_temp =
	    omap4460plus_scm_read_temp(scm_ptr, id);

	if (scm_ptr->therm_fw[id]->current_temp != -EINVAL) {
		thermal_sensor_set_temp(scm_ptr->therm_fw[id]);
		kobject_uevent(&scm_ptr->tsh_ptr[id].pdev->dev.kobj,
			       KOBJ_CHANGE);
	}

	return scm_ptr->therm_fw[id]->current_temp;
}
static void pcb_report_fw_temp(struct thermal_dev *tdev)
{
	struct platform_device *pdev = to_platform_device(tdev->dev);
	struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev);
	int ret;

	pcb_read_current_temp(temp_sensor);
	if (temp_sensor->therm_fw->current_temp != -EINVAL) {
		ret = thermal_sensor_set_temp(temp_sensor->therm_fw);
		if (ret == -ENODEV)
			pr_err("%s:thermal_sensor_set_temp reports error\n",
				__func__);
		else
			cancel_delayed_work_sync(&temp_sensor->pcb_sensor_work);
		kobject_uevent(&temp_sensor->dev->kobj, KOBJ_CHANGE);
	}
}
static irqreturn_t omap_talert_irq_handler(int irq, void *data)
{
	struct omap_temp_sensor *temp_sensor = (struct omap_temp_sensor *)data;
	int t_hot, t_cold, temp_offset, temp;
	char env_temp[20];
	char env_zone[20];
        char *envp[] = { env_temp, env_zone, NULL };

	t_hot = omap_temp_sensor_readl(temp_sensor, BGAP_STATUS_OFFSET)
	    & OMAP4_HOT_FLAG_MASK;
	t_cold = omap_temp_sensor_readl(temp_sensor, BGAP_STATUS_OFFSET)
	    & OMAP4_COLD_FLAG_MASK;
	temp_offset = omap_temp_sensor_readl(temp_sensor, BGAP_CTRL_OFFSET);
	if (t_hot) {
		temp_offset &= ~(OMAP4_MASK_HOT_MASK);
		temp_offset |= OMAP4_MASK_COLD_MASK;
	} else if (t_cold) {
		temp_offset &= ~(OMAP4_MASK_COLD_MASK);
		temp_offset |= OMAP4_MASK_HOT_MASK;
	}

	omap_temp_sensor_writel(temp_sensor, temp_offset, BGAP_CTRL_OFFSET);
	temp = omap_temp_sensor_readl(temp_sensor, TEMP_SENSOR_CTRL_OFFSET);
	temp &= (OMAP4_BGAP_TEMP_SENSOR_DTEMP_MASK);

	if (!temp_sensor->is_efuse_valid)
		pr_err_once("Non-trimmed BGAP, Temp not accurate\n");

	/* look up for temperature in the table and return the
	   temperature */
	if (temp < OMAP_ADC_START_VALUE || temp > OMAP_ADC_END_VALUE) {
		pr_err("invalid adc code reported by the sensor %d\n", temp);
	} else {
		temp_sensor->therm_fw->current_temp =
				adc_to_temp[temp - OMAP_ADC_START_VALUE];
		thermal_sensor_set_temp(temp_sensor->therm_fw);
		snprintf(env_temp, 20, "TEMP=%d",thermal_sensor_get_hotspot_temp(temp_sensor->therm_fw)/1000);
                envp[0] = env_temp;
		snprintf(env_zone, 20, "ZONE=%d",thermal_sensor_get_zone(temp_sensor->therm_fw));
                envp[1] = env_zone;
		kobject_uevent_env(&temp_sensor->dev->kobj, KOBJ_CHANGE, envp);
	}

	return IRQ_HANDLED;
}
static ssize_t set_temp_user_space(struct device *dev,
			struct device_attribute *devattr,
			const char *buf, size_t count)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct omap_temp_sensor *temp_sensor = platform_get_drvdata(pdev);
	long val;

	if (strict_strtol(buf, 10, &val)) {
		count = -EINVAL;
		goto out;
	}

	if (!temp_sensor->debug && debug_thermal) {
		pr_info("%s: Going into debug mode\n", __func__);
		disable_irq_nosync(temp_sensor->irq);
		temp_sensor->debug = 1;
	} else if (temp_sensor->debug && !debug_thermal) {
		pr_info("%s:Reenable temp sensor dbg mode %i\n",
			__func__, temp_sensor->debug);
		enable_irq(temp_sensor->irq);
		temp_sensor->debug = 0;
		temp_sensor->debug_temp = 0;
	} else if ((temp_sensor->debug == 0) &&
			(debug_thermal == 0)) {
		pr_info("%s:Not in debug mode\n", __func__);
		goto out;
	} else {
		pr_info("%s:Debug mode %i and setting temp to %li\n",
			__func__, temp_sensor->debug, val);
	}

	/* Set new temperature */
	temp_sensor->debug_temp = val;

	temp_sensor->therm_fw->current_temp = val;
	thermal_sensor_set_temp(temp_sensor->therm_fw);
	/* Send a kobj_change */
	kobject_uevent(&temp_sensor->dev->kobj, KOBJ_CHANGE);

out:
	return count;
}
static int omap_report_temp(struct thermal_dev *tdev)
{
	struct platform_device *pdev = to_platform_device(tdev->dev);
	struct omap_temp_sensor *temp_sensor = platform_get_drvdata(pdev);
	int ret;

	temp_sensor->therm_fw->current_temp =
			omap_read_current_temp(temp_sensor);

	if (temp_sensor->therm_fw->current_temp != -EINVAL) {
		ret = thermal_sensor_set_temp(temp_sensor->therm_fw);
		if (ret == -ENODEV)
			pr_err("%s:thermal_sensor_set_temp reports error\n",
				__func__);
		kobject_uevent(&temp_sensor->dev->kobj, KOBJ_CHANGE);
	}

	return temp_sensor->therm_fw->current_temp;
}
示例#7
0
static void sim_report_fw_temp(struct thermal_dev *tdev)
{
	struct platform_device *pdev = to_platform_device(tdev->dev);
	struct sim_temp_sensor *temp_sensor = platform_get_drvdata(pdev);
	int ret;

	if (NULL == temp_sensor) {
		pr_err("%s %d, platform_get_drvdata is NULL\n", __func__, __LINE__);
		return -1;
	}

	temp_sensor->therm_fw->current_temp = sim_read_current_temp(temp_sensor);
	if (temp_sensor->therm_fw->current_temp != -EINVAL) {
		ret = thermal_sensor_set_temp(temp_sensor->therm_fw);
		if (ret == -ENODEV)
			pr_err("%s:thermal_sensor_set_temp reports error\n",
				__func__);
		kobject_uevent(&temp_sensor->dev->kobj, KOBJ_CHANGE);
	}
}
static ssize_t tmp102_set_temp_user_space(struct device *dev,
		struct device_attribute *devattr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct tmp102_temp_sensor *tmp102 = i2c_get_clientdata(client);
	long val;

	if (strict_strtol(buf, 10, &val)) {
		count = -EINVAL;
		goto out;
	}

	/* Set new temperature */
	tmp102->debug_temp = val;

	tmp102->therm_fw->current_temp = val;
	thermal_sensor_set_temp(tmp102->therm_fw);
	/* Send a kobj_change */
	kobject_uevent(&tmp102->dev->kobj, KOBJ_CHANGE);

out:
	return count;
}
static ssize_t set_temp_user_space(struct device *dev,
			struct device_attribute *devattr,
			const char *buf, size_t count)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev);
	long val;

	if (strict_strtol(buf, 10, &val)) {
		count = -EINVAL;
		goto out;
	}

	/* Set new temperature */
	temp_sensor->debug_temp = val;

	temp_sensor->therm_fw->current_temp = val;
	thermal_sensor_set_temp(temp_sensor->therm_fw);
	/* Send a kobj_change */
	kobject_uevent(&temp_sensor->dev->kobj, KOBJ_CHANGE);

out:
	return count;
}