119969707SMartin Blumenstingl /* SPDX-License-Identifier: GPL-2.0 */ 219969707SMartin Blumenstingl /* Copyright 2020 Martin Blumenstingl <martin.blumenstingl@googlemail.com> */ 319969707SMartin Blumenstingl 419969707SMartin Blumenstingl #ifndef __LIMA_DEVFREQ_H__ 519969707SMartin Blumenstingl #define __LIMA_DEVFREQ_H__ 619969707SMartin Blumenstingl 7*1d048afeSChristian Hewitt #include <linux/devfreq.h> 819969707SMartin Blumenstingl #include <linux/spinlock.h> 919969707SMartin Blumenstingl #include <linux/ktime.h> 1019969707SMartin Blumenstingl 1119969707SMartin Blumenstingl struct devfreq; 1219969707SMartin Blumenstingl struct thermal_cooling_device; 1319969707SMartin Blumenstingl 1419969707SMartin Blumenstingl struct lima_device; 1519969707SMartin Blumenstingl 1619969707SMartin Blumenstingl struct lima_devfreq { 1719969707SMartin Blumenstingl struct devfreq *devfreq; 1819969707SMartin Blumenstingl struct thermal_cooling_device *cooling; 19*1d048afeSChristian Hewitt struct devfreq_simple_ondemand_data gov_data; 2019969707SMartin Blumenstingl 2119969707SMartin Blumenstingl ktime_t busy_time; 2219969707SMartin Blumenstingl ktime_t idle_time; 2319969707SMartin Blumenstingl ktime_t time_last_update; 2419969707SMartin Blumenstingl int busy_count; 2519969707SMartin Blumenstingl /* 2619969707SMartin Blumenstingl * Protect busy_time, idle_time, time_last_update and busy_count 2719969707SMartin Blumenstingl * because these can be updated concurrently, for example by the GP 2819969707SMartin Blumenstingl * and PP interrupts. 2919969707SMartin Blumenstingl */ 3019969707SMartin Blumenstingl spinlock_t lock; 3119969707SMartin Blumenstingl }; 3219969707SMartin Blumenstingl 3319969707SMartin Blumenstingl int lima_devfreq_init(struct lima_device *ldev); 3419969707SMartin Blumenstingl void lima_devfreq_fini(struct lima_device *ldev); 3519969707SMartin Blumenstingl 3619969707SMartin Blumenstingl void lima_devfreq_record_busy(struct lima_devfreq *devfreq); 3719969707SMartin Blumenstingl void lima_devfreq_record_idle(struct lima_devfreq *devfreq); 3819969707SMartin Blumenstingl 394836cf04SQiang Yu int lima_devfreq_resume(struct lima_devfreq *devfreq); 404836cf04SQiang Yu int lima_devfreq_suspend(struct lima_devfreq *devfreq); 414836cf04SQiang Yu 4219969707SMartin Blumenstingl #endif 43