Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / mips / mips-boards / atlas / atlas_gdb.c
blobfb65280f1780d46f96f9f20245d102a8ed16a6ca
1 /*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 * This is the interface to the remote debugger stub.
20 #include <asm/io.h>
21 #include <asm/mips-boards/atlas.h>
22 #include <asm/mips-boards/saa9730_uart.h>
24 #define INB(a) inb((unsigned long)a)
25 #define OUTB(x,a) outb(x,(unsigned long)a)
28 * This is the interface to the remote debugger stub
29 * if the Philips part is used for the debug port,
30 * called from the platform setup code.
32 void *saa9730_base = (void *)ATLAS_SAA9730_REG;
34 static int saa9730_kgdb_active = 0;
36 #define SAA9730_BAUDCLOCK(baud) (((ATLAS_SAA9730_BAUDCLOCK/(baud))/16)-1)
38 int saa9730_kgdb_hook(int speed)
40 int baudclock;
41 t_uart_saa9730_regmap *kgdb_uart = (t_uart_saa9730_regmap *)(saa9730_base + SAA9730_UART_REGS_ADDR);
44 * Clear all interrupts
46 (void) INB(&kgdb_uart->Lsr);
47 (void) INB(&kgdb_uart->Msr);
48 (void) INB(&kgdb_uart->Thr_Rbr);
49 (void) INB(&kgdb_uart->Iir_Fcr);
52 * Now, initialize the UART
54 /* 8 data bits, one stop bit, no parity */
55 OUTB(SAA9730_LCR_DATA8, &kgdb_uart->Lcr);
57 baudclock = SAA9730_BAUDCLOCK(speed);
59 OUTB((baudclock >> 16) & 0xff, &kgdb_uart->BaudDivMsb);
60 OUTB( baudclock & 0xff, &kgdb_uart->BaudDivLsb);
62 /* Set RTS/DTR active */
63 OUTB(SAA9730_MCR_DTR | SAA9730_MCR_RTS, &kgdb_uart->Mcr);
64 saa9730_kgdb_active = 1;
66 return speed;
69 int saa9730_putDebugChar(char c)
71 t_uart_saa9730_regmap *kgdb_uart = (t_uart_saa9730_regmap *)(saa9730_base + SAA9730_UART_REGS_ADDR);
73 if (!saa9730_kgdb_active) { /* need to init device first */
74 return 0;
77 while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_THRE))
79 OUTB(c, &kgdb_uart->Thr_Rbr);
81 return 1;
84 char saa9730_getDebugChar(void)
86 t_uart_saa9730_regmap *kgdb_uart = (t_uart_saa9730_regmap *)(saa9730_base + SAA9730_UART_REGS_ADDR);
87 char c;
89 if (!saa9730_kgdb_active) { /* need to init device first */
90 return 0;
92 while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_DR))
95 c = INB(&kgdb_uart->Thr_Rbr);
96 return(c);