From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.dev.rtsoft.ru (unknown [85.21.88.2]) by ozlabs.org (Postfix) with SMTP id 9CF50DDD0B for ; Thu, 15 Mar 2007 20:48:17 +1100 (EST) Message-ID: <45F915FA.1090400@ru.mvista.com> Date: Thu, 15 Mar 2007 12:46:34 +0300 From: Andrei Konovalov MIME-Version: 1.0 To: "Martin, Tim" Subject: Re: UartLite for MontaVista - virtex4 References: <821B2170E9E7F04FA38DF7EC21DE487108663577@VCAEXCH01.hq.corp.viasat.com> In-Reply-To: <821B2170E9E7F04FA38DF7EC21DE487108663577@VCAEXCH01.hq.corp.viasat.com> Content-Type: multipart/mixed; boundary="------------060005080303060600060206" Cc: "Jantira Hengmeechai \(Tai\)" , linuxppc-embedded@ozlabs.org List-Id: Linux on Embedded PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , This is a multi-part message in MIME format. --------------060005080303060600060206 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------060005080303060600060206 Content-Type: text/x-patch; name="UARTLite-garbage-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="UARTLite-garbage-fix.patch" 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; --------------060005080303060600060206--