*
* (C) Copyright 2004, Greg Ungerer <greg.ungerer@opengear.com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm/arch/platform.h>
+#include <serial.h>
+#include <linux/compiler.h>
#ifndef CONFIG_SERIAL1
#error "Bad: you didn't configure serial ..."
int serial_console = 1;
-void serial_setbrg(void)
+static void ks8695_serial_setbrg(void)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
uartp->LCR = KS8695_UART_LINEC_WLEN8;
}
-int serial_init(void)
+static int ks8695_serial_init(void)
{
serial_console = 1;
serial_setbrg();
return 0;
}
-void serial_raw_putc(const char c)
+static void ks8695_serial_raw_putc(const char c)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
int i;
uartp->TX = c;
}
-void serial_putc(const char c)
+static void ks8695_serial_putc(const char c)
{
if (serial_console) {
- serial_raw_putc(c);
+ ks8695_serial_raw_putc(c);
if (c == '\n')
- serial_raw_putc('\r');
+ ks8695_serial_raw_putc('\r');
}
}
-int serial_tstc(void)
+static int ks8695_serial_tstc(void)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
if (serial_console)
return 0;
}
-void serial_puts(const char *s)
-{
- char c;
- while ((c = *s++) != 0)
- serial_putc(c);
-}
-
-int serial_getc(void)
+static int ks8695_serial_getc(void)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
;
return (uartp->RX);
}
+
+static struct serial_device ks8695_serial_drv = {
+ .name = "ks8695_serial",
+ .start = ks8695_serial_init,
+ .stop = NULL,
+ .setbrg = ks8695_serial_setbrg,
+ .putc = ks8695_serial_putc,
+ .puts = default_serial_puts,
+ .getc = ks8695_serial_getc,
+ .tstc = ks8695_serial_tstc,
+};
+
+void ks8695_serial_initialize(void)
+{
+ serial_register(&ks8695_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &ks8695_serial_drv;
+}