From patchwork Fri Aug 2 15:51:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Cooper X-Patchwork-Id: 2838021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E1F8BF535 for ; Fri, 2 Aug 2013 15:54:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F39632041D for ; Fri, 2 Aug 2013 15:54:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E38F12042A for ; Fri, 2 Aug 2013 15:54:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5HfI-0006a0-N9; Fri, 02 Aug 2013 15:53:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5Hev-0006pR-Gu; Fri, 02 Aug 2013 15:52:53 +0000 Received: from mho-03-ewr.mailhop.org ([204.13.248.66] helo=mho-01-ewr.mailhop.org) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5HeK-0006j4-4L for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2013 15:52:24 +0000 Received: from pool-72-84-113-162.nrflva.fios.verizon.net ([72.84.113.162] helo=titan) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1V5Hdz-000LvL-3z; Fri, 02 Aug 2013 15:51:55 +0000 Received: from triton.localdomain (omega.lakedaemon.net [10.16.5.5]) by titan (Postfix) with ESMTP id 57C0247A218; Fri, 2 Aug 2013 11:51:43 -0400 (EDT) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 72.84.113.162 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19Bs1WB72qB3zTon2LZA4e0vlt9/gEWuS4= From: Jason Cooper To: zonque@gmail.com, nico@fluxnic.net Subject: [RFC PATCH V2 6/9] serial: split out 8250 code, configurable reg addr Date: Fri, 2 Aug 2013 15:51:13 +0000 Message-Id: <30c8a8fcb81ea8ed3854e1b8af879a4ebb3f7e5e.1375457714.git.jason@lakedaemon.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: In-Reply-To: References: <51F2A014.7000209@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130802_115216_473395_586F1B49 X-CRM114-Status: GOOD ( 13.13 ) X-Spam-Score: -1.9 (-) Cc: stigge@antcom.de, thomas.petazzoni@free-electrons.com, swarren@nvidia.com, Jason Cooper , devicetree@vger.kernel.org, s.neumann@raumfeld.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason Cooper --- Makefile | 9 +++++++-- matcher.lds | 2 +- print.c | 8 +------- serial-8250.c | 21 +++++++++++++++++++++ serial.h | 10 ++++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 serial-8250.c create mode 100644 serial.h diff --git a/Makefile b/Makefile index bb3a154..c799012 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,17 @@ LDFLAGS=-static -nostdlib GCC=$(CROSS_COMPILE)gcc OBJCOPY=$(CROSS_COMPILE)objcopy LD=$(CROSS_COMPILE)ld -LOADADDR=0xa0008000 +LOADADDR=0x10008000 BINFMT=elf32-littlearm MFG=raumfeld +UART=8250 +UART_BASE=0xf1012000 + +CFLAGS+=-DUART_BASE=$(UART_BASE) BOARD_OBJ = board-$(MFG).o +UART_OBJ = serial-$(UART).o COMMON_OBJS = \ main.o \ @@ -38,7 +43,7 @@ zimage.o: input/zImage %.o: %.c $(GCC) $(CFLAGS) -c $^ -matcher: $(COMMON_OBJS) $(BOARD_OBJ) $(INPUT_OBJS) +matcher: $(COMMON_OBJS) $(BOARD_OBJ) $(UART_OBJ) $(INPUT_OBJS) $(LD) $(LDFLAGS) -T matcher.lds -o $@ $^ matcher.bin: matcher diff --git a/matcher.lds b/matcher.lds index f73ed1d..96eb16a 100644 --- a/matcher.lds +++ b/matcher.lds @@ -1,5 +1,5 @@ SECTIONS { - . = 0xa0008000; + . = 0x10008000; .text : { * (.text); } .data : { * (.data); } .rodata : { * (.rodata); } diff --git a/print.c b/print.c index c799380..9dbc7b6 100644 --- a/print.c +++ b/print.c @@ -1,5 +1,6 @@ #include "types.h" #include "print.h" +#include "serial.h" static inline void nop(int n) { @@ -7,12 +8,6 @@ static inline void nop(int n) asm("nop"); } -static void __putch(char c) -{ - *(volatile __u32 *) 0x40100000 = c; - nop(100); -} - void putch(char c) { __putch(c); @@ -39,4 +34,3 @@ void putstr(const char *s) while (*s) putch(*s++); } - diff --git a/serial-8250.c b/serial-8250.c new file mode 100644 index 0000000..0d5d35e --- /dev/null +++ b/serial-8250.c @@ -0,0 +1,21 @@ +#include "types.h" +#include "register.h" +#include "serial.h" + +/* + * Whole heartedly copied from barebox's mach-mvebu debug code. Thanks to + * Thomas Petazzoni for the original code. + */ +void __putch(char c) +{ + /* Wait until there is space in the FIFO */ + while (!(readl(UART_BASE + UART_LSR) & LSR_THRE)) + ; + + /* Send the character */ + writel(c, UART_BASE + UART_THR); + + /* Wait to make sure it hits the line */ + while (!(readl(UART_BASE + UART_LSR) & LSR_THRE)) + ; +} diff --git a/serial.h b/serial.h new file mode 100644 index 0000000..c5e4581 --- /dev/null +++ b/serial.h @@ -0,0 +1,10 @@ +#ifndef _SERIAL_H +#define _SERIAL_H + +#define BIT(nr) (1UL << (nr)) +#define UART_THR 0x00 +#define UART_LSR 0x14 +#define LSR_THRE BIT(5) + +void __putch(char); +#endif