13d0407baSopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
23d0407baSopenharmony_ci/*
33d0407baSopenharmony_ci * governor.h - internal header for devfreq governors.
43d0407baSopenharmony_ci *
53d0407baSopenharmony_ci * Copyright (C) 2011 Samsung Electronics
63d0407baSopenharmony_ci *	MyungJoo Ham <myungjoo.ham@samsung.com>
73d0407baSopenharmony_ci *
83d0407baSopenharmony_ci * This header is for devfreq governors in drivers/devfreq/
93d0407baSopenharmony_ci */
103d0407baSopenharmony_ci
113d0407baSopenharmony_ci#ifndef _GOVERNOR_H
123d0407baSopenharmony_ci#define _GOVERNOR_H
133d0407baSopenharmony_ci
143d0407baSopenharmony_ci#include <linux/devfreq.h>
153d0407baSopenharmony_ci
163d0407baSopenharmony_ci#define to_devfreq(DEV)	container_of((DEV), struct devfreq, dev)
173d0407baSopenharmony_ci
183d0407baSopenharmony_ci/* Devfreq events */
193d0407baSopenharmony_ci#define DEVFREQ_GOV_START			0x1
203d0407baSopenharmony_ci#define DEVFREQ_GOV_STOP			0x2
213d0407baSopenharmony_ci#define DEVFREQ_GOV_UPDATE_INTERVAL		0x3
223d0407baSopenharmony_ci#define DEVFREQ_GOV_SUSPEND			0x4
233d0407baSopenharmony_ci#define DEVFREQ_GOV_RESUME			0x5
243d0407baSopenharmony_ci
253d0407baSopenharmony_ci#define DEVFREQ_MIN_FREQ			0
263d0407baSopenharmony_ci#define DEVFREQ_MAX_FREQ			ULONG_MAX
273d0407baSopenharmony_ci
283d0407baSopenharmony_ci/**
293d0407baSopenharmony_ci * struct devfreq_governor - Devfreq policy governor
303d0407baSopenharmony_ci * @node:		list node - contains registered devfreq governors
313d0407baSopenharmony_ci * @name:		Governor's name
323d0407baSopenharmony_ci * @immutable:		Immutable flag for governor. If the value is 1,
333d0407baSopenharmony_ci *			this governor is never changeable to other governor.
343d0407baSopenharmony_ci * @interrupt_driven:	Devfreq core won't schedule polling work for this
353d0407baSopenharmony_ci *			governor if value is set to 1.
363d0407baSopenharmony_ci * @get_target_freq:	Returns desired operating frequency for the device.
373d0407baSopenharmony_ci *			Basically, get_target_freq will run
383d0407baSopenharmony_ci *			devfreq_dev_profile.get_dev_status() to get the
393d0407baSopenharmony_ci *			status of the device (load = busy_time / total_time).
403d0407baSopenharmony_ci *			If no_central_polling is set, this callback is called
413d0407baSopenharmony_ci *			only with update_devfreq() notified by OPP.
423d0407baSopenharmony_ci * @event_handler:      Callback for devfreq core framework to notify events
433d0407baSopenharmony_ci *                      to governors. Events include per device governor
443d0407baSopenharmony_ci *                      init and exit, opp changes out of devfreq, suspend
453d0407baSopenharmony_ci *                      and resume of per device devfreq during device idle.
463d0407baSopenharmony_ci *
473d0407baSopenharmony_ci * Note that the callbacks are called with devfreq->lock locked by devfreq.
483d0407baSopenharmony_ci */
493d0407baSopenharmony_cistruct devfreq_governor {
503d0407baSopenharmony_ci	struct list_head node;
513d0407baSopenharmony_ci
523d0407baSopenharmony_ci	const char name[DEVFREQ_NAME_LEN];
533d0407baSopenharmony_ci	const unsigned int immutable;
543d0407baSopenharmony_ci	const unsigned int interrupt_driven;
553d0407baSopenharmony_ci	int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
563d0407baSopenharmony_ci	int (*event_handler)(struct devfreq *devfreq,
573d0407baSopenharmony_ci				unsigned int event, void *data);
583d0407baSopenharmony_ci};
593d0407baSopenharmony_ci
603d0407baSopenharmony_civoid devfreq_monitor_start(struct devfreq *devfreq);
613d0407baSopenharmony_civoid devfreq_monitor_stop(struct devfreq *devfreq);
623d0407baSopenharmony_civoid devfreq_monitor_suspend(struct devfreq *devfreq);
633d0407baSopenharmony_civoid devfreq_monitor_resume(struct devfreq *devfreq);
643d0407baSopenharmony_civoid devfreq_update_interval(struct devfreq *devfreq, unsigned int *delay);
653d0407baSopenharmony_ci
663d0407baSopenharmony_ciint devfreq_add_governor(struct devfreq_governor *governor);
673d0407baSopenharmony_ciint devfreq_remove_governor(struct devfreq_governor *governor);
683d0407baSopenharmony_ci
693d0407baSopenharmony_ciint devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
703d0407baSopenharmony_ci
713d0407baSopenharmony_cistatic inline int devfreq_update_stats(struct devfreq *df)
723d0407baSopenharmony_ci{
733d0407baSopenharmony_ci	return df->profile->get_dev_status(df->dev.parent, &df->last_status);
743d0407baSopenharmony_ci}
753d0407baSopenharmony_ci#endif /* _GOVERNOR_H */
76