linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: zoss@devai.org (Zoltan Devai)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 14/15] ARM: uncompress: Get decompress UART info from DT
Date: Sun, 23 Oct 2011 23:10:44 +0200	[thread overview]
Message-ID: <1319404245-12740-14-git-send-email-zoss@devai.org> (raw)
In-Reply-To: <1319404245-12740-1-git-send-email-zoss@devai.org>

Allow the static decompress UART setup in uncompress.h
files to be overridden with an ucuart description in DT.

At a later stage, this may also allow to skip the
inclusion of uncompress.h files on arches which are DT-only,
to get rid of these files completely.

Signed-off-by: Zoltan Devai <zoss@devai.org>
---
 arch/arm/Kconfig                  |    9 +++++++
 arch/arm/boot/compressed/Makefile |    7 +++++
 arch/arm/boot/compressed/head.S   |    8 ++++++
 arch/arm/boot/compressed/print.c  |   45 +++++++++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7a011f4..edfd4b7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1866,6 +1866,15 @@ config ZBOOT_ROM_SH_MOBILE_SDHI
 
 endchoice
 
+config UCUART_DT
+	bool "Configure the decompress UART port from DT"
+	depends on OF
+	help
+	  With this option, the decompressor will use the UART port set up
+	  via the device tree.
+	  This configuration will override the hardcoded settings in any
+	  uncompress.h files.
+
 config ARM_APPENDED_DTB
 	bool "Use appended device tree blob to zImage (EXPERIMENTAL)"
 	depends on OF && !ZBOOT_ROM && EXPERIMENTAL
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index d955d4f..a4a1b8b 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -110,6 +110,13 @@ ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
 OBJS	+= $(libfdt_objs) atags_to_fdt.o
 endif
 
+$(addprefix $(obj)/,$(libfdt_objs) print.o): \
+	$(addprefix $(obj)/,$(libfdt_hdrs))
+
+ifeq ($(CONFIG_UCUART_DT),y)
+OBJS	+= $(libfdt_objs)
+endif
+
 targets       := vmlinux vmlinux.lds \
 		 piggy.$(suffix_y) piggy.$(suffix_y).o \
 		 lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS)
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 9f5ac11..b80e5df 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -443,6 +443,14 @@ not_relocated:	mov	r0, #0
 		cmp	r2, r3
 		blo	1b
 
+#ifdef CONFIG_UCUART_DT
+/* Set up the uncompress UART port from DT data */
+		stmfd	sp!, {r0-r3, ip, lr}
+		mov	r0, r6			@ ATAG / DT pointer
+		bl	ucuart_init_dt
+		ldmfd	sp!, {r0-r3, ip, lr}
+#endif /* CONFIG_UCUART_DT */
+
 /*
  * The C runtime environment should now be setup sufficiently.
  * Set up some pointers, and start decompressing.
diff --git a/arch/arm/boot/compressed/print.c b/arch/arm/boot/compressed/print.c
index 1529d15..cbb0dbf 100644
--- a/arch/arm/boot/compressed/print.c
+++ b/arch/arm/boot/compressed/print.c
@@ -49,9 +49,54 @@ void ucuart_init(int base, int regshift, enum ucuart_iotypes iotype,
 		 int flush_val);
 
 void ucuart_init_8250(int base, int regshift, enum ucuart_iotypes iotype);
+void ucuart_init_amba01x(int base);
 
 struct uncompress_uart ucuart;
 
+#ifdef CONFIG_UCUART_DT
+#include <libfdt.h>
+
+/* Just a concept sketch... */
+void ucuart_init_dt(void *fdt)
+{
+	int ret, offset;
+	const void *prop;
+	const int *uart_base, *uart_regshift;
+	enum ucuart_iotypes iotype = UCUART_IO_MEM8;
+
+	ret = fdt_check_header(fdt);
+	if (ret < 0)
+		return;
+
+	offset = fdt_path_offset(fdt, "/chosen");
+	if (offset == -FDT_ERR_NOTFOUND)
+		return;
+
+	prop = fdt_getprop(fdt, offset, "linux,ucuart-8250", NULL);
+	if (!prop) {
+		putstr("non-8250 uart\n");
+		return;
+	}
+
+	prop = fdt_getprop(fdt, offset, "linux,ucuart-io-32", NULL);
+	if (prop)
+		iotype = UCUART_IO_MEM32;
+
+	uart_base = fdt_getprop(fdt, offset, "linux,ucuart-base", NULL);
+	uart_regshift = fdt_getprop(fdt, offset, "linux,ucuart-regshift", NULL);
+
+	prop = fdt_getprop(fdt, offset, "linux,ucuart-8250", NULL);
+	if (prop)
+		ucuart_init_8250(*uart_base, *uart_regshift, iotype);
+
+	prop = fdt_getprop(fdt, offset, "linux,ucuart-amba01x", NULL);
+	if (prop)
+		ucuart_init_amba01x(*uart_base);
+
+	fdt_pack(fdt);
+}
+#endif
+
 #include <mach/uncompress.h>
 
 #ifndef ARCH_UCUART_NONGENERIC
-- 
1.7.4.1

  parent reply	other threads:[~2011-10-23 21:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-23 21:10 [RFC PATCH 01/15] ARM: uncompress.h: Remove unused arch_decomp_wdog defines Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 02/15] ARM: uncompress: Remove unused definition of ARCH_HAS_DECOMP_WATCHDOG Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 03/15] ARM: uncompress.h: Introduce ARCH_HAVE_DECOMP_SETUP Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 04/15] ARM: uncompress: Only call arch_decomp_setup when needed Zoltan Devai
2011-10-24  6:55   ` Uwe Kleine-König
2011-10-23 21:10 ` [RFC PATCH 05/15] ARM: uncompress.h: Remove unused arch_decomp_setup declarations Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 06/15] ARM: uncompress: Remove unused Trace functions Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 07/15] ARM: uncompress: Move decompressing related stuff to decompress.c Zoltan Devai
2011-10-24  9:17   ` Russell King - ARM Linux
2011-10-24  9:23     ` Russell King - ARM Linux
2011-10-23 21:10 ` [RFC PATCH 08/15] ARM: uncompress: Rename misc.c to print.c Zoltan Devai
2011-10-24  6:58   ` Uwe Kleine-König
2011-10-23 21:10 ` [RFC PATCH 09/15] ARM: uncompress: Introduce ucuart as low-level serial port driver Zoltan Devai
2011-10-24  9:26   ` Russell King - ARM Linux
2011-10-23 21:10 ` [RFC PATCH 10/15] ARM: uncompress.h: Convert machines to use the new ucuart driver Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 11/15] ARM: uncompress: Call arch_decomp_setup by default Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 12/15] ARM: uncompress.h: make the ucuart driver the default implementation Zoltan Devai
2011-10-23 21:10 ` [RFC PATCH 13/15] ARM: uncompress.h: Cleanup header guards and banners Zoltan Devai
2011-10-24  9:29   ` Russell King - ARM Linux
2011-10-23 21:10 ` Zoltan Devai [this message]
2011-10-24  9:30   ` [RFC PATCH 14/15] ARM: uncompress: Get decompress UART info from DT Russell King - ARM Linux
2011-10-25  7:38     ` Tony Lindgren
2011-10-23 21:10 ` [RFC PATCH 15/15] ARM: uncompress: Add documentation Zoltan Devai

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=1319404245-12740-14-git-send-email-zoss@devai.org \
    --to=zoss@devai.org \
    --cc=linux-arm-kernel@lists.infradead.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).