source: trunk/target/linux/brcm47xx/patches-2.6.35/014-MIPS-BCM47xx-Setup-and-register-serial-early.patch @ 22424

Last change on this file since 22424 was 22424, checked in by hauke, 6 years ago

brcm47xx: some fixes

  • fix return codes of nvram_getenv. Now it behaves like cfe_getenv.
  • also check cfe for kernel_args param.
  • some style fixes
File size: 2.3 KB
  • arch/mips/bcm47xx/setup.c

    From 9be402f069cc259ad5795b77567d66c4e7f6bef6 Mon Sep 17 00:00:00 2001
    From: Hauke Mehrtens <hauke@hauke-m.de>
    Date: Sun, 18 Jul 2010 14:59:24 +0200
    Subject: [PATCH 4/6] MIPS: BCM47xx: Setup and register serial early
    
    Swap the first and second serial if console=ttyS1 was set.
    Set it up and register it for early serial support.
    
    This patch has been in OpenWRT for a long time.
    
    Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
    ---
     arch/mips/bcm47xx/setup.c |   39 ++++++++++++++++++++++++++++++++++++++-
     1 files changed, 38 insertions(+), 1 deletions(-)
    
    a b  
    2828#include <linux/types.h> 
    2929#include <linux/ssb/ssb.h> 
    3030#include <linux/ssb/ssb_embedded.h> 
     31#include <linux/serial.h> 
     32#include <linux/serial_8250.h> 
    3133#include <asm/bootinfo.h> 
    3234#include <asm/reboot.h> 
    3335#include <asm/time.h> 
    static int bcm47xx_get_invariants(struct 
    190192 
    191193void __init plat_mem_setup(void) 
    192194{ 
    193         int err; 
     195        int i, err; 
     196        char buf[100]; 
     197        struct ssb_mipscore *mcore; 
    194198 
    195199        err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, 
    196200                                      bcm47xx_get_invariants); 
    197201        if (err) 
    198202                panic("Failed to initialize SSB bus (err %d)\n", err); 
     203        mcore = &ssb_bcm47xx.mipscore; 
     204 
     205        if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0 || 
     206            cfe_getenv("kernel_args", buf, sizeof(buf)) >= 0) { 
     207                if (strstr(buf, "console=ttyS1")) { 
     208                        struct ssb_serial_port port; 
     209 
     210                        printk(KERN_DEBUG "Swapping serial ports!\n"); 
     211                        /* swap serial ports */ 
     212                        memcpy(&port, &mcore->serial_ports[0], sizeof(port)); 
     213                        memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1], 
     214                               sizeof(port)); 
     215                        memcpy(&mcore->serial_ports[1], &port, sizeof(port)); 
     216                } 
     217        } 
     218 
     219        for (i = 0; i < mcore->nr_serial_ports; i++) { 
     220                struct ssb_serial_port *port = &(mcore->serial_ports[i]); 
     221                struct uart_port s; 
     222 
     223                memset(&s, 0, sizeof(s)); 
     224                s.line = i; 
     225                s.mapbase = (unsigned int) port->regs; 
     226                s.membase = port->regs; 
     227                s.irq = port->irq + 2; 
     228                s.uartclk = port->baud_base; 
     229                s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ; 
     230                s.iotype = SERIAL_IO_MEM; 
     231                s.regshift = port->reg_shift; 
     232 
     233                early_serial_setup(&s); 
     234        } 
     235        printk(KERN_DEBUG "Serial init done.\n"); 
    199236 
    200237        _machine_restart = bcm47xx_machine_restart; 
    201238        _machine_halt = bcm47xx_machine_halt; 
Note: See TracBrowser for help on using the repository browser.