内核8250串口驱动问题

268 views
Skip to first unread message

dongas

unread,
Oct 20, 2008, 6:45:34 AM10/20/08
to linux-...@zh-kernel.org
我们平台的Uart芯片类似于16550A,发送和接收端分别有一个16 byte的fifo。使用的驱动是基于内核自带的8250驱动。

在8250驱动内,16550A默认设置的接收中断触发level即threshold为8个byte,如下:
/* drivers/serial/8250.c */
……
[PORT_16550A] = {
.name = "16550A",
.fifo_size = 16,
.tx_loadsz = 8,
.fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10 | UART_FCR_T_TRIG_00,
.flags = UART_CAP_FIFO,
},
注:UART_FCR_R_TRIG_10表示8个bytes

下面这段是我们uart相关的datasheet上的描述
7:6 RX FIFO threshold W 0x0
RX FIFO threshold level. While data in RX FIFO
is equal to or greater than the specified threshold
level, hardware will generate an interrupt to host
if the interrupt is enabled. The level is
configurable as below:
[7:6] =
00: 1-byte in FIFO
01: 4-byte in FIFO
10: 8-byte in FIFO
11: 14-byte in FIFO

从上面的描述知道,当中断触发level设为8个bytes时, 理论上应该是当串口接收到等于或大于8个bytes时,
才会产生receive的中断,然后收到的字符push到tty buffer.(若错了请更正)
但我实际的调试结果是即使只接收到1个byte,串口也会立马产生中断。比如在控制台上敲一个字符(==从pc端发一个字符到target端)

或者通过串口调试助手发。
不仅仅我们的平台这样,后来我又看了一下omap5912 uart(ST16554)的rx threshold设的4个bytes也是同样的现象。

这里不太明白,恳请了解的前辈们指点一下!
究竟为什么uart只接收到一个字节也会产生中断即使rx threshold设为8个byte?

先谢了!
_______________________________________________
Linux 内核开发中文邮件列表
Linux-...@zh-kernel.org
http://zh-kernel.org/mailman/listinfo/linux-kernel
Linux 内核开发中文社区: http://zh-kernel.org

Nig...@viatech.com.cn

unread,
Oct 20, 2008, 7:50:12 AM10/20/08
to dong...@gmail.com, linux-...@zh-kernel.org
所说8个bytes产生中断是interrupt trigger level,就是RX FIFO中的数据到一定量的时候会触发中断

但是如果TX只发1个byte就完成了,这时候RX如果没有中断那就完全没办法接受
所以在URAT里都有一个timeout的机制,如果接受了1个byte但是过了一定时间还没有达到trigger level则uart硬件会产生一个timeout的中断


Nigel Li 李乃捷
Storage Team, Software Dept.
VIA Technologies(China)Inc, Ltd.
Tel: 86-10-59852288 ext. 2391
-----邮件原件-----
发件人: linux-kern...@zh-kernel.org [mailto:linux-kern...@zh-kernel.org] 代表 dongas
发送时间: 2008年10月20日 18:46
收件人: linux-...@zh-kernel.org
主题: 内核8250串口驱动问题

dongas

unread,
Oct 20, 2008, 9:21:19 PM10/20/08
to Nig...@viatech.com.cn, linux-...@zh-kernel.org
Dear Nigel,

> 所说8个bytes产生中断是interrupt trigger level,就是RX FIFO中的数据到一定量的时候会触发中断
>
> 但是如果TX只发1个byte就完成了,这时候RX如果没有中断那就完全没办法接受

对,我就是担心此问题。
> 所以在URAT里都有一个timeout的机制,如果接受了1个byte但是过了一定时间还没有达到trigger level则uart硬件会产生一个timeout的中断
是的。我在PC16550D/s3c2410的datasheet上都看到了这样的描述。看样子我们的datasheet上漏了这一句。
不过现在明白了,多谢Nigel兄的回复~!

Regards,
Dongas

benson

unread,
Oct 20, 2008, 9:13:37 PM10/20/08
to Nig...@viatech.com.cn, dong...@gmail.com, linux-...@zh-kernel.org
Dear Nigel,

Thx for your reply!

>-----邮件原件-----
>发件人: Nig...@viatech.com.cn [mailto:Nig...@viatech.com.cn]
>发送时间: 2008年10月20日 19:50
>收件人: dong...@gmail.com; linux-...@zh-kernel.org
>主题: 答复: 内核8250串口驱动问题
>
>所说8个bytes产生中断是interrupt trigger level,就是RX FIFO中的数据到一
>定量的时候会触发中断
>
>但是如果TX只发1个byte就完成了,这时候RX如果没有中断那就完全没
>办法接受
对,我就是担心此问题。
>所以在URAT里都有一个timeout的机制,如果接受了1个byte但是过了一
>定时间还没有达到trigger level则uart硬件会产生一个timeout的中断
是的。我在PC16550D/s3c2410的datasheet上都看到了这样的描述。看样子我们的
datasheet上漏了这一句。
不过现在明白了,多谢Nigel兄的回复~!

Regards,
Dongas
>--
>No virus found in this incoming message.
>Checked by AVG.
>Version: 7.5.549 / Virus Database: 270.8.1/1733 - Release Date: 2008-10-19
>18:02

====================================================================
CONFIDENTIALITY NOTE:
This e-mail and any attachments may contain confidential information and may
be protected by legal privilege. If you are not the intended addressee (or
authorized to receive for the addressee), be aware that any disclosure,
copying, distribution or use of this e-mail or any attachment is prohibited.
If you have received this e-mail in error, please notify us immediately by
returning it to the sender and delete this copy from your system. Thank you
for your cooperation.
Infomax Communication Co., Ltd.
====================================================================
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply all
Reply to author
Forward
0 new messages