/* sysfs interface : /sys/devices/platform/exynos5-tmu/temp */
static ssize_t
exynos_thermal_sensor_temp(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct exynos_tmu_data *data = th_zone->sensor_conf->private_data;
	u8 temp_code;
	unsigned long temp[EXYNOS_TMU_COUNT] = {0,};
	int i, len = 0;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		if (temp_code == 0xff)
			continue;
		temp[i] = code_to_temp(data, temp_code, i) * MCELSIUS;
	}

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++)
		len += snprintf(&buf[len], PAGE_SIZE, "sensor%d : %ld\n", i, temp[i]);

	return len;
}
Example #2
0
static ssize_t exynos_tmu_emulation_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{
	struct platform_device *pdev = container_of(dev,
					struct platform_device, dev);
	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
	unsigned int reg;
	u8 temp_code;
	int temp = 0;

	if (data->soc == SOC_ARCH_EXYNOS4210)
		goto out;

	mutex_lock(&data->lock);
	clk_enable(data->clk);
	reg = readl(data->base + EXYNOS_EMUL_CON);
	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	if (reg & EXYNOS_EMUL_ENABLE) {
		reg >>= EXYNOS_EMUL_DATA_SHIFT;
		temp_code = reg & EXYNOS_EMUL_DATA_MASK;
		temp = code_to_temp(data, temp_code);
	}
Example #3
0
static int exynos_tmu_read(struct exynos_tmu_data *data)
{
	u8 temp_code;
	int temp, i, max = INT_MIN, min = INT_MAX;
	int cold_event = 0;
	int hot_event = 0;
	enum tmu_noti_state_t cur_state;

	if (!th_zone || !th_zone->therm_dev)
		return -EPERM;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		temp = code_to_temp(data, temp_code, i);
		if (temp < 0)
			continue;

		if (temp > max)
			max = temp;
		if (temp < min)
			min = temp;
	}

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	/* check current tmu state */
	if (min <= COLD_TEMP && !old_cold)
		cold_event = 1;

	if (max >= HOT_CRITICAL_TEMP)
		cur_state = TMU_CRITICAL;
	else if (max > HOT_NORMAL_TEMP && max < HOT_CRITICAL_TEMP)
		cur_state = TMU_HOT;
	else if (max <= HOT_NORMAL_TEMP)
		cur_state = TMU_NORMAL;
	else
		cur_state = TMU_NORMAL;

	if (old_hot != cur_state)
		hot_event = cur_state;

	th_zone->therm_dev->last_temperature = max;

	exynos_tmu_call_notifier(cold_event, hot_event);

	return max;
}
Example #4
0
static int exynos_tmu_read(struct exynos_tmu_data *data)
{
	u8 temp_code;
	int temp;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	temp_code = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP);
	temp = code_to_temp(data, temp_code);

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	return temp;
}
Example #5
0
static int exynos4_tmu_read(void *tmu_data)
{
	struct exynos4_tmu_data *data = (struct exynos4_tmu_data*)tmu_data;
	u8 temp_code;
	int temp;

	mutex_lock(&data->lock);
	clk_enable(data->clk);
	
	temp_code = readb(data->base + EXYNOS4_TMU_REG_CURRENT_TEMP);
	temp = code_to_temp(data, temp_code);
	pr_debug("%s:.........temp %d\n", __func__, temp);
	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	return temp;
}
static int exynos_tmu_read(struct exynos_tmu_data *data)
{
	u8 temp_code;
	int temp, i;
	int cold_event = old_cold;
	int hot_event = old_hot;
	int alltemp[EXYNOS_TMU_COUNT] = {0,};

	if (!th_zone || !th_zone->therm_dev)
		return -EPERM;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		temp = code_to_temp(data, temp_code);
		alltemp[i] = temp;
	}

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	if (temp <= THRESH_MEM_TEMP0)
		cold_event = TMU_COLD;
	else
		cold_event = TMU_NORMAL;

	if (old_hot != TMU_THR_LV3 && temp >= THRESH_MEM_TEMP2)
		hot_event = TMU_THR_LV3;
	else if (old_hot != TMU_THR_LV2 && (temp >= THRESH_MEM_TEMP1 && temp < THRESH_MEM_TEMP2))
		hot_event = TMU_THR_LV2;
	else if (old_hot != TMU_THR_LV1 && (temp >= THRESH_MEM_TEMP0 && temp < THRESH_MEM_TEMP1))
		hot_event = TMU_THR_LV1;

	sec_debug_aux_log(SEC_DEBUG_AUXLOG_THERMAL_CHANGE, "[TMU] %d", temp);
	//printk("[TMU] %s : Thermal Read %d C", __func__, temp); Found it!
#ifdef CONFIG_EXYNOS4_EXPORT_TEMP
	tmu_curr_temperature = temp;
