Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311083

[PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Peter Hurley <peter@hurleysoftware.com>
Newsgroups linux.kernel
Subject [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties
Date Sun, 17 Jan 2016 00:30:03 +0100
Message-ID <qRIsb-2KH-43@gated-at.bofh.it> (permalink)
References <qRGJI-1Au-1@gated-at.bofh.it> <qRIsa-2KH-13@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=hurleysoftware-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FEjYYb7TVlSaiFpaPUfFW9K8wPcjyHGHVICBK0onGsk=; b=CBrOxd07SpICia57xzafRv/ReSsrdqDJJ0kZWjncsYM3oK05rLUAh23IDE2j4+/T6j xvSy76wG33QHpr2JyOQsdGgucj1rx+ZGVrd0j0h2fSa/fMPsPGb6f6uqJePXXYljqZo1 ywN9P8OY0miLduCym7jj2lJC/sbgj2Nmq3LKi56mL5Uzjze5lPquu7IpIwu58XhpOJMi cMieDfcwDsVQaSjaU1S2o4jg6vCjrPl7jy58Q/8zzZXo6Ju/XrDjC9qvwF0cYmFzUV3D wpY8OT9jD58c0EDqYOPynoOrQ+/A3kgHCSakE1DmBiLsivWe3PApPcdXqMqZks7EMc3V rsDw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FEjYYb7TVlSaiFpaPUfFW9K8wPcjyHGHVICBK0onGsk=; b=Zrd8U8owonKw/fsaJQI2vBVIYS8TkoLyhDd9mioralIRvAG+ir84WQ1QJsbJHpWCsF eM82kIaS99+MxI9NK6hOH39Y1L35lAmGcnG1m03P3j4d30HYkuoUNTTG6hJ7sJrXbowK kHbVVwBbQaGIuQJnsrylRz2kw1+MBDxuWcyiDygK57I2iSm8cD+J8fTpDXKRtdW9x8Bs i3OslFQ4sk+A943xnSVpQp/oQAWf9nH3HX7k8JmmxVVMcPCHdZ+sUQeC79WKL5Fgc/Jl Er47Uey4TIhWBk0KcWvwLv6FRoBO2AtloztR4hu5LBDcGlGHfirkPGs9kn8v3RvZnyXD nD4Q==
X-Gm-Message-State ALoCoQns07cf/C80CwW6zZUqXHe3mrWJ2vxQtGU4NyXhA930mQde+8bHG0mwbnxV84lac6O/ZJIfn7DRUguOtBP2EBWBzjQZrA==
X-Received by 10.98.64.215 with SMTP id f84mr25757666pfd.113.1452986676099; Sat, 16 Jan 2016 15:24:36 -0800 (PST)
X-Mailer git-send-email 2.7.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 102
Organization linux.* mail to news gateway
X-Original-Cc Jiri Slaby <jslaby@suse.cz>, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Cernekee <cernekee@gmail.com>, Jon Hunter <jonathanh@nvidia.com>, Paul Burton <paul.burton@imgtec.com>, Masahiro Yamada <yamada.masahiro@socionext.com>, Sebastian Frias <sf84@laposte.net>, Peter Hurley <peter@hurleysoftware.com>
X-Original-Date Sat, 16 Jan 2016 15:23:43 -0800
X-Original-Message-ID <1452986629-17210-7-git-send-email-peter@hurleysoftware.com>
X-Original-References <1452980244-20512-1-git-send-email-peter@hurleysoftware.com> <1452986629-17210-1-git-send-email-peter@hurleysoftware.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1311083

Show key headers only | View raw


Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
properties and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  2 +-
 drivers/tty/serial/earlycon.c | 31 +++++++++++++++++++++++++++++++
 include/linux/serial_core.h   |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cfd3b35..e8fd54a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -839,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match, options);
+		of_setup_earlycon(addr, match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7509ee34d..7089667 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,6 +19,7 @@
 #include <linux/io.h>
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
+#include <linux/of_fdt.h>
 
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
@@ -219,10 +220,13 @@ early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
+	const __be32 *val;
+	bool big_endian;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
@@ -230,6 +234,33 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	if (val)
+		port->mapbase += be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	if (val)
+		port->regshift = be32_to_cpu(*val);
+	big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
+		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
+		 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
+	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+	if (val) {
+		switch (be32_to_cpu(*val)) {
+		case 1:
+			port->iotype = UPIO_MEM;
+			break;
+		case 2:
+			port->iotype = UPIO_MEM16;
+			break;
+		case 4:
+			port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32;
+			break;
+		default:
+			pr_warn("[%s] unsupported reg-io-width\n", match->name);
+			return -EINVAL;
+		}
+	}
+
 	if (options) {
 		strlcpy(early_console_dev.options, options,
 			sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 62a4df0..6d1bed8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -360,6 +360,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
-- 
2.7.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 00/11] Earlycon cleanup Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
  [PATCH v5 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
  [PATCH v5 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
    Re: [PATCH v5 06/11] of: earlycon: Move address translation to  of_setup_earlycon() kbuild test robot <lkp@intel.com> - 2016-01-16 23:10 +0100
  [PATCH v5 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:40 +0100
  [PATCH v5 01/11] earlycon: Use common framework for earlycon declarations Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
    Re: [PATCH v5 05/11] of: earlycon: Initialize port fields from DT  properties kbuild test robot <lkp@intel.com> - 2016-01-16 23:00 +0100
  [PATCH v5 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 03/11] of: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 04/11] of: earlycon: Add options string handling Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 09/11] serial: 8250_early: Use port->regshift Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v5 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley <peter@hurleysoftware.com> - 2016-01-16 22:50 +0100
  [PATCH v6 11/12] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 05/12] of: earlycon: Add options string handling Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 04/12] of: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 09/12] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
  [PATCH v6 00/12] Earlycon cleanup Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 02/12] earlycon: Use common framework for earlycon declarations Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 10/12] serial: 8250_early: Use port->regshift Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 07/12] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 01/12] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 03/12] serial: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 08/12] serial: earlycon: Common log banner for command line and DT Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 06/12] of: earlycon: Initialize port fields from DT properties Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100
    [PATCH v6 12/12] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-17 00:30 +0100

csiph-web