2003-04-22 21:02:15 +02:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <uart8250.h>
|
|
|
|
#include <pc80/mc146818rtc.h>
|
|
|
|
|
|
|
|
/* Base Address */
|
2009-06-30 17:17:49 +02:00
|
|
|
#ifndef CONFIG_TTYS0_BASE
|
|
|
|
#define CONFIG_TTYS0_BASE 0x3f8
|
2003-04-22 21:02:15 +02:00
|
|
|
#endif
|
|
|
|
|
2009-06-30 17:17:49 +02:00
|
|
|
#ifndef CONFIG_TTYS0_BAUD
|
|
|
|
#define CONFIG_TTYS0_BAUD 115200
|
2003-04-22 21:02:15 +02:00
|
|
|
#endif
|
|
|
|
|
2009-06-30 17:17:49 +02:00
|
|
|
#ifndef CONFIG_TTYS0_DIV
|
|
|
|
#if ((115200%CONFIG_TTYS0_BAUD) != 0)
|
2003-04-22 21:02:15 +02:00
|
|
|
#error Bad ttys0 baud rate
|
|
|
|
#endif
|
2009-06-30 17:17:49 +02:00
|
|
|
#define CONFIG_TTYS0_DIV (115200/CONFIG_TTYS0_BAUD)
|
2004-01-14 18:08:14 +01:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
/* Line Control Settings */
|
2009-06-30 17:17:49 +02:00
|
|
|
#ifndef CONFIG_TTYS0_LCS
|
2003-04-22 21:02:15 +02:00
|
|
|
/* Set 8bit, 1 stop bit, no parity */
|
2009-06-30 17:17:49 +02:00
|
|
|
#define CONFIG_TTYS0_LCS 0x3
|
2003-04-22 21:02:15 +02:00
|
|
|
#endif
|
|
|
|
|
2009-06-30 17:17:49 +02:00
|
|
|
#define UART_LCS CONFIG_TTYS0_LCS
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-05-28 17:07:03 +02:00
|
|
|
static void ttyS0_init(void)
|
2003-04-22 21:02:15 +02:00
|
|
|
{
|
2004-05-28 17:07:03 +02:00
|
|
|
static const unsigned char div[8]={1,2,3,6,12,24,48,96};
|
2009-06-03 16:19:33 +02:00
|
|
|
int b_index=0;
|
2009-06-30 17:17:49 +02:00
|
|
|
unsigned int divisor=CONFIG_TTYS0_DIV;
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2009-06-03 16:19:33 +02:00
|
|
|
if(get_option(&b_index,"baud_rate")==0) {
|
2003-04-22 21:02:15 +02:00
|
|
|
divisor=div[b_index];
|
|
|
|
}
|
2009-06-30 17:17:49 +02:00
|
|
|
uart8250_init(CONFIG_TTYS0_BASE, divisor, CONFIG_TTYS0_LCS);
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|
|
|
|
|
2004-05-28 17:07:03 +02:00
|
|
|
static void ttyS0_tx_byte(unsigned char data)
|
2003-04-22 21:02:15 +02:00
|
|
|
{
|
2009-06-30 17:17:49 +02:00
|
|
|
uart8250_tx_byte(CONFIG_TTYS0_BASE, data);
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|
|
|
|
|
2004-05-28 17:07:03 +02:00
|
|
|
static unsigned char ttyS0_rx_byte(void)
|
2004-03-13 04:40:51 +01:00
|
|
|
{
|
2009-06-30 17:17:49 +02:00
|
|
|
return uart8250_rx_byte(CONFIG_TTYS0_BASE);
|
2004-03-13 04:40:51 +01:00
|
|
|
}
|
|
|
|
|
2004-05-28 17:07:03 +02:00
|
|
|
static int ttyS0_tst_byte(void)
|
2004-03-13 04:40:51 +01:00
|
|
|
{
|
2009-06-30 17:17:49 +02:00
|
|
|
return uart8250_can_rx_byte(CONFIG_TTYS0_BASE);
|
2004-03-13 04:40:51 +01:00
|
|
|
}
|
|
|
|
|
2007-10-24 16:42:12 +02:00
|
|
|
static const struct console_driver uart8250_console __console = {
|
2003-04-22 21:02:15 +02:00
|
|
|
.init = ttyS0_init,
|
|
|
|
.tx_byte = ttyS0_tx_byte,
|
2004-03-13 04:40:51 +01:00
|
|
|
.rx_byte = ttyS0_rx_byte,
|
|
|
|
.tst_byte = ttyS0_tst_byte,
|
2003-04-22 21:02:15 +02:00
|
|
|
};
|
|
|
|
|