blob: 357c0e105600496630cf3c90f723dbfdbc648fd0 [file] [log] [blame]
Steven J. Hill30700332012-05-30 21:02:49 +00001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */
8#include <linux/init.h>
9#include <linux/io.h>
10
11#include <asm/bootinfo.h>
12#include <asm/cacheflush.h>
13#include <asm/traps.h>
14#include <asm/mips-boards/generic.h>
15#include <asm/mips-boards/prom.h>
Steven J. Hill0be2abb2013-03-25 14:35:30 -050016#include <asm/fw/fw.h>
Steven J. Hill30700332012-05-30 21:02:49 +000017
18extern char except_vec_nmi;
19extern char except_vec_ejtag_debug;
20
Steven J. Hill0be2abb2013-03-25 14:35:30 -050021#ifdef CONFIG_SERIAL_8250_CONSOLE
22static void __init console_config(void)
Steven J. Hill30700332012-05-30 21:02:49 +000023{
Steven J. Hill0be2abb2013-03-25 14:35:30 -050024 char console_string[40];
25 int baud = 0;
26 char parity = '\0', bits = '\0', flow = '\0';
27 char *s;
Steven J. Hill30700332012-05-30 21:02:49 +000028
Steven J. Hill0be2abb2013-03-25 14:35:30 -050029 if ((strstr(fw_getcmdline(), "console=")) == NULL) {
30 s = fw_getenv("modetty0");
31 if (s) {
32 while (*s >= '0' && *s <= '9')
33 baud = baud*10 + *s++ - '0';
34 if (*s == ',')
35 s++;
36 if (*s)
37 parity = *s++;
38 if (*s == ',')
39 s++;
40 if (*s)
41 bits = *s++;
42 if (*s == ',')
43 s++;
44 if (*s == 'h')
45 flow = 'r';
46 }
47 if (baud == 0)
48 baud = 38400;
49 if (parity != 'n' && parity != 'o' && parity != 'e')
50 parity = 'n';
51 if (bits != '7' && bits != '8')
52 bits = '8';
53 if (flow == '\0')
54 flow = 'r';
55 sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
56 parity, bits, flow);
57 strcat(fw_getcmdline(), console_string);
Steven J. Hill30700332012-05-30 21:02:49 +000058 }
Steven J. Hill30700332012-05-30 21:02:49 +000059}
Steven J. Hill0be2abb2013-03-25 14:35:30 -050060#endif
Steven J. Hill30700332012-05-30 21:02:49 +000061
62static void __init mips_nmi_setup(void)
63{
64 void *base;
65
66 base = cpu_has_veic ?
67 (void *)(CAC_BASE + 0xa80) :
68 (void *)(CAC_BASE + 0x380);
69 memcpy(base, &except_vec_nmi, 0x80);
70 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
71}
72
73static void __init mips_ejtag_setup(void)
74{
75 void *base;
76
77 base = cpu_has_veic ?
78 (void *)(CAC_BASE + 0xa00) :
79 (void *)(CAC_BASE + 0x300);
80 memcpy(base, &except_vec_ejtag_debug, 0x80);
81 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
82}
83
84void __init prom_init(void)
85{
Steven J. Hill30700332012-05-30 21:02:49 +000086 board_nmi_handler_setup = mips_nmi_setup;
87 board_ejtag_handler_setup = mips_ejtag_setup;
88
Steven J. Hill0be2abb2013-03-25 14:35:30 -050089 fw_init_cmdline();
Steven J. Hill30700332012-05-30 21:02:49 +000090#ifdef CONFIG_EARLY_PRINTK
Steven J. Hill0be2abb2013-03-25 14:35:30 -050091 if ((strstr(fw_getcmdline(), "console=ttyS0")) != NULL)
92 fw_init_early_console(0);
93 else if ((strstr(fw_getcmdline(), "console=ttyS1")) != NULL)
94 fw_init_early_console(1);
Steven J. Hill30700332012-05-30 21:02:49 +000095#endif
96#ifdef CONFIG_SERIAL_8250_CONSOLE
Steven J. Hill0be2abb2013-03-25 14:35:30 -050097 if ((strstr(fw_getcmdline(), "console=")) == NULL)
98 strcat(fw_getcmdline(), " console=ttyS0,38400n8r");
99 console_config();
Steven J. Hill30700332012-05-30 21:02:49 +0000100#endif
101}
Steven J. Hill9b731002013-01-17 11:37:03 -0600102
103void prom_free_prom_memory(void)
104{
105}