aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2016-08-26 19:21:18 -0400
committerZhang Rui <rui.zhang@intel.com>2016-09-27 02:37:14 -0400
commit9176ae8668a005b5441604bd1b47eeec07c27d94 (patch)
tree562cd1a6eaadfe060f09bc16327d094b42dde405
parent998d924b712896c540c76c679fc7d53d6a880d5d (diff)
thermal: int340x: New Interface to read trip and notify
Separated the code for reading trip points from int340x_thermal_zone_add to a standalone function int340x_thermal_read_trips. This standlone interface to read is exported so that int340x drivers can re-read trips on ACPI notification for trip point change. Also the appropriate notification events are sent by int340x driver based on the acpi event using int340x_thermal_zone_device_update(). Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r--drivers/thermal/int340x_thermal/int3402_thermal.c3
-rw-r--r--drivers/thermal/int340x_thermal/int3403_thermal.c3
-rw-r--r--drivers/thermal/int340x_thermal/int340x_thermal_zone.c60
-rw-r--r--drivers/thermal/int340x_thermal/int340x_thermal_zone.h6
-rw-r--r--drivers/thermal/int340x_thermal/processor_thermal_device.c3
5 files changed, 48 insertions, 27 deletions
diff --git a/drivers/thermal/int340x_thermal/int3402_thermal.c b/drivers/thermal/int340x_thermal/int3402_thermal.c
index 69df3d960303..8e90b3151a42 100644
--- a/drivers/thermal/int340x_thermal/int3402_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3402_thermal.c
@@ -35,7 +35,8 @@ static void int3402_notify(acpi_handle handle, u32 event, void *data)
35 case INT3402_PERF_CHANGED_EVENT: 35 case INT3402_PERF_CHANGED_EVENT:
36 break; 36 break;
37 case INT3402_THERMAL_EVENT: 37 case INT3402_THERMAL_EVENT:
38 int340x_thermal_zone_device_update(priv->int340x_zone); 38 int340x_thermal_zone_device_update(priv->int340x_zone,
39 THERMAL_TRIP_VIOLATED);
39 break; 40 break;
40 default: 41 default:
41 break; 42 break;
diff --git a/drivers/thermal/int340x_thermal/int3403_thermal.c b/drivers/thermal/int340x_thermal/int3403_thermal.c
index 50a7a08e3a15..7643489f207c 100644
--- a/drivers/thermal/int340x_thermal/int3403_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3403_thermal.c
@@ -72,7 +72,8 @@ static void int3403_notify(acpi_handle handle,
72 case INT3403_PERF_CHANGED_EVENT: 72 case INT3403_PERF_CHANGED_EVENT:
73 break; 73 break;
74 case INT3403_THERMAL_EVENT: 74 case INT3403_THERMAL_EVENT:
75 int340x_thermal_zone_device_update(obj->int340x_zone); 75 int340x_thermal_zone_device_update(obj->int340x_zone,
76 THERMAL_TRIP_VIOLATED);
76 break; 77 break;
77 default: 78 default:
78 dev_err(&priv->pdev->dev, "Unsupported event [0x%x]\n", event); 79 dev_err(&priv->pdev->dev, "Unsupported event [0x%x]\n", event);
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
index b9b2666aa94c..145a5c53ff5c 100644
--- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
+++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
@@ -177,6 +177,42 @@ static int int340x_thermal_get_trip_config(acpi_handle handle, char *name,
177 return 0; 177 return 0;
178} 178}
179 179
180int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone)
181{
182 int trip_cnt = int34x_zone->aux_trip_nr;
183 int i;
184
185 int34x_zone->crt_trip_id = -1;
186 if (!int340x_thermal_get_trip_config(int34x_zone->adev->handle, "_CRT",
187 &int34x_zone->crt_temp))
188 int34x_zone->crt_trip_id = trip_cnt++;
189
190 int34x_zone->hot_trip_id = -1;
191 if (!int340x_thermal_get_trip_config(int34x_zone->adev->handle, "_HOT",
192 &int34x_zone->hot_temp))
193 int34x_zone->hot_trip_id = trip_cnt++;
194
195 int34x_zone->psv_trip_id = -1;
196 if (!int340x_thermal_get_trip_config(int34x_zone->adev->handle, "_PSV",
197 &int34x_zone->psv_temp))
198 int34x_zone->psv_trip_id = trip_cnt++;
199
200 for (i = 0; i < INT340X_THERMAL_MAX_ACT_TRIP_COUNT; i++) {
201 char name[5] = { '_', 'A', 'C', '0' + i, '\0' };
202
203 if (int340x_thermal_get_trip_config(int34x_zone->adev->handle,
204 name,
205 &int34x_zone->act_trips[i].temp))
206 break;
207
208 int34x_zone->act_trips[i].id = trip_cnt++;
209 int34x_zone->act_trips[i].valid = true;
210 }
211
212 return trip_cnt;
213}
214EXPORT_SYMBOL_GPL(int340x_thermal_read_trips);
215
180static struct thermal_zone_params int340x_thermal_params = { 216static struct thermal_zone_params int340x_thermal_params = {
181 .governor_name = "user_space", 217 .governor_name = "user_space",
182 .no_hwmon = true, 218 .no_hwmon = true,
@@ -188,7 +224,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
188 struct int34x_thermal_zone *int34x_thermal_zone; 224 struct int34x_thermal_zone *int34x_thermal_zone;
189 acpi_status status; 225 acpi_status status;
190 unsigned long long trip_cnt; 226 unsigned long long trip_cnt;
191 int trip_mask = 0, i; 227 int trip_mask = 0;
192 int ret; 228 int ret;
193 229
194 int34x_thermal_zone = kzalloc(sizeof(*int34x_thermal_zone), 230 int34x_thermal_zone = kzalloc(sizeof(*int34x_thermal_zone),
@@ -214,28 +250,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
214 int34x_thermal_zone->aux_trip_nr = trip_cnt; 250 int34x_thermal_zone->aux_trip_nr = trip_cnt;
215 } 251 }
216 252
217 int34x_thermal_zone->crt_trip_id = -1; 253 trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone);
218 if (!int340x_thermal_get_trip_config(adev->handle, "_CRT",
219 &int34x_thermal_zone->crt_temp))
220 int34x_thermal_zone->crt_trip_id = trip_cnt++;
221 int34x_thermal_zone->hot_trip_id = -1;
222 if (!int340x_thermal_get_trip_config(adev->handle, "_HOT",
223 &int34x_thermal_zone->hot_temp))
224 int34x_thermal_zone->hot_trip_id = trip_cnt++;
225 int34x_thermal_zone->psv_trip_id = -1;
226 if (!int340x_thermal_get_trip_config(adev->handle, "_PSV",
227 &int34x_thermal_zone->psv_temp))
228 int34x_thermal_zone->psv_trip_id = trip_cnt++;
229 for (i = 0; i < INT340X_THERMAL_MAX_ACT_TRIP_COUNT; i++) {
230 char name[5] = { '_', 'A', 'C', '0' + i, '\0' };
231 254
232 if (int340x_thermal_get_trip_config(adev->handle, name,
233 &int34x_thermal_zone->act_trips[i].temp))
234 break;
235
236 int34x_thermal_zone->act_trips[i].id = trip_cnt++;
237 int34x_thermal_zone->act_trips[i].valid = true;
238 }
239 int34x_thermal_zone->lpat_table = acpi_lpat_get_conversion_table( 255 int34x_thermal_zone->lpat_table = acpi_lpat_get_conversion_table(
240 adev->handle); 256 adev->handle);
241 257
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
index 65116b1f19f1..5f3ba4775c5c 100644
--- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
+++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
@@ -46,6 +46,7 @@ struct int34x_thermal_zone {
46struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *, 46struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,
47 struct thermal_zone_device_ops *override_ops); 47 struct thermal_zone_device_ops *override_ops);
48void int340x_thermal_zone_remove(struct int34x_thermal_zone *); 48void int340x_thermal_zone_remove(struct int34x_thermal_zone *);
49int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone);
49 50
50static inline void int340x_thermal_zone_set_priv_data( 51static inline void int340x_thermal_zone_set_priv_data(
51 struct int34x_thermal_zone *tzone, void *priv_data) 52 struct int34x_thermal_zone *tzone, void *priv_data)
@@ -60,9 +61,10 @@ static inline void *int340x_thermal_zone_get_priv_data(
60} 61}
61 62
62static inline void int340x_thermal_zone_device_update( 63static inline void int340x_thermal_zone_device_update(
63 struct int34x_thermal_zone *tzone) 64 struct int34x_thermal_zone *tzone,
65 enum thermal_notify_event event)
64{ 66{
65 thermal_zone_device_update(tzone->zone, THERMAL_EVENT_UNSPECIFIED); 67 thermal_zone_device_update(tzone->zone, event);
66} 68}
67 69
68#endif 70#endif
diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c b/drivers/thermal/int340x_thermal/processor_thermal_device.c
index 42c1ac057bad..ff3b36f339e3 100644
--- a/drivers/thermal/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -258,7 +258,8 @@ static void proc_thermal_notify(acpi_handle handle, u32 event, void *data)
258 switch (event) { 258 switch (event) {
259 case PROC_POWER_CAPABILITY_CHANGED: 259 case PROC_POWER_CAPABILITY_CHANGED:
260 proc_thermal_read_ppcc(proc_priv); 260 proc_thermal_read_ppcc(proc_priv);
261 int340x_thermal_zone_device_update(proc_priv->int340x_zone); 261 int340x_thermal_zone_device_update(proc_priv->int340x_zone,
262 THERMAL_DEVICE_POWER_CAPABILITY_CHANGED);
262 break; 263 break;
263 default: 264 default:
264 dev_err(proc_priv->dev, "Unsupported event [0x%x]\n", event); 265 dev_err(proc_priv->dev, "Unsupported event [0x%x]\n", event);