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

Commit f0ed8176 authored by Kishon Vijay Abraham I's avatar Kishon Vijay Abraham I
Browse files

phy: core: Let node ptr of PHY point to PHY and not of PHY provider



In case of multi-phy PHY providers, each PHY should be modeled as a sub
node of the PHY provider. Then each PHY will have a different node pointer
(node pointer of sub node) than that of PHY provider. Added this provision
in the PHY core.
Also fixed all drivers to use the updated API.

Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
parent 2a4c3701
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -53,9 +53,11 @@ unregister the PHY.
The PHY driver should create the PHY in order for other peripheral controllers
to make use of it. The PHY framework provides 2 APIs to create the PHY.

struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
struct phy *phy_create(struct device *dev, struct device_node *node,
		       const struct phy_ops *ops,
		       struct phy_init_data *init_data);
struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
			    const struct phy_ops *ops,
			    struct phy_init_data *init_data);

The PHY drivers can use one of the above 2 APIs to create the PHY by passing
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)

	platform_set_drvdata(pdev, phy);

	gphy = devm_phy_create(dev, &ops, NULL);
	gphy = devm_phy_create(dev, NULL, &ops, NULL);
	if (IS_ERR(gphy))
		return PTR_ERR(gphy);

+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
		if (!phy_desc)
			return -ENOMEM;

		phy = devm_phy_create(dev, &phy_berlin_sata_ops, NULL);
		phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops, NULL);
		if (IS_ERR(phy)) {
			dev_err(dev, "failed to create PHY %d\n", phy_id);
			return PTR_ERR(phy);
+18 −7
Original line number Diff line number Diff line
@@ -415,13 +415,20 @@ struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args
	struct phy *phy;
	struct class_dev_iter iter;
	struct device_node *node = dev->of_node;
	struct device_node *child;

	class_dev_iter_init(&iter, phy_class, NULL, NULL);
	while ((dev = class_dev_iter_next(&iter))) {
		phy = to_phy(dev);
		if (node != phy->dev.of_node)
		if (node != phy->dev.of_node) {
			for_each_child_of_node(node, child) {
				if (child == phy->dev.of_node)
					goto phy_found;
			}
			continue;
		}

phy_found:
		class_dev_iter_exit(&iter);
		return phy;
	}
@@ -579,12 +586,14 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
/**
 * phy_create() - create a new phy
 * @dev: device that is creating the new phy
 * @node: device node of the phy
 * @ops: function pointers for performing phy operations
 * @init_data: contains the list of PHY consumers or NULL
 *
 * Called to create a phy using phy framework.
 */
struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
struct phy *phy_create(struct device *dev, struct device_node *node,
		       const struct phy_ops *ops,
		       struct phy_init_data *init_data)
{
	int ret;
@@ -620,7 +629,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,

	phy->dev.class = phy_class;
	phy->dev.parent = dev;
	phy->dev.of_node = dev->of_node;
	phy->dev.of_node = node ?: dev->of_node;
	phy->id = id;
	phy->ops = ops;
	phy->init_data = init_data;
@@ -656,6 +665,7 @@ EXPORT_SYMBOL_GPL(phy_create);
/**
 * devm_phy_create() - create a new phy
 * @dev: device that is creating the new phy
 * @node: device node of the phy
 * @ops: function pointers for performing phy operations
 * @init_data: contains the list of PHY consumers or NULL
 *
@@ -664,7 +674,8 @@ EXPORT_SYMBOL_GPL(phy_create);
 * On driver detach, release function is invoked on the devres data,
 * then, devres data is freed.
 */
struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
			    const struct phy_ops *ops,
			    struct phy_init_data *init_data)
{
	struct phy **ptr, *phy;
@@ -673,7 +684,7 @@ struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
	if (!ptr)
		return ERR_PTR(-ENOMEM);

	phy = phy_create(dev, ops, init_data);
	phy = phy_create(dev, node, ops, init_data);
	if (!IS_ERR(phy)) {
		*ptr = phy;
		devres_add(dev, ptr);
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
	if (IS_ERR(state->regs))
		return PTR_ERR(state->regs);

	phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL);
	phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
	if (IS_ERR(phy)) {
		dev_err(dev, "failed to create Display Port PHY\n");
		return PTR_ERR(phy);
Loading