aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerhard Sittig <gsi@denx.de>2013-11-30 17:51:29 -0500
committerAnatolij Gustschin <agust@denx.de>2014-01-12 12:53:04 -0500
commite149b42b8605f4e0e86662fe880716ccdfdb4ef9 (patch)
treee0aa3e6109380fa73c8cd0e59628e82061615ce5
parentdff148ad7b69409181e12641cca6962e5f02cffe (diff)
serial: mpc512x: adjust for 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.cz> Cc: linux-serial@vger.kernel.org Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Gerhard Sittig <gsi@denx.de> Signed-off-by: Anatolij Gustschin <agust@denx.de>
-rw-r--r--drivers/tty/serial/mpc52xx_uart.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index ec06505e3ae6..6345f377a246 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -619,29 +619,55 @@ static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port)
619} 619}
620 620
621static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM]; 621static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM];
622static struct clk *psc_ipg_clk[MPC52xx_PSC_MAXNUM];
622 623
623/* called from within the .request_port() callback (allocation) */ 624/* called from within the .request_port() callback (allocation) */
624static int mpc512x_psc_alloc_clock(struct uart_port *port) 625static int mpc512x_psc_alloc_clock(struct uart_port *port)
625{ 626{
626 int psc_num; 627 int psc_num;
627 char clk_name[16];
628 struct clk *clk; 628 struct clk *clk;
629 int err; 629 int err;
630 630
631 psc_num = (port->mapbase & 0xf00) >> 8; 631 psc_num = (port->mapbase & 0xf00) >> 8;
632 snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num); 632
633 clk = devm_clk_get(port->dev, clk_name); 633 clk = devm_clk_get(port->dev, "mclk");
634 if (IS_ERR(clk)) { 634 if (IS_ERR(clk)) {
635 dev_err(port->dev, "Failed to get MCLK!\n"); 635 dev_err(port->dev, "Failed to get MCLK!\n");
636 return PTR_ERR(clk); 636 err = PTR_ERR(clk);
637 goto out_err;
637 } 638 }
638 err = clk_prepare_enable(clk); 639 err = clk_prepare_enable(clk);
639 if (err) { 640 if (err) {
640 dev_err(port->dev, "Failed to enable MCLK!\n"); 641 dev_err(port->dev, "Failed to enable MCLK!\n");
641 return err; 642 goto out_err;
642 } 643 }
643 psc_mclk_clk[psc_num] = clk; 644 psc_mclk_clk[psc_num] = clk;
645
646 clk = devm_clk_get(port->dev, "ipg");
647 if (IS_ERR(clk)) {
648 dev_err(port->dev, "Failed to get IPG clock!\n");
649 err = PTR_ERR(clk);
650 goto out_err;
651 }
652 err = clk_prepare_enable(clk);
653 if (err) {
654 dev_err(port->dev, "Failed to enable IPG clock!\n");
655 goto out_err;
656 }
657 psc_ipg_clk[psc_num] = clk;
658
644 return 0; 659 return 0;
660
661out_err:
662 if (psc_mclk_clk[psc_num]) {
663 clk_disable_unprepare(psc_mclk_clk[psc_num]);
664 psc_mclk_clk[psc_num] = NULL;
665 }
666 if (psc_ipg_clk[psc_num]) {
667 clk_disable_unprepare(psc_ipg_clk[psc_num]);
668 psc_ipg_clk[psc_num] = NULL;
669 }
670 return err;
645} 671}
646 672
647/* called from within the .release_port() callback (release) */ 673/* called from within the .release_port() callback (release) */
@@ -656,6 +682,10 @@ static void mpc512x_psc_relse_clock(struct uart_port *port)
656 clk_disable_unprepare(clk); 682 clk_disable_unprepare(clk);
657 psc_mclk_clk[psc_num] = NULL; 683 psc_mclk_clk[psc_num] = NULL;
658 } 684 }
685 if (psc_ipg_clk[psc_num]) {
686 clk_disable_unprepare(psc_ipg_clk[psc_num]);
687 psc_ipg_clk[psc_num] = NULL;
688 }
659} 689}
660 690
661/* implementation of the .clock() callback (enable/disable) */ 691/* implementation of the .clock() callback (enable/disable) */