Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * RISC-V SBI based earlycon
0004  *
0005  * Copyright (C) 2018 Anup Patel <anup@brainfault.org>
0006  */
0007 #include <linux/kernel.h>
0008 #include <linux/console.h>
0009 #include <linux/init.h>
0010 #include <linux/serial_core.h>
0011 #include <asm/sbi.h>
0012 
0013 static void sbi_putc(struct uart_port *port, unsigned char c)
0014 {
0015     sbi_console_putchar(c);
0016 }
0017 
0018 static void sbi_console_write(struct console *con,
0019                   const char *s, unsigned n)
0020 {
0021     struct earlycon_device *dev = con->data;
0022     uart_console_write(&dev->port, s, n, sbi_putc);
0023 }
0024 
0025 static int __init early_sbi_setup(struct earlycon_device *device,
0026                   const char *opt)
0027 {
0028     device->con->write = sbi_console_write;
0029     return 0;
0030 }
0031 EARLYCON_DECLARE(sbi, early_sbi_setup);