#endif
	th_zone->therm_dev->last_temperature = temp;
	exynos_tmu_call_notifier(cold_event, hot_event);
	sec_debug_aux_log(SEC_DEBUG_AUXLOG_THERMAL_CHANGE, "[TMU] alltemp[0]: %d", alltemp[0]);

	return temp;
}
Example #7
0
unsigned long exynos_thermal_get_value(void)
{
	struct exynos_tmu_data *data = th_zone->sensor_conf->private_data;
	u8 temp_code;
	unsigned long temp[EXYNOS_TMU_COUNT], max=0;
	int i = 0;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		if (temp_code == 0xff)
			continue;
		temp[i] = code_to_temp(data, temp_code, i);
		
		if(max < temp[i]) max = temp[i];
	}

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	return max;
}
Example #8
0
/* sysfs interface : /sys/devices/platform/exynos5-tmu/temp */
static ssize_t
exynos_thermal_sensor_temp(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct exynos_tmu_data *data = th_zone->sensor_conf->private_data;
	u8 temp_code;
	unsigned long temp[EXYNOS_TMU_COUNT];
	int i = 0;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		if (temp_code == 0xff)
			continue;
		temp[i] = code_to_temp(data, temp_code, i);
	}

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	return sprintf(&buf[0], "%ld %ld %ld %ld \n", temp[0],temp[1],temp[2],temp[3]);
}
/* sysfs interface : /sys/devices/platform/exynos5-tmu/curr_temp */
static ssize_t
exynos_thermal_curr_temp(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct exynos_tmu_data *data = th_zone->sensor_conf->private_data;
	unsigned long temp[EXYNOS_TMU_COUNT];
	int i, len = 0;

	if (!(soc_is_exynos5410() || soc_is_exynos5420() || soc_is_exynos5260()))
		return -EPERM;

	if (EXYNOS_TMU_COUNT < 4)
		return -EPERM;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		u8 temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		if (temp_code == 0xff)
			temp[i] = 0;
		else
			temp[i] = code_to_temp(data, temp_code, i) * 10;
	}

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

	len += sprintf(&buf[len], "%ld,", temp[0]);
	len += sprintf(&buf[len], "%ld,", temp[1]);
	len += sprintf(&buf[len], "%ld,", temp[2]);
	len += sprintf(&buf[len], "%ld,", temp[3]);
	len += sprintf(&buf[len], "%ld\n", temp[4]);

	return len;
}
static int exynos_tmu_read(struct exynos_tmu_data *data)
{
	u8 temp_code;
	int temp, i, max = INT_MIN, min = INT_MAX, gpu_temp = 0;

#ifdef CONFIG_ARM_EXYNOS5410_BUS_DEVFREQ
	enum tmu_noti_state_t cur_state;
#endif
	int alltemp[EXYNOS_TMU_COUNT] = {0,};

	if (!th_zone || !th_zone->therm_dev)
		return -EPERM;

	mutex_lock(&data->lock);
	clk_enable(data->clk);

	for (i = 0; i < EXYNOS_TMU_COUNT; i++) {
		temp_code = readb(data->base[i] + EXYNOS_TMU_REG_CURRENT_TEMP);
		temp = code_to_temp(data, temp_code, i);
		if (temp < 0)
			temp = 0;
		alltemp[i] = temp;

		if (temp > max)
			max = temp;
		if (temp < min)
			min = temp;
		if (soc_is_exynos5420() && i == EXYNOS_GPU_NUMBER)
			gpu_temp = temp;
	}
#ifdef CONFIG_SOC_EXYNOS5260
	if (alltemp[EXYNOS_GPU0_NUMBER] > alltemp[EXYNOS_GPU1_NUMBER])
		gpu_temp = alltemp[EXYNOS_GPU0_NUMBER];
	else
		gpu_temp = alltemp[EXYNOS_GPU1_NUMBER];
#endif

	clk_disable(data->clk);
	mutex_unlock(&data->lock);

#ifdef CONFIG_ARM_EXYNOS5410_BUS_DEVFREQ
	if (min <= COLD_TEMP)
		cur_state = TMU_COLD;

	if (max >= HOT_110)
		cur_state = TMU_110;
	else if (max > HOT_95 && max < HOT_110)
		cur_state = TMU_109;
	else if (max <= HOT_95)
		cur_state = TMU_95;

	if (cur_state >= HOT_95)
		pr_info("[TMU] POLLING: temp=%d, cpu=%d, int=%d, mif=%d, hot_event(for aref)=%d\n",
			max, g_cpufreq, g_intfreq, g_miffreq, cur_state);
	g_count++;

	/* to probe thermal run away caused by fimc-is */
	if ((max >= 112 && tmu_old_state == TMU_110)
			&& g_cam_err_count && g_intfreq == 800000) {
		cur_state = TMU_111;
	}
	exynos_tmu_call_notifier(cur_state);
#endif

	if (soc_is_exynos5420()) {
		/* check temperature state */
		exynos_check_tmu_noti_state(min, max);
		exynos_check_gpu_noti_state(gpu_temp);

#ifdef CONFIG_ARM_EXYNOS5420_BUS_DEVFREQ
		if (!check_mif_probed())
			goto out;
#endif
		exynos_check_mif_noti_state(max);
	}

	if (soc_is_exynos5260()) {
		exynos_check_tmu_noti_state(min, max);
		exynos_check_gpu_noti_state(gpu_temp);
		exynos_check_mif_noti_state(max);
	}

#ifdef CONFIG_ARM_EXYNOS5420_BUS_DEVFREQ
out:
#endif
	th_zone->therm_dev->last_temperature = max * MCELSIUS;
	DTM_DBG("[TMU] TMU0 = %d, TMU1 = %d, TMU2 = %d, TMU3 = %d, TMU4 = %d  -------  CPU : %d  ,  GPU : %d\n",
			alltemp[0], alltemp[1], alltemp[2], alltemp[3], alltemp[4], max, gpu_temp);

	return max;
}