[BACK]Return to cons_ns16550.c CVS log [TXT][DIR] Up to [local] / prex-old / boot / arm / cats

File: [local] / prex-old / boot / arm / cats / cons_ns16550.c (download)

Revision 1.1, Thu Jul 17 18:10:36 2008 UTC (15 years, 10 months ago) by nbrk
Branch: MAIN
CVS Tags: HEAD

initial bits of bootldr port to the Simtec's EB110ATX 'CATS' evaluation boards.

/*
 * $Id: cons_ns16550.c,v 1.1 2008/07/17 18:10:36 nbrk Exp $
 */
/*
 * ns16550 USARTs to be used by bootldr.
 */
#include <sys/types.h>
#include <platform.h>

#define IO_BASE	0x7c000000

#define USART0_BASE	(IO_BASE + 0x3f8)
#define USART1_BASE	(IO_BASE + 0x2f8)

#define UART_DR	0	/* TX/RX data register */
#define UART_LSR	5	/* line status register */
#define  LST_DR		0x01	/* receiver data ready */
#define  LSR_TEMT	0x40	/* transmitter empty */

void	bootuart_putc(int uartno, int c);
int	bootuart_getc(int uartno);


void
bootcons_putc(int uartno, int c)
{
	uint32_t	dev;
	
	dev = uartno == 1 ? USART1_BASE : USART0_BASE;

	/* poll TEMT */
	while ((*(volatile uint32_t *)(dev + UART_LSR * 4)) & LSR_TEMT != 1)
		;

	/* write tx fifo */
	*(volatile uint32_t *)(dev + UART_DR * 4) = (c & 0x7f);
}


int
bootcons_getc(int uartno)
{
	uint32_t	dev;
	
	dev = uartno == 1 ? USART1_BASE : USART0_BASE;

	/* poll DR */
	while ((*(volatile uint32_t *)(dev + UART_LSR) & LSR_TEMT != 1))
		;

	return (*(volatile uint32_t *)(dev + UART_DR) & 0x7f);
}


int
bootcons_init(void)
{
	/* XXX */
	return(0);
}