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