serial: mxc: Move cr1 and cr2 write to mxc_serial_setbrg
authorJagan Teki <jagan@amarulasolutions.com>
Tue, 6 Jun 2017 05:31:47 +0000 (05:31 +0000)
committerStefano Babic <sbabic@denx.de>
Wed, 12 Jul 2017 07:42:33 +0000 (09:42 +0200)
Control reg write should be part of setbrg for better
buadrate generation, so move cr1 and cr2 write to
mxc_serial_setbrg

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/serial/serial_mxc.c

index fbf8e51591a9425e4dd54508a932c24410314e8c..cf6f0447f2731290aa631bc03945d30c099afabf 100644 (file)
@@ -162,6 +162,9 @@ static void mxc_serial_setbrg(void)
        writel(0xf, &mxc_base->bir);
        writel(clk / (2 * gd->baudrate), &mxc_base->bmr);
 
+       writel(UCR2_WS | UCR2_IRTS | UCR2_RXEN | UCR2_TXEN | UCR2_SRST,
+              &mxc_base->cr2);
+       writel(UCR1_UARTEN, &mxc_base->cr1);
 }
 
 static int mxc_serial_getc(void)
@@ -216,11 +219,6 @@ static int mxc_serial_init(void)
 
        serial_setbrg();
 
-       writel(UCR2_WS | UCR2_IRTS | UCR2_RXEN | UCR2_TXEN | UCR2_SRST,
-              &mxc_base->cr2);
-
-       writel(UCR1_UARTEN, &mxc_base->cr1);
-
        return 0;
 }