9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* UART FIFO not working
@ 1995-10-31 23:06 Steve
  0 siblings, 0 replies; only message in thread
From: Steve @ 1995-10-31 23:06 UTC (permalink / raw)


When running on Pentium systems the checks for 16550 FIFO do
not work (registers don't respond fast enough).  Here is better
code that checks for FIFO's at system startup time and sets FIFO
depth based on baudrate.  Also, it detects certain chipsets that
are known to have non working FIFO's.

diff devuart.c devuart.c.orig
29,35c29
< 	 Frrst=	(1<<1),		/*  receiver reset */
< 	 Fxrst=	(1<<2),		/*  transmit reset */
< 	 Fdma=	(1<<3),
< 	 Ftrig1= 	0x00,	/*  trigger after 1 input character */
< 	 Ftrig4=	0x40,	/*  trigger after 4 input characters */
< 	 Ftrig8=	0x80,	/*  trigger after 8 input characters */
< 	 Ftrig14=	0xc0,	/* trigger after 14 characters */
---
> 	 Ftrig=	(1<<6),		/*  trigger after 4 input characters */
83c77,81
< 	int	fifo;		/* fifo control */
---
> 
> 	/* fifo control */
> 	int	fifoon;
> 	int	nofifo;
> 	int	istat;
136,141d133
< 
< 	/* Set the FIFO threshold based on the baudrate */
<  	if (up->fifo) 
< 		uartwrreg(up, Fifoctl, Fenab|Fxrst|Frrst| 
< 			  ((rate <= 1200) ? Ftrig1 :
< 				  (rate > 9600) ? Ftrig14 : Ftrig8));
235a228,255
> void
> uartfifoon(Uart *p)
> {
> 	ulong i, x;
> 
> 	if(p->nofifo)
> 		return;
> 
> 	x = splhi();
> 
> 	/* empty buffer */
> 	for(i = 0; i < 16; i++)
> 		uartrdreg(p, Data);
> 	uartintr(0, p);
> 
> 	/* turn on fifo */
> 	p->fifoon = 1;
> 	uartwrreg(p, Fifoctl, Fenab|Ftrig);
> 
> 	uartintr(0, p);
> 	if((p->istat & Fenabd) == 0){
> 		/* didn't work, must be an earlier chip type */
> 		p->nofifo = 1;
> 	}
> 		
> 	splx(x);
> }
> 
246a267,268
> 		/* turn on fifo's */
> 		uartfifoon(up);
250a273,278
> 
> 		/* turn off fifo's */
> 		if(up->fifoon){
> 			up->fifoon = 0;
> 			uartwrreg(up, Fifoctl, 0);
> 		}
314d341
< 	print("uart:");
317,335d343
< 
< 		/* Check for NS16550 fifo */
< 		up->fifo = 0;
< 		uartwrreg(up, Fifoctl, Fenab|Frrst|Fxrst|Ftrig14);
< 
< 		delay(100);
< 		
< 		print(" %d: ", up - uart);
< 		if ((uartrdreg(up, Istat) & 0xc0) == 0xc0) 
< 		    if ((uartrdreg(up, Fifoctl) & Ftrig14) == Ftrig14) {
< 			up->fifo = 1;
< 			print("ns16550a fifo", up - uart);
< 		    }
< 		    else 
< 			print("ns82550/16550, broken fifo");
< 		else
< 		    print("ns82450/16450, no fifo");
< 		uartwrreg(up, Fifoctl, 0);
< 	    
348d355
< 	print("\n");






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-10-31 23:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-10-31 23:06 UART FIFO not working Steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).