Linux 2.6.17.7
[linux/fpc-iii.git] / arch / mips / galileo-boards / ev96100 / puts.c
blob49dc6d137b9cceb60f40007d6c8b23227554dda1
2 /*
3 * Debug routines which directly access the uart.
4 */
6 #include <linux/types.h>
7 #include <asm/gt64120.h>
10 //#define SERIAL_BASE EV96100_UART0_REGS_BASE
11 #define SERIAL_BASE 0xBD000020
12 #define NS16550_BASE SERIAL_BASE
14 #define SERA_CMD 0x0D
15 #define SERA_DATA 0x08
16 //#define SERB_CMD 0x05
17 #define SERB_CMD 20
18 #define SERB_DATA 0x00
19 #define TX_BUSY 0x20
21 #define TIMEOUT 0xffff
22 #undef SLOW_DOWN
24 static const char digits[16] = "0123456789abcdef";
25 static volatile unsigned char *const com1 = (unsigned char *) SERIAL_BASE;
28 #ifdef SLOW_DOWN
29 static inline void slow_down()
31 int k;
32 for (k = 0; k < 10000; k++);
34 #else
35 #define slow_down()
36 #endif
38 void putch(const unsigned char c)
40 unsigned char ch;
41 int i = 0;
43 do {
44 ch = com1[SERB_CMD];
45 slow_down();
46 i++;
47 if (i > TIMEOUT) {
48 break;
50 } while (0 == (ch & TX_BUSY));
51 com1[SERB_DATA] = c;
54 void putchar(const unsigned char c)
56 unsigned char ch;
57 int i = 0;
59 do {
60 ch = com1[SERB_CMD];
61 slow_down();
62 i++;
63 if (i > TIMEOUT) {
64 break;
66 } while (0 == (ch & TX_BUSY));
67 com1[SERB_DATA] = c;
70 void puts(unsigned char *cp)
72 unsigned char ch;
73 int i = 0;
75 while (*cp) {
76 do {
77 ch = com1[SERB_CMD];
78 slow_down();
79 i++;
80 if (i > TIMEOUT) {
81 break;
83 } while (0 == (ch & TX_BUSY));
84 com1[SERB_DATA] = *cp++;
86 putch('\r');
87 putch('\n');
90 void fputs(unsigned char *cp)
92 unsigned char ch;
93 int i = 0;
95 while (*cp) {
97 do {
98 ch = com1[SERB_CMD];
99 slow_down();
100 i++;
101 if (i > TIMEOUT) {
102 break;
104 } while (0 == (ch & TX_BUSY));
105 com1[SERB_DATA] = *cp++;
110 void put64(uint64_t ul)
112 int cnt;
113 unsigned ch;
115 cnt = 16; /* 16 nibbles in a 64 bit long */
116 putch('0');
117 putch('x');
118 do {
119 cnt--;
120 ch = (unsigned char) (ul >> cnt * 4) & 0x0F;
121 putch(digits[ch]);
122 } while (cnt > 0);
125 void put32(unsigned u)
127 int cnt;
128 unsigned ch;
130 cnt = 8; /* 8 nibbles in a 32 bit long */
131 putch('0');
132 putch('x');
133 do {
134 cnt--;
135 ch = (unsigned char) (u >> cnt * 4) & 0x0F;
136 putch(digits[ch]);
137 } while (cnt > 0);