mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
thermal: core: Import Xiaomi board_sensor and thermal message changes
Change-Id: Ia19f1ed5fd5d9c0e71dc6f8bef53f6e7757a678f Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
parent
01054d5c60
commit
9e53ddbe20
@ -68,6 +68,8 @@ struct screen_monitor sm;
|
||||
static atomic_t switch_mode = ATOMIC_INIT(-1);
|
||||
static atomic_t temp_state = ATOMIC_INIT(0);
|
||||
static char boost_buf[128];
|
||||
const char *board_sensor;
|
||||
static char board_sensor_temp[128];
|
||||
|
||||
static atomic_t in_suspend;
|
||||
static bool power_off_triggered;
|
||||
@ -1745,6 +1747,38 @@ cpu_limits_store(struct device *dev,
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
thermal_board_sensor_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
if (!board_sensor)
|
||||
board_sensor = "invalid";
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%s", board_sensor);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(board_sensor, 0664,
|
||||
thermal_board_sensor_show, NULL);
|
||||
|
||||
static ssize_t
|
||||
thermal_board_sensor_temp_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return snprintf(buf, PAGE_SIZE, board_sensor_temp);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
thermal_board_sensor_temp_store(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t len)
|
||||
{
|
||||
snprintf(board_sensor_temp, PAGE_SIZE, buf);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(board_sensor_temp, 0664,
|
||||
thermal_board_sensor_temp_show, thermal_board_sensor_temp_store);
|
||||
|
||||
static DEVICE_ATTR(cpu_limits, 0664,
|
||||
cpu_limits_show, cpu_limits_store);
|
||||
|
||||
@ -1777,6 +1811,13 @@ static int create_thermal_message_node(void)
|
||||
ret = sysfs_create_file(&thermal_message_dev.kobj, &dev_attr_cpu_limits.attr);
|
||||
if (ret < 0)
|
||||
pr_warn("Thermal: create cpu limits node failed\n");
|
||||
ret = sysfs_create_file(&thermal_message_dev.kobj, &dev_attr_board_sensor.attr);
|
||||
if (ret < 0)
|
||||
pr_warn("Thermal: create board sensor node failed\n");
|
||||
|
||||
ret = sysfs_create_file(&thermal_message_dev.kobj, &dev_attr_board_sensor_temp.attr);
|
||||
if (ret < 0)
|
||||
pr_warn("Thermal: create board sensor temp node failed\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -1788,6 +1829,8 @@ static void destroy_thermal_message_node(void)
|
||||
sysfs_remove_file(&thermal_message_dev.kobj, &dev_attr_temp_state.attr);
|
||||
sysfs_remove_file(&thermal_message_dev.kobj, &dev_attr_boost.attr);
|
||||
sysfs_remove_file(&thermal_message_dev.kobj, &dev_attr_sconfig.attr);
|
||||
sysfs_remove_file(&thermal_message_dev.kobj, &dev_attr_board_sensor_temp.attr);
|
||||
sysfs_remove_file(&thermal_message_dev.kobj, &dev_attr_board_sensor.attr);
|
||||
#ifdef CONFIG_DRM
|
||||
sysfs_remove_file(&thermal_message_dev.kobj, &dev_attr_screen_state.attr);
|
||||
#endif
|
||||
@ -1827,6 +1870,23 @@ static int screen_state_for_thermal_callback(struct notifier_block *nb, unsigned
|
||||
}
|
||||
#endif
|
||||
|
||||
static int of_parse_thermal_message(void)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
||||
np = of_find_node_by_name(NULL, "thermal-message");
|
||||
if (!np)
|
||||
return -EINVAL;
|
||||
|
||||
if (of_property_read_string(np, "board-sensor", &board_sensor))
|
||||
return -EINVAL;
|
||||
|
||||
pr_info("%s board sensor: %s\n", board_sensor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int __init thermal_init(void)
|
||||
{
|
||||
int result;
|
||||
@ -1862,6 +1922,10 @@ static int __init thermal_init(void)
|
||||
if (result)
|
||||
pr_warn("Thermal: create thermal message node failed, return %d\n",
|
||||
result);
|
||||
result = of_parse_thermal_message();
|
||||
if (result)
|
||||
pr_warn("Thermal: Can not parse thermal message node, return %d\n",
|
||||
result);
|
||||
|
||||
#ifdef CONFIG_DRM
|
||||
sm.thermal_notifier.notifier_call = screen_state_for_thermal_callback;
|
||||
|
Loading…
x
Reference in New Issue
Block a user