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

Merge tag 'devfreq-next-for-5.10' of...

Merge tag 'devfreq-next-for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux into pm-devfreq

Pull devfreq updates for 5.10 from Chanwoo Choi:

"1. Update devfreq core
  -  Until now, devfreq and devfreq-event framework defined the fixed
     'devfreq' and 'devfreq-event' property to get the devfreq/devfreq-event
     phandle. But, these property names are not expressing the h/w. So,
     deprecate the fixed property names 'devfreq' and 'devfreq-event'. But,
     in order to keep the backward compatibility of devicetree, don't
     change the property name on devfreq device drivers and devicetree.

 2. Update devfreq driver
  - Replace reset_control_(assert|dessert) fucntions with reset_control_reset()
    for reseting the h/w during probe on tegra30-devfreq.c."

* tag 'devfreq-next-for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux:
  PM / devfreq: tegra30: Improve initial hardware resetting
  PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function
  PM / devfreq: Change prototype of devfreq_get_devfreq_by_phandle function
  PM / devfreq: Add devfreq_get_devfreq_by_node function
parents a1b8638b d353d120
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -213,20 +213,21 @@ EXPORT_SYMBOL_GPL(devfreq_event_reset_event);
 * devfreq_event_get_edev_by_phandle() - Get the devfreq-event dev from
 *					 devicetree.
 * @dev		: the pointer to the given device
 * @phandle_name: name of property holding a phandle value
 * @index	: the index into list of devfreq-event device
 *
 * Note that this function return the pointer of devfreq-event device.
 */
struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
						      int index)
					const char *phandle_name, int index)
{
	struct device_node *node;
	struct devfreq_event_dev *edev;

	if (!dev->of_node)
	if (!dev->of_node || !phandle_name)
		return ERR_PTR(-EINVAL);

	node = of_parse_phandle(dev->of_node, "devfreq-events", index);
	node = of_parse_phandle(dev->of_node, phandle_name, index);
	if (!node)
		return ERR_PTR(-ENODEV);

@@ -258,19 +259,20 @@ EXPORT_SYMBOL_GPL(devfreq_event_get_edev_by_phandle);
/**
 * devfreq_event_get_edev_count() - Get the count of devfreq-event dev
 * @dev		: the pointer to the given device
 * @phandle_name: name of property holding a phandle value
 *
 * Note that this function return the count of devfreq-event devices.
 */
int devfreq_event_get_edev_count(struct device *dev)
int devfreq_event_get_edev_count(struct device *dev, const char *phandle_name)
{
	int count;

	if (!dev->of_node) {
	if (!dev->of_node || !phandle_name) {
		dev_err(dev, "device does not have a device node entry\n");
		return -EINVAL;
	}

	count = of_property_count_elems_of_size(dev->of_node, "devfreq-events",
	count = of_property_count_elems_of_size(dev->of_node, phandle_name,
						sizeof(u32));
	if (count < 0) {
		dev_err(dev,
+42 −15
Original line number Diff line number Diff line
@@ -983,48 +983,75 @@ struct devfreq *devm_devfreq_add_device(struct device *dev,
EXPORT_SYMBOL(devm_devfreq_add_device);

#ifdef CONFIG_OF
/*
 * devfreq_get_devfreq_by_node - Get the devfreq device from devicetree
 * @node - pointer to device_node
 *
 * return the instance of devfreq device
 */
struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
{
	struct devfreq *devfreq;

	if (!node)
		return ERR_PTR(-EINVAL);

	mutex_lock(&devfreq_list_lock);
	list_for_each_entry(devfreq, &devfreq_list, node) {
		if (devfreq->dev.parent
			&& devfreq->dev.parent->of_node == node) {
			mutex_unlock(&devfreq_list_lock);
			return devfreq;
		}
	}
	mutex_unlock(&devfreq_list_lock);

	return ERR_PTR(-ENODEV);
}

/*
 * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree
 * @dev - instance to the given device
 * @phandle_name - name of property holding a phandle value
 * @index - index into list of devfreq
 *
 * return the instance of devfreq device
 */
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
					const char *phandle_name, int index)
{
	struct device_node *node;
	struct devfreq *devfreq;

	if (!dev)
	if (!dev || !phandle_name)
		return ERR_PTR(-EINVAL);

	if (!dev->of_node)
		return ERR_PTR(-EINVAL);

	node = of_parse_phandle(dev->of_node, "devfreq", index);
	node = of_parse_phandle(dev->of_node, phandle_name, index);
	if (!node)
		return ERR_PTR(-ENODEV);

	mutex_lock(&devfreq_list_lock);
	list_for_each_entry(devfreq, &devfreq_list, node) {
		if (devfreq->dev.parent
			&& devfreq->dev.parent->of_node == node) {
			mutex_unlock(&devfreq_list_lock);
	devfreq = devfreq_get_devfreq_by_node(node);
	of_node_put(node);

	return devfreq;
}
	}
	mutex_unlock(&devfreq_list_lock);
	of_node_put(node);

	return ERR_PTR(-EPROBE_DEFER);
}
#else
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
{
	return ERR_PTR(-ENODEV);
}

struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
					const char *phandle_name, int index)
{
	return ERR_PTR(-ENODEV);
}
#endif /* CONFIG_OF */
EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_node);
EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle);

/**
+4 −3
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
	 * Get the devfreq-event devices to get the current utilization of
	 * buses. This raw data will be used in devfreq ondemand governor.
	 */
	count = devfreq_event_get_edev_count(dev);
	count = devfreq_event_get_edev_count(dev, "devfreq-events");
	if (count < 0) {
		dev_err(dev, "failed to get the count of devfreq-event dev\n");
		ret = count;
@@ -209,7 +209,8 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
	}

	for (i = 0; i < count; i++) {
		bus->edev[i] = devfreq_event_get_edev_by_phandle(dev, i);
		bus->edev[i] = devfreq_event_get_edev_by_phandle(dev,
							"devfreq-events", i);
		if (IS_ERR(bus->edev[i])) {
			ret = -EPROBE_DEFER;
			goto err_regulator;
@@ -360,7 +361,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
	profile->exit = exynos_bus_passive_exit;

	/* Get the instance of parent devfreq device */
	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, "devfreq", 0);
	if (IS_ERR(parent_devfreq))
		return -EPROBE_DEFER;

+1 −1
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
		return PTR_ERR(data->dmc_clk);
	}

	data->edev = devfreq_event_get_edev_by_phandle(dev, 0);
	data->edev = devfreq_event_get_edev_by_phandle(dev, "devfreq-events", 0);
	if (IS_ERR(data->edev))
		return -EPROBE_DEFER;

+5 −3
Original line number Diff line number Diff line
@@ -822,8 +822,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
		return err;
	}

	reset_control_assert(tegra->reset);

	err = clk_prepare_enable(tegra->clock);
	if (err) {
		dev_err(&pdev->dev,
@@ -831,7 +829,11 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
		return err;
	}

	reset_control_deassert(tegra->reset);
	err = reset_control_reset(tegra->reset);
	if (err) {
		dev_err(&pdev->dev, "Failed to reset hardware: %d\n", err);
		goto disable_clk;
	}

	rate = clk_round_rate(tegra->emc_clock, ULONG_MAX);
	if (rate < 0) {
Loading