2 * (C) Copyright 2000-2006
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 * This source code is dual-licensed. You may use it under the terms of the
26 * GNU General Public License version 2, or under the license below.
28 * This source code has been made available to you by IBM on an AS-IS
29 * basis. Anyone receiving this source is licensed under IBM
30 * copyrights to use it in any way he or she deems fit, including
31 * copying it, modifying it, compiling it, and redistributing it either
32 * with or without modifications. No license under IBM patents or
33 * patent applications is to be implied by the copyright license.
35 * Any user of this software should understand that IBM cannot provide
36 * technical support for this software and will not be responsible for
37 * any consequences resulting from the use of this software.
39 * Any person who transfers this source code or any derivative work
40 * must include the IBM copyright notice, this paragraph, and the
41 * preceding two paragraphs in the transferred software.
43 * COPYRIGHT I B M CORPORATION 1995
44 * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
49 #include <asm/processor.h>
54 #ifdef CONFIG_SERIAL_MULTI
58 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
62 DECLARE_GLOBAL_DATA_PTR;
64 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
65 defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
66 defined(CONFIG_405EX) || defined(CONFIG_440)
68 #if defined(CONFIG_440)
69 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
70 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
71 defined(CONFIG_460EX) || defined(CONFIG_460GT)
72 #define UART0_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000300)
73 #define UART1_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000400)
75 #define UART0_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000200)
76 #define UART1_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000300)
79 #if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
80 #define UART2_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000600)
83 #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
84 #define UART2_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000500)
85 #define UART3_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x00000600)
88 #if defined(CONFIG_440GP)
89 #define CR0_MASK 0x3fff0000
90 #define CR0_EXTCLK_ENA 0x00600000
91 #define CR0_UDIV_POS 16
92 #define UDIV_SUBTRACT 1
93 #define UART0_SDR CPC0_CR0
94 #define MFREG(a, d) d = mfdcr(a)
95 #define MTREG(a, d) mtdcr(a, d)
96 #else /* #if defined(CONFIG_440GP) */
97 /* all other 440 PPC's access clock divider via sdr register */
98 #define CR0_MASK 0xdfffffff
99 #define CR0_EXTCLK_ENA 0x00800000
100 #define CR0_UDIV_POS 0
101 #define UDIV_SUBTRACT 0
102 #define UART0_SDR SDR0_UART0
103 #define UART1_SDR SDR0_UART1
104 #if defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
105 defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
106 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
107 defined(CONFIG_460EX) || defined(CONFIG_460GT)
108 #define UART2_SDR SDR0_UART2
110 #if defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
111 defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
112 defined(CONFIG_460EX) || defined(CONFIG_460GT)
113 #define UART3_SDR SDR0_UART3
115 #define MFREG(a, d) mfsdr(a, d)
116 #define MTREG(a, d) mtsdr(a, d)
117 #endif /* #if defined(CONFIG_440GP) */
118 #elif defined(CONFIG_405EP) || defined(CONFIG_405EZ)
119 #define UART0_BASE 0xef600300
120 #define UART1_BASE 0xef600400
121 #define UCR0_MASK 0x0000007f
122 #define UCR1_MASK 0x00007f00
123 #define UCR0_UDIV_POS 0
124 #define UCR1_UDIV_POS 8
126 #elif defined(CONFIG_405EX)
127 #define UART0_BASE 0xef600200
128 #define UART1_BASE 0xef600300
129 #define CR0_MASK 0x000000ff
130 #define CR0_EXTCLK_ENA 0x00800000
131 #define CR0_UDIV_POS 0
132 #define UDIV_SUBTRACT 0
133 #define UART0_SDR SDR0_UART0
134 #define UART1_SDR SDR0_UART1
135 #else /* CONFIG_405GP || CONFIG_405CR */
136 #define UART0_BASE 0xef600300
137 #define UART1_BASE 0xef600400
138 #define CR0_MASK 0x00001fff
139 #define CR0_EXTCLK_ENA 0x000000c0
140 #define CR0_UDIV_POS 1
144 /* using serial port 0 or 1 as U-Boot console ? */
145 #if defined(CONFIG_UART1_CONSOLE)
146 #define ACTING_UART0_BASE UART1_BASE
147 #define ACTING_UART1_BASE UART0_BASE
149 #define ACTING_UART0_BASE UART0_BASE
150 #define ACTING_UART1_BASE UART1_BASE
153 #if defined(CONFIG_405EP) && defined(CONFIG_SYS_EXT_SERIAL_CLOCK)
154 #error "External serial clock not supported on AMCC PPC405EP!"
157 #define UART_RBR 0x00
158 #define UART_THR 0x00
159 #define UART_IER 0x01
160 #define UART_IIR 0x02
161 #define UART_FCR 0x02
162 #define UART_LCR 0x03
163 #define UART_MCR 0x04
164 #define UART_LSR 0x05
165 #define UART_MSR 0x06
166 #define UART_SCR 0x07
167 #define UART_DLL 0x00
168 #define UART_DLM 0x01
170 /*-----------------------------------------------------------------------------+
171 | Line Status Register.
172 +-----------------------------------------------------------------------------*/
173 #define asyncLSRDataReady1 0x01
174 #define asyncLSROverrunError1 0x02
175 #define asyncLSRParityError1 0x04
176 #define asyncLSRFramingError1 0x08
177 #define asyncLSRBreakInterrupt1 0x10
178 #define asyncLSRTxHoldEmpty1 0x20
179 #define asyncLSRTxShiftEmpty1 0x40
180 #define asyncLSRRxFifoError1 0x80
182 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
183 /*-----------------------------------------------------------------------------+
185 +-----------------------------------------------------------------------------*/
192 volatile static serial_buffer_t buf_info;
195 static void serial_init_common(u32 base, u32 udiv, u16 bdiv)
197 PPC4xx_SYS_INFO sys_info;
200 get_sys_info(&sys_info);
202 /* Correct UART frequency in bd-info struct now that
203 * the UART divisor is available
205 #ifdef CONFIG_SYS_EXT_SERIAL_CLOCK
206 gd->uart_clk = CONFIG_SYS_EXT_SERIAL_CLOCK;
208 gd->uart_clk = sys_info.freqUART / udiv;
211 out_8((u8 *)base + UART_LCR, 0x80); /* set DLAB bit */
212 out_8((u8 *)base + UART_DLL, bdiv); /* set baudrate divisor */
213 out_8((u8 *)base + UART_DLM, bdiv >> 8); /* set baudrate divisor */
214 out_8((u8 *)base + UART_LCR, 0x03); /* clear DLAB; set 8 bits, no parity */
215 out_8((u8 *)base + UART_FCR, 0x00); /* disable FIFO */
216 out_8((u8 *)base + UART_MCR, 0x00); /* no modem control DTR RTS */
217 val = in_8((u8 *)base + UART_LSR); /* clear line status */
218 val = in_8((u8 *)base + UART_RBR); /* read receive buffer */
219 out_8((u8 *)base + UART_SCR, 0x00); /* set scratchpad */
220 out_8((u8 *)base + UART_IER, 0x00); /* set interrupt enable reg */
223 #if (defined(CONFIG_440) || defined(CONFIG_405EX)) && \
224 !defined(CONFIG_SYS_EXT_SERIAL_CLOCK)
225 static void serial_divs (int baudrate, unsigned long *pudiv,
226 unsigned short *pbdiv)
229 unsigned long div; /* total divisor udiv * bdiv */
230 unsigned long umin; /* minimum udiv */
231 unsigned short diff; /* smallest diff */
232 unsigned long udiv; /* best udiv */
233 unsigned short idiff; /* current diff */
234 unsigned short ibdiv; /* current bdiv */
236 unsigned long est; /* current estimate */
238 get_sys_info(&sysinfo);
240 udiv = 32; /* Assume lowest possible serial clk */
241 div = sysinfo.freqPLB / (16 * baudrate); /* total divisor */
242 umin = sysinfo.pllOpbDiv << 1; /* 2 x OPB divisor */
243 diff = 32; /* highest possible */
245 /* i is the test udiv value -- start with the largest
246 * possible (32) to minimize serial clock and constrain
249 for (i = 32; i > umin; i--) {
252 idiff = (est > div) ? (est-div) : (div-est);
255 break; /* can't do better */
256 } else if (idiff < diff) {
257 udiv = i; /* best so far */
258 diff = idiff; /* update lowest diff*/
266 #elif defined(CONFIG_405EZ)
268 static void serial_divs (int baudrate, unsigned long *pudiv,
269 unsigned short *pbdiv)
272 unsigned long div; /* total divisor udiv * bdiv */
273 unsigned long umin; /* minimum udiv */
274 unsigned short diff; /* smallest diff */
275 unsigned long udiv; /* best udiv */
276 unsigned short idiff; /* current diff */
277 unsigned short ibdiv; /* current bdiv */
279 unsigned long est; /* current estimate */
280 unsigned long plloutb;
281 unsigned long cpr_pllc;
284 /* check the pll feedback source */
285 mfcpr(CPR0_PLLC, cpr_pllc);
287 get_sys_info(&sysinfo);
289 plloutb = ((CONFIG_SYS_CLK_FREQ * ((cpr_pllc & PLLC_SRC_MASK) ?
290 sysinfo.pllFwdDivB : sysinfo.pllFwdDiv) *
291 sysinfo.pllFbkDiv) / sysinfo.pllFwdDivB);
292 udiv = 256; /* Assume lowest possible serial clk */
293 div = plloutb / (16 * baudrate); /* total divisor */
294 umin = (plloutb / get_OPB_freq()) << 1; /* 2 x OPB divisor */
295 diff = 256; /* highest possible */
297 /* i is the test udiv value -- start with the largest
298 * possible (256) to minimize serial clock and constrain
301 for (i = 256; i > umin; i--) {
304 idiff = (est > div) ? (est-div) : (div-est);
307 break; /* can't do better */
308 } else if (idiff < diff) {
309 udiv = i; /* best so far */
310 diff = idiff; /* update lowest diff*/
315 mfcpr(CPC0_PERD0, reg);
317 reg |= ((udiv - 0) << 8) | (udiv - 0);
318 mtcpr(CPC0_PERD0, reg);
321 #endif /* defined(CONFIG_440) && !defined(CONFIG_SYS_EXT_SERIAL_CLK) */
324 * Minimal serial functions needed to use one of the SMC ports
325 * as serial console interface.
328 #if defined(CONFIG_440)
329 int serial_init_dev(unsigned long base)
334 #ifdef CONFIG_SYS_EXT_SERIAL_CLOCK
338 MFREG(UART0_SDR, reg);
341 #ifdef CONFIG_SYS_EXT_SERIAL_CLOCK
342 reg |= CR0_EXTCLK_ENA;
344 tmp = gd->baudrate * 16;
345 bdiv = (CONFIG_SYS_EXT_SERIAL_CLOCK + tmp / 2) / tmp;
347 /* For 440, the cpu clock is on divider chain A, UART on divider
348 * chain B ... so cpu clock is irrelevant. Get the "optimized"
349 * values that are subject to the 1/2 opb clock constraint
351 serial_divs (gd->baudrate, &udiv, &bdiv);
354 reg |= (udiv - UDIV_SUBTRACT) << CR0_UDIV_POS; /* set the UART divisor */
357 * Configure input clock to baudrate generator for all
358 * available serial ports here
360 MTREG(UART0_SDR, reg);
361 #if defined(UART1_SDR)
362 MTREG(UART1_SDR, reg);
364 #if defined(UART2_SDR)
365 MTREG(UART2_SDR, reg);
367 #if defined(UART3_SDR)
368 MTREG(UART3_SDR, reg);
371 serial_init_common(base, udiv, bdiv);
376 #else /* !defined(CONFIG_440) */
378 int serial_init_dev (unsigned long base)
388 mfsdr(UART0_SDR, reg);
390 #ifdef CONFIG_SYS_EXT_SERIAL_CLOCK
391 reg |= CR0_EXTCLK_ENA;
393 tmp = gd->baudrate * 16;
394 bdiv = (CONFIG_SYS_EXT_SERIAL_CLOCK + tmp / 2) / tmp;
396 serial_divs(gd->baudrate, &udiv, &bdiv);
398 reg |= (udiv - UDIV_SUBTRACT) << CR0_UDIV_POS; /* set the UART divisor */
401 * Configure input clock to baudrate generator for all
402 * available serial ports here
404 mtsdr(UART0_SDR, reg);
406 #if defined(UART1_SDR)
407 mtsdr(UART1_SDR, reg);
410 #elif defined(CONFIG_405EZ)
411 serial_divs(gd->baudrate, &udiv, &bdiv);
415 reg = mfdcr(CPC0_UCR) & ~(UCR0_MASK | UCR1_MASK);
417 tmp = CONFIG_SYS_BASE_BAUD * 16;
418 udiv = (clk + tmp / 2) / tmp;
419 if (udiv > UDIV_MAX) /* max. n bits for udiv */
421 reg |= (udiv) << UCR0_UDIV_POS; /* set the UART divisor */
422 reg |= (udiv) << UCR1_UDIV_POS; /* set the UART divisor */
423 mtdcr (CPC0_UCR, reg);
424 #else /* CONFIG_405EP */
425 reg = mfdcr(CPC0_CR0) & ~CR0_MASK;
426 #ifdef CONFIG_SYS_EXT_SERIAL_CLOCK
427 clk = CONFIG_SYS_EXT_SERIAL_CLOCK;
429 reg |= CR0_EXTCLK_ENA;
432 #ifdef CONFIG_SYS_405_UART_ERRATA_59
433 udiv = 31; /* Errata 59: stuck at 31 */
435 tmp = CONFIG_SYS_BASE_BAUD * 16;
436 udiv = (clk + tmp / 2) / tmp;
437 if (udiv > UDIV_MAX) /* max. n bits for udiv */
441 reg |= (udiv - 1) << CR0_UDIV_POS; /* set the UART divisor */
442 mtdcr (CPC0_CR0, reg);
443 #endif /* CONFIG_405EP */
444 tmp = gd->baudrate * udiv * 16;
445 bdiv = (clk + tmp / 2) / tmp;
446 #endif /* CONFIG_405EX */
448 serial_init_common(base, udiv, bdiv);
453 #endif /* if defined(CONFIG_440) */
455 void serial_setbrg_dev(unsigned long base)
457 serial_init_dev(base);
460 void serial_putc_dev(unsigned long base, const char c)
465 serial_putc_dev(base, '\r');
467 /* check THRE bit, wait for transmiter available */
468 for (i = 1; i < 3500; i++) {
469 if ((in_8((u8 *)base + UART_LSR) & 0x20) == 0x20)
474 out_8((u8 *)base + UART_THR, c); /* put character out */
477 void serial_puts_dev (unsigned long base, const char *s)
480 serial_putc_dev (base, *s++);
483 int serial_getc_dev (unsigned long base)
485 unsigned char status = 0;
488 #if defined(CONFIG_HW_WATCHDOG)
489 WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */
490 #endif /* CONFIG_HW_WATCHDOG */
492 status = in_8((u8 *)base + UART_LSR);
493 if ((status & asyncLSRDataReady1) != 0x0)
496 if ((status & ( asyncLSRFramingError1 |
497 asyncLSROverrunError1 |
498 asyncLSRParityError1 |
499 asyncLSRBreakInterrupt1 )) != 0) {
500 out_8((u8 *)base + UART_LSR,
501 asyncLSRFramingError1 |
502 asyncLSROverrunError1 |
503 asyncLSRParityError1 |
504 asyncLSRBreakInterrupt1);
508 return (0x000000ff & (int) in_8((u8 *)base));
511 int serial_tstc_dev (unsigned long base)
513 unsigned char status;
515 status = in_8((u8 *)base + UART_LSR);
516 if ((status & asyncLSRDataReady1) != 0x0)
519 if ((status & ( asyncLSRFramingError1 |
520 asyncLSROverrunError1 |
521 asyncLSRParityError1 |
522 asyncLSRBreakInterrupt1 )) != 0) {
523 out_8((u8 *)base + UART_LSR,
524 asyncLSRFramingError1 |
525 asyncLSROverrunError1 |
526 asyncLSRParityError1 |
527 asyncLSRBreakInterrupt1);
533 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
535 void serial_isr (void *arg)
539 const int rx_get = buf_info.rx_get;
540 int rx_put = buf_info.rx_put;
542 if (rx_get <= rx_put)
543 space = CONFIG_SERIAL_SOFTWARE_FIFO - (rx_put - rx_get);
545 space = rx_get - rx_put;
547 while (serial_tstc_dev (ACTING_UART0_BASE)) {
548 c = serial_getc_dev (ACTING_UART0_BASE);
550 buf_info.rx_buffer[rx_put++] = c;
553 if (rx_put == CONFIG_SERIAL_SOFTWARE_FIFO)
555 if (space < CONFIG_SERIAL_SOFTWARE_FIFO / 4) {
556 /* Stop flow by setting RTS inactive */
557 out_8((u8 *)ACTING_UART0_BASE + UART_MCR,
558 in_8((u8 *)ACTING_UART0_BASE + UART_MCR) &
562 buf_info.rx_put = rx_put;
565 void serial_buffered_init (void)
567 serial_puts ("Switching to interrupt driven serial input mode.\n");
568 buf_info.rx_buffer = malloc (CONFIG_SERIAL_SOFTWARE_FIFO);
572 if (in_8((u8 *)ACTING_UART0_BASE + UART_MSR) & 0x10)
573 serial_puts ("Check CTS signal present on serial port: OK.\n");
575 serial_puts ("WARNING: CTS signal not present on serial port.\n");
577 irq_install_handler ( VECNUM_U0 /*UART0 */ /*int vec */ ,
578 serial_isr /*interrupt_handler_t *handler */ ,
579 (void *) &buf_info /*void *arg */ );
581 /* Enable "RX Data Available" Interrupt on UART */
582 out_8(ACTING_UART0_BASE + UART_IER, 0x01);
584 out_8(ACTING_UART0_BASE + UART_MCR,
585 in_8((u8 *)ACTING_UART0_BASE + UART_MCR) | 0x01);
586 /* Start flow by setting RTS active */
587 out_8(ACTING_UART0_BASE + UART_MCR,
588 in_8((u8 *)ACTING_UART0_BASE + UART_MCR) | 0x02);
589 /* Setup UART FIFO: RX trigger level: 4 byte, Enable FIFO */
590 out_8(ACTING_UART0_BASE + UART_FCR, (1 << 6) | 1);
593 void serial_buffered_putc (const char c)
596 #if defined(CONFIG_HW_WATCHDOG)
597 while (!(in_8((u8 *)ACTING_UART0_BASE + UART_MSR) & 0x10))
600 while (!(in_8((u8 *)ACTING_UART0_BASE + UART_MSR) & 0x10));
605 void serial_buffered_puts (const char *s)
610 int serial_buffered_getc (void)
614 int rx_get = buf_info.rx_get;
617 #if defined(CONFIG_HW_WATCHDOG)
618 while (rx_get == buf_info.rx_put)
621 while (rx_get == buf_info.rx_put);
623 c = buf_info.rx_buffer[rx_get++];
624 if (rx_get == CONFIG_SERIAL_SOFTWARE_FIFO)
626 buf_info.rx_get = rx_get;
628 rx_put = buf_info.rx_put;
629 if (rx_get <= rx_put)
630 space = CONFIG_SERIAL_SOFTWARE_FIFO - (rx_put - rx_get);
632 space = rx_get - rx_put;
634 if (space > CONFIG_SERIAL_SOFTWARE_FIFO / 2) {
635 /* Start flow by setting RTS active */
636 out_8(ACTING_UART0_BASE + UART_MCR,
637 in_8((u8 *)ACTING_UART0_BASE + UART_MCR) | 0x02);
643 int serial_buffered_tstc (void)
645 return (buf_info.rx_get != buf_info.rx_put) ? 1 : 0;
648 #endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
650 #if defined(CONFIG_CMD_KGDB)
652 AS HARNOIS : according to CONFIG_KGDB_SER_INDEX kgdb uses serial port
654 - if CONFIG_KGDB_SER_INDEX = 1 => serial port number 0 :
655 configuration has been already done
656 - if CONFIG_KGDB_SER_INDEX = 2 => serial port number 1 :
657 configure port 1 for serial I/O with rate = CONFIG_KGDB_BAUDRATE
659 #if (CONFIG_KGDB_SER_INDEX & 2)
660 void kgdb_serial_init (void)
666 br_reg = (((((gd->cpu_clk / 16) / 18) * 10) / CONFIG_KGDB_BAUDRATE) +
669 * Init onboard 16550 UART
671 out_8((u8 *)ACTING_UART1_BASE + UART_LCR, 0x80); /* set DLAB bit */
672 out_8((u8 *)ACTING_UART1_BASE + UART_DLL, (br_reg & 0x00ff)); /* set divisor for 9600 baud */
673 out_8((u8 *)ACTING_UART1_BASE + UART_DLM, ((br_reg & 0xff00) >> 8)); /* set divisor for 9600 baud */
674 out_8((u8 *)ACTING_UART1_BASE + UART_LCR, 0x03); /* line control 8 bits no parity */
675 out_8((u8 *)ACTING_UART1_BASE + UART_FCR, 0x00); /* disable FIFO */
676 out_8((u8 *)ACTING_UART1_BASE + UART_MCR, 0x00); /* no modem control DTR RTS */
677 val = in_8((u8 *)ACTING_UART1_BASE + UART_LSR); /* clear line status */
678 val = in_8((u8 *)ACTING_UART1_BASE + UART_RBR); /* read receive buffer */
679 out_8((u8 *)ACTING_UART1_BASE + UART_SCR, 0x00); /* set scratchpad */
680 out_8((u8 *)ACTING_UART1_BASE + UART_IER, 0x00); /* set interrupt enable reg */
683 void putDebugChar (const char c)
688 out_8((u8 *)ACTING_UART1_BASE + UART_THR, c); /* put character out */
690 /* check THRE bit, wait for transfer done */
691 while ((in_8((u8 *)ACTING_UART1_BASE + UART_LSR) & 0x20) != 0x20);
694 void putDebugStr (const char *s)
700 int getDebugChar (void)
702 unsigned char status = 0;
705 status = in_8((u8 *)ACTING_UART1_BASE + UART_LSR);
706 if ((status & asyncLSRDataReady1) != 0x0)
709 if ((status & (asyncLSRFramingError1 |
710 asyncLSROverrunError1 |
711 asyncLSRParityError1 |
712 asyncLSRBreakInterrupt1 )) != 0) {
713 out_8((u8 *)ACTING_UART1_BASE + UART_LSR,
714 asyncLSRFramingError1 |
715 asyncLSROverrunError1 |
716 asyncLSRParityError1 |
717 asyncLSRBreakInterrupt1);
721 return (0x000000ff & (int) in_8((u8 *)ACTING_UART1_BASE));
724 void kgdb_interruptible (int yes)
729 #else /* ! (CONFIG_KGDB_SER_INDEX & 2) */
731 void kgdb_serial_init (void)
733 serial_printf ("[on serial] ");
736 void putDebugChar (int c)
741 void putDebugStr (const char *str)
746 int getDebugChar (void)
748 return serial_getc ();
751 void kgdb_interruptible (int yes)
755 #endif /* (CONFIG_KGDB_SER_INDEX & 2) */
759 #if defined(CONFIG_SERIAL_MULTI)
760 int serial0_init(void)
762 return (serial_init_dev(UART0_BASE));
765 int serial1_init(void)
767 return (serial_init_dev(UART1_BASE));
770 void serial0_setbrg (void)
772 serial_setbrg_dev(UART0_BASE);
775 void serial1_setbrg (void)
777 serial_setbrg_dev(UART1_BASE);
780 void serial0_putc(const char c)
782 serial_putc_dev(UART0_BASE,c);
785 void serial1_putc(const char c)
787 serial_putc_dev(UART1_BASE, c);
790 void serial0_puts(const char *s)
792 serial_puts_dev(UART0_BASE, s);
795 void serial1_puts(const char *s)
797 serial_puts_dev(UART1_BASE, s);
800 int serial0_getc(void)
802 return(serial_getc_dev(UART0_BASE));
805 int serial1_getc(void)
807 return(serial_getc_dev(UART1_BASE));
810 int serial0_tstc(void)
812 return (serial_tstc_dev(UART0_BASE));
815 int serial1_tstc(void)
817 return (serial_tstc_dev(UART1_BASE));
820 struct serial_device serial0_device =
832 struct serial_device serial1_device =
847 int serial_init(void)
849 return serial_init_dev(ACTING_UART0_BASE);
852 void serial_setbrg(void)
854 serial_setbrg_dev(ACTING_UART0_BASE);
857 void serial_putc(const char c)
859 serial_putc_dev(ACTING_UART0_BASE, c);
862 void serial_puts(const char *s)
864 serial_puts_dev(ACTING_UART0_BASE, s);
867 int serial_getc(void)
869 return serial_getc_dev(ACTING_UART0_BASE);
872 int serial_tstc(void)
874 return serial_tstc_dev(ACTING_UART0_BASE);
876 #endif /* CONFIG_SERIAL_MULTI */
878 #endif /* CONFIG_405GP || CONFIG_405CR */