1f3ba9122SRob Herring /* SPDX-License-Identifier: GPL-2.0 */ 2f3ba9122SRob Herring /* Copyright 2019 Collabora ltd. */ 3f3ba9122SRob Herring 4f3ba9122SRob Herring #ifndef __PANFROST_DEVFREQ_H__ 5f3ba9122SRob Herring #define __PANFROST_DEVFREQ_H__ 6f3ba9122SRob Herring 7*1f8644d5SLukasz Luba #include <linux/devfreq.h> 8ed85df3fSClément Péron #include <linux/spinlock.h> 99bfacfc8SClément Péron #include <linux/ktime.h> 109bfacfc8SClément Péron 119bfacfc8SClément Péron struct devfreq; 12fd587ff0SClément Péron struct opp_table; 139bfacfc8SClément Péron struct thermal_cooling_device; 149bfacfc8SClément Péron 159bfacfc8SClément Péron struct panfrost_device; 169bfacfc8SClément Péron 179bfacfc8SClément Péron struct panfrost_devfreq { 189bfacfc8SClément Péron struct devfreq *devfreq; 19fd587ff0SClément Péron struct opp_table *regulators_opp_table; 209bfacfc8SClément Péron struct thermal_cooling_device *cooling; 21*1f8644d5SLukasz Luba struct devfreq_simple_ondemand_data gov_data; 2281f2fbe6SClément Péron bool opp_of_table_added; 23ed85df3fSClément Péron 249bfacfc8SClément Péron ktime_t busy_time; 259bfacfc8SClément Péron ktime_t idle_time; 269bfacfc8SClément Péron ktime_t time_last_update; 27ed85df3fSClément Péron int busy_count; 28ed85df3fSClément Péron /* 29ed85df3fSClément Péron * Protect busy_time, idle_time, time_last_update and busy_count 30ed85df3fSClément Péron * because these can be updated concurrently between multiple jobs. 31ed85df3fSClément Péron */ 32ed85df3fSClément Péron spinlock_t lock; 339bfacfc8SClément Péron }; 349bfacfc8SClément Péron 35f3ba9122SRob Herring int panfrost_devfreq_init(struct panfrost_device *pfdev); 36aa4fffecSSteven Price void panfrost_devfreq_fini(struct panfrost_device *pfdev); 37f3ba9122SRob Herring 38f3ba9122SRob Herring void panfrost_devfreq_resume(struct panfrost_device *pfdev); 39f3ba9122SRob Herring void panfrost_devfreq_suspend(struct panfrost_device *pfdev); 40f3ba9122SRob Herring 419bfacfc8SClément Péron void panfrost_devfreq_record_busy(struct panfrost_devfreq *devfreq); 429bfacfc8SClément Péron void panfrost_devfreq_record_idle(struct panfrost_devfreq *devfreq); 43f3ba9122SRob Herring 44f3ba9122SRob Herring #endif /* __PANFROST_DEVFREQ_H__ */ 45