Lines Matching +full:speed +full:- +full:bin
1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/nvmem-consumer.h>
19 last = pfdevfreq->time_last_update; in panfrost_devfreq_update_utilization()
21 if (pfdevfreq->busy_count > 0) in panfrost_devfreq_update_utilization()
22 pfdevfreq->busy_time += ktime_sub(now, last); in panfrost_devfreq_update_utilization()
24 pfdevfreq->idle_time += ktime_sub(now, last); in panfrost_devfreq_update_utilization()
26 pfdevfreq->time_last_update = now; in panfrost_devfreq_update_utilization()
43 ptdev->pfdevfreq.current_frequency = *freq; in panfrost_devfreq_target()
50 pfdevfreq->busy_time = 0; in panfrost_devfreq_reset()
51 pfdevfreq->idle_time = 0; in panfrost_devfreq_reset()
52 pfdevfreq->time_last_update = ktime_get(); in panfrost_devfreq_reset()
59 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_get_dev_status()
62 status->current_frequency = clk_get_rate(pfdev->clock); in panfrost_devfreq_get_dev_status()
64 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
68 status->total_time = ktime_to_ns(ktime_add(pfdevfreq->busy_time, in panfrost_devfreq_get_dev_status()
69 pfdevfreq->idle_time)); in panfrost_devfreq_get_dev_status()
71 status->busy_time = ktime_to_ns(pfdevfreq->busy_time); in panfrost_devfreq_get_dev_status()
75 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
77 dev_dbg(pfdev->dev, "busy %lu total %lu %lu %% freq %lu MHz\n", in panfrost_devfreq_get_dev_status()
78 status->busy_time, status->total_time, in panfrost_devfreq_get_dev_status()
79 status->busy_time / (status->total_time / 100), in panfrost_devfreq_get_dev_status()
80 status->current_frequency / 1000 / 1000); in panfrost_devfreq_get_dev_status()
97 ret = nvmem_cell_read_variable_le_u32(dev, "speed-bin", &val); in panfrost_read_speedbin()
100 * -ENOENT means that this platform doesn't support speedbins in panfrost_read_speedbin()
101 * as it didn't declare any speed-bin nvmem: in this case, we in panfrost_read_speedbin()
103 * supposed to read the bin value, but we failed doing so. in panfrost_read_speedbin()
105 if (ret != -ENOENT && ret != -EOPNOTSUPP) { in panfrost_read_speedbin()
106 DRM_DEV_ERROR(dev, "Cannot read speed-bin (%d).", ret); in panfrost_read_speedbin()
112 DRM_DEV_DEBUG(dev, "Using speed-bin = 0x%x\n", val); in panfrost_read_speedbin()
122 struct device *dev = &pfdev->pdev->dev; in panfrost_devfreq_init()
125 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_init()
128 if (pfdev->comp->num_supplies > 1) { in panfrost_devfreq_init()
130 * GPUs with more than 1 supply require platform-specific handling: in panfrost_devfreq_init()
141 ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names); in panfrost_devfreq_init()
144 if (ret != -ENODEV) { in panfrost_devfreq_init()
145 if (ret != -EPROBE_DEFER) in panfrost_devfreq_init()
154 if (ret == -ENODEV) in panfrost_devfreq_init()
158 pfdevfreq->opp_of_table_added = true; in panfrost_devfreq_init()
160 spin_lock_init(&pfdevfreq->lock); in panfrost_devfreq_init()
164 cur_freq = clk_get_rate(pfdev->clock); in panfrost_devfreq_init()
178 pfdevfreq->current_frequency = cur_freq; in panfrost_devfreq_init()
194 pfdevfreq->fast_rate = freq; in panfrost_devfreq_init()
202 pfdevfreq->gov_data.upthreshold = 45; in panfrost_devfreq_init()
203 pfdevfreq->gov_data.downdifferential = 5; in panfrost_devfreq_init()
207 &pfdevfreq->gov_data); in panfrost_devfreq_init()
212 pfdevfreq->devfreq = devfreq; in panfrost_devfreq_init()
218 pfdevfreq->cooling = cooling; in panfrost_devfreq_init()
225 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_fini()
227 if (pfdevfreq->cooling) { in panfrost_devfreq_fini()
228 devfreq_cooling_unregister(pfdevfreq->cooling); in panfrost_devfreq_fini()
229 pfdevfreq->cooling = NULL; in panfrost_devfreq_fini()
235 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_resume()
237 if (!pfdevfreq->devfreq) in panfrost_devfreq_resume()
242 devfreq_resume_device(pfdevfreq->devfreq); in panfrost_devfreq_resume()
247 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_suspend()
249 if (!pfdevfreq->devfreq) in panfrost_devfreq_suspend()
252 devfreq_suspend_device(pfdevfreq->devfreq); in panfrost_devfreq_suspend()
259 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_busy()
262 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
266 pfdevfreq->busy_count++; in panfrost_devfreq_record_busy()
268 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
275 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_idle()
278 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()
282 WARN_ON(--pfdevfreq->busy_count < 0); in panfrost_devfreq_record_idle()
284 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()