aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mpc512x-psc.c
diff options
context:
space:
mode:
authorGerhard Sittig <gsi@denx.de>2013-11-30 17:51:28 -0500
committerAnatolij Gustschin <agust@denx.de>2014-01-12 12:53:04 -0500
commitdff148ad7b69409181e12641cca6962e5f02cffe (patch)
tree162d4fc6f89cfbfc94c3acdfa6ff1e147262bbf1 /drivers/spi/spi-mpc512x-psc.c
parent7d71d5b2e80623242b0c0823ce6cb635d089c8b2 (diff)
spi: mpc512x: adjust to OF based clock lookup
after device tree based clock lookup became available, the peripheral driver need no longer construct clock names which include the PSC index, remove the "psc%d_mclk" template and unconditionally use 'mclk' acquire and release the 'ipg' clock item for register access as well Cc: Mark Brown <broonie@kernel.org> Cc: linux-spi@vger.kernel.org Signed-off-by: Gerhard Sittig <gsi@denx.de> Acked-by: Mark Brown <broonie@linaro.org> Signed-off-by: Anatolij Gustschin <agust@denx.de>
Diffstat (limited to 'drivers/spi/spi-mpc512x-psc.c')
-rw-r--r--drivers/spi/spi-mpc512x-psc.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 9602bbd8d7ea..de66c676c248 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -40,6 +40,7 @@ struct mpc512x_psc_spi {
40 unsigned int irq; 40 unsigned int irq;
41 u8 bits_per_word; 41 u8 bits_per_word;
42 struct clk *clk_mclk; 42 struct clk *clk_mclk;
43 struct clk *clk_ipg;
43 u32 mclk_rate; 44 u32 mclk_rate;
44 45
45 struct completion txisrdone; 46 struct completion txisrdone;
@@ -475,8 +476,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
475 struct spi_master *master; 476 struct spi_master *master;
476 int ret; 477 int ret;
477 void *tempp; 478 void *tempp;
478 int psc_num;
479 char clk_name[16];
480 struct clk *clk; 479 struct clk *clk;
481 480
482 master = spi_alloc_master(dev, sizeof *mps); 481 master = spi_alloc_master(dev, sizeof *mps);
@@ -520,9 +519,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
520 goto free_master; 519 goto free_master;
521 init_completion(&mps->txisrdone); 520 init_completion(&mps->txisrdone);
522 521
523 psc_num = master->bus_num; 522 clk = devm_clk_get(dev, "mclk");
524 snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
525 clk = devm_clk_get(dev, clk_name);
526 if (IS_ERR(clk)) { 523 if (IS_ERR(clk)) {
527 ret = PTR_ERR(clk); 524 ret = PTR_ERR(clk);
528 goto free_irq; 525 goto free_irq;
@@ -533,17 +530,29 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
533 mps->clk_mclk = clk; 530 mps->clk_mclk = clk;
534 mps->mclk_rate = clk_get_rate(clk); 531 mps->mclk_rate = clk_get_rate(clk);
535 532
533 clk = devm_clk_get(dev, "ipg");
534 if (IS_ERR(clk)) {
535 ret = PTR_ERR(clk);
536 goto free_mclk_clock;
537 }
538 ret = clk_prepare_enable(clk);
539 if (ret)
540 goto free_mclk_clock;
541 mps->clk_ipg = clk;
542
536 ret = mpc512x_psc_spi_port_config(master, mps); 543 ret = mpc512x_psc_spi_port_config(master, mps);
537 if (ret < 0) 544 if (ret < 0)
538 goto free_clock; 545 goto free_ipg_clock;
539 546
540 ret = devm_spi_register_master(dev, master); 547 ret = devm_spi_register_master(dev, master);
541 if (ret < 0) 548 if (ret < 0)
542 goto free_clock; 549 goto free_ipg_clock;
543 550
544 return ret; 551 return ret;
545 552
546free_clock: 553free_ipg_clock:
554 clk_disable_unprepare(mps->clk_ipg);
555free_mclk_clock:
547 clk_disable_unprepare(mps->clk_mclk); 556 clk_disable_unprepare(mps->clk_mclk);
548free_irq: 557free_irq:
549 free_irq(mps->irq, mps); 558 free_irq(mps->irq, mps);
@@ -561,6 +570,7 @@ static int mpc512x_psc_spi_do_remove(struct device *dev)
561 struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); 570 struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
562 571
563 clk_disable_unprepare(mps->clk_mclk); 572 clk_disable_unprepare(mps->clk_mclk);
573 clk_disable_unprepare(mps->clk_ipg);
564 free_irq(mps->irq, mps); 574 free_irq(mps->irq, mps);
565 if (mps->psc) 575 if (mps->psc)
566 iounmap(mps->psc); 576 iounmap(mps->psc);