2 #include <linux/config.h>
8 /* we need uint32 uint8 */
9 /* #include "types.h" */
10 typedef unsigned char uint8
;
11 typedef unsigned int uint32
;
13 /* --- END OF CONFIG --- */
15 #define UART16550_BAUD_2400 2400
16 #define UART16550_BAUD_4800 4800
17 #define UART16550_BAUD_9600 9600
18 #define UART16550_BAUD_19200 19200
19 #define UART16550_BAUD_38400 38400
20 #define UART16550_BAUD_57600 57600
21 #define UART16550_BAUD_115200 115200
23 #define UART16550_PARITY_NONE 0
24 #define UART16550_PARITY_ODD 0x08
25 #define UART16550_PARITY_EVEN 0x18
26 #define UART16550_PARITY_MARK 0x28
27 #define UART16550_PARITY_SPACE 0x38
29 #define UART16550_DATA_5BIT 0x0
30 #define UART16550_DATA_6BIT 0x1
31 #define UART16550_DATA_7BIT 0x2
32 #define UART16550_DATA_8BIT 0x3
34 #define UART16550_STOP_1BIT 0x0
35 #define UART16550_STOP_2BIT 0x4
37 /* ----------------------------------------------------- */
41 /* [stevel] we use the IT8712 serial port for kgdb */
42 #define DEBUG_BASE 0xB40003F8 /* 8712 serial port 1 base address */
43 #define MAX_BAUD 115200
45 /* === END OF CONFIG === */
48 #define OFS_RCV_BUFFER 0
49 #define OFS_TRANS_HOLD 0
50 #define OFS_SEND_BUFFER 0
51 #define OFS_INTR_ENABLE 1
53 #define OFS_DATA_FORMAT 3
54 #define OFS_LINE_CONTROL 3
55 #define OFS_MODEM_CONTROL 4
56 #define OFS_RS232_OUTPUT 4
57 #define OFS_LINE_STATUS 5
58 #define OFS_MODEM_STATUS 6
59 #define OFS_RS232_INPUT 6
60 #define OFS_SCRATCH_PAD 7
62 #define OFS_DIVISOR_LSB 0
63 #define OFS_DIVISOR_MSB 1
66 /* memory-mapped read/write of the port */
67 #define UART16550_READ(y) (*((volatile uint8*)(DEBUG_BASE + y)))
68 #define UART16550_WRITE(y,z) ((*((volatile uint8*)(DEBUG_BASE + y))) = z)
70 void debugInit(uint32 baud
, uint8 data
, uint8 parity
, uint8 stop
)
72 /* disable interrupts */
73 UART16550_WRITE(OFS_INTR_ENABLE
, 0);
75 /* set up buad rate */
80 UART16550_WRITE(OFS_LINE_CONTROL
, 0x80);
83 divisor
= MAX_BAUD
/ baud
;
84 UART16550_WRITE(OFS_DIVISOR_LSB
, divisor
& 0xff);
85 UART16550_WRITE(OFS_DIVISOR_MSB
, (divisor
& 0xff00) >> 8);
88 UART16550_WRITE(OFS_LINE_CONTROL
, 0x0);
92 UART16550_WRITE(OFS_DATA_FORMAT
, data
| parity
| stop
);
95 static int remoteDebugInitialized
= 0;
97 uint8
getDebugChar(void)
99 if (!remoteDebugInitialized
) {
100 remoteDebugInitialized
= 1;
101 debugInit(UART16550_BAUD_115200
,
103 UART16550_PARITY_NONE
, UART16550_STOP_1BIT
);
106 while ((UART16550_READ(OFS_LINE_STATUS
) & 0x1) == 0);
107 return UART16550_READ(OFS_RCV_BUFFER
);
111 int putDebugChar(uint8 byte
)
113 if (!remoteDebugInitialized
) {
114 remoteDebugInitialized
= 1;
115 debugInit(UART16550_BAUD_115200
,
117 UART16550_PARITY_NONE
, UART16550_STOP_1BIT
);
120 while ((UART16550_READ(OFS_LINE_STATUS
) & 0x20) == 0);
121 UART16550_WRITE(OFS_SEND_BUFFER
, byte
);