Lines Matching +full:cooling +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0
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()
28 static int panfrost_devfreq_target(struct device *dev, unsigned long *freq, in panfrost_devfreq_target()
43 pfdevfreq->busy_time = 0; in panfrost_devfreq_reset()
44 pfdevfreq->idle_time = 0; in panfrost_devfreq_reset()
45 pfdevfreq->time_last_update = ktime_get(); in panfrost_devfreq_reset()
48 static int panfrost_devfreq_get_dev_status(struct device *dev, in panfrost_devfreq_get_dev_status()
52 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_get_dev_status()
55 status->current_frequency = clk_get_rate(pfdev->clock); in panfrost_devfreq_get_dev_status()
57 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
61 status->total_time = ktime_to_ns(ktime_add(pfdevfreq->busy_time, in panfrost_devfreq_get_dev_status()
62 pfdevfreq->idle_time)); in panfrost_devfreq_get_dev_status()
64 status->busy_time = ktime_to_ns(pfdevfreq->busy_time); in panfrost_devfreq_get_dev_status()
68 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
70 dev_dbg(pfdev->dev, "busy %lu total %lu %lu %% freq %lu MHz\n", in panfrost_devfreq_get_dev_status()
71 status->busy_time, status->total_time, in panfrost_devfreq_get_dev_status()
72 status->busy_time / (status->total_time / 100), in panfrost_devfreq_get_dev_status()
73 status->current_frequency / 1000 / 1000); in panfrost_devfreq_get_dev_status()
90 struct device *dev = &pfdev->pdev->dev; in panfrost_devfreq_init()
92 struct thermal_cooling_device *cooling; in panfrost_devfreq_init() local
93 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_init()
95 if (pfdev->comp->num_supplies > 1) { in panfrost_devfreq_init()
97 * GPUs with more than 1 supply require platform-specific handling: in panfrost_devfreq_init()
104 ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names); in panfrost_devfreq_init()
107 if (ret != -ENODEV) { in panfrost_devfreq_init()
108 if (ret != -EPROBE_DEFER) in panfrost_devfreq_init()
117 if (ret == -ENODEV) in panfrost_devfreq_init()
121 pfdevfreq->opp_of_table_added = true; in panfrost_devfreq_init()
123 spin_lock_init(&pfdevfreq->lock); in panfrost_devfreq_init()
127 cur_freq = clk_get_rate(pfdev->clock); in panfrost_devfreq_init()
151 pfdevfreq->gov_data.upthreshold = 45; in panfrost_devfreq_init()
152 pfdevfreq->gov_data.downdifferential = 5; in panfrost_devfreq_init()
156 &pfdevfreq->gov_data); in panfrost_devfreq_init()
161 pfdevfreq->devfreq = devfreq; in panfrost_devfreq_init()
163 cooling = devfreq_cooling_em_register(devfreq, NULL); in panfrost_devfreq_init()
164 if (IS_ERR(cooling)) in panfrost_devfreq_init()
165 DRM_DEV_INFO(dev, "Failed to register cooling device\n"); in panfrost_devfreq_init()
167 pfdevfreq->cooling = cooling; in panfrost_devfreq_init()
174 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_fini()
176 if (pfdevfreq->cooling) { in panfrost_devfreq_fini()
177 devfreq_cooling_unregister(pfdevfreq->cooling); in panfrost_devfreq_fini()
178 pfdevfreq->cooling = NULL; in panfrost_devfreq_fini()
184 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_resume()
186 if (!pfdevfreq->devfreq) in panfrost_devfreq_resume()
191 devfreq_resume_device(pfdevfreq->devfreq); in panfrost_devfreq_resume()
196 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_suspend()
198 if (!pfdevfreq->devfreq) in panfrost_devfreq_suspend()
201 devfreq_suspend_device(pfdevfreq->devfreq); in panfrost_devfreq_suspend()
208 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_busy()
211 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
215 pfdevfreq->busy_count++; in panfrost_devfreq_record_busy()
217 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
224 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_idle()
227 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()
231 WARN_ON(--pfdevfreq->busy_count < 0); in panfrost_devfreq_record_idle()
233 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()