Exemplo n.º 1
0
/* Initialise the serial port. The settings are always 8 data bits, no parity,
 * 1 stop bit, no start bits.
 */
static int serial_init_dev(const int dev_index)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);

	/* FIFO enable, Tx/Rx FIFO clear */
	uart->UFCON = 0x07;
	uart->UMCON = 0x0;

	/* Normal,No parity,1 stop,8 bit */
	uart->ULCON = 0x3;
	/*
	 * tx=level,rx=edge,disable timeout int.,enable rx error int.,
	 * normal,interrupt or polling
	 */
	uart->UCON = 0x245;

#ifdef CONFIG_HWFLOW
	uart->UMCON = 0x1; /* RTS up */
#endif

	/* FIXME: This is sooooooooooooooooooo ugly */
#if defined(CONFIG_ARCH_GTA02_v1) || defined(CONFIG_ARCH_GTA02_v2)
	/* we need auto hw flow control on the gsm and gps port */
	if (dev_index == 0 || dev_index == 1)
		uart->UMCON = 0x10;
#endif
	_serial_setbrg(dev_index);

	return (0);
}
Exemplo n.º 2
0
void serial_setbrg (void)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
	int i;
	unsigned int reg = 0;

	/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
	reg = get_PCLK() / (16 * gd->baudrate) - 1;

	/* FIFO enable, Tx/Rx FIFO clear */
	uart->UFCON = 0x07;
	uart->UMCON = 0x0;
	/* Normal,No parity,1 stop,8 bit */
	uart->ULCON = 0x3;
	/*
	 * tx=level,rx=edge,disable timeout int.,enable rx error int.,
	 * normal,interrupt or polling
	 */
	uart->UCON = 0x245;
	uart->UBRDIV = reg;

#ifdef CONFIG_HWFLOW
	uart->UMCON = 0x1; /* RTS up */
#endif
	for (i = 0; i < 100; i++);
}
Exemplo n.º 3
0
__u8 do_getc(unsigned long timeout, int *statp)
{
	__u8	c, rxstat;
	int	do_timeout = timeout != 0;
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);

	getc_errno = 0;	/* reste errno */

	while(!(uart->UTRSTAT & 0x1)) {

		if (do_timeout) {
			if (!timeout)
				break;
			timeout--;
		}

	}

	if (do_timeout && timeout == 0) {
		c = 0;
		rxstat = -1;
	} else {
		c = (uart->URXH & 0xff);
		rxstat = (uart->UERSTAT & 0xf);
	}

	if (rxstat) {
		getc_errno = rxstat;
		if (statp)
			*statp = rxstat;
	}
	return (c);
}
Exemplo n.º 4
0
void put_onechar(uint8_t ch)
{
	S3C24X0_UART *const uart0 = S3C24X0_GetBase_UART(0);
	while(!(uart0->UTRSTAT & UTRSTAT_TRANS_EMPTY))
		;
	uart0->UTXH = ch;
	
}
Exemplo n.º 5
0
void init_uart()
{	/*get uart0 reg addr*/
	S3C24X0_UART  *const uart0 = S3C24X0_GetBase_UART(0);
	/*stop bit:1bit,word len 8bit,no parity bit*/
	uart0->ULCON = ULCON_PARITY_MODE | ULCON_STOP_BIT | ULCON_WORD_LEN;
	/*pclk,tx and rx int type:level,trans and recv mode :poll or interrupt*/
	uart0->UCON = UCON_CLOCK_SEL|UCON_TX_INT_TYPE|UCON_RX_INT_TYPE|UCON_RX_TIME_OUT|UCON_RX_ERROR_STS|UCON_TX_MODE|UCON_RX_MODE;
	
}
Exemplo n.º 6
0
uint8_t get_onechar()
{
	uint8_t value;
	S3C24X0_UART *const uart0 = S3C24X0_GetBase_UART(0);
	while(!(uart0->UTRSTAT & UTRSTAT_RECV_BUF_READY))
		;
	value = uart0->URXH;
	return value;
}
Exemplo n.º 7
0
/*
 * Read a single byte from the serial port. Returns 1 on success, 0
 * otherwise. When the function is succesfull, the character read is
 * written into its argument c.
 */
int _serial_getc (const int dev_index)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);

	/* wait for character to arrive */
	while (!(uart->UTRSTAT & 0x1));

	return uart->URXH & 0xff;
}
Exemplo n.º 8
0
/*
 * Read a single byte from the serial port. Returns 1 on success, 0
 * otherwise. When the function is succesfull, the character read is
 * written into its argument c.
 */
int serial_getc (void)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);

	/* wait for character to arrive */
	while (!(uart->UTRSTAT & 0x1));

	return uart->URXH & 0xff;
}
Exemplo n.º 9
0
void _serial_setbrg(const int dev_index)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);
	unsigned int reg = 0;
	int i;

	/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
	reg = get_PCLK() / (16 * gd->baudrate) - 1;

	uart->UBRDIV = reg;
	for (i = 0; i < 100; i++);
}
Exemplo n.º 10
0
/*
 * Output a single byte to the serial port.
 */
void serial_putc(const char c)
{
	S3C24X0_UART *const uart = S3C24X0_GetBase_UART(S3C24X0_UART0);

	/* wait for room in the tx FIFO */
	while (!(uart->UTRSTAT & 0x2));

	uart->UTXH = c;

	/* If \n, also do \r */
	if (c == '\n')
		serial_putc('\r');
}
Exemplo n.º 11
0
void init_baud(uint32_t baud)
{
	uint32_t ubrdivn;
	S3C24X0_UART  * const uart0 = S3C24X0_GetBase_UART(0);
	/*stop bit:1bit,word len 8bit,no parity bit*/
	uart0->ULCON = ULCON_PARITY_MODE | ULCON_STOP_BIT | ULCON_WORD_LEN;
	/*pclk,tx and rx int type:level,trans and recv mode :poll or interrupt*/
	uart0->UCON = UCON_CLOCK_SEL|UCON_TX_INT_TYPE|UCON_RX_INT_TYPE|UCON_RX_TIME_OUT|UCON_RX_ERROR_STS|UCON_TX_MODE|UCON_RX_MODE;

	ubrdivn =  (clkpara.pclk/(baud*16));
	ubrdivn -= 1;
	uart0->UBRDIV0 = ubrdivn;
}
Exemplo n.º 12
0
/*
 * Output a single byte to the serial port.
 */
void _serial_putc (const char c, const int dev_index)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);
#ifdef CONFIG_MODEM_SUPPORT
	if (be_quiet)
		return;
#endif

	/* wait for room in the tx FIFO */
	while (!(uart->UTRSTAT & 0x2));

#ifdef CONFIG_HWFLOW
	/* Wait for CTS up */
	while(hwflow && !(uart->UMSTAT & 0x1))
		;
#endif

	uart->UTXH = c;

	/* If \n, also do \r */
	if (c == '\n')
		serial_putc ('\r');
}
Exemplo n.º 13
0
/*
 * Test whether a character is in the RX buffer
 */
int _serial_tstc(const int dev_index)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);

	return uart->UTRSTAT & 0x1;
}
Exemplo n.º 14
0
/*
 * Test whether a character is in the RX buffer
 */
int serial_tstc (void)
{
	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);

	return uart->UTRSTAT & 0x1;
}