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

Commit 79e6f262 authored by Kishon Vijay Abraham I's avatar Kishon Vijay Abraham I Committed by Yaniv Gardi
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.

Change-Id: I1c6ad35456cb1b06561c95e2de79559c0e49babb
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
[ygardi@codeaurora.org: merging with qcom-specific changes, and removing
non existing files]
Git-commit: f0ed817638b59aa927f1f7e9564dd8796b18dc4f
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/kishon/linux-phy.git/


Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
parent d420d8ef
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
+18 −7
Original line number Diff line number Diff line
@@ -398,13 +398,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;
	}
@@ -562,12 +569,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;
@@ -593,7 +602,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;
@@ -625,6 +634,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
 *
@@ -633,7 +643,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;
@@ -642,7 +653,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
@@ -644,7 +644,7 @@ static int msm_sata_phy_probe(struct platform_device *pdev)
		goto out;
	}

	generic_phy = devm_phy_create(dev, &msm_sata_phy_ops, NULL);
	generic_phy = devm_phy_create(dev, NULL, &msm_sata_phy_ops, NULL);
	if (IS_ERR(generic_phy)) {
		err =  PTR_ERR(generic_phy);
		dev_err(dev, "%s: failed to create phy %d\n", __func__, err);
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
		goto out;
	}

	generic_phy = devm_phy_create(dev, ufs_qcom_phy_gen_ops, NULL);
	generic_phy = devm_phy_create(dev, NULL, ufs_qcom_phy_gen_ops, NULL);
	if (IS_ERR(generic_phy)) {
		err =  PTR_ERR(generic_phy);
		dev_err(dev, "%s: failed to create phy %d\n", __func__, err);
+10 −5
Original line number Diff line number Diff line
@@ -156,9 +156,10 @@ void devm_phy_put(struct device *dev, struct phy *phy);
struct phy *of_phy_get(struct device_node *np, const char *con_id);
struct phy *of_phy_simple_xlate(struct device *dev,
	struct of_phandle_args *args);
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,
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
	const struct phy_ops *ops, struct phy_init_data *init_data);
void phy_destroy(struct phy *phy);
void devm_phy_destroy(struct device *dev, struct phy *phy);
@@ -297,13 +298,17 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev,
}

static inline struct phy *phy_create(struct device *dev,
	const struct phy_ops *ops, struct phy_init_data *init_data)
				     struct device_node *node,
				     const struct phy_ops *ops,
				     struct phy_init_data *init_data)
{
	return ERR_PTR(-ENOSYS);
}

static inline struct phy *devm_phy_create(struct device *dev,
	const struct phy_ops *ops, struct phy_init_data *init_data)
					  struct device_node *node,
					  const struct phy_ops *ops,
					  struct phy_init_data *init_data)
{
	return ERR_PTR(-ENOSYS);
}