linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: linuxppc-dev@ozlabs.org, jwboyer@linux.vnet.ibm.com
Subject: [PATCH v3 12/12] Uartlite: Let the console be initialized earlier
Date: Mon, 01 Oct 2007 20:16:09 -0600	[thread overview]
Message-ID: <20071002021609.9579.5233.stgit@trillian.cg.shawcable.net> (raw)
In-Reply-To: <20071002021334.9579.68179.stgit@trillian.cg.shawcable.net>

From: Grant Likely <grant.likely@secretlab.ca>

By configuring it earlier we get console output sooner which is helpful
for debugging when the kernel crashes before the serial drivers are
initialized.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 drivers/serial/uartlite.c |   41 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index 0904c2a..2b8404c 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -373,6 +373,31 @@ static void ulite_console_write(struct console *co, const char *s,
 		spin_unlock_irqrestore(&port->lock, flags);
 }
 
+#if defined(CONFIG_OF)
+static inline void __init ulite_console_of_find_device(int id)
+{
+	struct device_node *np;
+	struct resource res;
+	const unsigned int *of_id;
+	int rc;
+
+	for_each_compatible_node(np, NULL, "xilinx,uartlite") {
+		of_id = of_get_property(np, "port-number", NULL);
+		if ((!of_id) || (*of_id != id))
+			continue;
+
+		rc = of_address_to_resource(np, 0, &res);
+		if (rc)
+			continue;
+
+		ulite_ports[id].mapbase = res.start;
+		return;
+	}
+}
+#else /* CONFIG_OF */
+static inline void __init ulite_console_of_find_device(int id) { /* do nothing */ }
+#endif /* CONFIG_OF */
+
 static int __init ulite_console_setup(struct console *co, char *options)
 {
 	struct uart_port *port;
@@ -386,10 +411,20 @@ static int __init ulite_console_setup(struct console *co, char *options)
 
 	port = &ulite_ports[co->index];
 
+	/* Check if it is an OF device */
+	if (!port->mapbase)
+		ulite_console_of_find_device(co->index);
+
+	/* Do we have a device now? */
+	if (!port->mapbase) {
+		pr_debug("console on ttyUL%i not present\n", co->index);
+		return -ENODEV;
+	}
+
 	/* not initialized yet? */
 	if (!port->membase) {
-		pr_debug("console on ttyUL%i not initialized\n", co->index);
-		return -ENODEV;
+		if (ulite_request_port(port))
+			return -ENODEV;
 	}
 
 	if (options)
@@ -461,7 +496,7 @@ static int __devinit ulite_assign(struct device *dev, int id, u32 base, int irq)
 		return -EINVAL;
 	}
 
-	if (ulite_ports[id].mapbase) {
+	if ((ulite_ports[id].mapbase) && (ulite_ports[id].mapbase != base)) {
 		dev_err(dev, "cannot assign to %s%i; it is already in use\n",
 			ULITE_NAME, id);
 		return -EBUSY;

  parent reply	other threads:[~2007-10-02  2:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-02  2:15 [PATCH v3 00/12] Xilinx Virtex and Uartlite arch/powerpc patches ready for merge Grant Likely
2007-10-02  2:15 ` [PATCH v3 01/12] Virtex: Add uartlite bootwrapper driver Grant Likely
2007-10-02  2:15 ` [PATCH v3 02/12] Virtex: Add Kconfig macros for Xilinx Virtex board support Grant Likely
2007-10-02 19:04   ` Peter Korsgaard
2007-10-02 19:06     ` Grant Likely
2007-10-02  2:15 ` [PATCH v3 03/12] Virtex: add xilinx interrupt controller driver Grant Likely
2007-10-02  2:15 ` [PATCH v3 04/12] Virtex: Add generic Xilinx Virtex board support Grant Likely
2007-10-02  2:15 ` [PATCH v3 05/12] Add PowerPC Xilinx Virtex entry to maintainers Grant Likely
2007-10-02 18:53   ` Peter Korsgaard
2007-10-02 19:02     ` Grant Likely
2007-10-02  2:15 ` [PATCH v3 06/12] Uartlite: Fix reg io to access documented register size Grant Likely
2007-10-02  2:15 ` [PATCH v3 07/12] Uartlite: change name of ports to ulite_ports Grant Likely
2007-10-02 18:53   ` Peter Korsgaard
2007-10-02  2:15 ` [PATCH v3 08/12] Uartlite: Add macro for uartlite device name Grant Likely
2007-10-02 19:05   ` Peter Korsgaard
2007-10-02  2:15 ` [PATCH v3 09/12] Uartlite: Separate the bus binding from the driver proper Grant Likely
2007-10-02  2:15 ` [PATCH v3 10/12] Uartlite: Comment block tidy Grant Likely
2007-10-02 19:05   ` Peter Korsgaard
2007-10-02  2:16 ` [PATCH v3 11/12] Uartlite: Add of-platform-bus binding Grant Likely
2007-10-02 18:54   ` Peter Korsgaard
2007-10-02  2:16 ` Grant Likely [this message]
2007-10-02 18:54   ` [PATCH v3 12/12] Uartlite: Let the console be initialized earlier Peter Korsgaard

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=20071002021609.9579.5233.stgit@trillian.cg.shawcable.net \
    --to=grant.likely@secretlab.ca \
    --cc=jwboyer@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.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).