Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 1 | /* |
| 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. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 16 | #include <asm/fw/fw.h> |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 17 | |
| 18 | extern char except_vec_nmi; |
| 19 | extern char except_vec_ejtag_debug; |
| 20 | |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 21 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 22 | static void __init console_config(void) |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 23 | { |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 24 | char console_string[40]; |
| 25 | int baud = 0; |
| 26 | char parity = '\0', bits = '\0', flow = '\0'; |
| 27 | char *s; |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 28 | |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 29 | 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. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 58 | } |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 59 | } |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 60 | #endif |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 61 | |
| 62 | static 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 | |
| 73 | static 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 | |
| 84 | void __init prom_init(void) |
| 85 | { |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 86 | board_nmi_handler_setup = mips_nmi_setup; |
| 87 | board_ejtag_handler_setup = mips_ejtag_setup; |
| 88 | |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 89 | fw_init_cmdline(); |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 90 | #ifdef CONFIG_EARLY_PRINTK |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 91 | 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. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 95 | #endif |
| 96 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
Steven J. Hill | 0be2abb | 2013-03-25 14:35:30 -0500 | [diff] [blame^] | 97 | if ((strstr(fw_getcmdline(), "console=")) == NULL) |
| 98 | strcat(fw_getcmdline(), " console=ttyS0,38400n8r"); |
| 99 | console_config(); |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 100 | #endif |
| 101 | } |
Steven J. Hill | 9b73100 | 2013-01-17 11:37:03 -0600 | [diff] [blame] | 102 | |
| 103 | void prom_free_prom_memory(void) |
| 104 | { |
| 105 | } |