]>
Commit | Line | Data |
---|---|---|
983fda83 WD |
1 | /* |
2 | * (C) Copyright 2004, Freescale, Inc | |
3 | * TsiChung Liew, Tsi-Chung.Liew@freescale.com. | |
4 | * | |
5 | * See file CREDITS for list of people who contributed to this | |
6 | * project. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License as | |
10 | * published by the Free Software Foundation; either version 2 of | |
11 | * the License, or (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
21 | * MA 02111-1307 USA | |
22 | * | |
23 | */ | |
24 | ||
25 | /* | |
26 | * Minimal serial functions needed to use one of the PSC ports | |
27 | * as serial console interface. | |
28 | */ | |
29 | ||
30 | #include <common.h> | |
31 | #include <mpc8220.h> | |
32 | ||
33 | int serial_init (void) | |
34 | { | |
35 | DECLARE_GLOBAL_DATA_PTR; | |
36 | ||
37 | #if defined (CONFIG_EXTUART_CONSOLE) | |
38 | volatile uchar *cpld = (volatile uchar *) CFG_CPLD_BASE; | |
39 | #endif | |
40 | ||
41 | /* Check CPLD Switch 2 whether is external or internal */ | |
42 | #if defined (CONFIG_EXTUART_CONSOLE) | |
43 | if ((*cpld & 0x02) == 0x02) { | |
44 | gd->bExtUart = 1; | |
45 | return ext_serial_init (); | |
46 | } else | |
47 | #endif | |
48 | { | |
49 | #if defined(CONFIG_PSC_CONSOLE) | |
50 | gd->bExtUart = 0; | |
51 | return psc_serial_init (); | |
52 | #endif | |
53 | } | |
54 | ||
55 | return (0); | |
56 | } | |
57 | ||
58 | void serial_putc (const char c) | |
59 | { | |
60 | DECLARE_GLOBAL_DATA_PTR; | |
61 | ||
62 | if (gd->bExtUart) { | |
63 | #if defined (CONFIG_EXTUART_CONSOLE) | |
64 | ext_serial_putc (c); | |
65 | #endif | |
66 | } else { | |
67 | #if defined(CONFIG_PSC_CONSOLE) | |
68 | psc_serial_putc (c); | |
69 | #endif | |
70 | } | |
71 | } | |
72 | ||
73 | void serial_puts (const char *s) | |
74 | { | |
75 | DECLARE_GLOBAL_DATA_PTR; | |
76 | ||
77 | if (gd->bExtUart) { | |
78 | #if defined (CONFIG_EXTUART_CONSOLE) | |
79 | ext_serial_puts (s); | |
80 | #endif | |
81 | } else { | |
82 | #if defined(CONFIG_PSC_CONSOLE) | |
83 | psc_serial_puts (s); | |
84 | #endif | |
85 | } | |
86 | } | |
87 | ||
88 | int serial_getc (void) | |
89 | { | |
90 | DECLARE_GLOBAL_DATA_PTR; | |
91 | ||
92 | if (gd->bExtUart) { | |
93 | #if defined (CONFIG_EXTUART_CONSOLE) | |
94 | return ext_serial_getc (); | |
95 | #endif | |
96 | } else { | |
97 | #if defined(CONFIG_PSC_CONSOLE) | |
98 | return psc_serial_getc (); | |
99 | #endif | |
100 | } | |
101 | } | |
102 | ||
103 | int serial_tstc (void) | |
104 | { | |
105 | DECLARE_GLOBAL_DATA_PTR; | |
106 | ||
107 | if (gd->bExtUart) { | |
108 | #if defined (CONFIG_EXTUART_CONSOLE) | |
109 | return ext_serial_tstc (); | |
110 | #endif | |
111 | } else { | |
112 | #if defined(CONFIG_PSC_CONSOLE) | |
113 | return psc_serial_tstc (); | |
114 | #endif | |
115 | } | |
116 | } | |
117 | ||
118 | void serial_setbrg (void) | |
119 | { | |
120 | DECLARE_GLOBAL_DATA_PTR; | |
121 | ||
122 | if (gd->bExtUart) { | |
123 | #if defined (CONFIG_EXTUART_CONSOLE) | |
124 | ext_serial_setbrg (); | |
125 | #endif | |
126 | } else { | |
127 | #if defined(CONFIG_PSC_CONSOLE) | |
128 | psc_serial_setbrg (); | |
129 | #endif | |
130 | } | |
131 | } |