Subject: Re: More com driver changes; need testers
To: Charles M. Hannum <mycroft@gnu.ai.mit.edu>
From: Anders Hjalmarsson <econahja@econahja.econ.gu.se>
List: port-i386
Date: 05/02/1997 22:16:49
I still have some problems, even with the new changes, the patch
below fixes most of them.  There are several changes for the Hayes ESP
handling, and two changes for any chip. There are several constants
in the patch which should be defines in hayespreg.h instead. I have not
tested it on ordinary com ports except with a mouse but I think they
solve some of the problems for them too.
 
I can now run ppp without a constant stream of bad fcs errors (though I
always seem to get one at the start of a session).
I still get a steady flow of 'ppp_deflate0: exceeded mru (1508 > 1504)'
but they seem harmless. Can anybody explain what they mean ?

This patch should be applied to com.c after Charles Hannum's patch.

*** com.c.old	Fri May  2 21:40:53 1997
--- com.c	Fri May  2 21:40:53 1997
***************
*** 145,150 ****
--- 145,153 ----
  integrate void comtxint		__P((struct com_softc *, struct tty *));
  integrate void commsrint	__P((struct com_softc *, struct tty *));
  integrate void com_schedrx	__P((struct com_softc *));
+ #ifdef COM_HAYESP
+ integrate int comesi_trspace	__P((bus_space_tag_t iot, bus_space_handle_t hayespioh));
+ #endif
  
  struct cfdriver com_cd = {
  	NULL, "com", DV_TTY
***************
*** 180,185 ****
--- 183,206 ----
  
  #define	COMUNIT(x)	(minor(x))
  
+ #ifdef COM_HAYESP
+ integrate int
+ comesi_trspace(iot, hayespioh)
+ 	bus_space_tag_t iot;
+ 	bus_space_handle_t hayespioh;
+ {
+ 	u_int8_t vl, vh;
+ 	int n;
+ 
+ 	bus_space_write_1(iot, hayespioh, HAYESP_CMD1, 0xff);
+ 	bus_space_write_1(iot, hayespioh, HAYESP_CMD1, 0x15);
+ 	vh = bus_space_read_1(iot, hayespioh, HAYESP_STATUS1);
+ 	vl = bus_space_read_1(iot, hayespioh, HAYESP_STATUS2);
+ 	n = (vh << 8) | vl;
+ 	return n;
+ }
+ #endif
+ 
  int
  comspeed(speed)
  	long speed;
***************
*** 286,291 ****
--- 307,316 ----
  
  	printf(": ESP");
  
+ 	/* Reset the card, do we need the delay? XXX */
+ 	bus_space_write_1(iot, hayespioh, HAYESP_CMD1, 0);
+ 	delay(1000);
+ 	
   	/* Check ESP Self Test bits. */
  	/* Check for ESP version 2.0: bits 4,5,6 == 010 */
  	bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_GETTEST);
***************
*** 399,404 ****
--- 424,444 ----
  			bus_space_write_1(iot, hayespioh, HAYESP_CMD2,
  			     HAYESP_LOBYTE(HAYESP_RXLOWMARK));
  
+ 			/* Set trigger levels */
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD1, 0x0b);
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD2, 
+ 			     HAYESP_HIBYTE(256));
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD2,
+ 			     HAYESP_LOBYTE(256));
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD2,
+ 			     HAYESP_HIBYTE(768));
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD2,
+ 			     HAYESP_LOBYTE(768));
+ 
+ 			/* Set receive timeout to 10ms */
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD1, 0x0c);
+ 			bus_space_write_1(iot, hayespioh, HAYESP_CMD2, 10);
+ 
  			break;
  		}
  		bus_space_unmap(iot, hayespioh, HAYESP_NPORTS);
***************
*** 1060,1066 ****
  	int s;
  
  	s = spltty();
! 	if (ISSET(tp->t_state, TS_BUSY))
  		goto out;
  	if (ISSET(tp->t_state, TS_TIMEOUT | TS_TTSTOP))
  		goto stopped;
--- 1100,1106 ----
  	int s;
  
  	s = spltty();
! 	if (ISSET(tp->t_state, TS_BUSY) || !ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_TXRDY))
  		goto out;
  	if (ISSET(tp->t_state, TS_TIMEOUT | TS_TTSTOP))
  		goto stopped;
***************
*** 1105,1110 ****
--- 1145,1155 ----
  	{
  		int n;
  
+ #ifdef COM_HAYESP
+ 		if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) {
+ 			n = comesi_trspace(iot, sc->sc_hayespioh);
+ 		} else
+ #endif
  		n = sc->sc_fifolen;
  		if (n > sc->sc_tbc)
  			n = sc->sc_tbc;
***************
*** 1269,1276 ****
  	CLR(tp->t_state, TS_BUSY);
  	if (ISSET(tp->t_state, TS_FLUSH))
  		CLR(tp->t_state, TS_FLUSH);
! 	else
! 		ndflush(&tp->t_outq, (int)(sc->sc_tba - tp->t_outq.c_cf));
  	(*linesw[tp->t_line].l_start)(tp);
  }
  
--- 1314,1320 ----
  	CLR(tp->t_state, TS_BUSY);
  	if (ISSET(tp->t_state, TS_FLUSH))
  		CLR(tp->t_state, TS_FLUSH);
! 	ndflush(&tp->t_outq, (int)(sc->sc_tba - tp->t_outq.c_cf));
  	(*linesw[tp->t_line].l_start)(tp);
  }
  
***************
*** 1482,1487 ****
--- 1526,1536 ----
  		if (sc->sc_tbc > 0) {
  			int n;
  
+ #ifdef COM_HAYESP
+ 			if (ISSET(sc->sc_hwflags, COM_HW_HAYESP))
+ 				n = comesi_trspace(iot, sc->sc_hayespioh);
+ 			else
+ #endif
  			n = sc->sc_fifolen;
  			if (n > sc->sc_tbc)
  				n = sc->sc_tbc;