hc
2023-12-09 958e46acc8e900e8569dd467c1af9b8d2d019394
kernel/include/soc/rockchip/rockchip_system_monitor.h
....@@ -6,9 +6,21 @@
66 #ifndef __SOC_ROCKCHIP_SYSTEM_MONITOR_H
77 #define __SOC_ROCKCHIP_SYSTEM_MONITOR_H
88
9
+#include <linux/pm_opp.h>
10
+#include <linux/pm_qos.h>
11
+#include <linux/regulator/consumer.h>
12
+
913 enum monitor_dev_type {
10
- MONITOR_TPYE_CPU = 0, /* CPU */
11
- MONITOR_TPYE_DEV, /* GPU, NPU, DMC, and so on */
14
+ MONITOR_TYPE_CPU = 0, /* CPU */
15
+ MONITOR_TYPE_DEV, /* GPU, NPU, DMC, and so on */
16
+};
17
+
18
+enum system_monitor_event_type {
19
+ SYSTEM_MONITOR_CHANGE_TEMP = 0,
20
+};
21
+
22
+struct system_monitor_event_data {
23
+ int temp;
1224 };
1325
1426 struct volt_adjust_table {
....@@ -26,31 +38,42 @@
2638 * struct temp_opp_table - System monitor device OPP description structure
2739 * @rate: Frequency in hertz
2840 * @volt: Target voltage in microvolt
41
+ * @mem_volt: Target voltage for memory in microvolt
2942 * @low_temp_volt: Target voltage when low temperature, in microvolt
43
+ * @low_temp_mem_volt: Target voltage for memory when low temperature,
44
+ * in microvolt
3045 * @max_volt: Maximum voltage in microvolt
46
+ * @max_mem_volt: Maximum voltage for memory in microvolt
3147 */
3248 struct temp_opp_table {
3349 unsigned long rate;
3450 unsigned long volt;
51
+ unsigned long mem_volt;
3552 unsigned long low_temp_volt;
53
+ unsigned long low_temp_mem_volt;
3654 unsigned long max_volt;
55
+ unsigned long max_mem_volt;
3756 };
3857
3958 /**
4059 * struct monitor_dev_info - structure for a system monitor device
4160 * @dev: Device registered by system monitor
42
- * @devfreq_nb: Notifier block used to notify devfreq object
43
- * that it should reevaluate operable frequencies
4461 * @low_temp_adjust_table: Voltage margin for different OPPs when lowe
4562 * temperature
4663 * @opp_table: Frequency and voltage information of device
4764 * @devp: Device-specific system monitor profile
4865 * @node: Node in monitor_dev_list
49
- * @temp_freq_table: Maximum frequency at different temperature and the
50
- * frequency will not be changed by thermal framework.
5166 * @high_limit_table: Limit maximum frequency at different temperature,
5267 * but the frequency is also changed by thermal framework.
5368 * @volt_adjust_mutex: A mutex to protect changing voltage.
69
+ * @max_temp_freq_req: CPU maximum frequency constraint changed according
70
+ * to temperature.
71
+ * @min_sta_freq_req: CPU minimum frequency constraint changed according
72
+ * to system status.
73
+ * @max_sta_freq_req: CPU maximum frequency constraint changed according
74
+ * to system status.
75
+ * @dev_max_freq_req: Devices maximum frequency constraint changed according
76
+ * to temperature.
5477 * @low_limit: Limit maximum frequency when low temperature, in Hz
5578 * @high_limit: Limit maximum frequency when high temperature, in Hz
5679 * @max_volt: Maximum voltage in microvolt
....@@ -63,8 +86,6 @@
6386 * @reboot_freq: Limit maximum and minimum frequency when reboot, in KHz
6487 * @status_min_limit: Minimum frequency of some status frequency, in KHz
6588 * @status_max_limit: Minimum frequency of all status frequency, in KHz
66
- * @freq_table: Optional list of frequencies in descending order
67
- * @max_state: The size of freq_table
6889 * @low_temp: Low temperature trip point, in millicelsius
6990 * @high_temp: High temperature trip point, in millicelsius
7091 * @temp_hysteresis: A low hysteresis value on low_temp, in millicelsius
....@@ -76,44 +97,53 @@
7697 */
7798 struct monitor_dev_info {
7899 struct device *dev;
79
- struct notifier_block devfreq_nb;
80100 struct volt_adjust_table *low_temp_adjust_table;
81101 struct temp_opp_table *opp_table;
82102 struct monitor_dev_profile *devp;
83103 struct list_head node;
84
- struct temp_freq_table *temp_freq_table;
85104 struct temp_freq_table *high_limit_table;
86105 struct mutex volt_adjust_mutex;
106
+ struct freq_qos_request max_temp_freq_req;
107
+ struct freq_qos_request min_sta_freq_req;
108
+ struct freq_qos_request max_sta_freq_req;
109
+ struct dev_pm_qos_request dev_max_freq_req;
110
+ struct regulator *early_reg;
111
+ struct regulator **regulators;
112
+ struct dev_pm_set_opp_data *set_opp_data;
113
+ struct clk *clk;
87114 unsigned long low_limit;
88115 unsigned long high_limit;
89116 unsigned long max_volt;
90117 unsigned long low_temp_min_volt;
91118 unsigned long high_temp_max_volt;
92
- unsigned long wide_temp_limit;
93119 unsigned int video_4k_freq;
94120 unsigned int reboot_freq;
121
+ unsigned int init_freq;
95122 unsigned int status_min_limit;
96123 unsigned int status_max_limit;
97
- unsigned long *freq_table;
98
- unsigned int max_state;
124
+ unsigned int early_min_volt;
125
+ unsigned int regulator_count;
99126 int low_temp;
100127 int high_temp;
101128 int temp_hysteresis;
102129 bool is_low_temp;
103130 bool is_high_temp;
104131 bool is_low_temp_enabled;
105
- bool is_status_freq_fixed;
106132 };
107133
108134 struct monitor_dev_profile {
109135 enum monitor_dev_type type;
110136 void *data;
137
+ bool is_checked;
111138 int (*low_temp_adjust)(struct monitor_dev_info *info, bool is_low);
112139 int (*high_temp_adjust)(struct monitor_dev_info *info, bool is_low);
140
+ int (*update_volt)(struct monitor_dev_info *info);
141
+ int (*set_opp)(struct dev_pm_set_opp_data *data);
113142 struct cpumask allowed_cpus;
143
+ struct rockchip_opp_info *opp_info;
114144 };
115145
116
-#if IS_ENABLED(CONFIG_ROCKCHIP_SYSTEM_MONITOR)
146
+#if IS_REACHABLE(CONFIG_ROCKCHIP_SYSTEM_MONITOR)
117147 struct monitor_dev_info *
118148 rockchip_system_monitor_register(struct device *dev,
119149 struct monitor_dev_profile *devp);
....@@ -122,16 +152,16 @@
122152 bool is_low);
123153 int rockchip_monitor_cpu_high_temp_adjust(struct monitor_dev_info *info,
124154 bool is_high);
155
+void rockchip_monitor_volt_adjust_lock(struct monitor_dev_info *info);
156
+void rockchip_monitor_volt_adjust_unlock(struct monitor_dev_info *info);
157
+int rockchip_monitor_check_rate_volt(struct monitor_dev_info *info);
125158 int rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info,
126159 bool is_low);
127160 int rockchip_monitor_dev_high_temp_adjust(struct monitor_dev_info *info,
128161 bool is_high);
129162 int rockchip_monitor_suspend_low_temp_adjust(int cpu);
130
-int
131
-rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev,
132
- int temp, unsigned long *state);
133
-int rockchip_monitor_opp_set_rate(struct monitor_dev_info *info,
134
- unsigned long target_freq);
163
+int rockchip_system_monitor_register_notifier(struct notifier_block *nb);
164
+void rockchip_system_monitor_unregister_notifier(struct notifier_block *nb);
135165 #else
136166 static inline struct monitor_dev_info *
137167 rockchip_system_monitor_register(struct device *dev,
....@@ -158,6 +188,22 @@
158188 return 0;
159189 };
160190
191
+static inline void
192
+rockchip_monitor_volt_adjust_lock(struct monitor_dev_info *info)
193
+{
194
+}
195
+
196
+static inline void
197
+rockchip_monitor_volt_adjust_unlock(struct monitor_dev_info *info)
198
+{
199
+}
200
+
201
+static inline int
202
+rockchip_monitor_check_rate_volt(struct monitor_dev_info *info)
203
+{
204
+ return 0;
205
+}
206
+
161207 static inline int
162208 rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info, bool is_low)
163209 {
....@@ -177,17 +223,15 @@
177223 };
178224
179225 static inline int
180
-rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev,
181
- int temp, unsigned long *state)
226
+rockchip_system_monitor_register_notifier(struct notifier_block *nb)
182227 {
183228 return 0;
184
-}
229
+};
185230
186
-static inline int rockchip_monitor_opp_set_rate(struct monitor_dev_info *info,
187
- unsigned long target_freq)
231
+static inline void
232
+rockchip_system_monitor_unregister_notifier(struct notifier_block *nb)
188233 {
189
- return 0;
190
-}
234
+};
191235 #endif /* CONFIG_ROCKCHIP_SYSTEM_MONITOR */
192236
193237 #endif