[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / ppc / syslib / ppc4xx_kgdb.c
blobfe8668bf8137403288aff26d831e5cc6b6156ee3
1 #include <linux/config.h>
2 #include <linux/types.h>
3 #include <asm/ibm4xx.h>
4 #include <linux/kernel.h>
8 #define LSR_DR 0x01 /* Data ready */
9 #define LSR_OE 0x02 /* Overrun */
10 #define LSR_PE 0x04 /* Parity error */
11 #define LSR_FE 0x08 /* Framing error */
12 #define LSR_BI 0x10 /* Break */
13 #define LSR_THRE 0x20 /* Xmit holding register empty */
14 #define LSR_TEMT 0x40 /* Xmitter empty */
15 #define LSR_ERR 0x80 /* Error */
17 #include <platforms/4xx/ibm_ocp.h>
19 extern struct NS16550* COM_PORTS[];
20 #ifndef NULL
21 #define NULL 0x00
22 #endif
24 static volatile struct NS16550 *kgdb_debugport = NULL;
26 volatile struct NS16550 *
27 NS16550_init(int chan)
29 volatile struct NS16550 *com_port;
30 int quot;
31 #ifdef BASE_BAUD
32 quot = BASE_BAUD / 9600;
33 #else
34 quot = 0x000c; /* 0xc = 9600 baud (on a pc) */
35 #endif
37 com_port = (struct NS16550 *) COM_PORTS[chan];
39 com_port->lcr = 0x00;
40 com_port->ier = 0xFF;
41 com_port->ier = 0x00;
42 com_port->lcr = com_port->lcr | 0x80; /* Access baud rate */
43 com_port->dll = ( quot & 0x00ff ); /* 0xc = 9600 baud */
44 com_port->dlm = ( quot & 0xff00 ) >> 8;
45 com_port->lcr = 0x03; /* 8 data, 1 stop, no parity */
46 com_port->mcr = 0x00; /* RTS/DTR */
47 com_port->fcr = 0x07; /* Clear & enable FIFOs */
49 return( com_port );
53 void
54 NS16550_putc(volatile struct NS16550 *com_port, unsigned char c)
56 while ((com_port->lsr & LSR_THRE) == 0)
58 com_port->thr = c;
59 return;
62 unsigned char
63 NS16550_getc(volatile struct NS16550 *com_port)
65 while ((com_port->lsr & LSR_DR) == 0)
67 return (com_port->rbr);
70 unsigned char
71 NS16550_tstc(volatile struct NS16550 *com_port)
73 return ((com_port->lsr & LSR_DR) != 0);
77 #if defined(CONFIG_KGDB_TTYS0)
78 #define KGDB_PORT 0
79 #elif defined(CONFIG_KGDB_TTYS1)
80 #define KGDB_PORT 1
81 #elif defined(CONFIG_KGDB_TTYS2)
82 #define KGDB_PORT 2
83 #elif defined(CONFIG_KGDB_TTYS3)
84 #define KGDB_PORT 3
85 #else
86 #error "invalid kgdb_tty port"
87 #endif
89 void putDebugChar( unsigned char c )
91 if ( kgdb_debugport == NULL )
92 kgdb_debugport = NS16550_init(KGDB_PORT);
93 NS16550_putc( kgdb_debugport, c );
96 int getDebugChar( void )
98 if (kgdb_debugport == NULL)
99 kgdb_debugport = NS16550_init(KGDB_PORT);
101 return(NS16550_getc(kgdb_debugport));
104 void kgdb_interruptible(int enable)
106 return;
109 void putDebugString(char* str)
111 while (*str != '\0') {
112 putDebugChar(*str);
113 str++;
115 putDebugChar('\r');
116 return;
119 void
120 kgdb_map_scc(void)
122 printk("kgdb init \n");
123 kgdb_debugport = NS16550_init(KGDB_PORT);