diff --git a/drivers/devfreq/rockchip_dmc.c b/drivers/devfreq/rockchip_dmc.c index 4b856fcce16b..0e6b76df8455 100644 --- a/drivers/devfreq/rockchip_dmc.c +++ b/drivers/devfreq/rockchip_dmc.c @@ -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,