Anup Patel | 27de1f5 | 2018-12-04 19:25:05 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * RISC-V SBI based earlycon |
| 4 | * |
| 5 | * Copyright (C) 2018 Anup Patel <anup@brainfault.org> |
| 6 | */ |
| 7 | #include <linux/kernel.h> |
| 8 | #include <linux/console.h> |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/serial_core.h> |
| 11 | #include <asm/sbi.h> |
| 12 | |
Andreas Schwab | a19f747 | 2019-01-10 18:11:39 +0100 | [diff] [blame] | 13 | static void sbi_putc(struct uart_port *port, int c) |
Anup Patel | 27de1f5 | 2018-12-04 19:25:05 +0530 | [diff] [blame] | 14 | { |
Andreas Schwab | a19f747 | 2019-01-10 18:11:39 +0100 | [diff] [blame] | 15 | sbi_console_putchar(c); |
| 16 | } |
Anup Patel | 27de1f5 | 2018-12-04 19:25:05 +0530 | [diff] [blame] | 17 | |
Andreas Schwab | a19f747 | 2019-01-10 18:11:39 +0100 | [diff] [blame] | 18 | static void sbi_console_write(struct console *con, |
| 19 | const char *s, unsigned n) |
| 20 | { |
| 21 | struct earlycon_device *dev = con->data; |
| 22 | uart_console_write(&dev->port, s, n, sbi_putc); |
Anup Patel | 27de1f5 | 2018-12-04 19:25:05 +0530 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | static int __init early_sbi_setup(struct earlycon_device *device, |
| 26 | const char *opt) |
| 27 | { |
| 28 | device->con->write = sbi_console_write; |
| 29 | return 0; |
| 30 | } |
| 31 | EARLYCON_DECLARE(sbi, early_sbi_setup); |