forked from mirrors/linux
		
	Thermal: exynos: fix cooling state translation
Signed-off-by: Zhang Rui <rui.zhang@intel.com> Tested-by: Amit Daniel kachhap <amit.daniel@samsung.com>
This commit is contained in:
		
							parent
							
								
									fc35b35cbe
								
							
						
					
					
						commit
						57df810693
					
				
					 4 changed files with 24 additions and 23 deletions
				
			
		|  | @ -196,6 +196,17 @@ static int get_property(unsigned int cpu, unsigned long input, | ||||||
| 	return -EINVAL; | 	return -EINVAL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) | ||||||
|  | { | ||||||
|  | 	unsigned int val; | ||||||
|  | 
 | ||||||
|  | 	if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) | ||||||
|  | 		return THERMAL_CSTATE_INVALID; | ||||||
|  | 	return (unsigned long)val; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | EXPORT_SYMBOL(cpufreq_cooling_get_level); | ||||||
|  | 
 | ||||||
| /**
 | /**
 | ||||||
|  * get_cpu_frequency - get the absolute value of frequency from level. |  * get_cpu_frequency - get the absolute value of frequency from level. | ||||||
|  * @cpu: cpu for which frequency is fetched. |  * @cpu: cpu for which frequency is fetched. | ||||||
|  |  | ||||||
|  | @ -242,26 +242,6 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal, | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq) |  | ||||||
| { |  | ||||||
| 	int i = 0, ret = -EINVAL; |  | ||||||
| 	struct cpufreq_frequency_table *table = NULL; |  | ||||||
| #ifdef CONFIG_CPU_FREQ |  | ||||||
| 	table = cpufreq_frequency_get_table(cpu); |  | ||||||
| #endif |  | ||||||
| 	if (!table) |  | ||||||
| 		return ret; |  | ||||||
| 
 |  | ||||||
| 	while (table[i].frequency != CPUFREQ_TABLE_END) { |  | ||||||
| 		if (table[i].frequency == CPUFREQ_ENTRY_INVALID) |  | ||||||
| 			continue; |  | ||||||
| 		if (table[i].frequency == freq) |  | ||||||
| 			return i; |  | ||||||
| 		i++; |  | ||||||
| 	} |  | ||||||
| 	return ret; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /* Bind callback functions for thermal zone */ | /* Bind callback functions for thermal zone */ | ||||||
| static int exynos_bind(struct thermal_zone_device *thermal, | static int exynos_bind(struct thermal_zone_device *thermal, | ||||||
| 			struct thermal_cooling_device *cdev) | 			struct thermal_cooling_device *cdev) | ||||||
|  | @ -288,8 +268,8 @@ static int exynos_bind(struct thermal_zone_device *thermal, | ||||||
| 	/* Bind the thermal zone to the cpufreq cooling device */ | 	/* Bind the thermal zone to the cpufreq cooling device */ | ||||||
| 	for (i = 0; i < tab_size; i++) { | 	for (i = 0; i < tab_size; i++) { | ||||||
| 		clip_data = (struct freq_clip_table *)&(tab_ptr[i]); | 		clip_data = (struct freq_clip_table *)&(tab_ptr[i]); | ||||||
| 		level = exynos_get_frequency_level(0, clip_data->freq_clip_max); | 		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max); | ||||||
| 		if (level < 0) | 		if (level == THERMAL_CSTATE_INVALID) | ||||||
| 			return 0; | 			return 0; | ||||||
| 		switch (GET_ZONE(i)) { | 		switch (GET_ZONE(i)) { | ||||||
| 		case MONITOR_ZONE: | 		case MONITOR_ZONE: | ||||||
|  |  | ||||||
|  | @ -42,6 +42,8 @@ struct thermal_cooling_device *cpufreq_cooling_register( | ||||||
|  * @cdev: thermal cooling device pointer. |  * @cdev: thermal cooling device pointer. | ||||||
|  */ |  */ | ||||||
| void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); | ||||||
|  | 
 | ||||||
|  | unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); | ||||||
| #else /* !CONFIG_CPU_THERMAL */ | #else /* !CONFIG_CPU_THERMAL */ | ||||||
| static inline struct thermal_cooling_device *cpufreq_cooling_register( | static inline struct thermal_cooling_device *cpufreq_cooling_register( | ||||||
| 	const struct cpumask *clip_cpus) | 	const struct cpumask *clip_cpus) | ||||||
|  | @ -53,6 +55,11 @@ static inline void cpufreq_cooling_unregister( | ||||||
| { | { | ||||||
| 	return; | 	return; | ||||||
| } | } | ||||||
|  | static inline unsigned long cpufreq_cooling_get_level(unsigned int, | ||||||
|  | 						 unsigned int) | ||||||
|  | { | ||||||
|  | 	return THERMAL_CSTATE_INVALID; | ||||||
|  | } | ||||||
| #endif	/* CONFIG_CPU_THERMAL */ | #endif	/* CONFIG_CPU_THERMAL */ | ||||||
| 
 | 
 | ||||||
| #endif /* __CPU_COOLING_H__ */ | #endif /* __CPU_COOLING_H__ */ | ||||||
|  |  | ||||||
|  | @ -33,8 +33,11 @@ | ||||||
| #define THERMAL_MAX_TRIPS	12 | #define THERMAL_MAX_TRIPS	12 | ||||||
| #define THERMAL_NAME_LENGTH	20 | #define THERMAL_NAME_LENGTH	20 | ||||||
| 
 | 
 | ||||||
|  | /* invalid cooling state */ | ||||||
|  | #define THERMAL_CSTATE_INVALID -1UL | ||||||
|  | 
 | ||||||
| /* No upper/lower limit requirement */ | /* No upper/lower limit requirement */ | ||||||
| #define THERMAL_NO_LIMIT	-1UL | #define THERMAL_NO_LIMIT	THERMAL_CSTATE_INVALID | ||||||
| 
 | 
 | ||||||
| /* Unit conversion macros */ | /* Unit conversion macros */ | ||||||
| #define KELVIN_TO_CELSIUS(t)	(long)(((long)t-2732 >= 0) ?	\ | #define KELVIN_TO_CELSIUS(t)	(long)(((long)t-2732 >= 0) ?	\ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Zhang Rui
						Zhang Rui