Lines Matching refs:pfdevfreq
13 static void panfrost_devfreq_update_utilization(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_update_utilization() argument
18 last = pfdevfreq->time_last_update; in panfrost_devfreq_update_utilization()
20 if (pfdevfreq->busy_count > 0) in panfrost_devfreq_update_utilization()
21 pfdevfreq->busy_time += ktime_sub(now, last); in panfrost_devfreq_update_utilization()
23 pfdevfreq->idle_time += ktime_sub(now, last); in panfrost_devfreq_update_utilization()
25 pfdevfreq->time_last_update = now; in panfrost_devfreq_update_utilization()
46 static void panfrost_devfreq_reset(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_reset() argument
48 pfdevfreq->busy_time = 0; in panfrost_devfreq_reset()
49 pfdevfreq->idle_time = 0; in panfrost_devfreq_reset()
50 pfdevfreq->time_last_update = ktime_get(); in panfrost_devfreq_reset()
57 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_get_dev_status() local
62 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
64 panfrost_devfreq_update_utilization(pfdevfreq); in panfrost_devfreq_get_dev_status()
66 status->total_time = ktime_to_ns(ktime_add(pfdevfreq->busy_time, in panfrost_devfreq_get_dev_status()
67 pfdevfreq->idle_time)); in panfrost_devfreq_get_dev_status()
69 status->busy_time = ktime_to_ns(pfdevfreq->busy_time); in panfrost_devfreq_get_dev_status()
71 panfrost_devfreq_reset(pfdevfreq); in panfrost_devfreq_get_dev_status()
73 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
98 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_init() local
110 pfdevfreq->regulators_opp_table = opp_table; in panfrost_devfreq_init()
120 pfdevfreq->opp_of_table_added = true; in panfrost_devfreq_init()
122 spin_lock_init(&pfdevfreq->lock); in panfrost_devfreq_init()
124 panfrost_devfreq_reset(pfdevfreq); in panfrost_devfreq_init()
144 pfdevfreq->devfreq = devfreq; in panfrost_devfreq_init()
150 pfdevfreq->cooling = cooling; in panfrost_devfreq_init()
161 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_fini() local
163 if (pfdevfreq->cooling) { in panfrost_devfreq_fini()
164 devfreq_cooling_unregister(pfdevfreq->cooling); in panfrost_devfreq_fini()
165 pfdevfreq->cooling = NULL; in panfrost_devfreq_fini()
168 if (pfdevfreq->opp_of_table_added) { in panfrost_devfreq_fini()
170 pfdevfreq->opp_of_table_added = false; in panfrost_devfreq_fini()
173 if (pfdevfreq->regulators_opp_table) { in panfrost_devfreq_fini()
174 dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table); in panfrost_devfreq_fini()
175 pfdevfreq->regulators_opp_table = NULL; in panfrost_devfreq_fini()
181 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_resume() local
183 if (!pfdevfreq->devfreq) in panfrost_devfreq_resume()
186 panfrost_devfreq_reset(pfdevfreq); in panfrost_devfreq_resume()
188 devfreq_resume_device(pfdevfreq->devfreq); in panfrost_devfreq_resume()
193 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_suspend() local
195 if (!pfdevfreq->devfreq) in panfrost_devfreq_suspend()
198 devfreq_suspend_device(pfdevfreq->devfreq); in panfrost_devfreq_suspend()
201 void panfrost_devfreq_record_busy(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_record_busy() argument
205 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_busy()
208 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
210 panfrost_devfreq_update_utilization(pfdevfreq); in panfrost_devfreq_record_busy()
212 pfdevfreq->busy_count++; in panfrost_devfreq_record_busy()
214 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
217 void panfrost_devfreq_record_idle(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_record_idle() argument
221 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_idle()
224 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()
226 panfrost_devfreq_update_utilization(pfdevfreq); in panfrost_devfreq_record_idle()
228 WARN_ON(--pfdevfreq->busy_count < 0); in panfrost_devfreq_record_idle()
230 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()