stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [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> |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 7 | * |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 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 | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 38 | #include <serial.h> |
| 39 | #include <linux/compiler.h> |
| 40 | |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 41 | #include "../../Marvell/include/memory.h" |
| 42 | #include "serial.h" |
| 43 | |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 44 | #include "mpsc.h" |
| 45 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 46 | DECLARE_GLOBAL_DATA_PTR; |
| 47 | |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 48 | static int cpci750_serial_init(void) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 49 | { |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 50 | mpsc_init (gd->baudrate); |
| 51 | |
| 52 | return (0); |
| 53 | } |
| 54 | |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 55 | static void cpci750_serial_putc(const char c) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 56 | { |
| 57 | if (c == '\n') |
| 58 | mpsc_putchar ('\r'); |
| 59 | |
| 60 | mpsc_putchar (c); |
| 61 | } |
| 62 | |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 63 | static int cpci750_serial_getc(void) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 64 | { |
| 65 | return mpsc_getchar (); |
| 66 | } |
| 67 | |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 68 | static int cpci750_serial_tstc(void) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 69 | { |
| 70 | return mpsc_test_char (); |
| 71 | } |
| 72 | |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 73 | static void cpci750_serial_setbrg(void) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 74 | { |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 75 | galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate); |
| 76 | } |
| 77 | |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 78 | static struct serial_device cpci750_serial_drv = { |
| 79 | .name = "cpci750_serial", |
| 80 | .start = cpci750_serial_init, |
| 81 | .stop = NULL, |
| 82 | .setbrg = cpci750_serial_setbrg, |
| 83 | .putc = cpci750_serial_putc, |
Marek Vasut | d9c6449 | 2012-10-06 14:07:02 +0000 | [diff] [blame] | 84 | .puts = default_serial_puts, |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 85 | .getc = cpci750_serial_getc, |
| 86 | .tstc = cpci750_serial_tstc, |
| 87 | }; |
| 88 | |
| 89 | void cpci750_serial_initialize(void) |
| 90 | { |
| 91 | serial_register(&cpci750_serial_drv); |
| 92 | } |
| 93 | |
| 94 | __weak struct serial_device *default_serial_console(void) |
| 95 | { |
| 96 | return &cpci750_serial_drv; |
| 97 | } |
Marek Vasut | 7aa03ef | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 98 | |
Jon Loeliger | 4ed9ed6 | 2007-07-09 18:24:55 -0500 | [diff] [blame] | 99 | #if defined(CONFIG_CMD_KGDB) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 100 | void kgdb_serial_init (void) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | void putDebugChar (int c) |
| 105 | { |
| 106 | serial_putc (c); |
| 107 | } |
| 108 | |
| 109 | void putDebugStr (const char *str) |
| 110 | { |
| 111 | serial_puts (str); |
| 112 | } |
| 113 | |
| 114 | int getDebugChar (void) |
| 115 | { |
| 116 | return serial_getc (); |
| 117 | } |
| 118 | |
| 119 | void kgdb_interruptible (int yes) |
| 120 | { |
| 121 | return; |
| 122 | } |
Jon Loeliger | 13f7599 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 123 | #endif |