xref: /openbmc/linux/drivers/gpu/drm/lima/lima_devfreq.h (revision 3aa139aa9fdc138a84243dc49dc18d9b40e1c6e4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright 2020 Martin Blumenstingl <martin.blumenstingl@googlemail.com> */
3 
4 #ifndef __LIMA_DEVFREQ_H__
5 #define __LIMA_DEVFREQ_H__
6 
7 #include <linux/spinlock.h>
8 #include <linux/ktime.h>
9 
10 struct devfreq;
11 struct thermal_cooling_device;
12 
13 struct lima_device;
14 
15 struct lima_devfreq {
16 	struct devfreq *devfreq;
17 	struct thermal_cooling_device *cooling;
18 
19 	ktime_t busy_time;
20 	ktime_t idle_time;
21 	ktime_t time_last_update;
22 	int busy_count;
23 	/*
24 	 * Protect busy_time, idle_time, time_last_update and busy_count
25 	 * because these can be updated concurrently, for example by the GP
26 	 * and PP interrupts.
27 	 */
28 	spinlock_t lock;
29 };
30 
31 int lima_devfreq_init(struct lima_device *ldev);
32 void lima_devfreq_fini(struct lima_device *ldev);
33 
34 void lima_devfreq_record_busy(struct lima_devfreq *devfreq);
35 void lima_devfreq_record_idle(struct lima_devfreq *devfreq);
36 
37 int lima_devfreq_resume(struct lima_devfreq *devfreq);
38 int lima_devfreq_suspend(struct lima_devfreq *devfreq);
39 
40 #endif
41