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)
committerKishon Vijay Abraham I <kishon@ti.com>
Tue, 22 Jul 2014 07:16:11 +0000 (12:46 +0530)
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>
18 files changed:
Documentation/phy.txt
drivers/phy/phy-bcm-kona-usb2.c
drivers/phy/phy-berlin-sata.c
drivers/phy/phy-core.c
drivers/phy/phy-exynos-dp-video.c
drivers/phy/phy-exynos-mipi-video.c
drivers/phy/phy-exynos5-usbdrd.c
drivers/phy/phy-exynos5250-sata.c
drivers/phy/phy-hix5hd2-sata.c
drivers/phy/phy-mvebu-sata.c
drivers/phy/phy-omap-usb2.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-twl4030-usb.c
drivers/phy/phy-xgene.c
include/linux/phy/phy.h

index ebff6ee52441edbca95a0ebc8b20cd49ac218d3d..c6594af94d25529f15b38f7b877e22adf591f65d 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 e94f5a6a5645a33acaad36e64da7ac9c2d44b364..894fe74c1e44fc8931933b7f1fd2ec0110619e7c 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 c5e688b0899f5f3b31097d9408d7a5f6b82118ca..5c3a0424aeb41e412a6d77d1f3fd9618561d1973 100644 (file)
@@ -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);
index 527e744a3809acaaab24f431854c02b60b268553..ff5eec5af8173d4b4356152a63f71f3e9d2741c3 100644 (file)
@@ -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,13 +586,15 @@ 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_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;
@@ -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,8 +674,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;
 
@@ -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);
index 098f822a2fa4f420d1f23f1b4138634395b7ff0a..8b3026e2af7f7b517dad1898d8200ee5744b76a4 100644 (file)
@@ -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);
index 6d6bcf52a10ec108d0d7b08adbd8495b393b4072..b55a92e1249626ba7fc2aad781bd8a82ac169069 100644 (file)
@@ -136,7 +136,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 205159db37a32501c13bac80c67006d9ffeb5885..b05302b09c9fd0f0bdca202f1b52f1e51b94e0f1 100644 (file)
@@ -635,7 +635,8 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
        dev_vdbg(dev, "Creating usbdrd_phy phy\n");
 
        for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {
-               struct phy *phy = devm_phy_create(dev, &exynos5_usbdrd_phy_ops,
+               struct phy *phy = devm_phy_create(dev, NULL,
+                                                 &exynos5_usbdrd_phy_ops,
                                                  NULL);
                if (IS_ERR(phy)) {
                        dev_err(dev, "Failed to create usbdrd_phy phy\n");
index 05689450f93b0297dd73b36d6d58a0cfd0771581..19a679aca4acbe9ea4556fb104fe8958c1cf449a 100644 (file)
@@ -210,7 +210,7 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
                return ret;
        }
 
-       sata_phy->phy = devm_phy_create(dev, &exynos_sata_phy_ops, NULL);
+       sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops, NULL);
        if (IS_ERR(sata_phy->phy)) {
                clk_disable_unprepare(sata_phy->phyclk);
                dev_err(dev, "failed to create PHY\n");
index d44283453d716358bc4f312e19bc5c2084de74c0..6a08fa5f81eba7b2b734065dd0491567886a739f 100644 (file)
@@ -156,7 +156,7 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
        if (IS_ERR(priv->peri_ctrl))
                priv->peri_ctrl = NULL;
 
-       phy = devm_phy_create(dev, &hix5hd2_sata_phy_ops, NULL);
+       phy = devm_phy_create(dev, NULL, &hix5hd2_sata_phy_ops, NULL);
        if (IS_ERR(phy)) {
                dev_err(dev, "failed to create PHY\n");
                return PTR_ERR(phy);
index d70ecd6a1b3f51e60077559159912e2564e6b1a1..cc3c0e166dafba9e90241ff71c604d24ac351392 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 34b396146c8a1e2fbc273b4f3cdadc13640e6e50..93d78359246c82c815418df9fc3aec0f1f11f5c7 100644 (file)
@@ -263,7 +263,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, phy);
 
-       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 c9b4dd6becf55503249146c97eddf1b211fd5a11..d7c01aa1f8d745e73a2e371fb08d4cd8c4601936 100644 (file)
@@ -228,7 +228,8 @@ static int qcom_apq8064_sata_phy_probe(struct platform_device *pdev)
        if (IS_ERR(phy->mmio))
                return PTR_ERR(phy->mmio);
 
-       generic_phy = devm_phy_create(dev, &qcom_apq8064_sata_phy_ops, NULL);
+       generic_phy = devm_phy_create(dev, NULL, &qcom_apq8064_sata_phy_ops,
+                                     NULL);
        if (IS_ERR(generic_phy)) {
                dev_err(dev, "%s: failed to create phy\n", __func__);
                return PTR_ERR(generic_phy);
index 16aae7a285f0bc69300bcdea01a85269ac6abba2..ae30640a411d60091b08138a9dbe4726667c2b1d 100644 (file)
@@ -196,7 +196,8 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
                struct samsung_usb2_phy_instance *p = &drv->instances[i];
 
                dev_dbg(dev, "Creating phy \"%s\"\n", label);
-               p->phy = devm_phy_create(dev, &samsung_usb2_phy_ops, NULL);
+               p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops,
+                                        NULL);
                if (IS_ERR(p->phy)) {
                        dev_err(drv->dev, "Failed to create usb2_phy \"%s\"\n",
                                label);
index 7a4ea552f621cf10e466d82cafc578a8603c2439..61ebea49709bf9f003cf97cd9d4f1e7e45cbfc5f 100644 (file)
@@ -295,7 +295,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
                                return PTR_ERR(phy->pmu);
                }
 
-               phy->phy = devm_phy_create(dev, &sun4i_usb_phy_ops, NULL);
+               phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops, NULL);
                if (IS_ERR(phy->phy)) {
                        dev_err(dev, "failed to create PHY %d\n", i);
                        return PTR_ERR(phy->phy);
index 93bcd67f1b22f8341489142ac194b67ce49cc301..b964aa967b465429fae1ad7383cd0635785ba152 100644 (file)
@@ -400,7 +400,7 @@ static int ti_pipe3_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 2e0e9b3774c88d7501462466dd858d3a3bf7edd0..e1a6623d4696f1c24267292764b58f65b6137f47 100644 (file)
@@ -695,7 +695,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 4aa1ccd1511f16b4beffacb6316e11b34e316f58..db809b97219ec916f7bcc02d3fc63c2459e77f56 100644 (file)
@@ -1707,7 +1707,7 @@ static int xgene_phy_probe(struct platform_device *pdev)
        ctx->dev = &pdev->dev;
        platform_set_drvdata(pdev, ctx);
 
-       ctx->phy = devm_phy_create(ctx->dev, &xgene_phy_ops, NULL);
+       ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops, NULL);
        if (IS_ERR(ctx->phy)) {
                dev_dbg(&pdev->dev, "Failed to create PHY\n");
                rc = PTR_ERR(ctx->phy);
index 9a86945247421db41f0f0e0e248cc991d2676f1d..8cb6f815475b0f5a237e6305986bc5e60ab08b8c 100644 (file)
@@ -158,9 +158,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_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);
@@ -299,13 +300,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);
 }