int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf) { int ret; if (!sensor_conf) { pr_err("Temperature sensor not initialised\n"); return -EINVAL; } th_zone = kzalloc(sizeof(struct exynos4_thermal_zone), GFP_KERNEL); if (!th_zone) { ret = -ENOMEM; goto err_unregister; } th_zone->sensor_conf = sensor_conf; th_zone->sensor_data = sensor_conf->sensor_data; if (!th_zone->sensor_data) { pr_err("Temperature sensor data not initialised\n"); ret = -EINVAL; goto err_unregister; } th_zone->cool_dev = cpufreq_cooling_register( (struct freq_pctg_table *)th_zone->sensor_data->freq_tab, th_zone->sensor_data->freq_tab_count, cpumask_of(0)); if (IS_ERR(th_zone->cool_dev)) { pr_err("Failed to register cpufreq cooling device\n"); ret = -EINVAL; goto err_unregister; } th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, 4, NULL, &exynos4_dev_ops, 0, 0, 0, 1000); if (IS_ERR(th_zone->therm_dev)) { pr_err("Failed to register thermal zone device\n"); ret = -EINVAL; goto err_unregister; } th_zone->active_interval = 5; th_zone->idle_interval = 10; exynos4_set_mode(th_zone->therm_dev, THERMAL_DEVICE_DISABLED); pr_info("Exynos: Kernel Thermal management registered\n"); return 0; err_unregister: exynos4_unregister_thermal(); return ret; }
/* Register with the in-kernel thermal management */ static int exynos4_register_thermal(struct thermal_sensor_conf *sensor_conf) { int ret, count, tab_size; struct freq_clip_table *tab_ptr; if (!sensor_conf || !sensor_conf->read_temperature) { pr_err("Temperature sensor not initialised\n"); return -EINVAL; } th_zone = kzalloc(sizeof(struct exynos4_thermal_zone), GFP_KERNEL); if (!th_zone) { ret = -ENOMEM; goto err_unregister; } th_zone->sensor_conf = sensor_conf; tab_ptr = (struct freq_clip_table *)sensor_conf->cooling_data.freq_data; tab_size = sensor_conf->cooling_data.freq_clip_count; /* Register the cpufreq cooling device */ th_zone->cool_dev_size = 1; count = 0; th_zone->cool_dev[count] = cpufreq_cooling_register( (struct freq_clip_table *)&(tab_ptr[count]), tab_size, cpumask_of(0), THERMAL_TRIP_STATE_INSTANCE); if (IS_ERR(th_zone->cool_dev[count])) { pr_err("Failed to register cpufreq cooling device\n"); ret = -EINVAL; th_zone->cool_dev_size = 0; goto err_unregister; } th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, 3, NULL, &exynos4_dev_ops, 0, 0, 0, IDLE_INTERVAL); if (IS_ERR(th_zone->therm_dev)) { pr_err("Failed to register thermal zone device\n"); ret = -EINVAL; goto err_unregister; } th_zone->mode = THERMAL_DEVICE_ENABLED; pr_info("Exynos: Kernel Thermal management registered\n"); return 0; err_unregister: exynos4_unregister_thermal(); return ret; }
static int __devexit exynos4_tmu_remove(struct platform_device *pdev) { struct exynos4_tmu_data *data = platform_get_drvdata(pdev); exynos4_tmu_control(pdev, false); exynos4_unregister_thermal(); clk_put(data->clk); free_irq(data->irq, data); iounmap(data->base); release_mem_region(data->mem->start, resource_size(data->mem)); platform_set_drvdata(pdev, NULL); kfree(data); return 0; }