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()
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()
53 static int panfrost_devfreq_get_dev_status(struct device *dev, in panfrost_devfreq_get_dev_status()
57 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_get_dev_status()
60 status->current_frequency = clk_get_rate(pfdev->clock); in panfrost_devfreq_get_dev_status()
62 spin_lock_irqsave(&pfdevfreq->lock, irqflags); 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()
73 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
75 dev_dbg(pfdev->dev, "busy %lu total %lu %lu %% freq %lu MHz\n", in panfrost_devfreq_get_dev_status()
76 status->busy_time, status->total_time, in panfrost_devfreq_get_dev_status()
77 status->busy_time / (status->total_time / 100), in panfrost_devfreq_get_dev_status()
78 status->current_frequency / 1000 / 1000); in panfrost_devfreq_get_dev_status()
94 struct device *dev = &pfdev->pdev->dev; in panfrost_devfreq_init()
97 struct thermal_cooling_device *cooling; in panfrost_devfreq_init() local
98 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_init()
100 opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, in panfrost_devfreq_init()
101 pfdev->comp->num_supplies); in panfrost_devfreq_init()
105 if (ret != -ENODEV) { in panfrost_devfreq_init()
110 pfdevfreq->regulators_opp_table = opp_table; in panfrost_devfreq_init()
116 if (ret == -ENODEV) 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()
126 cur_freq = clk_get_rate(pfdev->clock); in panfrost_devfreq_init()
144 pfdevfreq->devfreq = devfreq; in panfrost_devfreq_init()
146 cooling = of_devfreq_cooling_register(dev->of_node, devfreq); in panfrost_devfreq_init()
147 if (IS_ERR(cooling)) in panfrost_devfreq_init()
148 DRM_DEV_INFO(dev, "Failed to register cooling device\n"); in panfrost_devfreq_init()
150 pfdevfreq->cooling = cooling; in panfrost_devfreq_init()
161 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_fini()
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()
169 dev_pm_opp_of_remove_table(&pfdev->pdev->dev); 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()
183 if (!pfdevfreq->devfreq) 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()
195 if (!pfdevfreq->devfreq) in panfrost_devfreq_suspend()
198 devfreq_suspend_device(pfdevfreq->devfreq); in panfrost_devfreq_suspend()
205 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_busy()
208 spin_lock_irqsave(&pfdevfreq->lock, irqflags); 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()
221 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_idle()
224 spin_lock_irqsave(&pfdevfreq->lock, irqflags); 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()