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

1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/device.h>
24 last = devfreq->time_last_update; in lima_devfreq_update_utilization()
26 if (devfreq->busy_count > 0) in lima_devfreq_update_utilization()
27 devfreq->busy_time += ktime_sub(now, last); in lima_devfreq_update_utilization()
29 devfreq->idle_time += ktime_sub(now, last); in lima_devfreq_update_utilization()
31 devfreq->time_last_update = now; in lima_devfreq_update_utilization()
34 static int lima_devfreq_target(struct device *dev, unsigned long *freq, in lima_devfreq_target()
49 devfreq->busy_time = 0; in lima_devfreq_reset()
50 devfreq->idle_time = 0; in lima_devfreq_reset()
51 devfreq->time_last_update = ktime_get(); in lima_devfreq_reset()
54 static int lima_devfreq_get_dev_status(struct device *dev, in lima_devfreq_get_dev_status()
58 struct lima_devfreq *devfreq = &ldev->devfreq; in lima_devfreq_get_dev_status()
61 status->current_frequency = clk_get_rate(ldev->clk_gpu); in lima_devfreq_get_dev_status()
63 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_get_dev_status()
67 status->total_time = ktime_to_ns(ktime_add(devfreq->busy_time, in lima_devfreq_get_dev_status()
68 devfreq->idle_time)); in lima_devfreq_get_dev_status()
69 status->busy_time = ktime_to_ns(devfreq->busy_time); in lima_devfreq_get_dev_status()
73 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_get_dev_status()
75 dev_dbg(ldev->dev, "busy %lu total %lu %lu %% freq %lu MHz\n", in lima_devfreq_get_dev_status()
76 status->busy_time, status->total_time, in lima_devfreq_get_dev_status()
77 status->busy_time / (status->total_time / 100), in lima_devfreq_get_dev_status()
78 status->current_frequency / 1000 / 1000); in lima_devfreq_get_dev_status()
92 struct lima_devfreq *devfreq = &ldev->devfreq; in lima_devfreq_fini()
94 if (devfreq->cooling) { in lima_devfreq_fini()
95 devfreq_cooling_unregister(devfreq->cooling); in lima_devfreq_fini()
96 devfreq->cooling = NULL; in lima_devfreq_fini()
99 if (devfreq->devfreq) { in lima_devfreq_fini()
100 devm_devfreq_remove_device(ldev->dev, devfreq->devfreq); in lima_devfreq_fini()
101 devfreq->devfreq = NULL; in lima_devfreq_fini()
107 struct thermal_cooling_device *cooling; in lima_devfreq_init() local
108 struct device *dev = ldev->dev; in lima_devfreq_init()
110 struct lima_devfreq *ldevfreq = &ldev->devfreq; in lima_devfreq_init()
116 if (!device_property_present(dev, "operating-points-v2")) in lima_devfreq_init()
120 spin_lock_init(&ldevfreq->lock); in lima_devfreq_init()
133 if (ret != -ENODEV) in lima_devfreq_init()
143 cur_freq = clk_get_rate(ldev->clk_gpu); in lima_devfreq_init()
156 ldevfreq->gov_data.upthreshold = 30; in lima_devfreq_init()
157 ldevfreq->gov_data.downdifferential = 5; in lima_devfreq_init()
161 &ldevfreq->gov_data); in lima_devfreq_init()
167 ldevfreq->devfreq = devfreq; in lima_devfreq_init()
169 cooling = of_devfreq_cooling_register(dev->of_node, devfreq); in lima_devfreq_init()
170 if (IS_ERR(cooling)) in lima_devfreq_init()
171 dev_info(dev, "Failed to register cooling device\n"); in lima_devfreq_init()
173 ldevfreq->cooling = cooling; in lima_devfreq_init()
182 if (!devfreq->devfreq) in lima_devfreq_record_busy()
185 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_record_busy()
189 devfreq->busy_count++; in lima_devfreq_record_busy()
191 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_record_busy()
198 if (!devfreq->devfreq) in lima_devfreq_record_idle()
201 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_record_idle()
205 WARN_ON(--devfreq->busy_count < 0); in lima_devfreq_record_idle()
207 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_record_idle()
214 if (!devfreq->devfreq) in lima_devfreq_resume()
217 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_resume()
221 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_resume()
223 return devfreq_resume_device(devfreq->devfreq); in lima_devfreq_resume()
228 if (!devfreq->devfreq) in lima_devfreq_suspend()
231 return devfreq_suspend_device(devfreq->devfreq); in lima_devfreq_suspend()