一步一步解决kernel2.6 usb host driver

(以下讨论基于kernel 2.6.11,arm9 s3c2410,arm-linux-gcc 3.4.1 )
=================================================
2.6在s3c2410上usb host不工作的直接结果就是提示110错误:
usb 1-1: device descriptor read/64, error -110
追踪错误代码,我们来看看能不能找到导致这个错误的线索。
include/asm-generic/errno.h
#define eproto 71 /* protocol error */
#define eilseq 84 /* illegal byte sequence */
#define etimedout 110 /* connection timed out */
documentation/usb/error-codes.txt
-eproto (*, **) a) bitstuff error
b) no response packet received within the
prescribed bus turn-around time
c) unknown usb error
-eilseq (*, **) a) crc mismatch
b) no response packet received within the
prescribed bus turn-around time
c) unknown usb error
-etimedout (**) no response packet received within the prescribed
bus turn-around time. this error may instead be
reported as -eproto or -eilseq.
由此我们可以判断,这个错误与 usb 设备的超时有关。报告这个错误的地方在drivers/usb/core/hub.c中的hub_port_init部分,由于usb_get_device_descriptor获取 usb 设备信息的时候产生了超时。这样基本可以确定三种情况,1、usb 设备及接口有问题;2、usb core有问题;3、usb driver有问题。
我们可以很容易地排除1和2的可能性,问题应该在usb driver implement部分造成的。2.6的usb driver把usb规范中对usb接口的操作集中到了core里面,针对不同设备的implement分别归为host、gadget、storage等。基本确定问题就在ohci-s3c2410.c里。
跟踪进入ohci-s3c2410.c,这里面主要完成s3c2410 usb host设备的初始化工作,包括电源、时钟、寄存器等。
其实很多问题在互联网上已经被遇到和解决,我们要做的就是多参考别人的成功经验,这样可以节省时间,同时能够帮助我们找到一些思路。借助google这双强大的翅膀,我们来看看能找到什么:
http://www.linux-usb.org/faq.html#ts6
q: why doesn’t usb work at all? i get “device not accepting address”.
a: you may have some problem with your pci setup that’s preventing your usb host controller from getting hardware interrupts. when linux submits a request, but never hears back from the controller, this is the diagnostic you’ll see. to see if this is the problem, look at /proc/interrupts to see if the interrupt count for your host controller driver ever goes up. if it doesn’t, this is the problem: either your bios isn’t telling the truth to linux (acpi sometimes confuses these things, or setting the expected os to windows in your bios), or linux doesn’t understand what it’s saying.
sometimes a bios fix will be available for your motherboard, and in other cases a more recent kernel will have a linux fix. you may be able to work around this by passing the noapic boot option to your kernel, or (when you’re using an add-in pci card) moving the usb adapter to some other pci slot. if you’re using a current kernel and bios, report this problem to the linux-kernel mailing list, with details about your motherboard and bios.
google返回的大量结果中有个建议是设置old_scheme_first标志,让驱动程序优先处理采用老式结构的设备:
设置old_scheme_first=y
测试结果并没有太大帮助,不是这个原因引发的。
linux-usb-devel mail list 上ben大哥正在不断更新他的ohci-s3c2410 driver,但好像还没最终完成。
http://www.mail-archive.com/linux-usb-devel%40lists.sourceforge.net/msg33670.html
跟踪ohci-s3c2410.c,发现to_s3c2410_info返回null,很明显,是platform_data没有定义,在 include/asm/arch/usb-control.h中已经有struct s3c2410_hcd_info,那么仿照simtec的usb-simtec.c,来构造自己的platform_data。
static struct s3c2410_hcd_info smdk2410_usbcfg = {
.port[0] = {
.flags = s3c_hcdflg_used
},
};
然后在smdk2410_init中完成初始化:
s3c_device_usb.dev.platform_data = &smdk2410_usbcfg;
重新make zimage,情况有所变化:
初始化usb controller的过程中有一行debug信息:
s3c2410-ohci: ctrl: typereq=0x2303 val=0x8 idx=0x1 len=0 ==> -115
在include/asm-generic/errno.h中查了一下这个错误代码:
#define einprogress 115 /* operation now in progress */
在documentation/usb/error-codes.txt中的解释是:
-einprogress urb still pending, no results yet
(that is, if drivers see this it’s a bug.)
这时无论插入什么usb设备,usb鼠标、u盘、usb无线网卡,都报告:
usb 1-1: new full speed usb device using s3c2410-ohci and address 2
s3c2410-ohci s3c2410-ohci: urb c3c430c0 path 1 ep0in 5ec20000 cc 5 –> status -110

IQE 宣布推出可用于 MicroLED 显示器认证的 8 英寸 (200mm) RGB 外延产品
日本推出“全树脂电池”_或在2021年秋季启动量产
串口通讯的概念及接口电路
NEX 3 5G、Mate 30 Pro和Galaxy Note10+的表现都很不错,该怎么选呢?
综合布线系统设计流程怎样的?
一步一步解决kernel2.6 usb host driver
何小鹏回应:智能汽车生态的核心来自硬件体系和软件生态的运营
PCB设计之如何去耦
2019OPPO开发者大会企业合作论坛暨企业业务高峰论坛在京举办
专为5G和AI设计的低功耗DDR5 DRAM
Maxim Integrated推出支持4路全景视频信号流的解串器
2020 vivo应用服务分会场:开发者迎来重塑市场格局新机遇
变压器的定期修理周期是多久?变压器绝缘损坏该如何处理?
融合识别和定位的远程交叉电子监控系统
在仿真软件中进行电路搭建与完成瞬时现象的仿真实验
第六届IEEE全球电磁兼容国际会议顺利举行
物联网和大数据的连接谁将受益?
华为通知将下修 Mate40 出货 砍单幅度达 30%
广汽本田首款纯电动轿车EA6重磅亮相广州车展
艾迈斯半导体发布业内首个安卓系统后置3D dToF解决方案