Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4c9d8ef authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'devfreq-for-next' of...

Merge branch 'devfreq-for-next' of git://git.infradead.org/users/kmpark/linux-samsung into pm-devfreq

* 'devfreq-for-next' of git://git.infradead.org/users/kmpark/linux-samsung:
  PM / devfreq: add min/max_freq limit requested by users.
  PM / devfreq: fixed syntax errors.
  devfreq: Remove MODULE_ALIAS for exynos4 busfreq driver
  devfreq: exynos4_bus: Use dev_get_drvdata at appropriate places
parents d2346963 6530b9de
Loading
Loading
Loading
Loading
+70 −0
Original line number Original line Diff line number Diff line
@@ -501,12 +501,82 @@ static ssize_t show_central_polling(struct device *dev,
		       !to_devfreq(dev)->governor->no_central_polling);
		       !to_devfreq(dev)->governor->no_central_polling);
}
}


static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
			      const char *buf, size_t count)
{
	struct devfreq *df = to_devfreq(dev);
	unsigned long value;
	int ret;
	unsigned long max;

	ret = sscanf(buf, "%lu", &value);
	if (ret != 1)
		goto out;

	mutex_lock(&df->lock);
	max = df->max_freq;
	if (value && max && value > max) {
		ret = -EINVAL;
		goto unlock;
	}

	df->min_freq = value;
	update_devfreq(df);
	ret = count;
unlock:
	mutex_unlock(&df->lock);
out:
	return ret;
}

static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr,
			     char *buf)
{
	return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq);
}

static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
			      const char *buf, size_t count)
{
	struct devfreq *df = to_devfreq(dev);
	unsigned long value;
	int ret;
	unsigned long min;

	ret = sscanf(buf, "%lu", &value);
	if (ret != 1)
		goto out;

	mutex_lock(&df->lock);
	min = df->min_freq;
	if (value && min && value < min) {
		ret = -EINVAL;
		goto unlock;
	}

	df->max_freq = value;
	update_devfreq(df);
	ret = count;
unlock:
	mutex_unlock(&df->lock);
out:
	return ret;
}

static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr,
			     char *buf)
{
	return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq);
}

static struct device_attribute devfreq_attrs[] = {
static struct device_attribute devfreq_attrs[] = {
	__ATTR(governor, S_IRUGO, show_governor, NULL),
	__ATTR(governor, S_IRUGO, show_governor, NULL),
	__ATTR(cur_freq, S_IRUGO, show_freq, NULL),
	__ATTR(cur_freq, S_IRUGO, show_freq, NULL),
	__ATTR(central_polling, S_IRUGO, show_central_polling, NULL),
	__ATTR(central_polling, S_IRUGO, show_central_polling, NULL),
	__ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval,
	__ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval,
	       store_polling_interval),
	       store_polling_interval),
	__ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq),
	__ATTR(max_freq, S_IRUGO | S_IWUSR, show_max_freq, store_max_freq),
	{ },
	{ },
};
};


+4 −13
Original line number Original line Diff line number Diff line
@@ -622,9 +622,7 @@ static int exynos4_bus_setvolt(struct busfreq_data *data, struct opp *opp,
static int exynos4_bus_target(struct device *dev, unsigned long *_freq)
static int exynos4_bus_target(struct device *dev, unsigned long *_freq)
{
{
	int err = 0;
	int err = 0;
	struct platform_device *pdev = container_of(dev, struct platform_device,
	struct busfreq_data *data = dev_get_drvdata(dev);
						    dev);
	struct busfreq_data *data = platform_get_drvdata(pdev);
	struct opp *opp = devfreq_recommended_opp(dev, _freq);
	struct opp *opp = devfreq_recommended_opp(dev, _freq);
	unsigned long old_freq = opp_get_freq(data->curr_opp);
	unsigned long old_freq = opp_get_freq(data->curr_opp);
	unsigned long freq = opp_get_freq(opp);
	unsigned long freq = opp_get_freq(opp);
@@ -689,9 +687,7 @@ static int exynos4_get_busier_dmc(struct busfreq_data *data)
static int exynos4_bus_get_dev_status(struct device *dev,
static int exynos4_bus_get_dev_status(struct device *dev,
				      struct devfreq_dev_status *stat)
				      struct devfreq_dev_status *stat)
{
{
	struct platform_device *pdev = container_of(dev, struct platform_device,
	struct busfreq_data *data = dev_get_drvdata(dev);
						    dev);
	struct busfreq_data *data = platform_get_drvdata(pdev);
	int busier_dmc;
	int busier_dmc;
	int cycles_x2 = 2; /* 2 x cycles */
	int cycles_x2 = 2; /* 2 x cycles */
	void __iomem *addr;
	void __iomem *addr;
@@ -739,9 +735,7 @@ static int exynos4_bus_get_dev_status(struct device *dev,


static void exynos4_bus_exit(struct device *dev)
static void exynos4_bus_exit(struct device *dev)
{
{
	struct platform_device *pdev = container_of(dev, struct platform_device,
	struct busfreq_data *data = dev_get_drvdata(dev);
						    dev);
	struct busfreq_data *data = platform_get_drvdata(pdev);


	devfreq_unregister_opp_notifier(dev, data->devfreq);
	devfreq_unregister_opp_notifier(dev, data->devfreq);
}
}
@@ -1087,9 +1081,7 @@ static __devexit int exynos4_busfreq_remove(struct platform_device *pdev)


static int exynos4_busfreq_resume(struct device *dev)
static int exynos4_busfreq_resume(struct device *dev)
{
{
	struct platform_device *pdev = container_of(dev, struct platform_device,
	struct busfreq_data *data = dev_get_drvdata(dev);
						    dev);
	struct busfreq_data *data = platform_get_drvdata(pdev);


	busfreq_mon_reset(data);
	busfreq_mon_reset(data);
	return 0;
	return 0;
@@ -1132,4 +1124,3 @@ module_exit(exynos4_busfreq_exit);
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("EXYNOS4 busfreq driver with devfreq framework");
MODULE_DESCRIPTION("EXYNOS4 busfreq driver with devfreq framework");
MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
MODULE_ALIAS("exynos4-busfreq");
+4 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,10 @@ static int devfreq_performance_func(struct devfreq *df,
	 * target callback should be able to get floor value as
	 * target callback should be able to get floor value as
	 * said in devfreq.h
	 * said in devfreq.h
	 */
	 */
	if (!df->max_freq)
		*freq = UINT_MAX;
		*freq = UINT_MAX;
	else
		*freq = df->max_freq;
	return 0;
	return 0;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ static int devfreq_powersave_func(struct devfreq *df,
	 * target callback should be able to get ceiling value as
	 * target callback should be able to get ceiling value as
	 * said in devfreq.h
	 * said in devfreq.h
	 */
	 */
	*freq = 0;
	*freq = df->min_freq;
	return 0;
	return 0;
}
}


+9 −3
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
	unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
	unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
	struct devfreq_simple_ondemand_data *data = df->data;
	struct devfreq_simple_ondemand_data *data = df->data;
	unsigned long max = (df->max_freq) ? df->max_freq : UINT_MAX;


	if (err)
	if (err)
		return err;
		return err;
@@ -41,7 +42,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,


	/* Assume MAX if it is going to be divided by zero */
	/* Assume MAX if it is going to be divided by zero */
	if (stat.total_time == 0) {
	if (stat.total_time == 0) {
		*freq = UINT_MAX;
		*freq = max;
		return 0;
		return 0;
	}
	}


@@ -54,13 +55,13 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
	/* Set MAX if it's busy enough */
	/* Set MAX if it's busy enough */
	if (stat.busy_time * 100 >
	if (stat.busy_time * 100 >
	    stat.total_time * dfso_upthreshold) {
	    stat.total_time * dfso_upthreshold) {
		*freq = UINT_MAX;
		*freq = max;
		return 0;
		return 0;
	}
	}


	/* Set MAX if we do not know the initial frequency */
	/* Set MAX if we do not know the initial frequency */
	if (stat.current_frequency == 0) {
	if (stat.current_frequency == 0) {
		*freq = UINT_MAX;
		*freq = max;
		return 0;
		return 0;
	}
	}


@@ -79,6 +80,11 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
	b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
	b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
	*freq = (unsigned long) b;
	*freq = (unsigned long) b;


	if (df->min_freq && *freq < df->min_freq)
		*freq = df->min_freq;
	if (df->max_freq && *freq > df->max_freq)
		*freq = df->max_freq;

	return 0;
	return 0;
}
}


Loading