aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/sibyte/common/cfe_console.c
diff options
context:
space:
mode:
authorImre Kaloz <kaloz@openwrt.org>2009-06-02 08:22:06 -0400
committerRalf Baechle <ralf@linux-mips.org>2009-06-17 06:06:27 -0400
commit05f94eebd55ef69a354d3ea70179e40ea4c34de6 (patch)
treee97c73c3b3eeabcc888f8b5f21d97a2976eabc5c /arch/mips/sibyte/common/cfe_console.c
parent435f81f4a24206f82ce10d430fa6f312cee80669 (diff)
MIPS: Sibyte: Remove standalone kernel support
CFE is the only supported and used bootloader on the SiByte boards, the standalone kernel support has been never used outside Broadcom. Remove it and make the kernel use CFE by default. Signed-off-by: Imre Kaloz <kaloz@openwrt.org> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/sibyte/common/cfe_console.c')
-rw-r--r--arch/mips/sibyte/common/cfe_console.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/arch/mips/sibyte/common/cfe_console.c b/arch/mips/sibyte/common/cfe_console.c
new file mode 100644
index 000000000000..81e3d54376e9
--- /dev/null
+++ b/arch/mips/sibyte/common/cfe_console.c
@@ -0,0 +1,79 @@
1#include <linux/init.h>
2#include <linux/errno.h>
3#include <linux/console.h>
4
5#include <asm/sibyte/board.h>
6
7#include <asm/fw/cfe/cfe_api.h>
8#include <asm/fw/cfe/cfe_error.h>
9
10extern int cfe_cons_handle;
11
12static void cfe_console_write(struct console *cons, const char *str,
13 unsigned int count)
14{
15 int i, last, written;
16
17 for (i=0, last=0; i<count; i++) {
18 if (!str[i])
19 /* XXXKW can/should this ever happen? */
20 return;
21 if (str[i] == '\n') {
22 do {
23 written = cfe_write(cfe_cons_handle, &str[last], i-last);
24 if (written < 0)
25 ;
26 last += written;
27 } while (last < i);
28 while (cfe_write(cfe_cons_handle, "\r", 1) <= 0)
29 ;
30 }
31 }
32 if (last != count) {
33 do {
34 written = cfe_write(cfe_cons_handle, &str[last], count-last);
35 if (written < 0)
36 ;
37 last += written;
38 } while (last < count);
39 }
40
41}
42
43static int cfe_console_setup(struct console *cons, char *str)
44{
45 char consdev[32];
46 /* XXXKW think about interaction with 'console=' cmdline arg */
47 /* If none of the console options are configured, the build will break. */
48 if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
49#ifdef CONFIG_SERIAL_SB1250_DUART
50 if (!strcmp(consdev, "uart0")) {
51 setleds("u0cn");
52 } else if (!strcmp(consdev, "uart1")) {
53 setleds("u1cn");
54#endif
55#ifdef CONFIG_VGA_CONSOLE
56 } else if (!strcmp(consdev, "pcconsole0")) {
57 setleds("pccn");
58#endif
59 } else
60 return -ENODEV;
61 }
62 return 0;
63}
64
65static struct console sb1250_cfe_cons = {
66 .name = "cfe",
67 .write = cfe_console_write,
68 .setup = cfe_console_setup,
69 .flags = CON_PRINTBUFFER,
70 .index = -1,
71};
72
73static int __init sb1250_cfe_console_init(void)
74{
75 register_console(&sb1250_cfe_cons);
76 return 0;
77}
78
79console_initcall(sb1250_cfe_console_init);