Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc. |
| 4 | * |
| 5 | * modified for marvell db64360 eval board by |
| 6 | * Ingo Assmus <ingo.assmus@keymile.com> |
| 7 | * |
| 8 | * modified for cpci750 board by |
| 9 | * Reinhard Arlt <reinhard.arlt@esd-electronics.com> |
| 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * serial.c - serial support for esd cpci750 board |
| 16 | */ |
| 17 | |
| 18 | /* supports the MPSC */ |
| 19 | |
| 20 | #include <common.h> |
| 21 | #include <command.h> |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 22 | #include <serial.h> |
| 23 | #include <linux/compiler.h> |
| 24 | |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 25 | #include "../../Marvell/include/memory.h" |
| 26 | #include "serial.h" |
| 27 | |
| 28 | #include "mpsc.h" |
| 29 | |
| 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 32 | static int p3mx_serial_init(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 33 | { |
| 34 | mpsc_init (gd->baudrate); |
| 35 | |
| 36 | return (0); |
| 37 | } |
| 38 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 39 | static void p3mx_serial_putc(const char c) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 40 | { |
| 41 | if (c == '\n') |
| 42 | mpsc_putchar ('\r'); |
| 43 | |
| 44 | mpsc_putchar (c); |
| 45 | } |
| 46 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 47 | static int p3mx_serial_getc(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 48 | { |
| 49 | return mpsc_getchar (); |
| 50 | } |
| 51 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 52 | static int p3mx_serial_tstc(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 53 | { |
| 54 | return mpsc_test_char (); |
| 55 | } |
| 56 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 57 | static void p3mx_serial_setbrg(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 58 | { |
| 59 | galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate); |
| 60 | } |
| 61 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 62 | static struct serial_device p3mx_serial_drv = { |
| 63 | .name = "p3mx_serial", |
| 64 | .start = p3mx_serial_init, |
| 65 | .stop = NULL, |
| 66 | .setbrg = p3mx_serial_setbrg, |
| 67 | .putc = p3mx_serial_putc, |
Marek Vasut | ec3fd68 | 2012-10-06 14:07:02 +0000 | [diff] [blame] | 68 | .puts = default_serial_puts, |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 69 | .getc = p3mx_serial_getc, |
| 70 | .tstc = p3mx_serial_tstc, |
| 71 | }; |
| 72 | |
| 73 | void p3mx_serial_initialize(void) |
| 74 | { |
| 75 | serial_register(&p3mx_serial_drv); |
| 76 | } |
| 77 | |
| 78 | __weak struct serial_device *default_serial_console(void) |
| 79 | { |
| 80 | return &p3mx_serial_drv; |
| 81 | } |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame] | 82 | |
Jon Loeliger | 3fe0010 | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 83 | #if defined(CONFIG_CMD_KGDB) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 84 | void kgdb_serial_init (void) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | void putDebugChar (int c) |
| 89 | { |
| 90 | serial_putc (c); |
| 91 | } |
| 92 | |
| 93 | void putDebugStr (const char *str) |
| 94 | { |
| 95 | serial_puts (str); |
| 96 | } |
| 97 | |
| 98 | int getDebugChar (void) |
| 99 | { |
| 100 | return serial_getc (); |
| 101 | } |
| 102 | |
| 103 | void kgdb_interruptible (int yes) |
| 104 | { |
| 105 | return; |
| 106 | } |
Jon Loeliger | 3fe0010 | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 107 | #endif |