db8500_thermal.c (75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37) | db8500_thermal.c (cb063a83ca321fbf0cb2b4044186f241d89f3dc1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * db8500_thermal.c - DB8500 Thermal Management Implementation 4 * 5 * Copyright (C) 2012 ST-Ericsson 6 * Copyright (C) 2012 Linaro Ltd. 7 * 8 * Author: Hongbo Zhang <hongbo.zhang@linaro.com> 9 */ 10 11#include <linux/cpu_cooling.h> 12#include <linux/interrupt.h> 13#include <linux/mfd/dbx500-prcmu.h> 14#include <linux/module.h> 15#include <linux/of.h> | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * db8500_thermal.c - DB8500 Thermal Management Implementation 4 * 5 * Copyright (C) 2012 ST-Ericsson 6 * Copyright (C) 2012 Linaro Ltd. 7 * 8 * Author: Hongbo Zhang <hongbo.zhang@linaro.com> 9 */ 10 11#include <linux/cpu_cooling.h> 12#include <linux/interrupt.h> 13#include <linux/mfd/dbx500-prcmu.h> 14#include <linux/module.h> 15#include <linux/of.h> |
16#include <linux/platform_data/db8500_thermal.h> | |
17#include <linux/platform_device.h> 18#include <linux/slab.h> 19#include <linux/thermal.h> 20 21#define PRCMU_DEFAULT_MEASURE_TIME 0xFFF 22#define PRCMU_DEFAULT_LOW_TEMP 0 | 16#include <linux/platform_device.h> 17#include <linux/slab.h> 18#include <linux/thermal.h> 19 20#define PRCMU_DEFAULT_MEASURE_TIME 0xFFF 21#define PRCMU_DEFAULT_LOW_TEMP 0 |
22#define COOLING_DEV_MAX 8 |
|
23 | 23 |
24struct db8500_trip_point { 25 unsigned long temp; 26 enum thermal_trip_type type; 27 char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH]; 28}; 29 30struct db8500_thsens_platform_data { 31 struct db8500_trip_point trip_points[THERMAL_MAX_TRIPS]; 32 int num_trips; 33}; 34 |
|
24struct db8500_thermal_zone { 25 struct thermal_zone_device *therm_dev; 26 struct mutex th_lock; 27 struct work_struct therm_work; 28 struct db8500_thsens_platform_data *trip_tab; 29 enum thermal_device_mode mode; 30 enum thermal_trend trend; 31 unsigned long cur_temp_pseudo; --- 264 unchanged lines hidden (view full) --- 296 297 if (cur_mode == THERMAL_DEVICE_DISABLED) 298 return; 299 300 thermal_zone_device_update(pzone->therm_dev, THERMAL_EVENT_UNSPECIFIED); 301 dev_dbg(&pzone->therm_dev->device, "thermal work finished.\n"); 302} 303 | 35struct db8500_thermal_zone { 36 struct thermal_zone_device *therm_dev; 37 struct mutex th_lock; 38 struct work_struct therm_work; 39 struct db8500_thsens_platform_data *trip_tab; 40 enum thermal_device_mode mode; 41 enum thermal_trend trend; 42 unsigned long cur_temp_pseudo; --- 264 unchanged lines hidden (view full) --- 307 308 if (cur_mode == THERMAL_DEVICE_DISABLED) 309 return; 310 311 thermal_zone_device_update(pzone->therm_dev, THERMAL_EVENT_UNSPECIFIED); 312 dev_dbg(&pzone->therm_dev->device, "thermal work finished.\n"); 313} 314 |
304#ifdef CONFIG_OF | |
305static struct db8500_thsens_platform_data* 306 db8500_thermal_parse_dt(struct platform_device *pdev) 307{ 308 struct db8500_thsens_platform_data *ptrips; 309 struct device_node *np = pdev->dev.of_node; 310 char prop_name[32]; 311 const char *tmp_str; 312 u32 tmp_data; --- 52 unchanged lines hidden (view full) --- 365 } 366 } 367 return ptrips; 368 369err_parse_dt: 370 dev_err(&pdev->dev, "Parsing device tree data error.\n"); 371 return NULL; 372} | 315static struct db8500_thsens_platform_data* 316 db8500_thermal_parse_dt(struct platform_device *pdev) 317{ 318 struct db8500_thsens_platform_data *ptrips; 319 struct device_node *np = pdev->dev.of_node; 320 char prop_name[32]; 321 const char *tmp_str; 322 u32 tmp_data; --- 52 unchanged lines hidden (view full) --- 375 } 376 } 377 return ptrips; 378 379err_parse_dt: 380 dev_err(&pdev->dev, "Parsing device tree data error.\n"); 381 return NULL; 382} |
373#else 374static inline struct db8500_thsens_platform_data* 375 db8500_thermal_parse_dt(struct platform_device *pdev) 376{ 377 return NULL; 378} 379#endif | |
380 381static int db8500_thermal_probe(struct platform_device *pdev) 382{ 383 struct db8500_thermal_zone *pzone = NULL; 384 struct db8500_thsens_platform_data *ptrips = NULL; 385 struct device_node *np = pdev->dev.of_node; 386 int low_irq, high_irq, ret = 0; 387 unsigned long dft_low, dft_high; 388 | 383 384static int db8500_thermal_probe(struct platform_device *pdev) 385{ 386 struct db8500_thermal_zone *pzone = NULL; 387 struct db8500_thsens_platform_data *ptrips = NULL; 388 struct device_node *np = pdev->dev.of_node; 389 int low_irq, high_irq, ret = 0; 390 unsigned long dft_low, dft_high; 391 |
389 if (np) 390 ptrips = db8500_thermal_parse_dt(pdev); 391 else 392 ptrips = dev_get_platdata(&pdev->dev); | 392 if (!np) 393 return -EINVAL; |
393 | 394 |
395 ptrips = db8500_thermal_parse_dt(pdev); |
|
394 if (!ptrips) 395 return -EINVAL; 396 397 pzone = devm_kzalloc(&pdev->dev, sizeof(*pzone), GFP_KERNEL); 398 if (!pzone) 399 return -ENOMEM; 400 401 mutex_init(&pzone->th_lock); --- 91 unchanged lines hidden (view full) --- 493 dft_high = ptrips->trip_points[0].temp; 494 495 db8500_thermal_update_config(pzone, 0, THERMAL_TREND_STABLE, 496 dft_low, dft_high); 497 498 return 0; 499} 500 | 396 if (!ptrips) 397 return -EINVAL; 398 399 pzone = devm_kzalloc(&pdev->dev, sizeof(*pzone), GFP_KERNEL); 400 if (!pzone) 401 return -ENOMEM; 402 403 mutex_init(&pzone->th_lock); --- 91 unchanged lines hidden (view full) --- 495 dft_high = ptrips->trip_points[0].temp; 496 497 db8500_thermal_update_config(pzone, 0, THERMAL_TREND_STABLE, 498 dft_low, dft_high); 499 500 return 0; 501} 502 |
501#ifdef CONFIG_OF | |
502static const struct of_device_id db8500_thermal_match[] = { 503 { .compatible = "stericsson,db8500-thermal" }, 504 {}, 505}; 506MODULE_DEVICE_TABLE(of, db8500_thermal_match); | 503static const struct of_device_id db8500_thermal_match[] = { 504 { .compatible = "stericsson,db8500-thermal" }, 505 {}, 506}; 507MODULE_DEVICE_TABLE(of, db8500_thermal_match); |
507#endif | |
508 509static struct platform_driver db8500_thermal_driver = { 510 .driver = { 511 .name = "db8500-thermal", 512 .of_match_table = of_match_ptr(db8500_thermal_match), 513 }, 514 .probe = db8500_thermal_probe, 515 .suspend = db8500_thermal_suspend, 516 .resume = db8500_thermal_resume, 517 .remove = db8500_thermal_remove, 518}; 519 520module_platform_driver(db8500_thermal_driver); 521 522MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>"); 523MODULE_DESCRIPTION("DB8500 thermal driver"); 524MODULE_LICENSE("GPL"); | 508 509static struct platform_driver db8500_thermal_driver = { 510 .driver = { 511 .name = "db8500-thermal", 512 .of_match_table = of_match_ptr(db8500_thermal_match), 513 }, 514 .probe = db8500_thermal_probe, 515 .suspend = db8500_thermal_suspend, 516 .resume = db8500_thermal_resume, 517 .remove = db8500_thermal_remove, 518}; 519 520module_platform_driver(db8500_thermal_driver); 521 522MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>"); 523MODULE_DESCRIPTION("DB8500 thermal driver"); 524MODULE_LICENSE("GPL"); |