Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/evbarm Add options GUMSTIX_NETBSD_ARGS_CONSOLE and ...



details:   https://anonhg.NetBSD.org/src/rev/39200c6438cf
branches:  trunk
changeset: 752797:39200c6438cf
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Sun Mar 07 09:18:51 2010 +0000

description:
Add options GUMSTIX_NETBSD_ARGS_CONSOLE and GUMSTIX_NETBSD_ARGS_BUSHEADER.
  Can specify arg 'console='(*new*) and 'busheader=' from u-boot.  These args
  use dynamically configuration.
Also change function name.  s/_line/_liner/.

diffstat:

 sys/arch/evbarm/conf/GUMSTIX              |    8 +-
 sys/arch/evbarm/conf/files.gumstix        |    4 +-
 sys/arch/evbarm/gumstix/gumstix_machdep.c |  126 ++++++++++++++++++++++-------
 3 files changed, 106 insertions(+), 32 deletions(-)

diffs (truncated from 320 to 300 lines):

diff -r d7a5f1e21d10 -r 39200c6438cf sys/arch/evbarm/conf/GUMSTIX
--- a/sys/arch/evbarm/conf/GUMSTIX      Sun Mar 07 09:05:19 2010 +0000
+++ b/sys/arch/evbarm/conf/GUMSTIX      Sun Mar 07 09:18:51 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: GUMSTIX,v 1.44 2010/03/07 07:33:29 kiyohara Exp $
+#      $NetBSD: GUMSTIX,v 1.45 2010/03/07 09:18:51 kiyohara Exp $
 #
 #      GUMSTIX -- Gumstix. Inc. gumstix platforms kernel
 #
@@ -22,6 +22,12 @@
 #options       XSCALE_CACHE_WRITE_THROUGH
 options        XSCALE_CACHE_READ_WRITE_ALLOCATE
 
+# Gumstix options
+# if not specfied 'busheader=' in args from u-boot, use GXIO_DEFAULT_EXPANSION.
+options        GUMSTIX_NETBSD_ARGS_BUSHEADER
+options        GUMSTIX_NETBSD_ARGS_CONSOLE     # dynamically configure console
+                                               # 'console=lcd' or ffuart,stuart
+
 # Standard system options
 
 options        RTC_OFFSET=0    # hardware clock is this many mins. west of GMT
diff -r d7a5f1e21d10 -r 39200c6438cf sys/arch/evbarm/conf/files.gumstix
--- a/sys/arch/evbarm/conf/files.gumstix        Sun Mar 07 09:05:19 2010 +0000
+++ b/sys/arch/evbarm/conf/files.gumstix        Sun Mar 07 09:18:51 2010 +0000
@@ -1,9 +1,11 @@
-#      $NetBSD: files.gumstix,v 1.14 2009/08/09 07:10:13 kiyohara Exp $
+#      $NetBSD: files.gumstix,v 1.15 2010/03/07 09:18:51 kiyohara Exp $
 #
 # Gumstix. Inc. Gumstix boards configuration info
 #
 
 file   arch/evbarm/gumstix/gumstix_machdep.c
+defflag opt_gumstix.h                          GUMSTIX_NETBSD_ARGS_BUSHEADER
+                                               GUMSTIX_NETBSD_ARGS_CONSOLE
 
 # CPU support and integrated peripherals
 include "arch/arm/xscale/files.pxa2x0"
diff -r d7a5f1e21d10 -r 39200c6438cf sys/arch/evbarm/gumstix/gumstix_machdep.c
--- a/sys/arch/evbarm/gumstix/gumstix_machdep.c Sun Mar 07 09:05:19 2010 +0000
+++ b/sys/arch/evbarm/gumstix/gumstix_machdep.c Sun Mar 07 09:18:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gumstix_machdep.c,v 1.24 2010/01/24 03:46:48 kiyohara Exp $ */
+/*     $NetBSD: gumstix_machdep.c,v 1.25 2010/03/07 09:18:51 kiyohara Exp $ */
 /*
  * Copyright (C) 2005, 2006, 2007  WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -137,6 +137,7 @@
  * boards using RedBoot firmware.
  */
 
+#include "opt_gumstix.h"
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
 #include "opt_pmap_debug.h"
@@ -257,7 +258,7 @@
 /* Prototypes */
 static void    read_system_serial(void);
 static void    process_kernel_args(int, char *[]);
-static void    process_kernel_args_line(char *);
+static void    process_kernel_args_liner(char *);
 #ifdef KGDB
 static void    kgdb_port_init(void);
 #endif
@@ -282,6 +283,10 @@
 int comcnspeed = CONSPEED;
 int comcnmode = CONMODE;
 
+#ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
+static char console[16];
+#endif
+
 extern void gxio_config_pin(void);
 extern void gxio_config_expansion(char *);
 
@@ -351,8 +356,7 @@
        /*NOTREACHED*/
 }
 
-static inline
-pd_entry_t *
+static inline pd_entry_t *
 read_ttb(void)
 {
   long ttb;
@@ -501,17 +505,13 @@
 
        pxa2x0_clkman_bootstrap(GUMSTIX_CLKMAN_VBASE);
 
+#ifndef GUMSTIX_NETBSD_ARGS_CONSOLE
        consinit();
+#endif
 #ifdef KGDB
        kgdb_port_init();
 #endif
 
-       /* Talk to the user */
-       printf("\nNetBSD/evbarm (gumstix) booting ...\n");
-
-       /* Read system serial */
-       read_system_serial();
-
         /*
         * Examine the boot args string for options we need to know about
         * now.
@@ -526,7 +526,16 @@
                 * Maybe r3 is 'boot args string' of 'bootm'.  This string is
                 * linely.
                 */
-               process_kernel_args_line((char *)u_boot_args[r3]);
+               process_kernel_args_liner((char *)u_boot_args[r3]);
+#ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
+       consinit();
+#endif
+
+       /* Talk to the user */
+       printf("\nNetBSD/evbarm (gumstix) booting ...\n");
+
+       /* Read system serial */
+       read_system_serial();
 
        memstart = SDRAM_START;
        memsize = ram_size;
@@ -939,7 +948,12 @@
        printf("\n");
 }
 
