wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Peter De Schrijver (p2@mind.be), Mind Linux Solutions, NV. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of |
| 8 | * the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 18 | * MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <asm/u-boot.h> |
| 23 | #include <asm/processor.h> |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
| 26 | #include <configs/ML2.h> |
| 27 | |
| 28 | #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2) |
| 29 | #include <ns16550.h> |
| 30 | #endif |
| 31 | |
| 32 | #if 0 |
| 33 | #include "serial.h" |
| 34 | #endif |
| 35 | |
| 36 | #if (defined CFG_INIT_CHAN1) || (defined CFG_INIT_CHAN2) |
| 37 | const NS16550_t COM_PORTS[] = { (NS16550_t) CFG_NS16550_COM1, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 38 | (NS16550_t) CFG_NS16550_COM2 }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | int |
| 42 | serial_init (void) |
| 43 | { |
| 44 | DECLARE_GLOBAL_DATA_PTR; |
| 45 | |
| 46 | int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate; |
| 47 | |
| 48 | #ifdef CFG_INIT_CHAN1 |
| 49 | (void)NS16550_init(COM_PORTS[0], clock_divisor); |
| 50 | #endif |
| 51 | #ifdef CFG_INIT_CHAN2 |
| 52 | (void)NS16550_init(COM_PORTS[1], clock_divisor); |
| 53 | #endif |
| 54 | return 0; |
| 55 | |
| 56 | } |
| 57 | |
| 58 | void |
| 59 | serial_putc(const char c) |
| 60 | { |
| 61 | if (c == '\n') |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 62 | NS16550_putc(COM_PORTS[CFG_DUART_CHAN], '\r'); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 63 | |
| 64 | NS16550_putc(COM_PORTS[CFG_DUART_CHAN], c); |
| 65 | } |
| 66 | |
| 67 | int |
| 68 | serial_getc(void) |
| 69 | { |
| 70 | return NS16550_getc(COM_PORTS[CFG_DUART_CHAN]); |
| 71 | } |
| 72 | |
| 73 | int |
| 74 | serial_tstc(void) |
| 75 | { |
| 76 | return NS16550_tstc(COM_PORTS[CFG_DUART_CHAN]); |
| 77 | } |
| 78 | |
| 79 | void |
| 80 | serial_setbrg (void) |
| 81 | { |
| 82 | DECLARE_GLOBAL_DATA_PTR; |
| 83 | |
| 84 | int clock_divisor = CFG_NS16550_CLK / 16 / gd->baudrate; |
| 85 | |
| 86 | #ifdef CFG_INIT_CHAN1 |
| 87 | NS16550_reinit(COM_PORTS[0], clock_divisor); |
| 88 | #endif |
| 89 | #ifdef CFG_INIT_CHAN2 |
| 90 | NS16550_reinit(COM_PORTS[1], clock_divisor); |
| 91 | #endif |
| 92 | } |
| 93 | |
| 94 | void |
| 95 | serial_puts (const char *s) |
| 96 | { |
| 97 | while (*s) { |
| 98 | serial_putc (*s++); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | #if (CONFIG_COMMANDS & CFG_CMD_KGDB) |
| 103 | void |
| 104 | kgdb_serial_init(void) |
| 105 | { |
| 106 | } |
| 107 | |
| 108 | void |
| 109 | putDebugChar (int c) |
| 110 | { |
| 111 | serial_putc (c); |
| 112 | } |
| 113 | |
| 114 | void |
| 115 | putDebugStr (const char *str) |
| 116 | { |
| 117 | serial_puts (str); |
| 118 | } |
| 119 | |
| 120 | int |
| 121 | getDebugChar (void) |
| 122 | { |
| 123 | return serial_getc(); |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | kgdb_interruptible (int yes) |
| 128 | { |
| 129 | return; |
| 130 | } |
| 131 | #endif /* CFG_CMD_KGDB */ |