All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: Paul Mackeras <paulus@samba.org>, linuxppc-dev@ozlabs.org
Subject: [PATCH] autodetect serial console on efika
Date: Mon, 21 Jan 2008 16:29:00 +0100	[thread overview]
Message-ID: <20080121152900.GA8664@aepfle.de> (raw)
In-Reply-To: <20070331150823.GA25421@aepfle.de>


Efika boards have to be booted with console=ttyPSC0 unless there is a
graphics card plugged in. Detect if the firmware stdout is the serial
connector.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 arch/powerpc/platforms/52xx/efika.c |   50 ++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

--- a/arch/powerpc/platforms/52xx/efika.c
+++ b/arch/powerpc/platforms/52xx/efika.c
@@ -13,6 +13,7 @@
 #include <linux/utsrelease.h>
 #include <linux/pci.h>
 #include <linux/of.h>
+#include <linux/console.h>
 #include <asm/prom.h>
 #include <asm/time.h>
 #include <asm/machdep.h>
@@ -208,12 +209,61 @@ static int __init efika_probe(void)
 	return 1;
 }
 
+/*
+ * Per default, input/output-device points to keyboard/screen
+ * If no card is installed, the built-in serial port is used as a fallback.
+ * But unfortunately, the firmware does not connect /chosen/{stdin,stdout}
+ * the the built-in serial node. Instead, a /failsafe node is created.
+ * More advanced hardware configurations cant be detected,
+ * boot with console=xyz123 to point the kernel to the correct device
+ */
+static void __init efika_init_early(void)
+{
+#ifdef CONFIG_SERIAL_MPC52xx
+	struct device_node *stdout_node;
+	const char *property;
+
+	if (strstr(cmd_line, "console="))
+		return;
+	/* find the boot console from /chosen/stdout */
+	if (!of_chosen)
+		return;
+	property = of_get_property(of_chosen, "linux,stdout-path", NULL);
+	if (!property)
+		return;
+	stdout_node = of_find_node_by_path(property);
+	if (!stdout_node)
+		return;
+	property = of_get_property(stdout_node, "device_type", NULL);
+	if (property && strcmp(property, "serial") == 0) {
+		/*
+		 * The 9pin connector is either /failsafe or /builtin/serial.
+		 * The optional graphics card has also type 'serial' in VGA mode.
+		 */
+		property = of_get_property(stdout_node, "name", NULL);
+		if (property) {
+			if (strcmp(property, "failsafe") == 0)
+				add_preferred_console("ttyPSC", 0, NULL);
+			else {
+				if (strcmp(property, "serial") == 0) {
+					property = of_get_property(stdout_node, "model", NULL);
+					if (property && strcmp(property, "mpc5200-serial") == 0)
+						add_preferred_console("ttyPSC", 0, NULL);
+				}
+			}
+		}
+	}
+	of_node_put(stdout_node);
+#endif
+}
+
 define_machine(efika)
 {
 	.name			= EFIKA_PLATFORM_NAME,
 	.probe			= efika_probe,
 	.setup_arch		= efika_setup_arch,
 	.init			= mpc52xx_declare_of_platform_devices,
+	.init_early		= efika_init_early,
 	.show_cpuinfo		= efika_show_cpuinfo,
 	.init_IRQ		= mpc52xx_init_irq,
 	.get_irq		= mpc52xx_get_irq,

  parent reply	other threads:[~2008-01-21 15:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-31 15:08 [PATCH] autodetect serial console on efika Olaf Hering
2007-03-31 17:06 ` Grant Likely
2007-04-09 12:56 ` Matt Sealey
2007-04-10 16:52   ` Olaf Hering
2007-04-10 20:25     ` Sylvain Munaut
2007-04-11  6:17       ` Olaf Hering
2007-04-11 18:47       ` Matt Sealey
2007-04-11 18:42     ` Matt Sealey
2007-04-12 15:59 ` Olaf Hering
2007-04-13  9:50   ` Matt Sealey
2008-01-21 15:29 ` Olaf Hering [this message]
2008-01-21 15:37   ` [PATCH] autodetect serial console on pegasos2 Olaf Hering
2008-01-21 15:56   ` [PATCH] autodetect serial console on efika Geert Uytterhoeven
2008-01-21 16:09   ` Andreas Schwab
2008-01-21 18:45   ` Grant Likely
2008-01-21 20:34     ` Olaf Hering
2008-01-21 20:38       ` Grant Likely

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=20080121152900.GA8664@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.