Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Nov 2006 21:20:20 GMT
From:      Marcel Moolenaar <xcllnt@mac.com>
To:        freebsd-i386@FreeBSD.org
Subject:   Re: i386/105616: UART PCI device just silent...
Message-ID:  <200611282120.kASLKKow008043@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR i386/105616; it has been noted by GNATS.

From: Marcel Moolenaar <xcllnt@mac.com>
To: puc-uart@oldach.net (Helge Oldach)
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: i386/105616: UART PCI device just silent...
Date: Tue, 28 Nov 2006 13:09:19 -0800

 --Apple-Mail-1--390117489
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=US-ASCII;
 	delsp=yes;
 	format=flowed
 
 
 On Nov 28, 2006, at 12:49 PM, Helge Oldach wrote:
 
 > Hi Marcel,
 >
 > one more observation:
 >
 > When I connect the two puc uart ports at different speeds,  
 > communication
 > still works fine. It even works with 50 against 115200 bps, in either
 > direction! Even piping files to remote works without visible errors.
 >
 > Further, if I place both sides at 50 bps (via "cu -s 50"),  
 > communication
 > is definitely much faster than one would expect at 50 bps. And it
 > doesn't seem to change when both ends are at 115200. I'd say the  
 > actual
 > speed is somewhere around 9600.
 >
 > It seems that setting clock rate on this board does not work properly,
 > but instead some default non-standard value remains set forever...
 
 Interesting. The uart(4) driver in -STABLE writes the baudrate in a
 single 16-bit wide operation. The uart(4) driver in -CURRENT doesn't
 do that. Could you try the attached patch?
 
 thanks!
 
 -- 
 Marcel Moolenaar
 xcllnt@mac.com
 
 
 --Apple-Mail-1--390117489
 Content-Transfer-Encoding: 7bit
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name=uart.diff
 Content-Disposition: attachment;
 	filename=uart.diff
 
 Index: ic/ns16550.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/ic/ns16550.h,v
 retrieving revision 1.16
 diff -u -r1.16 ns16550.h
 --- ic/ns16550.h	20 Nov 2004 23:19:42 -0000	1.16
 +++ ic/ns16550.h	28 Nov 2006 21:06:52 -0000
 @@ -127,7 +127,8 @@
  #define	com_dlbl	com_dll
  #define	com_dlm		1	/* divisor latch high (R/W) */
  #define	com_dlbh	com_dlm
 -#define	REG_DL		com_dll
 +#define	REG_DLL		com_dll
 +#define	REG_DLH		com_dlm
  
  /* 16450 register #7.  Not multiplexed. */
  #define	com_scr		7	/* scratch register (R/W) */
 Index: uart/uart.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/uart/uart.h,v
 retrieving revision 1.4
 diff -u -r1.4 uart.h
 --- uart/uart.h	6 Jan 2005 01:43:26 -0000	1.4
 +++ uart/uart.h	28 Nov 2006 21:05:06 -0000
 @@ -50,12 +50,6 @@
  #define	uart_setreg(bas, reg, value)	\
  	bus_space_write_1((bas)->bst, (bas)->bsh, uart_regofs(bas, reg), value)
  
 -/* 16-bit I/O (e.g. to divisor latch) */
 -#define	uart_getdreg(bas, reg)		\
 -	bus_space_read_2((bas)->bst, (bas)->bsh, uart_regofs(bas, reg))
 -#define	uart_setdreg(bas, reg, value)	\
 -	bus_space_write_2((bas)->bst, (bas)->bsh, uart_regofs(bas, reg), value)
 -
  /*
   * XXX we don't know the length of the bus space address range in use by
   * the UART. Since barriers don't use the length field currently, we put
 Index: uart/uart_dev_ns8250.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/uart/uart_dev_ns8250.c,v
 retrieving revision 1.14
 diff -u -r1.14 uart_dev_ns8250.c
 --- uart/uart_dev_ns8250.c	6 Jan 2005 01:43:26 -0000	1.14
 +++ uart/uart_dev_ns8250.c	28 Nov 2006 21:04:48 -0000
 @@ -75,7 +75,7 @@
  	lcr = uart_getreg(bas, REG_LCR);
  	uart_setreg(bas, REG_LCR, lcr | LCR_DLAB);
  	uart_barrier(bas);
 -	divisor = uart_getdreg(bas, REG_DL);
 +	divisor = uart_getreg(bas, REG_DLL) | (uart_getreg(bas, REG_DLH) << 8);
  	uart_barrier(bas);
  	uart_setreg(bas, REG_LCR, lcr);
  	uart_barrier(bas);
 @@ -194,12 +194,13 @@
  
  	/* Set baudrate. */
  	if (baudrate > 0) {
 -		uart_setreg(bas, REG_LCR, lcr | LCR_DLAB);
 -		uart_barrier(bas);
  		divisor = ns8250_divisor(bas->rclk, baudrate);
  		if (divisor == 0)
  			return (EINVAL);
 -		uart_setdreg(bas, REG_DL, divisor);
 +		uart_setreg(bas, REG_LCR, lcr | LCR_DLAB);
 +		uart_barrier(bas);
 +		uart_setreg(bas, REG_DLL, divisor & 0xff);
 +		uart_setreg(bas, REG_DLH, (divisor >> 8) & 0xff);
  		uart_barrier(bas);
  	}
  
 @@ -519,7 +520,8 @@
  		lcr = uart_getreg(bas, REG_LCR);
  		uart_setreg(bas, REG_LCR, lcr | LCR_DLAB);
  		uart_barrier(bas);
 -		divisor = uart_getdreg(bas, REG_DL);
 +		divisor = uart_getreg(bas, REG_DLL) |
 +		    (uart_getreg(bas, REG_DLH) << 8);
  		uart_barrier(bas);
  		uart_setreg(bas, REG_LCR, lcr);
  		uart_barrier(bas);
 
 --Apple-Mail-1--390117489
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=US-ASCII;
 	format=flowed
 
 
 
 --Apple-Mail-1--390117489--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611282120.kASLKKow008043>