⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sa1100_usb

📁 上传linux-jx2410的源代码
💻
字号:
StrongARM SA-1100 USB function DriverWard Willats <ward.willats@extenex.com> -  08Mar011. History''''''''''Brad Parker <brad@parker.boston.ma.us> ported the DEC/Compaq "Itsy"SA-1100 USB Function driver to the 2.4.x code base in late 2000, foruse as an "ethernet over usb" link. His original notes are here insection 4. Nicolas Pitre <nico@cam.org> rewrote the transmitter andreciver (endpoints 1 and 2) in late 2000 to use the standard SA DMAAPI and I added a bulk character interface and reworked the controlcontrol module code and rewrote endpoint zero in early 2001.This release (22Feb01) is the first that completely separatesclient modules (usb-eth.c and usb-char.c) from the SA-1100 USB core.(usb_ctl, usb_ep0, usb_send and usb_receive)and makes the wholemess a module. Oleg Drokin has done a huge amount of work, fixingthings I break and adding support for the generic usbnet driverfrom the AC tree.2. Usage''''''''Turn on CONFIG_SA1100_USB_NETLINK to use the "ethernet over usb"functionality. Turn it off to use the character orientedinterface. The character driver currently uses mknod c 10 240.Programming:The public interface is in sa1100_usb.h. For a client USB serviceto use the SA-1100 USB core driver it should:1. Call sa1100_usb_open() to get the usb core assigned to it.2. Setup descriptors as appropriate for the task at hand. Esp.important are endpoint max packet lengths, vendor and product IDs,and type of endpoint (bulk or interrupt). Callsa1100_get_descriptor_ptr() to get this.3. Call sa1100_usb_start() to actually start the usb hardware.At this time the host will configure the device....at shutdown...4. Call sa1100_usb_stop() to stop the USB core.5. Call sa1100_usb_close() to free the core for use by anotherclient.3. Netlink Usage''''''''''''''''StrongARM SA-1100 USB function "ethernet over usb driver"Brad Parker <brad@parker.boston.ma.us>I ported the DEC "Itsy" usb "ethernet over usb driver" code to the 2.4.xbase and made some enhacements and bug fixes.  This code has 2 sides andimplements a simple "ethernet over usb" functionality.function (SA1100) side:- the driver has two endpoints and uses interrupt and bulk transfer toreceive/send packets.  the driver does not require any other usb codeand should work on most any sa1100.host (SA1111) side:- because the SA1111 usb host is not working yet I tested this driver(usb-net-host.c) on a 2.2.14 based PC with the latest usb backport.It has been fully converted to use URBs and worked well with my UHCIbased controller.TESTING:To test you need an assabet on the 'function' side, a PC on the 'host'side and a USB A-B cable to connect them together.Boot a kernel on the assabet with "USB function and net-host support"(CONFIG_SA1100_USB) turned on.  This will define an interface named"usbf".  Once it's booted you can setup the interface with	mount -t proc /proc /proc	/sbin/ifconfig usbf 1.1.1.2I used a 2.2.14 kernel on a x86 PC for the host side.  It has a builtin UHCI usb controller chip.  I installed the latest USB backport fromhttp://www.linux-usb.org onto the 2.2.14 kernel sources and turned on"USB net-host" (CONFIG_USB_NET_HOST) as a module.  Load the module"usb-net-host.o" and connect the USB cable to the assabet.  Configurethe usb network interface with	/sbin/ifconfig usb0 1.1.1.1You should be able to "ping" the assabet now with	ping -c 1 1.1.1.2If the assabet is running inetd the usual network services such astelnet and ftp should work.Oleg Drokin in 2.4.2-rmk1-np2 (08Mar01) added module config params forread and write size to the usb-eth.c client to allow dynamic settingof the DATA0/DATA1 packet size on the usb wire:usb_rsize - number of bytes in OUT packets from host to SA1100usb_wsize - number of bytes in IN packets from SA1100 to hostThis allows dynamic tuning for performance or to prevent overruningthe the host with data.4. Known Issues'''''''''''''''- We are fiddling with various ways to set the IMP register inusb_send.c. A small percentage of the time, this value does not"take."- I've started to bring back the /proc interface, but clientsof the sa-usb core currently don't have a directory or somethingto put their stats into.- Only a useful subset of ep0 setup calls have been implemented.5. Mysteries of the Universe''''''''''''''''''''''''''''This driver has been hard to develop because the documentationprovided by Intel is incomplete, and the UDC itself seems to have avariety of bugs. The errata for the part is particularly scary! Thissection is an attempt to document some of the discoveries andquestions I have come across while working on this thing.pp 11-63 of the "Intel Strong ARM SA-1110 Microprocessor AdvancedDeveloper Information" give an ominous warning about how "due tointernal synchronization required by the UDC configuration registers,it is possible for the procesor to write the UDC refisters and FIFOstoo fast." This has led to a variety of approaches that attempt tobang on the hardware repeatedly and read it back until the write"sticks."All of these approaches have been problematic. Currently some macrosin udc_ctl.h that Nicolas wrote are being used. My hardware guy toldme that writes would never be "lost" but stuck on some internal bus inthe UDC module and propagated to the rest of the circuit when the timewas right. Indeed this seemed to be the case, for example, it seemsimpossible to reliably read back the interrupt mask register of the UDC when inthe interrupt service routine. Often times the state was not reflectedon a read until after pending interrupt sources were cleared.I was feeling prety good about this and was ripping out the loopingmacros right and left until I came upon a situation where, whilereceiving a continuous set of 1 character packets, ep1 (usb_receive.c)could not clear receive packet complete (RPC). After much desperatefaliling about it turns out changing the UDC_flip() macro to bang likecrazy on the RPC bit did in fact clear it, and clear itconsistently. So go figure.Other items of interest:- Upon emerging from a reset, the UDC will clear the mask register exceptfor a mask on suspend.- USB 1.0 spec says maximum size of a DATA0/1 packet is 64 bytes,which is what the character driver is using. However, the UDC can do256 bytes and every host I've tried can handle it, even though theyare not required to. (Perhaps it is a problem when hubs are on theline, but the SA UDC has other problems in a hub environment -- likeeven getting the correct address -- per the errata).- Endpoint zero FIFOs: ARGHHH! Just leave those routines alone.Believe me, I have tried every other variation you can think of.Probably.- Sometimes I get a setup request of 0x80 from Windows hosts. I havenot determined if this is a read_fifo error (none is reported) or ifthis is some undocumented secret Redmond handshake only known toinitiates of the inner-order.6. Test Program'''''''''''''''This is now in the /proc interface. (For good or ill, probably don'tactually need to dump all this stuff..)7. Errors and Notes on Intel's 1110 Documentation'''''''''''''''''''''''''''''''''''''''''''''''''These corrections apply to "Intel StrongARM SA-1110 Microprocessor,Advanced Developer's Manual of December 1999" Some of these have beencorrected in later editions, some not. There have been several updatesto this document published through 2000. Always use the latestavailable on http://developer.intel.com/design/strong/collateral.htm.pp 11-65 section 11.8.3.8 bit 2, reserved is now the resume interruptmask. SRM is now SUSIM on SA-1110, and masks only the suspendinterrupt.pp 11-67 section 11.8.6, Max IN register, end should be 9 _bytes_not 9 bits.pp 11-68 section 11.8.7.3, SST. This is set by the CPU _not_ the UDC.And it looks like you don't get a SST if you FST yourself.pp 11-68 section 11.8.7.5, DE. This is set by the CPU _not_ the UDC.pp 11-73 section 11.8.9.7, UDCCS2 table, bit 2, Should be "valid onlywhen _TPC_ (not RPC) is set.pp 11-74 section 11.8.10, should end with a GET_DESCRIPTOR _orsimilar_ command. (Like, for example, GET_CONFIGURATION).8. Change History'''''''''''''''''Following are current chages  8Mar01 (released in 2.4.2-rmk1-np2?)- Resetting UDC when coming out of suspend helped enumeration getgoing considerably.- Added support for client-supplied notify routine to be calledby the USB core when core reaches "configured" state.- Added error returns from interrupt reads and buffer flush ioctlcalls to usb-char. Added usb-char.h file for ioctl calls.- Fixed bug that kept usb-char transmitter from working the secondtime the module was loaded.- Turned off a lot of the noise in /proc- Added specialty routines in ep0 to set and clear bits.- More enumeration fiddling.- There are horrible hacks to set max IN length in usb_send  that ARE GOING AWAY SOON! REALLY!*** Following changes 26Feb01 (released in 2.4.2-rmk1-np1)- usb-eth integration with generic usbnet from AC tree.- Creation of public interface for usb clients in sa1100_usb.hand final separation into a "core" driver (usb_ctl.c, usb_ep0.cusb_recv.c usb_send.c) and "client" services (usb-eth.c andusb-char.c). Modularized.- Descriptor handling rewritten. Support for string descriptorsadded. More bugs in ep0 fixed. More setup packets handled.- /proc interface in usb_ctl returning- removed client specific stuff from usbd_info_t and hid thestructure in usb_ctl. Removed RAM-backing of address and pktsizein this structure. Now the descriptor values are gospel.- usb_dbg.h eliminated- Many bugs fixed in usb-char.c- Fiddled startup sequence so should start everytime.- Arch specific "soft connect" hook in usb_ctl.c- Bumped the interation count in write/set/clear macrosin usb_ctl.h up to 10000. This seemed to help various bitsetting in ep0 and usb_send.c.*** Following changes 10Feb01 release:- endpoint zero entirely rewitten- Various changes by Oleg to make Netlink work again after the  2.4.1-rmk1-np1 release.- Resetting of new max packet length done after clearing TPCin usb_send, per Nicolas Pitre.*** Following changes 23Jan01 (came out in 2.4.1-rmk1-np1):- Moved host initiated SET/GET feature stall into endpoint code ofusb_send.c and usb_receive.c and removed stallep from usb_ctl.cOpposite of a SET_FEATURE stall is a reset, so no code to unstall isprovided.- Added explicit USB state machine to usb_ctl so driver and devicestate can be tracked closely and explicitly. Added hard-wirednotification routines in endpoints 1 and 2 so they can track devicestate changes as required. State machine has notion of "zombie" statethe covers USB states NONATTACHED, ATTACHED and POWERED since theseare murky, and USB driver currently has no way to differentiatebetween the two.- Reworked ISR in usb_ctl so reset has higher priority than any otherevent. Stopped using sync macros to clear interrupt pending flags and setmask registers since it appears mask register changes are notalways reflected on a mask register read until the pending flag iscleared (yet other tests show they are always clearedeventually). Toggle suspend/resume interrupt masks back and forth duringsuspend and resume to debounce and keep UDC internal state machine insync per Intel documentation.- Flipped UDC flip, clear, write and set macros from do{}while towhile() loops. Theory is you might save a loop iteration if valuebecomes valid immediately. Also, my hardware guy says writes are never"lost", just pipelined and not executed immediately depending oninternal device conditions (like setting int masks when intspending), so moved write cycles in macros outside of loops.- Added #defines to SA-1110.h for suspend and resume interrupt maskbits per Intel eratta. Submitted to ARM patch system (444/1).- Removed task queue and defered execution of configure() fromusb_ctl.- Removed usb_write_reg() from usb_ctl.c, and various cruft fromusb_ctl.h.- Added sa1100_usb_xmitter_avail() to usb_send.c. Makes implementingpoll() fileop easier.- Added sa1100_usb_send_reset() to usb_send.c. Makes implementingtransmitter timeout easier.- Added API to usb_ctl to set vendor and product ID- Changed BMATTR descriptor fron int to bulk, when not using netlink. (Allthe docs say UDC does not support INT xfers -- though, at the protocollevel I don't see why not, since bulk and int are both justIN-DATA-ACK. I figure netlink may rely on this, and not just acontinuous pending read from the host, but for "pure bulk" hostpolling may not be generally correct.)- Removed unused rx_lock and tx_lock from usb_ctl- Converted everyone to SA-1100.h and nuked hardware defines in usb_ctl.h- Removed udc_init() in usb_ctl.c and folded functionality into udc_start().- Clear force stall (FST) in udc_start and reset so UDC actually runs whenfirst turned on.- Emit NAK in receiver until ep1_start() for error (RPE) case too.- Remove enable/disable UDC from reset handler in udc_ctl. The UDC hasalready been reset, so no need to do this again.- Explicitly set address to zero in ep0_reset()- Added "naking" boolean to usb_receiv.c. An attempt to solve ahypothetical race condition where we are in the critical sectioninitiating a read from base-level code, a RPC happens, and start()might clear the condition before the packet is handled by the ISR.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -