#include "thermal_core.h"
-#if defined(CONFIG_ECT)
-#include <soc/samsung/ect_parser.h>
-#include "samsung/exynos_tmu.h"
-#endif
-
/*** DT thermal zone device callbacks ***/
static int of_thermal_get_temp(struct thermal_zone_device *tz,
struct device_node *np, *child, *sensor_np;
struct thermal_zone_device *tzd = ERR_PTR(-ENODEV);
-#if defined(CONFIG_ECT)
- struct thermal_instance *instance;
- struct __thermal_zone *__tz;
- void *thermal_block;
- struct ect_ap_thermal_function *function;
- int i = 0, zone = 0;
- struct exynos_tmu_data *tmu_data;
- int hotplug_threshold_temp = 0, hotplug_flag = 0;
- unsigned int freq;
- unsigned long level = THERMAL_CSTATE_INVALID;
- unsigned long max_level = THERMAL_CSTATE_INVALID;
- int temperature;
-#endif
-
np = of_find_node_by_name(NULL, "thermal-zones");
if (!np)
return ERR_PTR(-ENODEV);
if (sensor_specs.np == sensor_np && id == sensor_id) {
tzd = thermal_zone_of_add_sensor(child, sensor_np,
data, ops);
-#if defined(CONFIG_ECT)
- __tz = tzd->devdata;
- tmu_data = (struct exynos_tmu_data *)data;
-
- thermal_block = ect_get_block(BLOCK_AP_THERMAL);
- if (thermal_block == NULL) {
- dev_err(dev, "Failed to get thermal block");
- goto ect_exit;
- }
-
- pr_info("%s %d thermal zone_name = %s \n", __func__, __LINE__, tzd->type);
- function = ect_ap_thermal_get_function(thermal_block, tzd->type);
- if (function == NULL) {
- dev_err(dev, "Failed to get thermal block %s", tzd->type);
- goto ect_exit;
- }
-
- __tz->ntrips = __tz->num_tbps = function->num_of_range;
- dev_info(dev, "Trip count parsed from ECT : %d, zone : %s", function->num_of_range, tzd->type);
-
- /* Find thermal zone number with thermal zone name defined in DT */
- for (zone = 0; zone < ARRAY_SIZE(tz_zone_names); zone++)
- if (!strcasecmp(tzd->type, tz_zone_names[zone]))
- break;
-
- if (zone == ARRAY_SIZE(tz_zone_names))
- dev_err(dev, "Error!!! Thermal zone name isn't matched!!\n");
-
- instance = list_first_entry(&tzd->thermal_instances, typeof(*instance), tz_node);
-
- for (i = 0; i < function->num_of_range && instance != NULL; ++i) {
- temperature = function->range_list[i].lower_bound_temperature;
- freq = function->range_list[i].max_frequency;
-
- switch (zone) {
- case MNGS_QUAD :
- case MNGS_DUAL :
- case BIG :
- level = cpufreq_cooling_get_level(4, freq);
- break;
- case APOLLO :
- case LITTLE :
- level = cpufreq_cooling_get_level(0, freq);
- break;
- case GPU :
- level = gpufreq_cooling_get_level(0, freq);
- break;
- case ISP :
- level = isp_cooling_get_level(0, freq);
- break;
- default :
- level = 0;
- break;
- }
-
- instance->cdev->ops->get_max_state(instance->cdev, &max_level);
-
- if ((zone == ARRAY_SIZE(tz_zone_names) && level == 0) || level == THERMAL_CSTATE_INVALID)
- level = max_level;
-
- if (level > 100) {
- dev_err(dev, "Level is invalid!!! freq = %u, level = %lu, max_level=%lu\n",
- freq, level, max_level);
- level = 0;
- }
-
- /* Change 'trips' and 'tbps' data with ECT data instead of DT data */
- __tz->trips[i].temperature = temperature * MCELSIUS;
- __tz->tbps[i].max = level;
-
- /* Change thermal instance information with tbps data */
- instance->upper = __tz->tbps[i].max;
- instance = list_next_entry(instance, tz_node);
- pr_info("Parsed From ECT : [%d] Temperature : %d, frequency : %u, level = %lu\n",
- i, temperature, freq, __tz->tbps[i].max);
-
- if (function->range_list[i].flag != hotplug_flag) {
- hotplug_threshold_temp = temperature;
- hotplug_flag = function->range_list[i].flag;
- tmu_data->hotplug_out_threshold = temperature;
-
- if (i)
- tmu_data->hotplug_in_threshold = function->range_list[i-1].lower_bound_temperature;
-
- pr_info("[ECT]hotplug_threshold : %d \n", hotplug_threshold_temp);
- pr_info("[ECT]hotplug_in_threshold : %d \n", tmu_data->hotplug_in_threshold);
- pr_info("[ECT]hotplug_out_threshold : %d \n", tmu_data->hotplug_out_threshold);
- }
- }
-
- if (hotplug_threshold_temp != 0)
- tmu_data->hotplug_enable = true;
- else
- tmu_data->hotplug_enable = false;
-#endif
-ect_exit:
of_node_put(sensor_specs.np);
of_node_put(child);
goto exit;