summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFinley Xiao <finley.xiao@rock-chips.com>2019-03-17 19:31:42 +0800
committerTao Huang <huangtao@rock-chips.com>2019-04-22 14:42:12 +0800
commit53a75585c77d701fad089b44fa72aa6c00fc7639 (patch)
treeeb9c6483261623ac8b01985d00d714110cac5a9f /include
parentaa063641aa5a30586fe989069d11f86f46b4ae28 (diff)
soc: rockchip: system_monitor: Add wide-temperature control
Change-Id: I5c1f502f8602c011a9bb26e7e0425e60728f1b66 Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Diffstat (limited to 'include')
-rw-r--r--include/soc/rockchip/rockchip_system_monitor.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/soc/rockchip/rockchip_system_monitor.h b/include/soc/rockchip/rockchip_system_monitor.h
new file mode 100644
index 000000000000..4a5f1dbe9e53
--- /dev/null
+++ b/include/soc/rockchip/rockchip_system_monitor.h
@@ -0,0 +1,102 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+/*
+ * Copyright (C) 2019, Fuzhou Rockchip Electronics Co., Ltd
+ */
+
+#ifndef __SOC_ROCKCHIP_SYSTEM_MONITOR_H
+#define __SOC_ROCKCHIP_SYSTEM_MONITOR_H
+
+enum monitor_dev_type {
+ MONITOR_TPYE_CPU = 0, /* CPU */
+ MONITOR_TPYE_DEV, /* GPU, NPU, DMC, and so on */
+};
+
+struct volt_adjust_table {
+ unsigned int min; /* Minimum frequency in MHz */
+ unsigned int max; /* Maximum frequency in MHz */
+ int volt; /* Voltage in microvolt */
+};
+
+/**
+ * struct temp_opp_table - System monitor device OPP description structure
+ * @rate: Frequency in hertz
+ * @volt: Target voltage in microvolt
+ * @low_temp_volt: Target voltage when low temperature, in microvolt
+ * @max_volt: Maximum voltage in microvolt
+ */
+struct temp_opp_table {
+ unsigned long rate;
+ unsigned long volt;
+ unsigned long low_temp_volt;
+ unsigned long max_volt;
+};
+
+/**
+ * struct monitor_dev_info - structure for a system monitor device
+ * @dev: Device registered by system monitor
+ * @devfreq_nb: Notifier block used to notify devfreq object
+ * that it should reevaluate operable frequencies
+ * @low_temp_adjust_table: Voltage margin for different OPPs when lowe
+ * temperature
+ * @opp_table: Frequency and voltage information of device
+ * @devp: Device-specific system monitor profile
+ * @node: Node in monitor_dev_list
+ * @low_limit: Limit maximum frequency when low temperature, in Hz
+ * @high_limit: Limit maximum frequency when high temperature, in Hz
+ * @max_volt: Maximum voltage in microvolt
+ * @low_temp_min_volt: Minimum voltage of OPPs when low temperature, in
+ * microvolt
+ * @high_temp_max_volt: Maximum voltage when high temperature, in microvolt
+ * @wide_temp_limit: Target maximum frequency when low or high temperature,
+ * in Hz
+ * @low_temp: Low temperature trip point, in millicelsius
+ * @high_temp: High temperature trip point, in millicelsius
+ * @temp_hysteresis: A low hysteresis value on low_temp, in millicelsius
+ * @is_low_temp: True if current temperature less than low_temp
+ * @is_high_temp: True if current temperature greater than high_temp
+ * @is_low_temp_enabled: True if device node contains low temperature
+ * configuration
+ */
+struct monitor_dev_info {
+ struct device *dev;
+ struct notifier_block devfreq_nb;
+ struct volt_adjust_table *low_temp_adjust_table;
+ struct temp_opp_table *opp_table;
+ struct monitor_dev_profile *devp;
+ struct list_head node;
+ unsigned long low_limit;
+ unsigned long high_limit;
+ unsigned long max_volt;
+ unsigned long low_temp_min_volt;
+ unsigned long high_temp_max_volt;
+ unsigned long wide_temp_limit;
+ int low_temp;
+ int high_temp;
+ int temp_hysteresis;
+ bool is_low_temp;
+ bool is_high_temp;
+ bool is_low_temp_enabled;
+};
+
+struct monitor_dev_profile {
+ enum monitor_dev_type type;
+ void *data;
+ int (*low_temp_adjust)(struct monitor_dev_info *info, bool is_low);
+ int (*high_temp_adjust)(struct monitor_dev_info *info, bool is_low);
+ struct cpumask allowed_cpus;
+};
+
+struct monitor_dev_info *
+rockchip_system_monitor_register(struct device *dev,
+ struct monitor_dev_profile *devp);
+void rockchip_system_monitor_unregister(struct monitor_dev_info *info);
+int rockchip_monitor_cpu_low_temp_adjust(struct monitor_dev_info *info,
+ bool is_low);
+int rockchip_monitor_cpu_high_temp_adjust(struct monitor_dev_info *info,
+ bool is_high);
+int rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info,
+ bool is_low);
+int rockchip_monitor_dev_high_temp_adjust(struct monitor_dev_info *info,
+ bool is_high);
+int rockchip_monitor_suspend_low_temp_adjust(struct monitor_dev_info *info);
+#endif