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 71f8644d5SLukasz 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; 129bfacfc8SClément Péron struct thermal_cooling_device; 139bfacfc8SClément Péron 149bfacfc8SClément Péron struct panfrost_device; 159bfacfc8SClément Péron 169bfacfc8SClément Péron struct panfrost_devfreq { 179bfacfc8SClément Péron struct devfreq *devfreq; 189bfacfc8SClément Péron struct thermal_cooling_device *cooling; 191f8644d5SLukasz Luba struct devfreq_simple_ondemand_data gov_data; 2081f2fbe6SClément Péron bool opp_of_table_added; 21ed85df3fSClément Péron 22*f11b0417SAdrián Larumbe unsigned long current_frequency; 23*f11b0417SAdrián Larumbe unsigned long fast_rate; 24*f11b0417SAdrián Larumbe 259bfacfc8SClément Péron ktime_t busy_time; 269bfacfc8SClément Péron ktime_t idle_time; 279bfacfc8SClément Péron ktime_t time_last_update; 28ed85df3fSClément Péron int busy_count; 29ed85df3fSClément Péron /* 30ed85df3fSClément Péron * Protect busy_time, idle_time, time_last_update and busy_count 31ed85df3fSClément Péron * because these can be updated concurrently between multiple jobs. 32ed85df3fSClément Péron */ 33ed85df3fSClément Péron spinlock_t lock; 349bfacfc8SClément Péron }; 359bfacfc8SClément Péron 36f3ba9122SRob Herring int panfrost_devfreq_init(struct panfrost_device *pfdev); 37aa4fffecSSteven Price void panfrost_devfreq_fini(struct panfrost_device *pfdev); 38f3ba9122SRob Herring 39f3ba9122SRob Herring void panfrost_devfreq_resume(struct panfrost_device *pfdev); 40f3ba9122SRob Herring void panfrost_devfreq_suspend(struct panfrost_device *pfdev); 41f3ba9122SRob Herring 429bfacfc8SClément Péron void panfrost_devfreq_record_busy(struct panfrost_devfreq *devfreq); 439bfacfc8SClément Péron void panfrost_devfreq_record_idle(struct panfrost_devfreq *devfreq); 44f3ba9122SRob Herring 45f3ba9122SRob Herring #endif /* __PANFROST_DEVFREQ_H__ */ 46