Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/marvell Add MVSOC_CONSOLE_EARLY option to get a...



details:   https://anonhg.NetBSD.org/src/rev/30aa6678cf06
branches:  trunk
changeset: 780857:30aa6678cf06
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Aug 10 02:18:20 2012 +0000

description:
Add MVSOC_CONSOLE_EARLY option to get a com console as soon as initarm
is entered.

diffstat:

 sys/arch/arm/marvell/mvsoc.c |  61 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 2 deletions(-)

diffs (96 lines):

diff -r 61f0d03378d7 -r 30aa6678cf06 sys/arch/arm/marvell/mvsoc.c
--- a/sys/arch/arm/marvell/mvsoc.c      Thu Aug 09 23:56:35 2012 +0000
+++ b/sys/arch/arm/marvell/mvsoc.c      Fri Aug 10 02:18:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mvsoc.c,v 1.8 2012/08/01 10:34:42 kiyohara Exp $       */
+/*     $NetBSD: mvsoc.c,v 1.9 2012/08/10 02:18:20 matt Exp $   */
 /*
  * Copyright (c) 2007, 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsoc.c,v 1.8 2012/08/01 10:34:42 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsoc.c,v 1.9 2012/08/10 02:18:20 matt Exp $");
 
 #include "opt_cputypes.h"
 #include "opt_mvsoc.h"
@@ -48,6 +48,11 @@
 
 #include "locators.h"
 
+#ifdef MVSOC_CONSOLE_EARLY
+#include <dev/ic/ns16550reg.h>
+#include <dev/ic/comreg.h>
+#include <dev/cons.h>
+#endif
 
 static int mvsoc_match(device_t, struct cfdata *, void *);
 static void mvsoc_attach(device_t, device_t, void *);
@@ -63,6 +68,53 @@
 void (*mvsoc_intr_init)(void);
 
 
+#ifdef MVSOC_CONSOLE_EARLY
+static vaddr_t com_base;
+
+static inline uint32_t
+uart_read(bus_size_t o)
+{
+       return *(volatile uint32_t *)(com_base + (o << 2));
+}
+
+static inline void
+uart_write(bus_size_t o, uint32_t v)
+{
+       *(volatile uint32_t *)(com_base + (o << 2)) = v;
+}
+
+static int
+mvsoc_cngetc(dev_t dv)
+{
+        if ((uart_read(com_lsr) & LSR_RXRDY) == 0)
+               return -1;
+
+       return uart_read(com_data) & 0xff;
+}
+
+static void
+mvsoc_cnputc(dev_t dv, int c)
+{
+       int timo = 150000;
+
+        while ((uart_read(com_lsr) & LSR_TXRDY) == 0 && --timo > 0)
+               ;
+
+       uart_write(com_data, c);
+
+       timo = 150000;
+        while ((uart_read(com_lsr) & LSR_TSRE) == 0 && --timo > 0)
+               ;
+}
+
+static struct consdev mvsoc_earlycons = {
+       .cn_putc = mvsoc_cnputc,
+       .cn_getc = mvsoc_cngetc,
+       .cn_pollc = nullcnpollc,
+};
+#endif
+
+
 /* attributes */
 static struct {
        int tag;
@@ -522,6 +574,11 @@
        dsc_base = iobase + MVSOC_DSC_BASE;
        mlmb_base = iobase + MVSOC_MLMB_BASE;
        pex_base = iobase + MVSOC_PEX_BASE;
+#ifdef MVSOC_CONSOLE_EARLY
+       com_base = iobase + MVSOC_COM0_BASE;
+       cn_tab = &mvsoc_earlycons;
+       printf("Hello\n");
+#endif
 }
 
 /*



Home | Main Index | Thread Index | Old Index