• Home
  • Raw
  • Download

Lines Matching refs:devfreq

52 static struct devfreq *find_device_devfreq(struct device *dev)  in find_device_devfreq()
54 struct devfreq *tmp_devfreq; in find_device_devfreq()
76 static int devfreq_get_freq_level(struct devfreq *devfreq, unsigned long freq) in devfreq_get_freq_level() argument
80 for (lev = 0; lev < devfreq->profile->max_state; lev++) in devfreq_get_freq_level()
81 if (freq == devfreq->profile->freq_table[lev]) in devfreq_get_freq_level()
92 static int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) in devfreq_update_status() argument
99 prev_lev = devfreq_get_freq_level(devfreq, devfreq->previous_freq); in devfreq_update_status()
105 devfreq->time_in_state[prev_lev] += in devfreq_update_status()
106 cur_time - devfreq->last_stat_updated; in devfreq_update_status()
108 lev = devfreq_get_freq_level(devfreq, freq); in devfreq_update_status()
115 devfreq->trans_table[(prev_lev * in devfreq_update_status()
116 devfreq->profile->max_state) + lev]++; in devfreq_update_status()
117 devfreq->total_trans++; in devfreq_update_status()
121 devfreq->last_stat_updated = cur_time; in devfreq_update_status()
160 int update_devfreq(struct devfreq *devfreq) in update_devfreq() argument
166 if (!mutex_is_locked(&devfreq->lock)) { in update_devfreq()
171 if (!devfreq->governor) in update_devfreq()
175 err = devfreq->governor->get_target_freq(devfreq, &freq); in update_devfreq()
187 if (devfreq->min_freq && freq < devfreq->min_freq) { in update_devfreq()
188 freq = devfreq->min_freq; in update_devfreq()
191 if (devfreq->max_freq && freq > devfreq->max_freq) { in update_devfreq()
192 freq = devfreq->max_freq; in update_devfreq()
196 err = devfreq->profile->target(devfreq->dev.parent, &freq, flags); in update_devfreq()
200 if (devfreq->profile->freq_table) in update_devfreq()
201 if (devfreq_update_status(devfreq, freq)) in update_devfreq()
202 dev_err(&devfreq->dev, in update_devfreq()
205 devfreq->previous_freq = freq; in update_devfreq()
218 struct devfreq *devfreq = container_of(work, in devfreq_monitor() local
219 struct devfreq, work.work); in devfreq_monitor()
221 mutex_lock(&devfreq->lock); in devfreq_monitor()
222 err = update_devfreq(devfreq); in devfreq_monitor()
224 dev_err(&devfreq->dev, "dvfs failed with (%d) error\n", err); in devfreq_monitor()
226 queue_delayed_work(devfreq_wq, &devfreq->work, in devfreq_monitor()
227 msecs_to_jiffies(devfreq->profile->polling_ms)); in devfreq_monitor()
228 mutex_unlock(&devfreq->lock); in devfreq_monitor()
240 void devfreq_monitor_start(struct devfreq *devfreq) in devfreq_monitor_start() argument
242 INIT_DEFERRABLE_WORK(&devfreq->work, devfreq_monitor); in devfreq_monitor_start()
243 if (devfreq->profile->polling_ms) in devfreq_monitor_start()
244 queue_delayed_work(devfreq_wq, &devfreq->work, in devfreq_monitor_start()
245 msecs_to_jiffies(devfreq->profile->polling_ms)); in devfreq_monitor_start()
257 void devfreq_monitor_stop(struct devfreq *devfreq) in devfreq_monitor_stop() argument
259 cancel_delayed_work_sync(&devfreq->work); in devfreq_monitor_stop()
275 void devfreq_monitor_suspend(struct devfreq *devfreq) in devfreq_monitor_suspend() argument
277 mutex_lock(&devfreq->lock); in devfreq_monitor_suspend()
278 if (devfreq->stop_polling) { in devfreq_monitor_suspend()
279 mutex_unlock(&devfreq->lock); in devfreq_monitor_suspend()
283 devfreq_update_status(devfreq, devfreq->previous_freq); in devfreq_monitor_suspend()
284 devfreq->stop_polling = true; in devfreq_monitor_suspend()
285 mutex_unlock(&devfreq->lock); in devfreq_monitor_suspend()
286 cancel_delayed_work_sync(&devfreq->work); in devfreq_monitor_suspend()
298 void devfreq_monitor_resume(struct devfreq *devfreq) in devfreq_monitor_resume() argument
302 mutex_lock(&devfreq->lock); in devfreq_monitor_resume()
303 if (!devfreq->stop_polling) in devfreq_monitor_resume()
306 if (!delayed_work_pending(&devfreq->work) && in devfreq_monitor_resume()
307 devfreq->profile->polling_ms) in devfreq_monitor_resume()
308 queue_delayed_work(devfreq_wq, &devfreq->work, in devfreq_monitor_resume()
309 msecs_to_jiffies(devfreq->profile->polling_ms)); in devfreq_monitor_resume()
311 devfreq->last_stat_updated = jiffies; in devfreq_monitor_resume()
312 devfreq->stop_polling = false; in devfreq_monitor_resume()
314 if (devfreq->profile->get_cur_freq && in devfreq_monitor_resume()
315 !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) in devfreq_monitor_resume()
316 devfreq->previous_freq = freq; in devfreq_monitor_resume()
319 mutex_unlock(&devfreq->lock); in devfreq_monitor_resume()
331 void devfreq_interval_update(struct devfreq *devfreq, unsigned int *delay) in devfreq_interval_update() argument
333 unsigned int cur_delay = devfreq->profile->polling_ms; in devfreq_interval_update()
336 mutex_lock(&devfreq->lock); in devfreq_interval_update()
337 devfreq->profile->polling_ms = new_delay; in devfreq_interval_update()
339 if (devfreq->stop_polling) in devfreq_interval_update()
344 mutex_unlock(&devfreq->lock); in devfreq_interval_update()
345 cancel_delayed_work_sync(&devfreq->work); in devfreq_interval_update()
351 queue_delayed_work(devfreq_wq, &devfreq->work, in devfreq_interval_update()
352 msecs_to_jiffies(devfreq->profile->polling_ms)); in devfreq_interval_update()
358 mutex_unlock(&devfreq->lock); in devfreq_interval_update()
359 cancel_delayed_work_sync(&devfreq->work); in devfreq_interval_update()
360 mutex_lock(&devfreq->lock); in devfreq_interval_update()
361 if (!devfreq->stop_polling) in devfreq_interval_update()
362 queue_delayed_work(devfreq_wq, &devfreq->work, in devfreq_interval_update()
363 msecs_to_jiffies(devfreq->profile->polling_ms)); in devfreq_interval_update()
366 mutex_unlock(&devfreq->lock); in devfreq_interval_update()
382 struct devfreq *devfreq = container_of(nb, struct devfreq, nb); in devfreq_notifier_call() local
385 mutex_lock(&devfreq->lock); in devfreq_notifier_call()
386 ret = update_devfreq(devfreq); in devfreq_notifier_call()
387 mutex_unlock(&devfreq->lock); in devfreq_notifier_call()
397 static void _remove_devfreq(struct devfreq *devfreq) in _remove_devfreq() argument
400 if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) { in _remove_devfreq()
402 dev_warn(&devfreq->dev, "releasing devfreq which doesn't exist\n"); in _remove_devfreq()
405 list_del(&devfreq->node); in _remove_devfreq()
408 if (devfreq->governor) in _remove_devfreq()
409 devfreq->governor->event_handler(devfreq, in _remove_devfreq()
412 if (devfreq->profile->exit) in _remove_devfreq()
413 devfreq->profile->exit(devfreq->dev.parent); in _remove_devfreq()
415 mutex_destroy(&devfreq->lock); in _remove_devfreq()
416 kfree(devfreq); in _remove_devfreq()
427 struct devfreq *devfreq = to_devfreq(dev); in devfreq_dev_release() local
429 _remove_devfreq(devfreq); in devfreq_dev_release()
440 struct devfreq *devfreq_add_device(struct device *dev, in devfreq_add_device()
445 struct devfreq *devfreq; in devfreq_add_device() local
455 devfreq = find_device_devfreq(dev); in devfreq_add_device()
457 if (!IS_ERR(devfreq)) { in devfreq_add_device()
463 devfreq = kzalloc(sizeof(struct devfreq), GFP_KERNEL); in devfreq_add_device()
464 if (!devfreq) { in devfreq_add_device()
471 mutex_init(&devfreq->lock); in devfreq_add_device()
472 mutex_lock(&devfreq->lock); in devfreq_add_device()
473 devfreq->dev.parent = dev; in devfreq_add_device()
474 devfreq->dev.class = devfreq_class; in devfreq_add_device()
475 devfreq->dev.release = devfreq_dev_release; in devfreq_add_device()
476 devfreq->profile = profile; in devfreq_add_device()
477 strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); in devfreq_add_device()
478 devfreq->previous_freq = profile->initial_freq; in devfreq_add_device()
479 devfreq->data = data; in devfreq_add_device()
480 devfreq->nb.notifier_call = devfreq_notifier_call; in devfreq_add_device()
482 devfreq->trans_table = devm_kzalloc(dev, sizeof(unsigned int) * in devfreq_add_device()
483 devfreq->profile->max_state * in devfreq_add_device()
484 devfreq->profile->max_state, in devfreq_add_device()
486 devfreq->time_in_state = devm_kzalloc(dev, sizeof(unsigned int) * in devfreq_add_device()
487 devfreq->profile->max_state, in devfreq_add_device()
489 devfreq->last_stat_updated = jiffies; in devfreq_add_device()
491 dev_set_name(&devfreq->dev, "%s", dev_name(dev)); in devfreq_add_device()
492 err = device_register(&devfreq->dev); in devfreq_add_device()
494 put_device(&devfreq->dev); in devfreq_add_device()
495 mutex_unlock(&devfreq->lock); in devfreq_add_device()
499 mutex_unlock(&devfreq->lock); in devfreq_add_device()
502 list_add(&devfreq->node, &devfreq_list); in devfreq_add_device()
504 governor = find_devfreq_governor(devfreq->governor_name); in devfreq_add_device()
506 devfreq->governor = governor; in devfreq_add_device()
507 if (devfreq->governor) in devfreq_add_device()
508 err = devfreq->governor->event_handler(devfreq, in devfreq_add_device()
517 return devfreq; in devfreq_add_device()
520 list_del(&devfreq->node); in devfreq_add_device()
521 device_unregister(&devfreq->dev); in devfreq_add_device()
523 kfree(devfreq); in devfreq_add_device()
535 int devfreq_remove_device(struct devfreq *devfreq) in devfreq_remove_device() argument
537 if (!devfreq) in devfreq_remove_device()
540 device_unregister(&devfreq->dev); in devfreq_remove_device()
541 put_device(&devfreq->dev); in devfreq_remove_device()
549 struct devfreq **r = res; in devm_devfreq_dev_match()
559 devfreq_remove_device(*(struct devfreq **)res); in devm_devfreq_dev_release()
574 struct devfreq *devm_devfreq_add_device(struct device *dev, in devm_devfreq_add_device()
579 struct devfreq **ptr, *devfreq; in devm_devfreq_add_device() local
585 devfreq = devfreq_add_device(dev, profile, governor_name, data); in devm_devfreq_add_device()
586 if (IS_ERR(devfreq)) { in devm_devfreq_add_device()
591 *ptr = devfreq; in devm_devfreq_add_device()
594 return devfreq; in devm_devfreq_add_device()
603 void devm_devfreq_remove_device(struct device *dev, struct devfreq *devfreq) in devm_devfreq_remove_device() argument
606 devm_devfreq_dev_match, devfreq)); in devm_devfreq_remove_device()
618 int devfreq_suspend_device(struct devfreq *devfreq) in devfreq_suspend_device() argument
620 if (!devfreq) in devfreq_suspend_device()
623 if (!devfreq->governor) in devfreq_suspend_device()
626 return devfreq->governor->event_handler(devfreq, in devfreq_suspend_device()
639 int devfreq_resume_device(struct devfreq *devfreq) in devfreq_resume_device() argument
641 if (!devfreq) in devfreq_resume_device()
644 if (!devfreq->governor) in devfreq_resume_device()
647 return devfreq->governor->event_handler(devfreq, in devfreq_resume_device()
659 struct devfreq *devfreq; in devfreq_add_governor() local
678 list_for_each_entry(devfreq, &devfreq_list, node) { in devfreq_add_governor()
680 struct device *dev = devfreq->dev.parent; in devfreq_add_governor()
682 if (!strncmp(devfreq->governor_name, governor->name, in devfreq_add_governor()
685 if (devfreq->governor) { in devfreq_add_governor()
688 __func__, devfreq->governor->name); in devfreq_add_governor()
689 ret = devfreq->governor->event_handler(devfreq, in devfreq_add_governor()
695 devfreq->governor->name, ret); in devfreq_add_governor()
699 devfreq->governor = governor; in devfreq_add_governor()
700 ret = devfreq->governor->event_handler(devfreq, in devfreq_add_governor()
704 __func__, devfreq->governor->name, in devfreq_add_governor()
724 struct devfreq *devfreq; in devfreq_remove_governor() local
740 list_for_each_entry(devfreq, &devfreq_list, node) { in devfreq_remove_governor()
742 struct device *dev = devfreq->dev.parent; in devfreq_remove_governor()
744 if (!strncmp(devfreq->governor_name, governor->name, in devfreq_remove_governor()
747 if (!devfreq->governor) { in devfreq_remove_governor()
753 ret = devfreq->governor->event_handler(devfreq, in devfreq_remove_governor()
757 __func__, devfreq->governor->name, in devfreq_remove_governor()
760 devfreq->governor = NULL; in devfreq_remove_governor()
784 struct devfreq *df = to_devfreq(dev); in governor_store()
852 struct devfreq *devfreq = to_devfreq(dev); in cur_freq_show() local
854 if (devfreq->profile->get_cur_freq && in cur_freq_show()
855 !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) in cur_freq_show()
858 return sprintf(buf, "%lu\n", devfreq->previous_freq); in cur_freq_show()
879 struct devfreq *df = to_devfreq(dev); in polling_interval_store()
900 struct devfreq *df = to_devfreq(dev); in min_freq_store()
933 struct devfreq *df = to_devfreq(dev); in max_freq_store()
969 struct devfreq *df = to_devfreq(d); in available_frequencies_show()
1000 struct devfreq *devfreq = to_devfreq(dev); in trans_stat_show() local
1003 unsigned int max_state = devfreq->profile->max_state; in trans_stat_show()
1005 if (!devfreq->stop_polling && in trans_stat_show()
1006 devfreq_update_status(devfreq, devfreq->previous_freq)) in trans_stat_show()
1013 devfreq->profile->freq_table[i]); in trans_stat_show()
1018 if (devfreq->profile->freq_table[i] in trans_stat_show()
1019 == devfreq->previous_freq) { in trans_stat_show()
1025 devfreq->profile->freq_table[i]); in trans_stat_show()
1028 devfreq->trans_table[(i * max_state) + j]); in trans_stat_show()
1030 jiffies_to_msecs(devfreq->time_in_state[i])); in trans_stat_show()
1034 devfreq->total_trans); in trans_stat_show()
1051 ATTRIBUTE_GROUPS(devfreq);
1131 int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) in devfreq_register_opp_notifier() argument
1142 ret = srcu_notifier_chain_register(nh, &devfreq->nb); in devfreq_register_opp_notifier()
1158 int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq) in devfreq_unregister_opp_notifier() argument
1169 ret = srcu_notifier_chain_unregister(nh, &devfreq->nb); in devfreq_unregister_opp_notifier()
1177 devfreq_unregister_opp_notifier(dev, *(struct devfreq **)res); in devm_devfreq_opp_release()
1187 struct devfreq *devfreq) in devm_devfreq_register_opp_notifier() argument
1189 struct devfreq **ptr; in devm_devfreq_register_opp_notifier()
1196 ret = devfreq_register_opp_notifier(dev, devfreq); in devm_devfreq_register_opp_notifier()
1202 *ptr = devfreq; in devm_devfreq_register_opp_notifier()
1216 struct devfreq *devfreq) in devm_devfreq_unregister_opp_notifier() argument
1219 devm_devfreq_dev_match, devfreq)); in devm_devfreq_unregister_opp_notifier()