public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jagannadh.teki@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/7] serial: mxc: Move common init into _mxc_serial_init
Date: Tue,  6 Jun 2017 05:31:48 +0000	[thread overview]
Message-ID: <1496727111-3655-5-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1496727111-3655-1-git-send-email-jteki@openedev.com>

From: Jagan Teki <jagan@amarulasolutions.com>

Move the common initialization code into _mxc_serial_init
so-that dm and non-dm can call this func.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/serial/serial_mxc.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 288b610..4b19052 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -137,6 +137,21 @@ struct mxc_uart {
 	u32 ts;
 };
 
+static void _mxc_serial_init(struct mxc_uart *base)
+{
+	writel(0, &base->cr1);
+	writel(0, &base->cr2);
+
+	while (!(readl(&base->cr2) & UCR2_SRST));
+
+	writel(0x704 | UCR3_ADNIMP, &base->cr3);
+	writel(0x8000, &base->cr4);
+	writel(0x2b, &base->esc);
+	writel(0, &base->tim);
+
+	writel(0, &base->ts);
+}
+
 #ifndef CONFIG_DM_SERIAL
 
 #ifndef CONFIG_MXC_UART_BASE
@@ -205,17 +220,7 @@ static int mxc_serial_tstc(void)
  */
 static int mxc_serial_init(void)
 {
-	writel(0, &mxc_base->cr1);
-	writel(0, &mxc_base->cr2);
-
-	while (!(readl(&mxc_base->cr2) & UCR2_SRST));
-
-	writel(0x704 | UCR3_ADNIMP, &mxc_base->cr3);
-	writel(0x8000, &mxc_base->cr4);
-	writel(0x2b, &mxc_base->esc);
-	writel(0, &mxc_base->tim);
-
-	writel(0, &mxc_base->ts);
+	_mxc_serial_init(mxc_base);
 
 	serial_setbrg();
 
@@ -271,16 +276,8 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate)
 static int mxc_serial_probe(struct udevice *dev)
 {
 	struct mxc_serial_platdata *plat = dev->platdata;
-	struct mxc_uart *const uart = plat->reg;
 
-	writel(0, &uart->cr1);
-	writel(0, &uart->cr2);
-	while (!(readl(&uart->cr2) & UCR2_SRST));
-	writel(0x704 | UCR3_ADNIMP, &uart->cr3);
-	writel(0x8000, &uart->cr4);
-	writel(0x2b, &uart->esc);
-	writel(0, &uart->tim);
-	writel(0, &uart->ts);
+	_mxc_serial_init(plat->reg);
 
 	return 0;
 }
-- 
1.9.1

  parent reply	other threads:[~2017-06-06  5:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06  5:31 [U-Boot] [PATCH 0/7] serial: mxc: Add debug uart support Jagan Teki
2017-06-06  5:31 ` [U-Boot] [PATCH 1/7] serial: mxc: Add common mxc_uart reg space Jagan Teki
2017-06-06 21:08   ` Simon Glass
2017-06-29  8:28   ` Stefano Babic
2017-06-06  5:31 ` [U-Boot] [PATCH 2/7] serial: mxc: Use RFDIV in dm-code Jagan Teki
2017-06-06 21:08   ` Simon Glass
2017-06-06  5:31 ` [U-Boot] [PATCH 3/7] serial: mxc: Move cr1 and cr2 write to mxc_serial_setbrg Jagan Teki
2017-06-06 21:09   ` Simon Glass
2017-06-06  5:31 ` Jagan Teki [this message]
2017-06-06 21:09   ` [U-Boot] [PATCH 4/7] serial: mxc: Move common init into _mxc_serial_init Simon Glass
2017-06-06  5:31 ` [U-Boot] [PATCH 5/7] serial: mxc: Move common baud gen into _mxc_serial_setbrg Jagan Teki
2017-06-06 21:09   ` Simon Glass
2017-06-06  5:31 ` [U-Boot] [PATCH 6/7] serial: mxc: Code cleanup Jagan Teki
2017-06-06 21:09   ` Simon Glass
2017-06-06  5:31 ` [U-Boot] [PATCH 7/7] serial: mxc: Add debug uart support Jagan Teki
2017-06-06 21:09   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1496727111-3655-5-git-send-email-jteki@openedev.com \
    --to=jagannadh.teki@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox