File: [local] / prex-old / boot / arm / cats / cons_footbridge.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_footbridge.c,v 1.1 2008/07/17 18:10:36 nbrk Exp $
*/
/*
* DC21285 'footbridge' USART for bootldr boot messages.
* TODO: baud rate.
*/
#include <sys/types.h>
#define CSR_BASE 0x42000000
#define UARTDR 0x160 /* data register */
#define H_UBRLCR 0x168 /* baud rate, line control register */
#define M_UBRLCR 0x16c /* baud rate divisor (high) */
#define L_UBRLCR 0x170 /* baud rate divisor (low) */
#define UARTCON 0x174 /* control register */
#define UARTFLG 0x178 /* FIFO status */
void fuart_write(uint16_t reg, uint8_t data);
uint8_t fuart_read(uint16_t reg);
void
fuart_write(uint16_t reg, uint8_t data)
{
*(volatile uint32_t *)(CSR_BASE + reg) = data;
}
uint8_t
fuart_read(uint16_t reg)
{
return( *(volatile uint32_t *)(CSR_BASE + reg));
}
int
bootcons_init(void)
{
/* XXX set operation mode */
fuart_write(H_UBRLCR, 0x60 /*8bits*/);
/* enable UART */
fuart_write(UARTCON, 1);
return(0);
}
void
bootcons_putc(int uartno, int c)
{
while(fuart_read(UARTFLG) & 0x08 /*TXBSY*/)
;
fuart_write(UARTDR, (uint8_t)c);
}