brcm47xx: prepare brcm47xx patches for sending to mainline.
[openwrt.git] / target / linux / brcm47xx / patches-2.6.34 / 014-MIPS-BCM47xx-Setup-and-register-serial-early.patch
1 From 4c6a515310f29c89f25a54a115cde905f97330f8 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 18 Jul 2010 14:59:24 +0200
4 Subject: [PATCH 4/5] MIPS: BCM47xx: Setup and register serial early
5
6 Swap the first and second serial if console=ttyS1 was set.
7 Set it up and register it for early serial support.
8
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
10 ---
11  arch/mips/Kconfig         |    1 -
12  arch/mips/bcm47xx/setup.c |   36 +++++++++++++++++++++++++++++++++++-
13  2 files changed, 35 insertions(+), 2 deletions(-)
14
15 --- a/arch/mips/Kconfig
16 +++ b/arch/mips/Kconfig
17 @@ -65,7 +65,6 @@ config BCM47XX
18         select SSB_B43_PCI_BRIDGE if PCI
19         select SSB_PCICORE_HOSTMODE if PCI
20         select GENERIC_GPIO
21 -       select SYS_HAS_EARLY_PRINTK
22         select CFE
23         help
24          Support for BCM47XX based boards
25 --- a/arch/mips/bcm47xx/setup.c
26 +++ b/arch/mips/bcm47xx/setup.c
27 @@ -28,6 +28,8 @@
28  #include <linux/types.h>
29  #include <linux/ssb/ssb.h>
30  #include <linux/ssb/ssb_embedded.h>
31 +#include <linux/serial.h>
32 +#include <linux/serial_8250.h>
33  #include <asm/bootinfo.h>
34  #include <asm/reboot.h>
35  #include <asm/time.h>
36 @@ -181,12 +183,44 @@ static int bcm47xx_get_invariants(struct
37  
38  void __init plat_mem_setup(void)
39  {
40 -       int err;
41 +       int i, err;
42 +       char buf[100];
43 +       struct ssb_mipscore *mcore;
44  
45         err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
46                                       bcm47xx_get_invariants);
47         if (err)
48                 panic("Failed to initialize SSB bus (err %d)\n", err);
49 +       mcore = &ssb_bcm47xx.mipscore;
50 +
51 +       nvram_getenv("kernel_args", buf, sizeof(buf));
52 +       if (!strncmp(buf, "console=ttyS1", 13)) {
53 +               struct ssb_serial_port port;
54 +
55 +               printk("Swapping serial ports!\n");
56 +               /* swap serial ports */
57 +               memcpy(&port, &mcore->serial_ports[0], sizeof(port));
58 +               memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1], sizeof(port));
59 +               memcpy(&mcore->serial_ports[1], &port, sizeof(port));
60 +       }
61 +
62 +       for (i = 0; i < mcore->nr_serial_ports; i++) {
63 +               struct ssb_serial_port *port = &(mcore->serial_ports[i]);
64 +               struct uart_port s;
65 +
66 +               memset(&s, 0, sizeof(s));
67 +               s.line = i;
68 +               s.mapbase = (unsigned int) port->regs;
69 +               s.membase = port->regs;
70 +               s.irq = port->irq + 2;
71 +               s.uartclk = port->baud_base;
72 +               s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
73 +               s.iotype = SERIAL_IO_MEM;
74 +               s.regshift = port->reg_shift;
75 +
76 +               early_serial_setup(&s);
77 +       }
78 +       printk("Serial init done.\n");
79  
80         _machine_restart = bcm47xx_machine_restart;
81         _machine_halt = bcm47xx_machine_halt;