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 | * |
| 11 | * See file CREDITS for list of people who contributed to this |
| 12 | * project. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 27 | * MA 02111-1307 USA |
| 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * serial.c - serial support for esd cpci750 board |
| 32 | */ |
| 33 | |
| 34 | /* supports the MPSC */ |
| 35 | |
| 36 | #include <common.h> |
| 37 | #include <command.h> |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 38 | #include <serial.h> |
| 39 | #include <linux/compiler.h> |
| 40 | |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 41 | #include "../../Marvell/include/memory.h" |
| 42 | #include "serial.h" |
| 43 | |
| 44 | #include "mpsc.h" |
| 45 | |
| 46 | DECLARE_GLOBAL_DATA_PTR; |
| 47 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 48 | static int p3mx_serial_init(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 49 | { |
| 50 | mpsc_init (gd->baudrate); |
| 51 | |
| 52 | return (0); |
| 53 | } |
| 54 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 55 | static void p3mx_serial_putc(const char c) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 56 | { |
| 57 | if (c == '\n') |
| 58 | mpsc_putchar ('\r'); |
| 59 | |
| 60 | mpsc_putchar (c); |
| 61 | } |
| 62 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 63 | static int p3mx_serial_getc(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 64 | { |
| 65 | return mpsc_getchar (); |
| 66 | } |
| 67 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 68 | static int p3mx_serial_tstc(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 69 | { |
| 70 | return mpsc_test_char (); |
| 71 | } |
| 72 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 73 | static void p3mx_serial_setbrg(void) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 74 | { |
| 75 | galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate); |
| 76 | } |
| 77 | |
| 78 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 79 | static void p3mx_serial_puts(const char *s) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 80 | { |
| 81 | while (*s) { |
| 82 | serial_putc (*s++); |
| 83 | } |
| 84 | } |
| 85 | |
Marek Vasut | 088a4f3 | 2012-09-13 12:35:54 +0200 | [diff] [blame^] | 86 | #ifdef CONFIG_SERIAL_MULTI |
| 87 | static struct serial_device p3mx_serial_drv = { |
| 88 | .name = "p3mx_serial", |
| 89 | .start = p3mx_serial_init, |
| 90 | .stop = NULL, |
| 91 | .setbrg = p3mx_serial_setbrg, |
| 92 | .putc = p3mx_serial_putc, |
| 93 | .puts = p3mx_serial_puts, |
| 94 | .getc = p3mx_serial_getc, |
| 95 | .tstc = p3mx_serial_tstc, |
| 96 | }; |
| 97 | |
| 98 | void p3mx_serial_initialize(void) |
| 99 | { |
| 100 | serial_register(&p3mx_serial_drv); |
| 101 | } |
| 102 | |
| 103 | __weak struct serial_device *default_serial_console(void) |
| 104 | { |
| 105 | return &p3mx_serial_drv; |
| 106 | } |
| 107 | #else |
| 108 | int serial_init(void) |
| 109 | { |
| 110 | return p3mx_serial_init(); |
| 111 | } |
| 112 | |
| 113 | void serial_setbrg(void) |
| 114 | { |
| 115 | p3mx_serial_setbrg(); |
| 116 | } |
| 117 | |
| 118 | void serial_putc(const char c) |
| 119 | { |
| 120 | p3mx_serial_putc(c); |
| 121 | } |
| 122 | |
| 123 | void serial_puts(const char *s) |
| 124 | { |
| 125 | p3mx_serial_puts(s); |
| 126 | } |
| 127 | |
| 128 | int serial_getc(void) |
| 129 | { |
| 130 | return p3mx_serial_getc(); |
| 131 | } |
| 132 | |
| 133 | int serial_tstc(void) |
| 134 | { |
| 135 | return p3mx_serial_tstc(); |
| 136 | } |
| 137 | #endif |
| 138 | |
Jon Loeliger | 3fe0010 | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 139 | #if defined(CONFIG_CMD_KGDB) |
Stefan Roese | 1eac2a7 | 2006-11-29 15:42:37 +0100 | [diff] [blame] | 140 | void kgdb_serial_init (void) |
| 141 | { |
| 142 | } |
| 143 | |
| 144 | void putDebugChar (int c) |
| 145 | { |
| 146 | serial_putc (c); |
| 147 | } |
| 148 | |
| 149 | void putDebugStr (const char *str) |
| 150 | { |
| 151 | serial_puts (str); |
| 152 | } |
| 153 | |
| 154 | int getDebugChar (void) |
| 155 | { |
| 156 | return serial_getc (); |
| 157 | } |
| 158 | |
| 159 | void kgdb_interruptible (int yes) |
| 160 | { |
| 161 | return; |
| 162 | } |
Jon Loeliger | 3fe0010 | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 163 | #endif |