stroese | 771e05b | 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 | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 7 | * |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 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+ |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [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 | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 22 | #include <serial.h> |
| 23 | #include <linux/compiler.h> |
| 24 | |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 25 | #include "../../Marvell/include/memory.h" |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 26 | |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 27 | #include "mpsc.h" |
| 28 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 29 | DECLARE_GLOBAL_DATA_PTR; |
| 30 | |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 31 | static int cpci750_serial_init(void) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 32 | { |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 33 | mpsc_init (gd->baudrate); |
| 34 | |
| 35 | return (0); |
| 36 | } |
| 37 | |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 38 | static void cpci750_serial_putc(const char c) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 39 | { |
| 40 | if (c == '\n') |
| 41 | mpsc_putchar ('\r'); |
| 42 | |
| 43 | mpsc_putchar (c); |
| 44 | } |
| 45 | |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 46 | static int cpci750_serial_getc(void) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 47 | { |
| 48 | return mpsc_getchar (); |
| 49 | } |
| 50 | |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 51 | static int cpci750_serial_tstc(void) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 52 | { |
| 53 | return mpsc_test_char (); |
| 54 | } |
| 55 | |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 56 | static void cpci750_serial_setbrg(void) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 57 | { |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 58 | galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate); |
| 59 | } |
| 60 | |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 61 | static struct serial_device cpci750_serial_drv = { |
| 62 | .name = "cpci750_serial", |
| 63 | .start = cpci750_serial_init, |
| 64 | .stop = NULL, |
| 65 | .setbrg = cpci750_serial_setbrg, |
| 66 | .putc = cpci750_serial_putc, |
Marek Vasut | ec3fd68 | 2012-10-06 14:07:02 +0000 | [diff] [blame] | 67 | .puts = default_serial_puts, |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 68 | .getc = cpci750_serial_getc, |
| 69 | .tstc = cpci750_serial_tstc, |
| 70 | }; |
| 71 | |
| 72 | void cpci750_serial_initialize(void) |
| 73 | { |
| 74 | serial_register(&cpci750_serial_drv); |
| 75 | } |
| 76 | |
| 77 | __weak struct serial_device *default_serial_console(void) |
| 78 | { |
| 79 | return &cpci750_serial_drv; |
| 80 | } |
Marek Vasut | 619c90b | 2012-09-13 12:32:56 +0200 | [diff] [blame] | 81 | |
Jon Loeliger | b930726 | 2007-07-09 18:24:55 -0500 | [diff] [blame] | 82 | #if defined(CONFIG_CMD_KGDB) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 83 | void kgdb_serial_init (void) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | void putDebugChar (int c) |
| 88 | { |
| 89 | serial_putc (c); |
| 90 | } |
| 91 | |
| 92 | void putDebugStr (const char *str) |
| 93 | { |
| 94 | serial_puts (str); |
| 95 | } |
| 96 | |
| 97 | int getDebugChar (void) |
| 98 | { |
| 99 | return serial_getc (); |
| 100 | } |
| 101 | |
| 102 | void kgdb_interruptible (int yes) |
| 103 | { |
| 104 | return; |
| 105 | } |
Jon Loeliger | 77a3185 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 106 | #endif |