1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/init.h>
3 #include <linux/errno.h>
4 #include <linux/console.h>
6 #include <asm/sibyte/board.h>
8 #include <asm/fw/cfe/cfe_api.h>
9 #include <asm/fw/cfe/cfe_error.h>
11 extern int cfe_cons_handle
;
13 static void cfe_console_write(struct console
*cons
, const char *str
,
18 for (i
=0, last
=0; i
<count
; i
++) {
20 /* XXXKW can/should this ever happen? */
24 written
= cfe_write(cfe_cons_handle
, &str
[last
], i
-last
);
29 while (cfe_write(cfe_cons_handle
, "\r", 1) <= 0)
35 written
= cfe_write(cfe_cons_handle
, &str
[last
], count
-last
);
39 } while (last
< count
);
44 static int cfe_console_setup(struct console
*cons
, char *str
)
47 /* XXXKW think about interaction with 'console=' cmdline arg */
48 /* If none of the console options are configured, the build will break. */
49 if (cfe_getenv("BOOT_CONSOLE", consdev
, 32) >= 0) {
50 #ifdef CONFIG_SERIAL_SB1250_DUART
51 if (!strcmp(consdev
, "uart0")) {
53 } else if (!strcmp(consdev
, "uart1")) {
57 #ifdef CONFIG_VGA_CONSOLE
58 if (!strcmp(consdev
, "pcconsole0")) {
67 static struct console sb1250_cfe_cons
= {
69 .write
= cfe_console_write
,
70 .setup
= cfe_console_setup
,
71 .flags
= CON_PRINTBUFFER
,
75 static int __init
sb1250_cfe_console_init(void)
77 register_console(&sb1250_cfe_cons
);
81 console_initcall(sb1250_cfe_console_init
);