mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
PM / devfreq: rockchip_dmc: Add sysfs interface for ondemand_data
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Change-Id: I399a78aa2f63b266824a5cd302328a0d3e2aadcd
This commit is contained in:
@@ -2349,6 +2349,64 @@ static ssize_t rockchip_dmcfreq_status_store(struct device *dev,
|
||||
static DEVICE_ATTR(system_status, 0644, rockchip_dmcfreq_status_show,
|
||||
rockchip_dmcfreq_status_store);
|
||||
|
||||
static ssize_t upthreshold_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct rockchip_dmcfreq *dmcfreq = dev_get_drvdata(dev->parent);
|
||||
struct rockchip_dmcfreq_ondemand_data *data = &dmcfreq->ondemand_data;
|
||||
|
||||
return sprintf(buf, "%d\n", data->upthreshold);
|
||||
}
|
||||
|
||||
static ssize_t upthreshold_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
struct rockchip_dmcfreq *dmcfreq = dev_get_drvdata(dev->parent);
|
||||
struct rockchip_dmcfreq_ondemand_data *data = &dmcfreq->ondemand_data;
|
||||
unsigned int value;
|
||||
|
||||
if (kstrtouint(buf, 10, &value))
|
||||
return -EINVAL;
|
||||
|
||||
data->upthreshold = value;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RW(upthreshold);
|
||||
|
||||
static ssize_t downdifferential_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct rockchip_dmcfreq *dmcfreq = dev_get_drvdata(dev->parent);
|
||||
struct rockchip_dmcfreq_ondemand_data *data = &dmcfreq->ondemand_data;
|
||||
|
||||
return sprintf(buf, "%d\n", data->downdifferential);
|
||||
}
|
||||
|
||||
static ssize_t downdifferential_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
struct rockchip_dmcfreq *dmcfreq = dev_get_drvdata(dev->parent);
|
||||
struct rockchip_dmcfreq_ondemand_data *data = &dmcfreq->ondemand_data;
|
||||
unsigned int value;
|
||||
|
||||
if (kstrtouint(buf, 10, &value))
|
||||
return -EINVAL;
|
||||
|
||||
data->downdifferential = value;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RW(downdifferential);
|
||||
|
||||
static int devfreq_dmc_ondemand_func(struct devfreq *df,
|
||||
unsigned long *freq)
|
||||
{
|
||||
@@ -2776,6 +2834,14 @@ static void rockchip_dmcfreq_add_interface(struct rockchip_dmcfreq *dmcfreq)
|
||||
{
|
||||
struct devfreq *devfreq = dmcfreq->info.devfreq;
|
||||
|
||||
if (sysfs_create_file(&devfreq->dev.kobj, &dev_attr_upthreshold.attr))
|
||||
dev_err(dmcfreq->dev,
|
||||
"failed to register upthreshold sysfs file\n");
|
||||
if (sysfs_create_file(&devfreq->dev.kobj,
|
||||
&dev_attr_downdifferential.attr))
|
||||
dev_err(dmcfreq->dev,
|
||||
"failed to register downdifferential sysfs file\n");
|
||||
|
||||
if (!rockchip_add_system_status_interface(&devfreq->dev))
|
||||
return;
|
||||
if (sysfs_create_file(&devfreq->dev.kobj,
|
||||
|
||||
Reference in New Issue
Block a user