]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
phy: ti-pipe3: move sysctrl initialization to a separate function
authorKishon Vijay Abraham I <kishon@ti.com>
Mon, 21 Dec 2015 08:54:07 +0000 (14:24 +0530)
committerKishon Vijay Abraham I <kishon@ti.com>
Mon, 21 Dec 2015 08:56:27 +0000 (14:26 +0530)
No functional change. Moved sysctrl initialization done in probe to a
separate function as part of cleaning up ti_pipe3_probe.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/phy/phy-ti-pipe3.c

index 3379a4deeb16bddd8555dac0bf070aad0f962535..3154da08ff373de8faa91fe6d2fbdc92fa92755f 100644 (file)
@@ -376,6 +376,48 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
        return 0;
 }
 
+static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
+{
+       struct device *dev = phy->dev;
+       struct device_node *node = dev->of_node;
+       struct device_node *control_node;
+       struct platform_device *control_pdev;
+
+       control_node = of_parse_phandle(node, "ctrl-module", 0);
+       if (!control_node) {
+               dev_err(dev, "Failed to get control device phandle\n");
+               return -EINVAL;
+       }
+
+       control_pdev = of_find_device_by_node(control_node);
+       if (!control_pdev) {
+               dev_err(dev, "Failed to get control device\n");
+               return -EINVAL;
+       }
+
+       phy->control_dev = &control_pdev->dev;
+
+       if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
+               phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node,
+                                                       "syscon-pllreset");
+               if (IS_ERR(phy->dpll_reset_syscon)) {
+                       dev_info(dev,
+                                "can't get syscon-pllreset, sata dpll won't idle\n");
+                       phy->dpll_reset_syscon = NULL;
+               } else {
+                       if (of_property_read_u32_index(node,
+                                                      "syscon-pllreset", 1,
+                                                      &phy->dpll_reset_reg)) {
+                               dev_err(dev,
+                                       "couldn't get pllreset reg. offset\n");
+                               return -EINVAL;
+                       }
+               }
+       }
+
+       return 0;
+}
+
 static int ti_pipe3_probe(struct platform_device *pdev)
 {
        struct ti_pipe3 *phy;
@@ -383,8 +425,6 @@ static int ti_pipe3_probe(struct platform_device *pdev)
        struct phy_provider *phy_provider;
        struct resource *res;
        struct device_node *node = pdev->dev.of_node;
-       struct device_node *control_node;
-       struct platform_device *control_pdev;
        const struct of_device_id *match;
        struct device *dev = &pdev->dev;
        int ret;
@@ -413,42 +453,14 @@ static int ti_pipe3_probe(struct platform_device *pdev)
                        return PTR_ERR(phy->pll_ctrl_base);
        }
 
-       if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
-               phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node,
-                                                       "syscon-pllreset");
-               if (IS_ERR(phy->dpll_reset_syscon)) {
-                       dev_info(dev,
-                                "can't get syscon-pllreset, sata dpll won't idle\n");
-                       phy->dpll_reset_syscon = NULL;
-               } else {
-                       if (of_property_read_u32_index(node,
-                                                      "syscon-pllreset", 1,
-                                                      &phy->dpll_reset_reg)) {
-                               dev_err(dev,
-                                       "couldn't get pllreset reg. offset\n");
-                               return -EINVAL;
-                       }
-               }
-       }
+       ret = ti_pipe3_get_sysctrl(phy);
+       if (ret)
+               return ret;
 
        ret = ti_pipe3_get_clk(phy);
        if (ret)
                return ret;
 
-       control_node = of_parse_phandle(node, "ctrl-module", 0);
-       if (!control_node) {
-               dev_err(dev, "Failed to get control device phandle\n");
-               return -EINVAL;
-       }
-
-       control_pdev = of_find_device_by_node(control_node);
-       if (!control_pdev) {
-               dev_err(dev, "Failed to get control device\n");
-               return -EINVAL;
-       }
-
-       phy->control_dev = &control_pdev->dev;
-
        omap_control_phy_power(phy->control_dev, 0);
 
        platform_set_drvdata(pdev, phy);