xref: /openbmc/linux/drivers/gpu/drm/panfrost/panfrost_devfreq.h (revision 3aa139aa9fdc138a84243dc49dc18d9b40e1c6e4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright 2019 Collabora ltd. */
3 
4 #ifndef __PANFROST_DEVFREQ_H__
5 #define __PANFROST_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 panfrost_device;
14 
15 struct panfrost_devfreq {
16 	struct devfreq *devfreq;
17 	struct thermal_cooling_device *cooling;
18 	bool opp_of_table_added;
19 
20 	ktime_t busy_time;
21 	ktime_t idle_time;
22 	ktime_t time_last_update;
23 	int busy_count;
24 	/*
25 	 * Protect busy_time, idle_time, time_last_update and busy_count
26 	 * because these can be updated concurrently between multiple jobs.
27 	 */
28 	spinlock_t lock;
29 };
30 
31 int panfrost_devfreq_init(struct panfrost_device *pfdev);
32 void panfrost_devfreq_fini(struct panfrost_device *pfdev);
33 
34 void panfrost_devfreq_resume(struct panfrost_device *pfdev);
35 void panfrost_devfreq_suspend(struct panfrost_device *pfdev);
36 
37 void panfrost_devfreq_record_busy(struct panfrost_devfreq *devfreq);
38 void panfrost_devfreq_record_idle(struct panfrost_devfreq *devfreq);
39 
40 #endif /* __PANFROST_DEVFREQ_H__ */
41