+#ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
 static const char busheader_name[] = "busheader=";
+#endif
+#ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
+static const char console_name[] = "console=";
+#endif
 static void
 process_kernel_args(int argc, char *argv[])
 {
@@ -948,12 +962,21 @@
        boothowto = 0;
 
        for (i = 1, j = 0; i < argc; i++) {
+#ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
                if (!strncmp(argv[i], busheader_name, strlen(busheader_name))) {
                        /* configure for GPIOs of busheader side */
                        gxio_config_expansion(argv[i] + strlen(busheader_name));
                        gxio_configured = 1;
                        continue;
                }
+#endif
+#ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
+               if (!strncmp(argv[i], console_name, strlen(console_name))) {
+                       strncpy(console, argv[i] + strlen(console_name),
+                           sizeof(console));
+                       consinit();
+               }
+#endif
                if (j == MAX_BOOT_STRING) {
                        *(bootargs + j) = '\0';
                        continue;
@@ -972,28 +995,49 @@
 }
 
 static void
-process_kernel_args_line(char *args)
+process_kernel_args_liner(char *args)
 {
        int i;
-       char expansion[256], *p, c;
+       char *p = NULL;
 
        boothowto = 0;
 
        strncpy(bootargs, args, sizeof(bootargs));
+#ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
        p = strstr(bootargs, busheader_name);
-       if (p == NULL)
-               gxio_config_expansion(NULL);
-       else {
+       if (p) {
+               char expansion[256], c;
+
                i = 0;
                do {
                        c = *(p + strlen(busheader_name) + i);
                        if (c == ' ')
                                c = '\0';
                        expansion[i++] = c;
-               } while (c != '\0');
+               } while (c != '\0' && i < sizeof(expansion));
                gxio_config_expansion(expansion);
                strcpy(p, p + i);
        }
+#endif
+       if (p == NULL) {
+               gxio_config_expansion(NULL);
+       }
+#ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
+       p = strstr(bootargs, console_name);
+       if (p != NULL) {
+               char c;
+
+               i = 0;
+               do {
+                       c = *(p + strlen(console_name) + i);
+                       if (c == ' ')
+                               c = '\0';
+                       console[i++] = c;
+               } while (c != '\0' && i < sizeof(console));
+               consinit();
+               strcpy(p, p + i);
+       }
+#endif
        boot_args = bootargs;
 
        parse_mi_bootargs(boot_args);
@@ -1024,6 +1068,7 @@
 consinit(void)
 {
        static int consinit_called = 0;
+       int rv;
 
        if (consinit_called != 0)
                return;
@@ -1034,13 +1079,17 @@
 
 #ifdef FFUARTCONSOLE
 #ifdef KGDB
-       if (0 == strcmp(kgdb_devname, "ffuart")){
+       if (strcmp(kgdb_devname, "ffuart") == 0){
                /* port is reserved for kgdb */
        } else
 #endif
+#if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
+       if (console[0] == '\0' || strcasecmp(console, "ffuart") == 0)
+#endif
        {
-               if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE,
-                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
+               rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE,
+                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
+               if (rv == 0) {
                        pxa2x0_clkman_config(CKEN_FFUART, 1);
                        return;
                }
@@ -1049,13 +1098,17 @@
 
 #ifdef STUARTCONSOLE
 #ifdef KGDB
-       if (0 == strcmp(kgdb_devname, "stuart")) {
+       if (strcmp(kgdb_devname, "stuart") == 0) {
                /* port is reserved for kgdb */
        } else
 #endif
+#if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
+       if (console[0] == '\0' || strcasecmp(console, "stuart") == 0)
+#endif
        {
-               if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_STUART_BASE,
-                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
+               rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_STUART_BASE,
+                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
+               if (rv == 0) {
                        pxa2x0_clkman_config(CKEN_STUART, 1);
                        return;
                }
@@ -1064,13 +1117,17 @@
 
 #ifdef BTUARTCONSOLE
 #ifdef KGDB
-       if (0 == strcmp(kgdb_devname, "btuart")) {
+       if (strcmp(kgdb_devname, "btuart") == 0) {
                /* port is reserved for kgdb */
        } else
 #endif
+#if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
+       if (console[0] == '\0' || strcasecmp(console, "btuart") == 0)
+#endif
        {
-               if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE,
-                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
+               rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE,
+                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
+               if (rv == 0) {
                        pxa2x0_clkman_config(CKEN_BTUART, 1);
                        return;
                }
@@ -1079,13 +1136,17 @@
 
 #ifdef HWUARTCONSOLE
 #ifdef KGDB
-       if (0 == strcmp(kgdb_devname, "hwuart")) {
+       if (strcmp(kgdb_devname, "hwuart") == 0) {
                /* port is reserved for kgdb */
        } else
 #endif
+#if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
+       if (console[0] == '\0' || strcasecmp(console, "hwuart") == 0)
+#endif
        {
-               if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_HWUART_BASE,
-                   comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {



Home | Main Index | Thread Index | Old Index