18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * governor.h - internal header for devfreq governors. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011 Samsung Electronics 68c2ecf20Sopenharmony_ci * MyungJoo Ham <myungjoo.ham@samsung.com> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This header is for devfreq governors in drivers/devfreq/ 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _GOVERNOR_H 128c2ecf20Sopenharmony_ci#define _GOVERNOR_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/devfreq.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define to_devfreq(DEV) container_of((DEV), struct devfreq, dev) 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* Devfreq events */ 198c2ecf20Sopenharmony_ci#define DEVFREQ_GOV_START 0x1 208c2ecf20Sopenharmony_ci#define DEVFREQ_GOV_STOP 0x2 218c2ecf20Sopenharmony_ci#define DEVFREQ_GOV_UPDATE_INTERVAL 0x3 228c2ecf20Sopenharmony_ci#define DEVFREQ_GOV_SUSPEND 0x4 238c2ecf20Sopenharmony_ci#define DEVFREQ_GOV_RESUME 0x5 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define DEVFREQ_MIN_FREQ 0 268c2ecf20Sopenharmony_ci#define DEVFREQ_MAX_FREQ ULONG_MAX 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/** 298c2ecf20Sopenharmony_ci * struct devfreq_governor - Devfreq policy governor 308c2ecf20Sopenharmony_ci * @node: list node - contains registered devfreq governors 318c2ecf20Sopenharmony_ci * @name: Governor's name 328c2ecf20Sopenharmony_ci * @immutable: Immutable flag for governor. If the value is 1, 338c2ecf20Sopenharmony_ci * this governor is never changeable to other governor. 348c2ecf20Sopenharmony_ci * @interrupt_driven: Devfreq core won't schedule polling work for this 358c2ecf20Sopenharmony_ci * governor if value is set to 1. 368c2ecf20Sopenharmony_ci * @get_target_freq: Returns desired operating frequency for the device. 378c2ecf20Sopenharmony_ci * Basically, get_target_freq will run 388c2ecf20Sopenharmony_ci * devfreq_dev_profile.get_dev_status() to get the 398c2ecf20Sopenharmony_ci * status of the device (load = busy_time / total_time). 408c2ecf20Sopenharmony_ci * If no_central_polling is set, this callback is called 418c2ecf20Sopenharmony_ci * only with update_devfreq() notified by OPP. 428c2ecf20Sopenharmony_ci * @event_handler: Callback for devfreq core framework to notify events 438c2ecf20Sopenharmony_ci * to governors. Events include per device governor 448c2ecf20Sopenharmony_ci * init and exit, opp changes out of devfreq, suspend 458c2ecf20Sopenharmony_ci * and resume of per device devfreq during device idle. 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * Note that the callbacks are called with devfreq->lock locked by devfreq. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_cistruct devfreq_governor { 508c2ecf20Sopenharmony_ci struct list_head node; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci const char name[DEVFREQ_NAME_LEN]; 538c2ecf20Sopenharmony_ci const unsigned int immutable; 548c2ecf20Sopenharmony_ci const unsigned int interrupt_driven; 558c2ecf20Sopenharmony_ci int (*get_target_freq)(struct devfreq *this, unsigned long *freq); 568c2ecf20Sopenharmony_ci int (*event_handler)(struct devfreq *devfreq, 578c2ecf20Sopenharmony_ci unsigned int event, void *data); 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_civoid devfreq_monitor_start(struct devfreq *devfreq); 618c2ecf20Sopenharmony_civoid devfreq_monitor_stop(struct devfreq *devfreq); 628c2ecf20Sopenharmony_civoid devfreq_monitor_suspend(struct devfreq *devfreq); 638c2ecf20Sopenharmony_civoid devfreq_monitor_resume(struct devfreq *devfreq); 648c2ecf20Sopenharmony_civoid devfreq_update_interval(struct devfreq *devfreq, unsigned int *delay); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciint devfreq_add_governor(struct devfreq_governor *governor); 678c2ecf20Sopenharmony_ciint devfreq_remove_governor(struct devfreq_governor *governor); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciint devfreq_update_status(struct devfreq *devfreq, unsigned long freq); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistatic inline int devfreq_update_stats(struct devfreq *df) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci return df->profile->get_dev_status(df->dev.parent, &df->last_status); 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci#endif /* _GOVERNOR_H */ 76