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/devfreq.h> 8 #include <linux/spinlock.h> 9 #include <linux/ktime.h> 10 11 struct devfreq; 12 struct opp_table; 13 struct thermal_cooling_device; 14 15 struct panfrost_device; 16 17 struct panfrost_devfreq { 18 struct devfreq *devfreq; 19 struct opp_table *regulators_opp_table; 20 struct thermal_cooling_device *cooling; 21 struct devfreq_simple_ondemand_data gov_data; 22 bool opp_of_table_added; 23 24 ktime_t busy_time; 25 ktime_t idle_time; 26 ktime_t time_last_update; 27 int busy_count; 28 /* 29 * Protect busy_time, idle_time, time_last_update and busy_count 30 * because these can be updated concurrently between multiple jobs. 31 */ 32 spinlock_t lock; 33 }; 34 35 int panfrost_devfreq_init(struct panfrost_device *pfdev); 36 void panfrost_devfreq_fini(struct panfrost_device *pfdev); 37 38 void panfrost_devfreq_resume(struct panfrost_device *pfdev); 39 void panfrost_devfreq_suspend(struct panfrost_device *pfdev); 40 41 void panfrost_devfreq_record_busy(struct panfrost_devfreq *devfreq); 42 void panfrost_devfreq_record_idle(struct panfrost_devfreq *devfreq); 43 44 #endif /* __PANFROST_DEVFREQ_H__ */ 45