1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
|
/*
* drivers/misc/therm_fan_est.c
*
* Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/cpufreq.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/syscalls.h>
#include <linux/therm_est.h>
#include <linux/thermal.h>
#include <linux/module.h>
#include <linux/hwmon-sysfs.h>
#define DEFERRED_RESUME_TIME 3000
#define DEBUG 0
struct therm_fan_estimator {
long cur_temp;
#if DEBUG
long cur_temp_debug;
#endif
long polling_period;
struct workqueue_struct *workqueue;
struct delayed_work therm_fan_est_work;
long toffset;
int ntemp;
int ndevs;
struct therm_fan_est_subdevice *devs;
struct thermal_zone_device *thz;
int current_trip_index;
const char *cdev_type;
int active_trip_temps[MAX_ACTIVE_STATES];
int active_hysteresis[MAX_ACTIVE_STATES];
int active_trip_temps_hyst[(MAX_ACTIVE_STATES << 1) + 1];
struct thermal_zone_params *tzp;
int num_resources;
int trip_length;
const char *name;
};
static void fan_set_trip_temp_hyst(struct therm_fan_estimator *est, int trip,
unsigned long hyst_temp,
unsigned long trip_temp)
{
est->active_hysteresis[trip] = hyst_temp;
est->active_trip_temps[trip] = trip_temp;
est->active_trip_temps_hyst[(trip << 1)] = trip_temp;
est->active_trip_temps_hyst[((trip - 1) << 1) + 1] =
trip_temp - hyst_temp;
}
static void therm_fan_est_work_func(struct work_struct *work)
{
int i, j, index, trip_index, sum = 0;
long temp = 0;
struct delayed_work *dwork = container_of(work,
struct delayed_work, work);
struct therm_fan_estimator *est = container_of(
dwork,
struct therm_fan_estimator,
therm_fan_est_work);
for (i = 0; i < est->ndevs; i++) {
if (est->devs[i].get_temp(est->devs[i].dev_data, &temp))
continue;
est->devs[i].hist[(est->ntemp % HIST_LEN)] = temp;
}
for (i = 0; i < est->ndevs; i++) {
for (j = 0; j < HIST_LEN; j++) {
index = (est->ntemp - j + HIST_LEN) % HIST_LEN;
sum += est->devs[i].hist[index] *
est->devs[i].coeffs[j];
}
}
#if !DEBUG
est->cur_temp = sum / 100 + est->toffset;
#else
est->cur_temp = est->cur_temp_debug;
#endif
for (trip_index = 0;
trip_index < ((MAX_ACTIVE_STATES << 1) + 1); trip_index++) {
if (est->cur_temp < est->active_trip_temps_hyst[trip_index])
break;
}
if (est->current_trip_index != (trip_index - 1)) {
if (!((trip_index - 1) % 2) || (!est->current_trip_index) ||
((trip_index - est->current_trip_index) >= 2) ||
((trip_index - est->current_trip_index) <= -2)) {
pr_debug("%s, cur_temp:%ld, cur_trip_index:%d\n",
__func__, est->cur_temp, est->current_trip_index);
thermal_zone_device_update(est->thz);
}
est->current_trip_index = trip_index - 1;
}
est->ntemp++;
queue_delayed_work(est->workqueue, &est->therm_fan_est_work,
msecs_to_jiffies(est->polling_period));
}
static int therm_fan_est_bind(struct thermal_zone_device *thz,
struct thermal_cooling_device *cdev)
{
int i;
struct therm_fan_estimator *est = thz->devdata;
if (!strcmp(cdev->type, est->cdev_type)) {
for (i = 0; i < MAX_ACTIVE_STATES; i++)
thermal_zone_bind_cooling_device(thz, i, cdev, i, i);
}
return 0;
}
static int therm_fan_est_unbind(struct thermal_zone_device *thz,
struct thermal_cooling_device *cdev)
{
int i;
struct therm_fan_estimator *est = thz->devdata;
if (!strcmp(cdev->type, est->cdev_type)) {
for (i = 0; i < MAX_ACTIVE_STATES; i++)
thermal_zone_unbind_cooling_device(thz, i, cdev);
}
return 0;
}
static int therm_fan_est_get_trip_type(struct thermal_zone_device *thz,
int trip,
enum thermal_trip_type *type)
{
*type = THERMAL_TRIP_ACTIVE;
return 0;
}
static int therm_fan_est_get_trip_temp(struct thermal_zone_device *thz,
int trip, long *temp)
{
struct therm_fan_estimator *est = thz->devdata;
if (est->current_trip_index == 0)
*temp = 0;
if (trip * 2 <= est->current_trip_index) /* tripped then lower */
*temp = est->active_trip_temps_hyst[trip * 2 - 1];
else /* not tripped, then upper */
*temp = est->active_trip_temps_hyst[trip * 2];
return 0;
}
static int therm_fan_est_set_trip_temp(struct thermal_zone_device *thz,
int trip, long temp)
{
struct therm_fan_estimator *est = thz->devdata;
/*Need trip 0 to remain as it is*/
if (((temp - est->active_hysteresis[trip]) < 0) || (trip <= 0))
return -EINVAL;
fan_set_trip_temp_hyst(est, trip, est->active_hysteresis[trip], temp);
return 0;
}
static int therm_fan_est_get_temp(struct thermal_zone_device *thz, long *temp)
{
struct therm_fan_estimator *est = thz->devdata;
*temp = est->cur_temp;
return 0;
}
static int therm_fan_est_set_trip_hyst(struct thermal_zone_device *thz,
int trip, long hyst_temp)
{
struct therm_fan_estimator *est = thz->devdata;
/*Need trip 0 to remain as it is*/
if ((est->active_trip_temps[trip] - hyst_temp) < 0 || trip <= 0)
return -EINVAL;
fan_set_trip_temp_hyst(est, trip,
hyst_temp, est->active_trip_temps[trip]);
return 0;
}
static int therm_fan_est_get_trip_hyst(struct thermal_zone_device *thz,
int trip, long *temp)
{
struct therm_fan_estimator *est = thz->devdata;
*temp = est->active_hysteresis[trip];
return 0;
}
static struct thermal_zone_device_ops therm_fan_est_ops = {
.bind = therm_fan_est_bind,
.unbind = therm_fan_est_unbind,
.get_trip_type = therm_fan_est_get_trip_type,
.get_trip_temp = therm_fan_est_get_trip_temp,
.get_temp = therm_fan_est_get_temp,
.set_trip_temp = therm_fan_est_set_trip_temp,
.get_trip_hyst = therm_fan_est_get_trip_hyst,
.set_trip_hyst = therm_fan_est_set_trip_hyst,
};
static ssize_t show_coeff(struct device *dev,
struct device_attribute *da,
char *buf)
{
struct therm_fan_estimator *est = dev_get_drvdata(dev);
ssize_t len, total_len = 0;
int i, j;
for (i = 0; i < est->ndevs; i++) {
len = snprintf(buf + total_len, PAGE_SIZE, "[%d]", i);
total_len += len;
for (j = 0; j < HIST_LEN; j++) {
len = snprintf(buf + total_len, PAGE_SIZE, " %d",
est->devs[i].coeffs[j]);
total_len += len;
}
len = snprintf(buf + total_len, PAGE_SIZE, "\n");
total_len += len;
}
return strlen(buf);
}
static ssize_t set_coeff(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count)
{
struct therm_fan_estimator *est = dev_get_drvdata(dev);
int devid, scount;
long coeff[20];
if (HIST_LEN > 20)
return -EINVAL;
scount = sscanf(buf, "[%d] %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld " \
"%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",
&devid, &coeff[0], &coeff[1], &coeff[2], &coeff[3],
&coeff[4], &coeff[5], &coeff[6], &coeff[7], &coeff[8],
&coeff[9], &coeff[10], &coeff[11], &coeff[12],
&coeff[13], &coeff[14], &coeff[15], &coeff[16],
&coeff[17], &coeff[18], &coeff[19]);
if (scount != HIST_LEN + 1)
return -1;
if (devid < 0 || devid >= est->ndevs)
return -EINVAL;
/* This has obvious locking issues but don't worry about it */
memcpy(est->devs[devid].coeffs, coeff, sizeof(long) * HIST_LEN);
return count;
}
static ssize_t show_offset(struct device *dev,
struct device_attribute *da,
char *buf)
{
struct therm_fan_estimator *est = dev_get_drvdata(dev);
snprintf(buf, PAGE_SIZE, "%ld\n", est->toffset);
return strlen(buf);
}
static ssize_t set_offset(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count)
{
struct therm_fan_estimator *est = dev_get_drvdata(dev);
int offset;
if (kstrtoint(buf, 0, &offset))
return -EINVAL;
est->toffset = offset;
return count;
}
static ssize_t show_temps(struct device *dev,
struct device_attribute *da,
char *buf)
{
struct therm_fan_estimator *est = dev_get_drvdata(dev);
ssize_t total_len = 0;
int i, j;
int index;
/* This has obvious locking issues but don't worry about it */
for (i = 0; i < est->ndevs; i++) {
total_len += snprintf(buf + total_len, PAGE_SIZE, "[%d]", i);
for (j = 0; j < HIST_LEN; j++) {
index = (est->ntemp - j + HIST_LEN) % HIST_LEN;
total_len += snprintf(buf + total_len,
PAGE_SIZE,
" %d",
est->devs[i].hist[index]);
}
total_len += snprintf(buf + total_len, PAGE_SIZE, "\n");
}
return strlen(buf);
}
#if DEBUG
static ssize_t set_temps(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count)
{
struct therm_fan_estimator *est = dev_get_drvdata(dev);
int temp;
if (kstrtoint(buf, 0, &temp))
return -EINVAL;
est->cur_temp_debug = temp;
return count;
}
#endif
static struct sensor_device_attribute therm_fan_est_nodes[] = {
SENSOR_ATTR(coeff, S_IRUGO | S_IWUSR, show_coeff, set_coeff, 0),
SENSOR_ATTR(offset, S_IRUGO | S_IWUSR, show_offset, set_offset, 0),
#if DEBUG
SENSOR_ATTR(temps, S_IRUGO | S_IWUSR, show_temps, set_temps, 0),
#else
SENSOR_ATTR(temps, S_IRUGO, show_temps, 0, 0),
#endif
};
static int fan_est_match(struct thermal_zone_device *thz, void *data)
{
return (strcmp((char *)data, thz->type) == 0);
}
static int fan_est_get_temp_func(const char *data, long *temp)
{
struct thermal_zone_device *thz;
thz = thermal_zone_device_find((void *)data, fan_est_match);
if (!thz || thz->ops->get_temp == NULL || thz->ops->get_temp(thz, temp))
*temp = 25000;
return 0;
}
static int therm_fan_est_probe(struct platform_device *pdev)
{
int i, j;
long temp;
int err = 0;
int of_err = 0;
struct therm_fan_estimator *est_data;
struct therm_fan_est_subdevice *subdevs;
struct therm_fan_est_subdevice *dev;
struct thermal_zone_params *tzp;
struct device_node *node = NULL;
struct device_node *data_node = NULL;
int child_count = 0;
struct device_node *child = NULL;
const char *gov_name;
u32 value;
pr_info("THERMAL EST start of therm_fan_est_probe.\n");
if (!pdev)
return -EINVAL;
node = pdev->dev.of_node;
if (!node) {
pr_err("THERMAL EST: dev of_node NULL\n");
return -EINVAL;
}
data_node = of_parse_phandle(node, "shared_data", 0);
if (!data_node) {
pr_err("THERMAL EST shared data node parsing failed\n");
return -EINVAL;
}
child_count = of_get_child_count(data_node);
of_err |= of_property_read_u32(data_node, "ndevs", &value);
if (of_err) {
pr_err("THERMAL EST: missing ndevs\n");
return -ENXIO;
}
if (child_count != (int)value) {
pr_err("THERMAL EST: ndevs count mismatch\n");
return -EINVAL;
}
est_data = devm_kzalloc(&pdev->dev,
sizeof(struct therm_fan_estimator), GFP_KERNEL);
if (IS_ERR_OR_NULL(est_data))
return -ENOMEM;
est_data->ndevs = child_count;
pr_info("THERMAL EST: found %d subdevs\n", est_data->ndevs);
of_err |= of_property_read_string(node, "name", &est_data->name);
if (of_err) {
pr_err("THERMAL EST: name is missing\n");
err = -ENXIO;
goto free_est;
}
pr_info("THERMAL EST name: %s.\n", est_data->name);
of_err |= of_property_read_u32(node, "num_resources", &value);
if (of_err) {
pr_err("THERMAL EST: num_resources is missing\n");
err = -ENXIO;
goto free_est;
}
est_data->num_resources = value;
pr_info("THERMAL EST num_resources: %d\n", est_data->num_resources);
of_err |= of_property_read_u32(node, "trip_length", &value);
if (of_err) {
pr_err("THERMAL EST: missing trip length\n");
err = -ENXIO;
goto free_est;
}
est_data->trip_length = (int)value;
subdevs = devm_kzalloc(&pdev->dev,
child_count * sizeof(struct therm_fan_est_subdevice),
GFP_KERNEL);
if (IS_ERR_OR_NULL(subdevs)) {
err = -ENOMEM;
goto free_est;
}
/* initialize subdevs */
j = 0;
for_each_child_of_node(data_node, child) {
pr_info("[THERMAL EST subdev %d]\n", j);
of_err |= of_property_read_string(child, "dev_data",
&subdevs[j].dev_data);
if (of_err) {
pr_err("THERMAL EST subdev[%d] dev_data missed\n", j);
err = -ENXIO;
goto free_subdevs;
}
pr_info("THERMAL EST subdev name: %s\n",
(char *)subdevs[j].dev_data);
subdevs[j].get_temp = &fan_est_get_temp_func;
of_err |= of_property_read_u32_array(child, "coeffs",
subdevs[j].coeffs, est_data->trip_length);
for (i = 0; i < est_data->trip_length; i++)
pr_info("THERMAL EST index %d coeffs %d\n",
i, subdevs[j].coeffs[i]);
j++;
}
est_data->devs = subdevs;
of_err |= of_property_read_u32(data_node, "toffset", &value);
if (of_err) {
pr_err("THERMAL EST: missing toffset\n");
err = -ENXIO;
goto free_subdevs;
}
est_data->toffset = (long)value;
of_err |= of_property_read_u32(data_node, "polling_period", &value);
if (of_err) {
pr_err("THERMAL EST: missing polling_period\n");
err = -ENXIO;
goto free_subdevs;
}
est_data->polling_period = (long)value;
of_err |= of_property_read_u32_array(node, "active_trip_temps",
est_data->active_trip_temps, (size_t) est_data->trip_length);
if (of_err) {
pr_err("THERMAL EST: active trip temps failed to parse.\n");
err = -ENXIO;
goto free_subdevs;
}
of_err |= of_property_read_u32_array(node, "active_hysteresis",
est_data->active_hysteresis, (size_t) est_data->trip_length);
if (of_err) {
pr_err("THERMAL EST: active hysteresis failed to parse.\n");
err = -ENXIO;
goto free_subdevs;
}
for (i = 0; i < est_data->trip_length; i++)
pr_info("THERMAL EST index %d: trip_temp %d, hyst %d\n",
i, est_data->active_trip_temps[i],
est_data->active_hysteresis[i]);
est_data->active_trip_temps_hyst[0] = est_data->active_trip_temps[0];
for (i = 1; i < MAX_ACTIVE_STATES; i++)
fan_set_trip_temp_hyst(est_data, i,
est_data->active_hysteresis[i],
est_data->active_trip_temps[i]);
for (i = 0; i < (MAX_ACTIVE_STATES << 1) + 1; i++)
pr_info("THERMAL EST index %d: trip_temps_hyst %d\n",
i, est_data->active_trip_temps_hyst[i]);
for (i = 0; i < est_data->ndevs; i++) {
dev = &est_data->devs[i];
if (dev->get_temp(dev->dev_data, &temp)) {
err = -EINVAL;
goto free_subdevs;
}
for (j = 0; j < HIST_LEN; j++)
dev->hist[j] = temp;
pr_info("THERMAL EST init dev[%d] temp hist to %ld\n",
i, temp);
}
of_err |= of_property_read_string(data_node, "cdev_type",
&est_data->cdev_type);
if (of_err) {
pr_err("THERMAL EST: cdev_type is missing\n");
err = -EINVAL;
goto free_subdevs;
}
pr_info("THERMAL EST cdev_type: %s.\n", est_data->cdev_type);
tzp = devm_kzalloc(&pdev->dev, sizeof(struct thermal_zone_params),
GFP_KERNEL);
if (IS_ERR_OR_NULL(tzp)) {
err = -ENOMEM;
goto free_subdevs;
}
memset(tzp, 0, sizeof(struct thermal_zone_params));
of_err |= of_property_read_string(data_node, "tzp_governor_name",
&gov_name);
if (of_err) {
pr_err("THERMAL EST: governor name is missing\n");
err = -EINVAL;
goto free_tzp;
}
strcpy(tzp->governor_name, gov_name);
pr_info("THERMAL EST governor name: %s\n", tzp->governor_name);
est_data->tzp = tzp;
est_data->thz = thermal_zone_device_register(
(char *)dev_name(&pdev->dev),
10, 0x3FF, est_data,
&therm_fan_est_ops, tzp, 0, 0);
if (IS_ERR_OR_NULL(est_data->thz)) {
pr_err("THERMAL EST: thz register failed\n");
err = -EINVAL;
goto free_tzp;
}
pr_info("THERMAL EST: thz register success.\n");
/* workqueue related */
est_data->workqueue = alloc_workqueue(dev_name(&pdev->dev),
WQ_HIGHPRI | WQ_UNBOUND, 1);
if (!est_data->workqueue) {
err = -ENOMEM;
goto free_tzp;
}
est_data->current_trip_index = 0;
INIT_DELAYED_WORK(&est_data->therm_fan_est_work,
therm_fan_est_work_func);
queue_delayed_work(est_data->workqueue,
&est_data->therm_fan_est_work,
msecs_to_jiffies(est_data->polling_period));
for (i = 0; i < ARRAY_SIZE(therm_fan_est_nodes); i++)
device_create_file(&pdev->dev,
&therm_fan_est_nodes[i].dev_attr);
platform_set_drvdata(pdev, est_data);
pr_info("THERMAL EST: end of probe, return err: %d\n", err);
return err;
free_tzp:
devm_kfree(&pdev->dev, (void *)tzp);
free_subdevs:
devm_kfree(&pdev->dev, (void *)subdevs);
free_est:
devm_kfree(&pdev->dev, (void *)est_data);
return err;
}
static int therm_fan_est_remove(struct platform_device *pdev)
{
struct therm_fan_estimator *est = platform_get_drvdata(pdev);
if (!est)
return -EINVAL;
cancel_delayed_work(&est->therm_fan_est_work);
destroy_workqueue(est->workqueue);
thermal_zone_device_unregister(est->thz);
devm_kfree(&pdev->dev, (void *)est->tzp);
devm_kfree(&pdev->dev, (void *)est->devs);
devm_kfree(&pdev->dev, (void *)est);
return 0;
}
#if CONFIG_PM
static int therm_fan_est_suspend(struct platform_device *pdev,
pm_message_t state)
{
struct therm_fan_estimator *est = platform_get_drvdata(pdev);
if (!est)
return -EINVAL;
pr_debug("therm-fan-est: %s, cur_temp:%ld", __func__, est->cur_temp);
cancel_delayed_work(&est->therm_fan_est_work);
est->current_trip_index = 0;
return 0;
}
static int therm_fan_est_resume(struct platform_device *pdev)
{
struct therm_fan_estimator *est = platform_get_drvdata(pdev);
if (!est)
return -EINVAL;
pr_debug("therm-fan-est: %s, cur_temp:%ld", __func__, est->cur_temp);
queue_delayed_work(est->workqueue,
&est->therm_fan_est_work,
msecs_to_jiffies(DEFERRED_RESUME_TIME));
return 0;
}
#endif
static void therm_fan_est_shutdown(struct platform_device *pdev)
{
struct therm_fan_estimator *est = platform_get_drvdata(pdev);
pr_info("therm-fan-est: shutting down\n");
cancel_delayed_work_sync(&est->therm_fan_est_work);
destroy_workqueue(est->workqueue);
thermal_zone_device_unregister(est->thz);
devm_kfree(&pdev->dev, (void *)est->tzp);
devm_kfree(&pdev->dev, (void *)est->devs);
devm_kfree(&pdev->dev, (void *)est);
}
static const struct of_device_id of_thermal_est_match[] = {
{ .compatible = "loki-thermal-est", },
{ .compatible = "foster-thermal-est", },
{ .compatible = "thermal-fan-est", },
{},
};
MODULE_DEVICE_TABLE(of, of_thermal_est_match);
static struct platform_driver therm_fan_est_driver = {
.driver = {
.name = "therm-fan-est-driver",
.owner = THIS_MODULE,
.of_match_table = of_thermal_est_match,
},
.probe = therm_fan_est_probe,
.remove = therm_fan_est_remove,
#if CONFIG_PM
.suspend = therm_fan_est_suspend,
.resume = therm_fan_est_resume,
#endif
.shutdown = therm_fan_est_shutdown,
};
module_platform_driver(therm_fan_est_driver);
MODULE_DESCRIPTION("fan thermal estimator");
MODULE_AUTHOR("Anshul Jain <anshulj@nvidia.com>");
MODULE_LICENSE("GPL v2");
|