aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2015-12-21 03:54:06 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2015-12-21 03:56:27 -0500
commit234738ea33903a185530a997f9ddff68709929b9 (patch)
treeef197f18e837e9eea3daa1b79fd7a8560037fb38 /drivers/phy
parentd65ff52eb8ed5c8480fbff9ef720e2b56d9a6fb2 (diff)
phy: ti-pipe3: move clk initialization to a separate function
No functional change. Moved clock 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>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/phy-ti-pipe3.c127
1 files changed, 72 insertions, 55 deletions
diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
index c5111057d241..3379a4deeb16 100644
--- a/drivers/phy/phy-ti-pipe3.c
+++ b/drivers/phy/phy-ti-pipe3.c
@@ -308,48 +308,11 @@ static const struct phy_ops ops = {
308 308
309static const struct of_device_id ti_pipe3_id_table[]; 309static const struct of_device_id ti_pipe3_id_table[];
310 310
311static int ti_pipe3_probe(struct platform_device *pdev) 311static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
312{ 312{
313 struct ti_pipe3 *phy;
314 struct phy *generic_phy;
315 struct phy_provider *phy_provider;
316 struct resource *res;
317 struct device_node *node = pdev->dev.of_node;
318 struct device_node *control_node;
319 struct platform_device *control_pdev;
320 const struct of_device_id *match;
321 struct clk *clk; 313 struct clk *clk;
322 struct device *dev = &pdev->dev; 314 struct device *dev = phy->dev;
323 315 struct device_node *node = dev->of_node;
324 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
325 if (!phy)
326 return -ENOMEM;
327
328 phy->dev = dev;
329
330 if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
331 match = of_match_device(ti_pipe3_id_table, dev);
332 if (!match)
333 return -EINVAL;
334
335 phy->dpll_map = (struct pipe3_dpll_map *)match->data;
336 if (!phy->dpll_map) {
337 dev_err(dev, "no DPLL data\n");
338 return -EINVAL;
339 }
340
341 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
342 "pll_ctrl");
343 phy->pll_ctrl_base = devm_ioremap_resource(dev, res);
344 if (IS_ERR(phy->pll_ctrl_base))
345 return PTR_ERR(phy->pll_ctrl_base);
346
347 phy->sys_clk = devm_clk_get(dev, "sysclk");
348 if (IS_ERR(phy->sys_clk)) {
349 dev_err(dev, "unable to get sysclk\n");
350 return -EINVAL;
351 }
352 }
353 316
354 phy->refclk = devm_clk_get(dev, "refclk"); 317 phy->refclk = devm_clk_get(dev, "refclk");
355 if (IS_ERR(phy->refclk)) { 318 if (IS_ERR(phy->refclk)) {
@@ -369,25 +332,17 @@ static int ti_pipe3_probe(struct platform_device *pdev)
369 } 332 }
370 } else { 333 } else {
371 phy->wkupclk = ERR_PTR(-ENODEV); 334 phy->wkupclk = ERR_PTR(-ENODEV);
372 phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node, 335 }
373 "syscon-pllreset"); 336
374 if (IS_ERR(phy->dpll_reset_syscon)) { 337 if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
375 dev_info(dev, 338 phy->sys_clk = devm_clk_get(dev, "sysclk");
376 "can't get syscon-pllreset, sata dpll won't idle\n"); 339 if (IS_ERR(phy->sys_clk)) {
377 phy->dpll_reset_syscon = NULL; 340 dev_err(dev, "unable to get sysclk\n");
378 } else { 341 return -EINVAL;
379 if (of_property_read_u32_index(node,
380 "syscon-pllreset", 1,
381 &phy->dpll_reset_reg)) {
382 dev_err(dev,
383 "couldn't get pllreset reg. offset\n");
384 return -EINVAL;
385 }
386 } 342 }
387 } 343 }
388 344
389 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) { 345 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
390
391 clk = devm_clk_get(dev, "dpll_ref"); 346 clk = devm_clk_get(dev, "dpll_ref");
392 if (IS_ERR(clk)) { 347 if (IS_ERR(clk)) {
393 dev_err(dev, "unable to get dpll ref clk\n"); 348 dev_err(dev, "unable to get dpll ref clk\n");
@@ -418,6 +373,68 @@ static int ti_pipe3_probe(struct platform_device *pdev)
418 phy->div_clk = ERR_PTR(-ENODEV); 373 phy->div_clk = ERR_PTR(-ENODEV);
419 } 374 }
420 375
376 return 0;
377}
378
379static int ti_pipe3_probe(struct platform_device *pdev)
380{
381 struct ti_pipe3 *phy;
382 struct phy *generic_phy;
383 struct phy_provider *phy_provider;
384 struct resource *res;
385 struct device_node *node = pdev->dev.of_node;
386 struct device_node *control_node;
387 struct platform_device *control_pdev;
388 const struct of_device_id *match;
389 struct device *dev = &pdev->dev;
390 int ret;
391
392 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
393 if (!phy)
394 return -ENOMEM;
395
396 phy->dev = dev;
397
398 if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
399 match = of_match_device(ti_pipe3_id_table, dev);
400 if (!match)
401 return -EINVAL;
402
403 phy->dpll_map = (struct pipe3_dpll_map *)match->data;
404 if (!phy->dpll_map) {
405 dev_err(dev, "no DPLL data\n");
406 return -EINVAL;
407 }
408
409 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
410 "pll_ctrl");
411 phy->pll_ctrl_base = devm_ioremap_resource(dev, res);
412 if (IS_ERR(phy->pll_ctrl_base))
413 return PTR_ERR(phy->pll_ctrl_base);
414 }
415
416 if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
417 phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node,
418 "syscon-pllreset");
419 if (IS_ERR(phy->dpll_reset_syscon)) {
420 dev_info(dev,
421 "can't get syscon-pllreset, sata dpll won't idle\n");
422 phy->dpll_reset_syscon = NULL;
423 } else {
424 if (of_property_read_u32_index(node,
425 "syscon-pllreset", 1,
426 &phy->dpll_reset_reg)) {
427 dev_err(dev,
428 "couldn't get pllreset reg. offset\n");
429 return -EINVAL;
430 }
431 }
432 }
433
434 ret = ti_pipe3_get_clk(phy);
435 if (ret)
436 return ret;
437
421 control_node = of_parse_phandle(node, "ctrl-module", 0); 438 control_node = of_parse_phandle(node, "ctrl-module", 0);
422 if (!control_node) { 439 if (!control_node) {
423 dev_err(dev, "Failed to get control device phandle\n"); 440 dev_err(dev, "Failed to get control device phandle\n");