1 static void outb(unsigned char value, unsigned short port)
3 __builtin_outb(value, port);
6 static void outl(unsigned int value, unsigned short port)
8 __builtin_outl(value, port);
11 static unsigned char inb(unsigned short port)
13 return __builtin_inb(port);
16 static unsigned char inl(unsigned short port)
18 return __builtin_inl(port);
21 static unsigned int config_cmd(unsigned char bus, unsigned devfn, unsigned where)
23 return 0x80000000 | (bus << 16) | (devfn << 8) | (where & ~3);
26 static unsigned int pcibios_read_config_dword(
27 unsigned char bus, unsigned devfn, unsigned where)
29 outl(config_cmd(bus, devfn, where), 0xCF8);
36 #ifndef CONFIG_TTYS0_BASE
37 #define CONFIG_TTYS0_BASE 0x3f8
40 #ifndef CONFIG_TTYS0_BAUD
41 #define CONFIG_TTYS0_BAUD 115200
44 #if ((115200%CONFIG_TTYS0_BAUD) != 0)
45 #error Bad ttys0 baud rate
48 #define CONFIG_TTYS0_DIV (115200/CONFIG_TTYS0_BAUD)
50 /* Line Control Settings */
51 #ifndef CONFIG_TTYS0_LCS
52 /* Set 8bit, 1 stop bit, no parity */
53 #define CONFIG_TTYS0_LCS 0x3
56 #define UART_LCS CONFIG_TTYS0_LCS
76 int uart_can_tx_byte(void)
78 return inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x20;
81 void uart_wait_to_tx_byte(void)
83 while(!uart_can_tx_byte())
87 void uart_wait_until_sent(void)
89 while(!(inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x40))
93 void uart_tx_byte(unsigned char data)
95 uart_wait_to_tx_byte();
96 outb(data, CONFIG_TTYS0_BASE + UART_TBR);
97 /* Make certain the data clears the fifos */
98 uart_wait_until_sent();
103 /* disable interrupts */
104 outb(0x0, CONFIG_TTYS0_BASE + UART_IER);
106 outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
107 /* Set Baud Rate Divisor to 12 ==> 115200 Baud */
108 outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
109 outb(CONFIG_TTYS0_DIV & 0xFF, CONFIG_TTYS0_BASE + UART_DLL);
110 outb((CONFIG_TTYS0_DIV >> 8) & 0xFF, CONFIG_TTYS0_BASE + UART_DLM);
111 outb(UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
114 void __console_tx_char(unsigned char byte)
118 void __console_tx_nibble(unsigned nibble)
121 digit = nibble + '0';
125 __console_tx_char(digit);
128 void __console_tx_hex32(unsigned int value)
130 __console_tx_nibble((value >> 28) & 0x0f);
131 __console_tx_nibble((value >> 24) & 0x0f);
132 __console_tx_nibble((value >> 20) & 0x0f);
133 __console_tx_nibble((value >> 16) & 0x0f);
134 __console_tx_nibble((value >> 12) & 0x0f);
135 __console_tx_nibble((value >> 8) & 0x0f);
136 __console_tx_nibble((value >> 4) & 0x0f);
137 __console_tx_nibble(value & 0x0f);
140 void print_debug_hex32(unsigned int value) { __console_tx_hex32(value); }
146 htic = pcibios_read_config_dword(0, 0xc0, 0x6c);
147 print_debug_hex32(htic);