diff options
Diffstat (limited to 'arch/arm/mach-tegra/tegra3_thermal.c')
-rw-r--r-- | arch/arm/mach-tegra/tegra3_thermal.c | 97 |
1 files changed, 24 insertions, 73 deletions
diff --git a/arch/arm/mach-tegra/tegra3_thermal.c b/arch/arm/mach-tegra/tegra3_thermal.c index 8ad7bd5b670f..6322eb35ab79 100644 --- a/arch/arm/mach-tegra/tegra3_thermal.c +++ b/arch/arm/mach-tegra/tegra3_thermal.c @@ -37,15 +37,13 @@ struct tegra_thermal { struct tegra_thermal_device *device; - long temp_throttle_tj; long temp_shutdown_tj; -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + long temp_throttle_tj; struct thermal_zone_device *thz; int tc1; int tc2; long passive_delay; -#else - long temp_throttle_low_tj; #endif #ifdef CONFIG_TEGRA_EDP_LIMITS int edp_thermal_zone_val; @@ -62,10 +60,6 @@ static struct tegra_thermal thermal_state = { #endif }; -#ifndef CONFIG_TEGRA_THERMAL_SYSFS -static bool throttle_enb; -#endif - #ifdef CONFIG_TEGRA_EDP_LIMITS static inline long edp2tj(struct tegra_thermal *thermal, long edp_temp) @@ -92,7 +86,7 @@ static inline long tj2dev(struct tegra_thermal_device *dev, return tj_temp - dev->offset; } -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE static int tegra_thermal_zone_bind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdevice) { @@ -107,7 +101,7 @@ static int tegra_thermal_zone_unbind(struct thermal_zone_device *thermal, } static int tegra_thermal_zone_get_temp(struct thermal_zone_device *thz, - long *temp) + unsigned long *temp) { struct tegra_thermal *thermal = thz->devdata; thermal->device->get_temp(thermal->device->data, temp); @@ -130,8 +124,8 @@ static int tegra_thermal_zone_get_trip_type( } static int tegra_thermal_zone_get_trip_temp(struct thermal_zone_device *thz, - int trip, - long *temp) { + int trip, + unsigned long *temp) { struct tegra_thermal *thermal = thz->devdata; /* Support only Thermal Throttling (1 trip) for now */ @@ -152,20 +146,6 @@ static struct thermal_zone_device_ops tegra_thermal_zone_ops = { }; #endif -/* The thermal sysfs handles notifying the throttling - * cooling device */ -#ifndef CONFIG_TEGRA_THERMAL_SYSFS -static void tegra_therm_throttle(bool enable) -{ - if (throttle_enb != enable) { - mutex_lock(&thermal_state.mutex); - tegra_throttling_enable(enable); - throttle_enb = enable; - mutex_unlock(&thermal_state.mutex); - } -} -#endif - /* Make sure this function remains stateless */ void tegra_thermal_alert(void *data) { @@ -187,7 +167,7 @@ void tegra_thermal_alert(void *data) mutex_lock(&thermal_state.mutex); -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE if (thermal->thz) { if (!thermal->thz->passive) thermal_zone_device_update(thermal->thz); @@ -207,17 +187,11 @@ void tegra_thermal_alert(void *data) temp_low_tj = dev2tj(thermal->device, temp_low_dev); lo_limit_throttle_tj = temp_low_tj; + hi_limit_throttle_tj = thermal->temp_shutdown_tj; + +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE hi_limit_throttle_tj = thermal->temp_throttle_tj; -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - /* Check to see if we are currently throttling */ - if ((tegra_is_throttling() && - (temp_tj > thermal->temp_throttle_low_tj)) - || (temp_tj >= thermal->temp_throttle_tj)) { - lo_limit_throttle_tj = thermal->temp_throttle_low_tj; - hi_limit_throttle_tj = thermal->temp_shutdown_tj; - } -#else if (temp_tj > thermal->temp_throttle_tj) { lo_limit_throttle_tj = thermal->temp_throttle_tj; hi_limit_throttle_tj = thermal->temp_shutdown_tj; @@ -262,18 +236,6 @@ void tegra_thermal_alert(void *data) tj2dev(thermal->device, lo_limit_tj), tj2dev(thermal->device, hi_limit_tj)); -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - if (temp_tj >= thermal->temp_throttle_tj) { - /* start throttling */ - if (!tegra_is_throttling()) - tegra_therm_throttle(true); - } else if (temp_tj <= thermal->temp_throttle_low_tj) { - /* switch off throttling */ - if (tegra_is_throttling()) - tegra_therm_throttle(false); - } -#endif - #ifdef CONFIG_TEGRA_EDP_LIMITS /* inform edp governor */ if (thermal->edp_thermal_zone_val != temp_tj) @@ -288,7 +250,7 @@ done: int tegra_thermal_set_device(struct tegra_thermal_device *device) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE struct thermal_zone_device *thz; #endif @@ -298,7 +260,7 @@ int tegra_thermal_set_device(struct tegra_thermal_device *device) thermal_state.device = device; -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE thz = thermal_zone_device_register(thermal_state.device->name, 1, /* trips */ &thermal_state, @@ -330,22 +292,18 @@ int tegra_thermal_set_device(struct tegra_thermal_device *device) int __init tegra_thermal_init(struct tegra_thermal_data *data) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE thermal_state.tc1 = data->tc1; thermal_state.tc2 = data->tc2; thermal_state.passive_delay = data->passive_delay; -#else - thermal_state.temp_throttle_low_tj = data->temp_throttle + - data->temp_offset - - data->hysteresis_throttle; + thermal_state.temp_throttle_tj = data->temp_throttle + + data->temp_offset; #endif mutex_init(&thermal_state.mutex); #ifdef CONFIG_TEGRA_EDP_LIMITS thermal_state.edp_offset = data->edp_offset; thermal_state.hysteresis_edp = data->hysteresis_edp; #endif - thermal_state.temp_throttle_tj = data->temp_throttle + - data->temp_offset; thermal_state.temp_shutdown_tj = data->temp_shutdown + data->temp_offset; @@ -354,7 +312,7 @@ int __init tegra_thermal_init(struct tegra_thermal_data *data) int tegra_thermal_exit(void) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE if (thermal_state.thz) thermal_zone_device_unregister(thermal_state.thz); #endif @@ -364,19 +322,11 @@ int tegra_thermal_exit(void) #ifdef CONFIG_DEBUG_FS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE static int tegra_thermal_throttle_temp_tj_set(void *data, u64 val) { -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - long throttle_hysteresis = thermal_state.temp_throttle_tj - - thermal_state.temp_throttle_low_tj; -#endif - mutex_lock(&thermal_state.mutex); thermal_state.temp_throttle_tj = val; -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - thermal_state.temp_throttle_low_tj = thermal_state.temp_throttle_tj - - throttle_hysteresis; -#endif mutex_unlock(&thermal_state.mutex); tegra_thermal_alert(&thermal_state); @@ -394,6 +344,7 @@ DEFINE_SIMPLE_ATTRIBUTE(throttle_temp_tj_fops, tegra_thermal_throttle_temp_tj_get, tegra_thermal_throttle_temp_tj_set, "%llu\n"); +#endif static int tegra_thermal_shutdown_temp_tj_set(void *data, u64 val) { @@ -447,7 +398,7 @@ DEFINE_SIMPLE_ATTRIBUTE(temp_tj_fops, NULL, "%llu\n"); -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE static int tegra_thermal_tc1_set(void *data, u64 val) { thermal_state.thz->tc1 = val; @@ -507,10 +458,6 @@ static int __init tegra_thermal_debug_init(void) { thermal_debugfs_root = debugfs_create_dir("tegra_thermal", 0); - if (!debugfs_create_file("throttle_temp_tj", 0644, thermal_debugfs_root, - NULL, &throttle_temp_tj_fops)) - goto err_out; - if (!debugfs_create_file("shutdown_temp_tj", 0644, thermal_debugfs_root, NULL, &shutdown_temp_tj_fops)) goto err_out; @@ -519,7 +466,11 @@ static int __init tegra_thermal_debug_init(void) NULL, &temp_tj_fops)) goto err_out; -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + if (!debugfs_create_file("throttle_temp_tj", 0644, thermal_debugfs_root, + NULL, &throttle_temp_tj_fops)) + goto err_out; + if (!debugfs_create_file("tc1", 0644, thermal_debugfs_root, NULL, &tc1_fops)) goto err_out; |