phy: core: Let node ptr of PHY point to PHY and not of PHY provider
authorKishon Vijay Abraham I <kishon@ti.com>
Mon, 14 Jul 2014 10:25:02 +0000 (15:55 +0530)
committerSimon Horman <horms+renesas@verge.net.au>
Fri, 5 Dec 2014 04:13:21 +0000 (13:13 +0900)
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: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
(cherry picked from commit f0ed817638b59aa927f1f7e9564dd8796b18dc4f)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Conflicts:
drivers/phy/phy-berlin-sata.c
drivers/phy/phy-exynos5-usbdrd.c
drivers/phy/phy-exynos5250-sata.c
drivers/phy/phy-hix5hd2-sata.c
drivers/phy/phy-qcom-apq8064-sata.c
drivers/phy/phy-samsung-usb2.c
drivers/phy/phy-sun4i-usb.c
drivers/phy/phy-ti-pipe3.c
drivers/phy/phy-xgene.c

Documentation/phy.txt
drivers/phy/phy-bcm-kona-usb2.c
drivers/phy/phy-core.c
drivers/phy/phy-exynos-dp-video.c
drivers/phy/phy-exynos-mipi-video.c
drivers/phy/phy-mvebu-sata.c
drivers/phy/phy-omap-usb2.c
drivers/phy/phy-twl4030-usb.c
include/linux/phy/phy.h

index ebff6ee..c6594af 100644 (file)
@@ -53,10 +53,12 @@ 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_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops,
-       struct phy_init_data *init_data);
+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 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
 the device pointer, phy ops and init_data.
index efc5c1a..f90ce8c 100644 (file)
@@ -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);
 
index 34d56f7..59879bf 100644 (file)
@@ -368,13 +368,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;
        }
@@ -501,13 +508,15 @@ EXPORT_SYMBOL_GPL(devm_phy_optional_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_init_data *init_data)
+struct phy *phy_create(struct device *dev, struct device_node *node,
+                      const struct phy_ops *ops,
+                      struct phy_init_data *init_data)
 {
        int ret;
        int id;
@@ -532,7 +541,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;
@@ -565,6 +574,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
  *
@@ -573,8 +583,9 @@ 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_init_data *init_data)
+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;
 
@@ -582,7 +593,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);
index 0786fef..94fc0d1 100644 (file)
@@ -76,7 +76,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);
index ff02668..e29a100 100644 (file)
@@ -135,7 +135,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
        spin_lock_init(&state->slock);
 
        for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
-               struct phy *phy = devm_phy_create(dev,
+               struct phy *phy = devm_phy_create(dev, NULL,
                                        &exynos_mipi_video_phy_ops, NULL);
                if (IS_ERR(phy)) {
                        dev_err(dev, "failed to create PHY %d\n", i);
index d70ecd6..cc3c0e1 100644 (file)
@@ -99,7 +99,7 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
        if (IS_ERR(priv->clk))
                return PTR_ERR(priv->clk);
 
-       phy = devm_phy_create(&pdev->dev, &phy_mvebu_sata_ops, NULL);
+       phy = devm_phy_create(&pdev->dev, NULL, &phy_mvebu_sata_ops, NULL);
        if (IS_ERR(phy))
                return PTR_ERR(phy);
 
index 7699752..b1685bf 100644 (file)
@@ -203,7 +203,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, phy);
        pm_runtime_enable(phy->dev);
 
-       generic_phy = devm_phy_create(phy->dev, &ops, NULL);
+       generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
        if (IS_ERR(generic_phy))
                return PTR_ERR(generic_phy);
 
index aaac359..d142ca0 100644 (file)
@@ -711,7 +711,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
        otg->set_host           = twl4030_set_host;
        otg->set_peripheral     = twl4030_set_peripheral;
 
-       phy = devm_phy_create(twl->dev, &ops, init_data);
+       phy = devm_phy_create(twl->dev, NULL, &ops, init_data);
        if (IS_ERR(phy)) {
                dev_dbg(&pdev->dev, "Failed to create PHY\n");
                return PTR_ERR(phy);
index 3f83459..eab7fdf 100644 (file)
@@ -153,9 +153,10 @@ void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 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_init_data *init_data);
-struct phy *devm_phy_create(struct device *dev,
+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 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);
@@ -266,13 +267,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);
 }