aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorTudor Ambarus <tudor.ambarus@microchip.com>2019-02-05 12:33:33 -0500
committerMark Brown <broonie@kernel.org>2019-02-06 12:20:59 -0500
commitbd7905e2fed7047d4b0e83e2bfd37b808ec87e54 (patch)
treef6c0ba508ad8c4f63a0b8e8b42c8afb87ca6ed03 /drivers/spi
parent18f075145e08c75b46779c060cd28e544df6fbb3 (diff)
spi: atmel-quadspi: add support for named peripheral clock
Naming clocks is a good practice. Keep supporting unnamed peripheral clock, to be backward compatible with old DTs. While here, rename clk to pclk, to indicate that it is a peripheral clock. Suggested-by: Boris Brezillon <bbrezillon@kernel.org> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Boris Brezillon <bbrezillon@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/atmel-quadspi.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 19a3980775ad..336501d962e5 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -137,7 +137,7 @@
137struct atmel_qspi { 137struct atmel_qspi {
138 void __iomem *regs; 138 void __iomem *regs;
139 void __iomem *mem; 139 void __iomem *mem;
140 struct clk *clk; 140 struct clk *pclk;
141 struct platform_device *pdev; 141 struct platform_device *pdev;
142 u32 pending; 142 u32 pending;
143 u32 mr; 143 u32 mr;
@@ -341,7 +341,7 @@ static int atmel_qspi_setup(struct spi_device *spi)
341 if (!spi->max_speed_hz) 341 if (!spi->max_speed_hz)
342 return -EINVAL; 342 return -EINVAL;
343 343
344 src_rate = clk_get_rate(aq->clk); 344 src_rate = clk_get_rate(aq->pclk);
345 if (!src_rate) 345 if (!src_rate)
346 return -EINVAL; 346 return -EINVAL;
347 347
@@ -433,15 +433,18 @@ static int atmel_qspi_probe(struct platform_device *pdev)
433 } 433 }
434 434
435 /* Get the peripheral clock */ 435 /* Get the peripheral clock */
436 aq->clk = devm_clk_get(&pdev->dev, NULL); 436 aq->pclk = devm_clk_get(&pdev->dev, "pclk");
437 if (IS_ERR(aq->clk)) { 437 if (IS_ERR(aq->pclk))
438 aq->pclk = devm_clk_get(&pdev->dev, NULL);
439
440 if (IS_ERR(aq->pclk)) {
438 dev_err(&pdev->dev, "missing peripheral clock\n"); 441 dev_err(&pdev->dev, "missing peripheral clock\n");
439 err = PTR_ERR(aq->clk); 442 err = PTR_ERR(aq->pclk);
440 goto exit; 443 goto exit;
441 } 444 }
442 445
443 /* Enable the peripheral clock */ 446 /* Enable the peripheral clock */
444 err = clk_prepare_enable(aq->clk); 447 err = clk_prepare_enable(aq->pclk);
445 if (err) { 448 if (err) {
446 dev_err(&pdev->dev, "failed to enable the peripheral clock\n"); 449 dev_err(&pdev->dev, "failed to enable the peripheral clock\n");
447 goto exit; 450 goto exit;
@@ -452,25 +455,25 @@ static int atmel_qspi_probe(struct platform_device *pdev)
452 if (irq < 0) { 455 if (irq < 0) {
453 dev_err(&pdev->dev, "missing IRQ\n"); 456 dev_err(&pdev->dev, "missing IRQ\n");
454 err = irq; 457 err = irq;
455 goto disable_clk; 458 goto disable_pclk;
456 } 459 }
457 err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt, 460 err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt,
458 0, dev_name(&pdev->dev), aq); 461 0, dev_name(&pdev->dev), aq);
459 if (err) 462 if (err)
460 goto disable_clk; 463 goto disable_pclk;
461 464
462 err = atmel_qspi_init(aq); 465 err = atmel_qspi_init(aq);
463 if (err) 466 if (err)
464 goto disable_clk; 467 goto disable_pclk;
465 468
466 err = spi_register_controller(ctrl); 469 err = spi_register_controller(ctrl);
467 if (err) 470 if (err)
468 goto disable_clk; 471 goto disable_pclk;
469 472
470 return 0; 473 return 0;
471 474
472disable_clk: 475disable_pclk:
473 clk_disable_unprepare(aq->clk); 476 clk_disable_unprepare(aq->pclk);
474exit: 477exit:
475 spi_controller_put(ctrl); 478 spi_controller_put(ctrl);
476 479
@@ -484,7 +487,7 @@ static int atmel_qspi_remove(struct platform_device *pdev)
484 487
485 spi_unregister_controller(ctrl); 488 spi_unregister_controller(ctrl);
486 writel_relaxed(QSPI_CR_QSPIDIS, aq->regs + QSPI_CR); 489 writel_relaxed(QSPI_CR_QSPIDIS, aq->regs + QSPI_CR);
487 clk_disable_unprepare(aq->clk); 490 clk_disable_unprepare(aq->pclk);
488 return 0; 491 return 0;
489} 492}
490 493
@@ -492,7 +495,7 @@ static int __maybe_unused atmel_qspi_suspend(struct device *dev)
492{ 495{
493 struct atmel_qspi *aq = dev_get_drvdata(dev); 496 struct atmel_qspi *aq = dev_get_drvdata(dev);
494 497
495 clk_disable_unprepare(aq->clk); 498 clk_disable_unprepare(aq->pclk);
496 499
497 return 0; 500 return 0;
498} 501}
@@ -501,7 +504,7 @@ static int __maybe_unused atmel_qspi_resume(struct device *dev)
501{ 504{
502 struct atmel_qspi *aq = dev_get_drvdata(dev); 505 struct atmel_qspi *aq = dev_get_drvdata(dev);
503 506
504 clk_prepare_enable(aq->clk); 507 clk_prepare_enable(aq->pclk);
505 508
506 return atmel_qspi_init(aq); 509 return atmel_qspi_init(aq);
507} 510}