@@ -36,33 +36,39 @@ enum mlxsw_thermal_trips {
36
36
MLXSW_THERMAL_TEMP_TRIP_HOT ,
37
37
};
38
38
39
- struct mlxsw_thermal_trip {
40
- int type ;
41
- int temp ;
42
- int hyst ;
39
+ struct mlxsw_cooling_states {
43
40
int min_state ;
44
41
int max_state ;
45
42
};
46
43
47
- static const struct mlxsw_thermal_trip default_thermal_trips [] = {
44
+ static const struct thermal_trip default_thermal_trips [] = {
48
45
{ /* In range - 0-40% PWM */
49
46
.type = THERMAL_TRIP_ACTIVE ,
50
- .temp = MLXSW_THERMAL_ASIC_TEMP_NORM ,
51
- .hyst = MLXSW_THERMAL_HYSTERESIS_TEMP ,
52
- .min_state = 0 ,
53
- .max_state = (4 * MLXSW_THERMAL_MAX_STATE ) / 10 ,
47
+ .temperature = MLXSW_THERMAL_ASIC_TEMP_NORM ,
48
+ .hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP ,
54
49
},
55
50
{
56
51
/* In range - 40-100% PWM */
57
52
.type = THERMAL_TRIP_ACTIVE ,
58
- .temp = MLXSW_THERMAL_ASIC_TEMP_HIGH ,
59
- .hyst = MLXSW_THERMAL_HYSTERESIS_TEMP ,
60
- .min_state = (4 * MLXSW_THERMAL_MAX_STATE ) / 10 ,
61
- .max_state = MLXSW_THERMAL_MAX_STATE ,
53
+ .temperature = MLXSW_THERMAL_ASIC_TEMP_HIGH ,
54
+ .hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP ,
62
55
},
63
56
{ /* Warning */
64
57
.type = THERMAL_TRIP_HOT ,
65
- .temp = MLXSW_THERMAL_ASIC_TEMP_HOT ,
58
+ .temperature = MLXSW_THERMAL_ASIC_TEMP_HOT ,
59
+ },
60
+ };
61
+
62
+ static const struct mlxsw_cooling_states default_cooling_states [] = {
63
+ {
64
+ .min_state = 0 ,
65
+ .max_state = (4 * MLXSW_THERMAL_MAX_STATE ) / 10 ,
66
+ },
67
+ {
68
+ .min_state = (4 * MLXSW_THERMAL_MAX_STATE ) / 10 ,
69
+ .max_state = MLXSW_THERMAL_MAX_STATE ,
70
+ },
71
+ {
66
72
.min_state = MLXSW_THERMAL_MAX_STATE ,
67
73
.max_state = MLXSW_THERMAL_MAX_STATE ,
68
74
},
@@ -78,7 +84,8 @@ struct mlxsw_thermal;
78
84
struct mlxsw_thermal_module {
79
85
struct mlxsw_thermal * parent ;
80
86
struct thermal_zone_device * tzdev ;
81
- struct mlxsw_thermal_trip trips [MLXSW_THERMAL_NUM_TRIPS ];
87
+ struct thermal_trip trips [MLXSW_THERMAL_NUM_TRIPS ];
88
+ struct mlxsw_cooling_states cooling_states [MLXSW_THERMAL_NUM_TRIPS ];
82
89
int module ; /* Module or gearbox number */
83
90
u8 slot_index ;
84
91
};
@@ -99,7 +106,8 @@ struct mlxsw_thermal {
99
106
int polling_delay ;
100
107
struct thermal_cooling_device * cdevs [MLXSW_MFCR_PWMS_MAX ];
101
108
u8 cooling_levels [MLXSW_THERMAL_MAX_STATE + 1 ];
102
- struct mlxsw_thermal_trip trips [MLXSW_THERMAL_NUM_TRIPS ];
109
+ struct thermal_trip trips [MLXSW_THERMAL_NUM_TRIPS ];
110
+ struct mlxsw_cooling_states cooling_states [MLXSW_THERMAL_NUM_TRIPS ];
103
111
struct mlxsw_thermal_area line_cards [];
104
112
};
105
113
@@ -136,9 +144,9 @@ static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal,
136
144
static void
137
145
mlxsw_thermal_module_trips_reset (struct mlxsw_thermal_module * tz )
138
146
{
139
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_NORM ].temp = 0 ;
140
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HIGH ].temp = 0 ;
141
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HOT ].temp = 0 ;
147
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_NORM ].temperature = 0 ;
148
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HIGH ].temperature = 0 ;
149
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HOT ].temperature = 0 ;
142
150
}
143
151
144
152
static int
@@ -180,12 +188,12 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
180
188
* by subtracting double hysteresis value.
181
189
*/
182
190
if (crit_temp >= MLXSW_THERMAL_MODULE_TEMP_SHIFT )
183
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_NORM ].temp = crit_temp -
191
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_NORM ].temperature = crit_temp -
184
192
MLXSW_THERMAL_MODULE_TEMP_SHIFT ;
185
193
else
186
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_NORM ].temp = crit_temp ;
187
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HIGH ].temp = crit_temp ;
188
- tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HOT ].temp = emerg_temp ;
194
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_NORM ].temperature = crit_temp ;
195
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HIGH ].temperature = crit_temp ;
196
+ tz -> trips [MLXSW_THERMAL_TEMP_TRIP_HOT ].temperature = emerg_temp ;
189
197
190
198
return 0 ;
191
199
}
@@ -202,11 +210,11 @@ static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
202
210
return 0 ;
203
211
204
212
for (i = 0 ; i < MLXSW_THERMAL_NUM_TRIPS ; i ++ ) {
205
- const struct mlxsw_thermal_trip * trip = & thermal -> trips [i ];
213
+ const struct mlxsw_cooling_states * state = & thermal -> cooling_states [i ];
206
214
207
215
err = thermal_zone_bind_cooling_device (tzdev , i , cdev ,
208
- trip -> max_state ,
209
- trip -> min_state ,
216
+ state -> max_state ,
217
+ state -> min_state ,
210
218
THERMAL_WEIGHT_DEFAULT );
211
219
if (err < 0 ) {
212
220
dev_err (dev , "Failed to bind cooling device to trip %d\n" , i );
@@ -260,61 +268,6 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
260
268
return 0 ;
261
269
}
262
270
263
- static int mlxsw_thermal_get_trip_type (struct thermal_zone_device * tzdev ,
264
- int trip ,
265
- enum thermal_trip_type * p_type )
266
- {
267
- struct mlxsw_thermal * thermal = tzdev -> devdata ;
268
-
269
- if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS )
270
- return - EINVAL ;
271
-
272
- * p_type = thermal -> trips [trip ].type ;
273
- return 0 ;
274
- }
275
-
276
- static int mlxsw_thermal_get_trip_temp (struct thermal_zone_device * tzdev ,
277
- int trip , int * p_temp )
278
- {
279
- struct mlxsw_thermal * thermal = tzdev -> devdata ;
280
-
281
- if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS )
282
- return - EINVAL ;
283
-
284
- * p_temp = thermal -> trips [trip ].temp ;
285
- return 0 ;
286
- }
287
-
288
- static int mlxsw_thermal_set_trip_temp (struct thermal_zone_device * tzdev ,
289
- int trip , int temp )
290
- {
291
- struct mlxsw_thermal * thermal = tzdev -> devdata ;
292
-
293
- if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS )
294
- return - EINVAL ;
295
-
296
- thermal -> trips [trip ].temp = temp ;
297
- return 0 ;
298
- }
299
-
300
- static int mlxsw_thermal_get_trip_hyst (struct thermal_zone_device * tzdev ,
301
- int trip , int * p_hyst )
302
- {
303
- struct mlxsw_thermal * thermal = tzdev -> devdata ;
304
-
305
- * p_hyst = thermal -> trips [trip ].hyst ;
306
- return 0 ;
307
- }
308
-
309
- static int mlxsw_thermal_set_trip_hyst (struct thermal_zone_device * tzdev ,
310
- int trip , int hyst )
311
- {
312
- struct mlxsw_thermal * thermal = tzdev -> devdata ;
313
-
314
- thermal -> trips [trip ].hyst = hyst ;
315
- return 0 ;
316
- }
317
-
318
271
static struct thermal_zone_params mlxsw_thermal_params = {
319
272
.no_hwmon = true,
320
273
};
@@ -323,11 +276,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = {
323
276
.bind = mlxsw_thermal_bind ,
324
277
.unbind = mlxsw_thermal_unbind ,
325
278
.get_temp = mlxsw_thermal_get_temp ,
326
- .get_trip_type = mlxsw_thermal_get_trip_type ,
327
- .get_trip_temp = mlxsw_thermal_get_trip_temp ,
328
- .set_trip_temp = mlxsw_thermal_set_trip_temp ,
329
- .get_trip_hyst = mlxsw_thermal_get_trip_hyst ,
330
- .set_trip_hyst = mlxsw_thermal_set_trip_hyst ,
331
279
};
332
280
333
281
static int mlxsw_thermal_module_bind (struct thermal_zone_device * tzdev ,
@@ -342,11 +290,11 @@ static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
342
290
return 0 ;
343
291
344
292
for (i = 0 ; i < MLXSW_THERMAL_NUM_TRIPS ; i ++ ) {
345
- const struct mlxsw_thermal_trip * trip = & tz -> trips [i ];
293
+ const struct mlxsw_cooling_states * state = & tz -> cooling_states [i ];
346
294
347
295
err = thermal_zone_bind_cooling_device (tzdev , i , cdev ,
348
- trip -> max_state ,
349
- trip -> min_state ,
296
+ state -> max_state ,
297
+ state -> min_state ,
350
298
THERMAL_WEIGHT_DEFAULT );
351
299
if (err < 0 )
352
300
goto err_thermal_zone_bind_cooling_device ;
@@ -434,74 +382,10 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
434
382
return 0 ;
435
383
}
436
384
437
- static int
438
- mlxsw_thermal_module_trip_type_get (struct thermal_zone_device * tzdev , int trip ,
439
- enum thermal_trip_type * p_type )
440
- {
441
- struct mlxsw_thermal_module * tz = tzdev -> devdata ;
442
-
443
- if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS )
444
- return - EINVAL ;
445
-
446
- * p_type = tz -> trips [trip ].type ;
447
- return 0 ;
448
- }
449
-
450
- static int
451
- mlxsw_thermal_module_trip_temp_get (struct thermal_zone_device * tzdev ,
452
- int trip , int * p_temp )
453
- {
454
- struct mlxsw_thermal_module * tz = tzdev -> devdata ;
455
-
456
- if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS )
457
- return - EINVAL ;
458
-
459
- * p_temp = tz -> trips [trip ].temp ;
460
- return 0 ;
461
- }
462
-
463
- static int
464
- mlxsw_thermal_module_trip_temp_set (struct thermal_zone_device * tzdev ,
465
- int trip , int temp )
466
- {
467
- struct mlxsw_thermal_module * tz = tzdev -> devdata ;
468
-
469
- if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS )
470
- return - EINVAL ;
471
-
472
- tz -> trips [trip ].temp = temp ;
473
- return 0 ;
474
- }
475
-
476
- static int
477
- mlxsw_thermal_module_trip_hyst_get (struct thermal_zone_device * tzdev , int trip ,
478
- int * p_hyst )
479
- {
480
- struct mlxsw_thermal_module * tz = tzdev -> devdata ;
481
-
482
- * p_hyst = tz -> trips [trip ].hyst ;
483
- return 0 ;
484
- }
485
-
486
- static int
487
- mlxsw_thermal_module_trip_hyst_set (struct thermal_zone_device * tzdev , int trip ,
488
- int hyst )
489
- {
490
- struct mlxsw_thermal_module * tz = tzdev -> devdata ;
491
-
492
- tz -> trips [trip ].hyst = hyst ;
493
- return 0 ;
494
- }
495
-
496
385
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
497
386
.bind = mlxsw_thermal_module_bind ,
498
387
.unbind = mlxsw_thermal_module_unbind ,
499
388
.get_temp = mlxsw_thermal_module_temp_get ,
500
- .get_trip_type = mlxsw_thermal_module_trip_type_get ,
501
- .get_trip_temp = mlxsw_thermal_module_trip_temp_get ,
502
- .set_trip_temp = mlxsw_thermal_module_trip_temp_set ,
503
- .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get ,
504
- .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set ,
505
389
};
506
390
507
391
static int mlxsw_thermal_gearbox_temp_get (struct thermal_zone_device * tzdev ,
@@ -531,11 +415,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
531
415
.bind = mlxsw_thermal_module_bind ,
532
416
.unbind = mlxsw_thermal_module_unbind ,
533
417
.get_temp = mlxsw_thermal_gearbox_temp_get ,
534
- .get_trip_type = mlxsw_thermal_module_trip_type_get ,
535
- .get_trip_temp = mlxsw_thermal_module_trip_temp_get ,
536
- .set_trip_temp = mlxsw_thermal_module_trip_temp_set ,
537
- .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get ,
538
- .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set ,
539
418
};
540
419
541
420
static int mlxsw_thermal_get_max_state (struct thermal_cooling_device * cdev ,
@@ -617,7 +496,8 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
617
496
else
618
497
snprintf (tz_name , sizeof (tz_name ), "mlxsw-module%d" ,
619
498
module_tz -> module + 1 );
620
- module_tz -> tzdev = thermal_zone_device_register (tz_name ,
499
+ module_tz -> tzdev = thermal_zone_device_register_with_trips (tz_name ,
500
+ module_tz -> trips ,
621
501
MLXSW_THERMAL_NUM_TRIPS ,
622
502
MLXSW_THERMAL_TRIP_MASK ,
623
503
module_tz ,
@@ -661,6 +541,8 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
661
541
module_tz -> parent = thermal ;
662
542
memcpy (module_tz -> trips , default_thermal_trips ,
663
543
sizeof (thermal -> trips ));
544
+ memcpy (module_tz -> cooling_states , default_cooling_states ,
545
+ sizeof (thermal -> cooling_states ));
664
546
/* Initialize all trip point. */
665
547
mlxsw_thermal_module_trips_reset (module_tz );
666
548
/* Read module temperature and thresholds. */
@@ -756,7 +638,8 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
756
638
else
757
639
snprintf (tz_name , sizeof (tz_name ), "mlxsw-gearbox%d" ,
758
640
gearbox_tz -> module + 1 );
759
- gearbox_tz -> tzdev = thermal_zone_device_register (tz_name ,
641
+ gearbox_tz -> tzdev = thermal_zone_device_register_with_trips (tz_name ,
642
+ gearbox_tz -> trips ,
760
643
MLXSW_THERMAL_NUM_TRIPS ,
761
644
MLXSW_THERMAL_TRIP_MASK ,
762
645
gearbox_tz ,
@@ -813,6 +696,8 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
813
696
gearbox_tz = & area -> tz_gearbox_arr [i ];
814
697
memcpy (gearbox_tz -> trips , default_thermal_trips ,
815
698
sizeof (thermal -> trips ));
699
+ memcpy (gearbox_tz -> cooling_states , default_cooling_states ,
700
+ sizeof (thermal -> cooling_states ));
816
701
gearbox_tz -> module = i ;
817
702
gearbox_tz -> parent = thermal ;
818
703
gearbox_tz -> slot_index = area -> slot_index ;
@@ -928,6 +813,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
928
813
thermal -> core = core ;
929
814
thermal -> bus_info = bus_info ;
930
815
memcpy (thermal -> trips , default_thermal_trips , sizeof (thermal -> trips ));
816
+ memcpy (thermal -> cooling_states , default_cooling_states , sizeof (thermal -> cooling_states ));
931
817
thermal -> line_cards [0 ].slot_index = 0 ;
932
818
933
819
err = mlxsw_reg_query (thermal -> core , MLXSW_REG (mfcr ), mfcr_pl );
@@ -981,7 +867,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
981
867
MLXSW_THERMAL_SLOW_POLL_INT :
982
868
MLXSW_THERMAL_POLL_INT ;
983
869
984
- thermal -> tzdev = thermal_zone_device_register ("mlxsw" ,
870
+ thermal -> tzdev = thermal_zone_device_register_with_trips ("mlxsw" ,
871
+ thermal -> trips ,
985
872
MLXSW_THERMAL_NUM_TRIPS ,
986
873
MLXSW_THERMAL_TRIP_MASK ,
987
874
thermal ,
0 commit comments