public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Andrei Konovalov <akonovalov@ru•mvista.com>
To: "Martin, Tim" <tim.martin@viasat•com>
Cc: "Jantira Hengmeechai \(Tai\)" <Hengmeej@linsys•ca>,
	linuxppc-embedded@ozlabs•org
Subject: Re: UartLite for MontaVista - virtex4
Date: Thu, 15 Mar 2007 12:46:34 +0300	[thread overview]
Message-ID: <45F915FA.1090400@ru.mvista.com> (raw)
In-Reply-To: <821B2170E9E7F04FA38DF7EC21DE487108663577@VCAEXCH01.hq.corp.viasat.com>

[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]

Hello,

Martin, Tim wrote:
>> 	Could you tell me where exactly to get the  "xuartlite_serial.c"
> ?
>> 	 
>> 	I could not find "xuartlite_serial.c" in the drivers folder
> generated by EDK .
> (\ppc405_0\libsrc\linux_mvl31_v1_01_b\linux\drivers\char\xilinx_uartlite
> )
> 
> Here's the relevant snippet for xulite_send_handler():
>  
> /*
> * if(pxs->thr_chars[0] != 0) then
> * throttle/unthrottle character was just sent;
> * do not advance pgs->xmit_tail by ByteCount
> * in this case.
> */
> if (pxs->thr_chars[0] == 0) {
> pxs->tx_int_cnt += ByteCount;
> 
> if (pgs->xmit_cnt >= ByteCount) {
> pgs->xmit_cnt -= ByteCount;
> pgs->xmit_tail += ByteCount;
> } else {
> pgs->xmit_tail += pgs->xmit_cnt;
> pgs->xmit_cnt = 0;
> }
> if (pgs->xmit_tail >= SERIAL_XMIT_SIZE)
> pgs->xmit_tail -= SERIAL_XMIT_SIZE;
> } else {
> pxs->tx_thr_cnt += ByteCount;
> }

This seems to be a part of the fix. IIRC the "default"
gs_flush_buffer() method doesn't work well for UART Lite.
Hence the fix we have done quite some time ago (see below).
It includes the correction pointed out by Tim, and also adds
custom flush_buffer().
The patch is against a custom tree, but it should be easy to
make it apply to the 2.4 kernel tree Tai is using.
Probably this patch was not posted here just because the linuxppc-2.4
kernel tree had been obsoleted, and there was no support for
UART Lite in the kernel.org tree.

Thanks,
Andrei


[-- Attachment #2: UARTLite-garbage-fix.patch --]
[-- Type: text/x-patch, Size: 2280 bytes --]

diff -Nru linux.orig/drivers/char/xilinx_uartlite/xuartlite_serial.c linux.result/drivers/char/xilinx_uartlite/xuartlite_serial.c
--- linux.orig/drivers/char/xilinx_uartlite/xuartlite_serial.c	2005-02-08 13:04:27.000000000 +0300
+++ linux.result/drivers/char/xilinx_uartlite/xuartlite_serial.c	2005-02-08 13:37:40.000000000 +0300
@@ -540,15 +540,18 @@
 	if (pxs->thr_chars[0] == 0) {
 		pxs->tx_int_cnt += ByteCount;
 
-		pgs->xmit_tail += ByteCount;
-		if (pgs->xmit_tail >= SERIAL_XMIT_SIZE) {
-			pgs->xmit_tail -= SERIAL_XMIT_SIZE;
+		if (pgs->xmit_cnt >= ByteCount) {
+			pgs->xmit_cnt -= ByteCount;
+			pgs->xmit_tail += ByteCount;
+		} else {
+			pgs->xmit_tail += pgs->xmit_cnt;
+			pgs->xmit_cnt = 0;
 		}
-		pgs->xmit_cnt -= ByteCount;
+		if (pgs->xmit_tail >= SERIAL_XMIT_SIZE)
+			pgs->xmit_tail -= SERIAL_XMIT_SIZE;
 	} else {
 		pxs->tx_thr_cnt += ByteCount;
 	}
-
 	/* throttle/unthrottle stuff: queue a byte for transmission (if any),
 	 * indicate that there is a room for the next XON/XOFF */
 	pxs->thr_chars[0] = pxs->thr_chars[1];
@@ -661,6 +664,7 @@
 
 	pgs = &pxs->gs_data;
 	tty->driver_data = pgs;
+	tty->disc_data = pxs;
 	pgs->tty = tty;
 	pgs->count++;
 
@@ -770,6 +774,35 @@
 	func_exit();
 }
 
+static void
+xuli_flush_buffer (struct tty_struct *tty)
+{
+	struct gs_port *port;
+	struct xs_port *pxs;
+	unsigned long flags;
+
+	func_enter ();
+
+	if (!tty) return;
+
+	port = tty->driver_data;
+	if (!port) return;
+	
+	pxs = tty->disc_data;
+	if (!pxs)
+		return;
+	del_timer_sync(&pxs->tx_timer);
+	save_and_cli(flags);
+	XUartLite_DisableInterrupt(&pxs->x_uart_lite);
+	gs_flush_buffer(tty);
+	XUartLite_ResetFifos(&pxs->x_uart_lite);
+	XUartLite_Send(&pxs->x_uart_lite, port->xmit_buf, 0);	/* stop transmission */
+	pxs->rx_enabled = 1;
+	pxs->tx_started = 0;
+	XUartLite_EnableInterrupt(&pxs->x_uart_lite);
+	restore_flags(flags);
+}
+
 /*
  * Hang up the serial port
  */
@@ -1010,7 +1043,7 @@
 	xuli_driver.flush_chars = gs_flush_chars;
 	xuli_driver.write_room = gs_write_room;
 	xuli_driver.chars_in_buffer = gs_chars_in_buffer;
-	xuli_driver.flush_buffer = gs_flush_buffer;
+	xuli_driver.flush_buffer = xuli_flush_buffer;
 	xuli_driver.ioctl = xuli_ioctl;
 	xuli_driver.throttle = xuli_throttle;
 	xuli_driver.unthrottle = xuli_unthrottle;

      reply	other threads:[~2007-03-15  9:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-13 21:28 UartLite for MontaVista - virtex4 Jantira Hengmeechai (Tai)
2007-03-14 18:12 ` Martin, Tim
2007-03-14 21:28   ` Jantira Hengmeechai (Tai)
2007-03-14 21:29     ` Martin, Tim
2007-03-15  9:46       ` Andrei Konovalov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45F915FA.1090400@ru.mvista.com \
    --to=akonovalov@ru$(echo .)mvista.com \
    --cc=Hengmeej@linsys$(echo .)ca \
    --cc=linuxppc-embedded@ozlabs$(echo .)org \
    --cc=tim.martin@viasat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox