2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-29 23:53:55 +08:00
linux-next/include/linux/devfreq-event.h

192 lines
5.6 KiB
C
Raw Normal View History

PM / devfreq: event: Add devfreq_event class This patch adds a new class in devfreq, devfreq_event, which provides raw data (e.g., memory bus utilization, GPU utilization) for devfreq governors. - devfreq_event device : Provides raw data for a governor of a devfreq device - devfreq device : Monitors device state and changes frequency/voltage of the device using the raw data from its devfreq_event device. A devfreq device dertermines performance states (normally the frequency and the voltage vlues) based on the results its designtated devfreq governor: e.g., ondemand, performance, powersave. In order to give such results required by a devfreq device, the devfreq governor requires data that indicates the performance requirement given to the devfreq device. The conventional (previous) implementatino of devfreq subsystem requires a devfreq device driver to implement its own mechanism to acquire performance requirement for its governor. However, there had been issues with such requirements: 1. Although performance requirement of such devices is usually acquired from common devices (PMU/PPMU), we do not have any abstract structure to represent them properly. 2. Such performance requirement devices (PMU/PPMU) are actual hardware pieces that may be represented by Device Tree directly while devfreq device itself is a virtual entity that are not considered to be represented by Device Tree according to Device Tree folks. In order to address such issues, a devferq_event device (represented by this patch) provides a template for device drivers representing performance monitoring unit, which gives the basic or raw data for preformance requirement, which in turn, is required by devfreq governors. The following description explains the feature of two kind of devfreq class: - devfreq class (existing) : devfreq consumer device use raw data from devfreq_event device for determining proper current system state and change voltage/frequency dynamically using various governors. - devfreq_event class (new) : Provide measured raw data to devfreq device for governor Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> [Commit message rewritten & conflict resolved by MyungJoo] Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-01-26 12:16:27 +08:00
/*
* devfreq-event: a framework to provide raw data and events of devfreq devices
*
* Copyright (C) 2014 Samsung Electronics
* Author: Chanwoo Choi <cw00.choi@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __LINUX_DEVFREQ_EVENT_H__
#define __LINUX_DEVFREQ_EVENT_H__
#include <linux/device.h>
/**
* struct devfreq_event_dev - the devfreq-event device
*
* @node : Contain the devfreq-event device that have been registered.
* @dev : the device registered by devfreq-event class. dev.parent is
* the device using devfreq-event.
* @lock : a mutex to protect accessing devfreq-event.
* @enable_count: the number of enable function have been called.
* @desc : the description for devfreq-event device.
*
* This structure contains devfreq-event device information.
*/
struct devfreq_event_dev {
struct list_head node;
struct device dev;
struct mutex lock;
u32 enable_count;
const struct devfreq_event_desc *desc;
};
/**
* struct devfreq_event_data - the devfreq-event data
*
* @load_count : load count of devfreq-event device for the given period.
* @total_count : total count of devfreq-event device for the given period.
* each count may represent a clock cycle, a time unit
* (ns/us/...), or anything the device driver wants.
* Generally, utilization is load_count / total_count.
*
* This structure contains the data of devfreq-event device for polling period.
*/
struct devfreq_event_data {
unsigned long load_count;
unsigned long total_count;
};
/**
* struct devfreq_event_ops - the operations of devfreq-event device
*
* @enable : Enable the devfreq-event device.
* @disable : Disable the devfreq-event device.
* @reset : Reset all setting of the devfreq-event device.
* @set_event : Set the specific event type for the devfreq-event device.
* @get_event : Get the result of the devfreq-event devie with specific
* event type.
*
* This structure contains devfreq-event device operations which can be
* implemented by devfreq-event device drivers.
*/
struct devfreq_event_ops {
/* Optional functions */
int (*enable)(struct devfreq_event_dev *edev);
int (*disable)(struct devfreq_event_dev *edev);
int (*reset)(struct devfreq_event_dev *edev);
/* Mandatory functions */
int (*set_event)(struct devfreq_event_dev *edev);
int (*get_event)(struct devfreq_event_dev *edev,
struct devfreq_event_data *edata);
};
/**
* struct devfreq_event_desc - the descriptor of devfreq-event device
*
* @name : the name of devfreq-event device.
* @driver_data : the private data for devfreq-event driver.
* @ops : the operation to control devfreq-event device.
*
* Each devfreq-event device is described with a this structure.
* This structure contains the various data for devfreq-event device.
*/
struct devfreq_event_desc {
const char *name;
void *driver_data;
const struct devfreq_event_ops *ops;
PM / devfreq: event: Add devfreq_event class This patch adds a new class in devfreq, devfreq_event, which provides raw data (e.g., memory bus utilization, GPU utilization) for devfreq governors. - devfreq_event device : Provides raw data for a governor of a devfreq device - devfreq device : Monitors device state and changes frequency/voltage of the device using the raw data from its devfreq_event device. A devfreq device dertermines performance states (normally the frequency and the voltage vlues) based on the results its designtated devfreq governor: e.g., ondemand, performance, powersave. In order to give such results required by a devfreq device, the devfreq governor requires data that indicates the performance requirement given to the devfreq device. The conventional (previous) implementatino of devfreq subsystem requires a devfreq device driver to implement its own mechanism to acquire performance requirement for its governor. However, there had been issues with such requirements: 1. Although performance requirement of such devices is usually acquired from common devices (PMU/PPMU), we do not have any abstract structure to represent them properly. 2. Such performance requirement devices (PMU/PPMU) are actual hardware pieces that may be represented by Device Tree directly while devfreq device itself is a virtual entity that are not considered to be represented by Device Tree according to Device Tree folks. In order to address such issues, a devferq_event device (represented by this patch) provides a template for device drivers representing performance monitoring unit, which gives the basic or raw data for preformance requirement, which in turn, is required by devfreq governors. The following description explains the feature of two kind of devfreq class: - devfreq class (existing) : devfreq consumer device use raw data from devfreq_event device for determining proper current system state and change voltage/frequency dynamically using various governors. - devfreq_event class (new) : Provide measured raw data to devfreq device for governor Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> [Commit message rewritten & conflict resolved by MyungJoo] Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-01-26 12:16:27 +08:00
};
#if defined(CONFIG_PM_DEVFREQ_EVENT)
extern int devfreq_event_enable_edev(struct devfreq_event_dev *edev);
extern int devfreq_event_disable_edev(struct devfreq_event_dev *edev);
extern bool devfreq_event_is_enabled(struct devfreq_event_dev *edev);
extern int devfreq_event_set_event(struct devfreq_event_dev *edev);
extern int devfreq_event_get_event(struct devfreq_event_dev *edev,
struct devfreq_event_data *edata);
extern int devfreq_event_reset_event(struct devfreq_event_dev *edev);
extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, int index);
extern int devfreq_event_get_edev_count(struct device *dev);
extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
struct devfreq_event_desc *desc);
extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev);
extern struct devfreq_event_dev *devm_devfreq_event_add_edev(struct device *dev,
struct devfreq_event_desc *desc);
extern void devm_devfreq_event_remove_edev(struct device *dev,
struct devfreq_event_dev *edev);
static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
{
return edev->desc->driver_data;
}
#else
static inline int devfreq_event_enable_edev(struct devfreq_event_dev *edev)
{
return -EINVAL;
}
static inline int devfreq_event_disable_edev(struct devfreq_event_dev *edev)
{
return -EINVAL;
}
static inline bool devfreq_event_is_enabled(struct devfreq_event_dev *edev)
{
return false;
}
static inline int devfreq_event_set_event(struct devfreq_event_dev *edev)
{
return -EINVAL;
}
static inline int devfreq_event_get_event(struct devfreq_event_dev *edev,
struct devfreq_event_data *edata)
{
return -EINVAL;
}
static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
{
return -EINVAL;
}
static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, int index)
{
return ERR_PTR(-EINVAL);
}
static inline int devfreq_event_get_edev_count(struct device *dev)
{
return -EINVAL;
}
static inline struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
struct devfreq_event_desc *desc)
{
return ERR_PTR(-EINVAL);
}
static inline int devfreq_event_remove_edev(struct devfreq_event_dev *edev)
{
return -EINVAL;
}
static inline struct devfreq_event_dev *devm_devfreq_event_add_edev(
struct device *dev,
struct devfreq_event_desc *desc)
{
return ERR_PTR(-EINVAL);
}
static inline void devm_devfreq_event_remove_edev(struct device *dev,
struct devfreq_event_dev *edev)
{
}
static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
{
return NULL;
}
#endif /* CONFIG_PM_DEVFREQ_EVENT */
#endif /* __LINUX_DEVFREQ_EVENT_H__ */