linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: gregkh@linuxfoundation.org
Cc: jslaby@suse.cz, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, robh@kernel.org,
	Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 2/3] serial: 8250_early: prepare for dynamic BASE_BAUD
Date: Wed, 24 Dec 2014 12:42:15 +0530	[thread overview]
Message-ID: <1419405136-14520-3-git-send-email-vgupta@synopsys.com> (raw)
In-Reply-To: <1419405136-14520-1-git-send-email-vgupta@synopsys.com>

BASE_BAUD is pain in neck for multi-platform support as it hard codes at
build time the clk value for early uart.

Mitigate this by allowing arches/platforms to provide their own version
which can do dynamic setup based on DT values etc (see next patch for
usage)

This was needed for ARC SDP platforms based on 2 different FPGA flows, each
with a different UART clk value.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 drivers/tty/serial/earlycon.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 64fe25a4285c..bfd3537739e0 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -54,6 +54,15 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 	return base;
 }
 
+unsigned int __weak __init earlycon_base_baud(char *options)
+{
+#ifdef BASE_BAUD
+	return BASE_BAUD;
+#else
+	return 1843200/16;	/* x86 early console */
+#endif
+}
+
 static int __init parse_options(struct earlycon_device *device,
 				char *options)
 {
@@ -87,7 +96,7 @@ static int __init parse_options(struct earlycon_device *device,
 		return -EINVAL;
 	}
 
-	port->uartclk = BASE_BAUD * 16;
+	port->uartclk = earlycon_base_baud(options) * 16;
 
 	options = strchr(options, ',');
 	if (options) {
@@ -156,7 +165,7 @@ int __init of_setup_earlycon(unsigned long addr,
 
 	port->iotype = UPIO_MEM;
 	port->mapbase = addr;
-	port->uartclk = BASE_BAUD * 16;
+	port->uartclk = earlycon_base_baud(NULL) * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
 	early_console_dev.con->data = &early_console_dev;
-- 
1.8.3.2

  parent reply	other threads:[~2014-12-24  7:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-24  7:12 [PATCH 0/3] Early 8250 fixlets Vineet Gupta
2014-12-24  7:12 ` [PATCH 1/3] serial: 8250_early: optimize early 8250 uart Vineet Gupta
2014-12-24  7:12 ` Vineet Gupta [this message]
2014-12-24  7:12 ` [PATCH 3/3] ARC: runtime determine BASE_BAUD per machine Vineet Gupta

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=1419405136-14520-3-git-send-email-vgupta@synopsys.com \
    --to=vineet.gupta1@synopsys.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).