µ±Ç°Î»ÖãºLinux½Ì³Ì - LinuxÎÄ»¯ - Ò»²½Ò»²½½â¾ö kernel 2.6 usb host driver

Ò»²½Ò»²½½â¾ö kernel 2.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É豸µÄ³õʼ»¯¹¤×÷£¬°üÀ¨µçÔ´¡¢Ê±ÖÓ¡¢¼Ä´æÆ÷µÈ¡£

ÆäʵºÜ¶àÎÊÌâÔÚ»¥ÁªÍøÉÏÒѾ­±»Óöµ½ºÍ½â¾ö£¬ÎÒÃÇÒª×öµÄ¾ÍÊǶà²Î¿¼±ðÈ˵ijɹ¦¾­Ñ飬ÕâÑù¿ÉÒÔ½Úʡʱ¼ä£¬Í¬Ê±Äܹ»°ïÖúÎÒÃÇÕÒµ½Ò»Ð©Ë¼Â·¡£½èÖú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 ¨C> status -110

¿´ÉÏÈ¥ÕâÁ½¸ö´íÎóÓ¦¸Ã´æÔÚ¹ØÁª£¬¿ÉÄÜÇ°ÃæµÄ115´íÎóµ¼ÖÂÁ˺óÃæµÄ110´íÎó£»ÔÚ¸ú×Ù¹ý³ÌÖз¢ÏÖ115´íÎóÊÇÔÚGetPortStatusʱ²úÉúµÄ£¬´ÓÕâ¸öÇé¿öÀ´¿´£¬¿ÉÒÔÔÝʱÆÁ±Î0hci-s3c2410.cÖÐGetPortStatusµÄʵÏÖ²¿·Ö£¬¼ÌÐø¹Û²ì±ä»¯£¬½á¹û»¹ÊÇ110´íÎó£¬Òò´Ë¿ÉÒÔÅųý115 Ôì³É110´íÎóµÄ¼ÙÉè¡£

×îºó»³ÒÉÊÇʱÖÓÉèÖõÄÎÊÌ⣬±ã²ÎÕÕ2.4.18µÄ´úÂëÔÚclk_enable(clk)£»ºóÃæ¼ÓÁ˸öudelay(11)£»µ«ÊÇ´íÎó»¹ÊÇûÓнâ¾ö¡£

ÄÇôÐèÒª¶Ôohci-s3c2410.c½øÐÐÏêϸµÄÅŲéÁË£¬2.6°Ñϵͳ×ÊÔ´½øÐÐÁËÏêϸµÄ·ÖÀ࣬ÕâʹµÃÇý¶¯³ÌÐòÒªÍê³É³õʼ»¯ÏàÓ¦É豸¼Ä´æÆ÷µÄ¹¤×÷£¬²é±é ohci-s3c2410.c£¬¾¹È»Ã»ÓжÔs3c24102410µÄUPLLCON½øÐÐÉèÖõĴúÂ룬ÎÊÌâºÜ¿ÉÄܾÍÔÚÕâÀuser manual˵UPLLCONÐèÒª48.00MHz output£¬ ÓÚÊÇÔÚs3c2410_start_hcÀïÔö¼Ó£º

__raw_writel((0x78