summaryrefslogtreecommitdiff
path: root/common/usb.c
AgeCommit message (Collapse)Author
2012-12-17usb: Clean up newly allocated device nodes in case of configuration failureMilind Choudhary
If probe of a newly connected device fails for some reason, clean up the allocated entry in usb_dev array. Signed-off-by: Milind Choudhary <milindc@codeaurora.org> Signed-off-by: Simon Glass <sjg@chromium.org>
2012-11-20usb: use linux/usb/ch9.h instead of usbdescriptors.hIlya Yanok
Linux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one. As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device->speed instead. Old usbdescriptors.h included is not removed as it seems to be used by old USB device code. This makes usb.h and usbdevice.h incompatible. Fortunately the only place that tries to include both are the old MUSB code and it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute on musb_regs structure but this attribute seems to be unneeded (old MUSB code doesn't support any DMA at all). Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
2012-10-22usb: fallback safely when a configuration descriptor is too largeVincent Palatin
When a USB configuration descriptor was larger than our USB buffer (512 bytes), we were skipping the full descriptor reading but then we were still parsing and using it, triggering memory corruptions. Now in that case, it just skips this device enumeration and displays the appropriate message to the user, so he can fix the buffer if he wants. This bug was triggered by some UVC webcams which have very large configuration descriptors (e.g. a couple of kB) describing all their supported video encodings. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
2012-10-15usb: add support for multiple usb controllersLucas Stach
Allows to initialize more than one USB controller at once. v2: print message when controller stop fails Signed-off-by: Lucas Stach <dev@lynxeye.de> Reviewed-by: Marek Vasut <marex@denx.de>
2012-10-15usb: lowlevel interface change to support multiple controllersLucas Stach
Carry an index in the lowlevel usb functions to make specify the respective usb controller. Also pass through an controller struct from lowlevel_init to the creation of the root usb device of this controller. Signed-off-by: Lucas Stach <dev@lynxeye.de> Reviewed-by: Marek Vasut <marex@denx.de>
2012-07-18usb: check return value of submit_{control, bulk}_msgIlya Yanok
Return values of submit_{control,bulk}_msg() functions should be checked to detect possible error. Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
2012-07-18usb: pass cache-aligned buffer to usb_get_descriptor()Ilya Yanok
usb_get_descriptor passes it's buffer argument directly to usb_control_msg() so it has to be properly aligned/padded. Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
2012-05-20USB: Align buffers at cachelinePuneet Saxena
This avoids cache-alignment warnings shown in console when a usb command is entered. Whenever X bytes of unaligned buffer is invalidated, arm core invalidates X + Y bytes as per the cache line size and throws these warnings. Signed-off-by: Puneet Saxena <puneets@nvidia.com> Signed-off-by: Marek Vasut <marex@denx.de>
2012-05-20usb: use noinline defineMike Frysinger
Building usb for Blackfin boards fails as we get linux/compiler.h included which expands the "noinline" inside of the attribute and we get attribute(attribute(noinline)). Explicitly use the helper define to avoid this. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-19usb: replace wait_ms() with mdelay()Mike Frysinger
Common code has a mdelay() func, so use that instead of the usb-specific wait_ms() func. This also fixes the build errors: ohci-hcd.c: In function 'submit_common_msg': /usr/local/src/u-boot/blackfin/include/usb.h:202:44: sorry, unimplemented: inlining failed in call to 'wait_ms': function body not available ohci-hcd.c:1519:9: sorry, unimplemented: called from here /usr/local/src/u-boot/blackfin/include/usb.h:202:44: sorry, unimplemented: inlining failed in call to 'wait_ms': function body not available ohci-hcd.c:1816:10: sorry, unimplemented: called from here /usr/local/src/u-boot/blackfin/include/usb.h:202:44: sorry, unimplemented: inlining failed in call to 'wait_ms': function body not available ohci-hcd.c:1827:10: sorry, unimplemented: called from here /usr/local/src/u-boot/blackfin/include/usb.h:202:44: sorry, unimplemented: inlining failed in call to 'wait_ms': function body not available ohci-hcd.c:1844:10: sorry, unimplemented: called from here /usr/local/src/u-boot/blackfin/include/usb.h:202:44: sorry, unimplemented: inlining failed in call to 'wait_ms': function body not available ohci-hcd.c:1563:11: sorry, unimplemented: called from here /usr/local/src/u-boot/blackfin/include/usb.h:202:44: sorry, unimplemented: inlining failed in call to 'wait_ms': function body not available ohci-hcd.c:1583:9: sorry, unimplemented: called from here make[1]: *** [ohci-hcd.o] Error 1 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Marek Vasut <marex@denx.de>
2012-03-03USB: Make struct devrequest setup_packet localMarek Vasut
Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Remy Bohmer <linux@bohmer.net> Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-03-03USB: Separate out USB hub driverMarek Vasut
Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Remy Bohmer <linux@bohmer.net> Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-03-03USB: Staticize internal functionsMarek Vasut
Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Remy Bohmer <linux@bohmer.net> Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-12-16USB: Use (get|put)_unaligned for accessing wMaxPacketSizeTom Rini
In 9792987721c7980453fe6447c3fa6593b44f8458 Stefan describes a usecase where the previous behavior of leaving wMaxPacketSize be unaligned caused fatal problems. The initial fix for this problem was incomplete however as it showed another cases of non-aligned access that previously worked implicitly. This switches to making sure that all access of wMaxPacketSize are done via (get|put)_unaligned. In order to maintain a level of readability to the code in some cases we now use a variable for the value of wMaxPacketSize and in others, a macro. Cc: Minkyu Kang <mk7.kang@samsung.com> Cc: Remy Bohmer <linux@bohmer.net> OpenRISC: Tested-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Beagleboard xM, Pandaboard run-tested, s5p_goni build-tested. Signed-off-by: Tom Rini <trini@ti.com>
2011-11-15GCC4.6: Fix common/usb.c on xscaleMarek Vasut
The problem was that the code, when the function was compiled with -Os, was misgenerated. As in the function description, this is likely another manifestation of the bug in GCC. Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Remy Bohmer <linux@bohmer.net>
2011-10-27GCC4.6: Squash warnings in common/usb.cMarek Vasut
usb.c: In function ‘usb_parse_config’: usb.c:331:17: warning: variable ‘ch’ set but not used [-Wunused-but-set-variable] usb.c: In function ‘usb_hub_port_connect_change’: usb.c:1123:29: warning: variable ‘portchange’ set but not used [-Wunused-but-set-variable] usb.c: In function ‘usb_hub_configure’: usb.c:1183:25: warning: variable ‘hubsts’ set but not used [-Wunused-but-set-variable] Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Mike Frysinger <vapier@gentoo.org>
2011-10-09common/usb.c: fix warning: variable ... set but not usedWolfgang Denk
Fix: usb.c: In function 'usb_parse_config': usb.c:331:17: warning: variable 'ch' set but not used [-Wunused-but-set-variable] usb.c: In function 'usb_hub_port_connect_change': usb.c:1123:29: warning: variable 'portchange' set but not used [-Wunused-but-set-variable] usb.c: In function 'usb_hub_configure': usb.c:1183:25: warning: variable 'hubsts' set but not used [-Wunused-but-set-variable] Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Remy Bohmer <linux@bohmer.net> Acked-by: Remy Bohmer <linux@bohmer.net>
2011-10-04Revert "GCC4.6: Convert various empty macros to inline functions"Wolfgang Denk
This reverts commit 60ce53cf9f408d9ad721f8e7a87d6a564e6d5bac. The commit causes build breakage for a number of boards. This results from the fact that now the arguments of debug() actually get referenced (even if there is hope that the compiler will optimize away the debug() call). The obvious fix to that probem (change the code to always declare the referenced variables and data structures) increases the code size, and was this rejected. So it was decided to revert this commit until a better solution is found.
2011-10-01GCC4.6: Convert various empty macros to inline functionsMarek Vasut
Fix the following gcc4.6 problems: cmd_date.c: In function ‘do_date’: cmd_date.c:50:6: warning: variable ‘old_bus’ set but not used [-Wunused-but-set-variable] asix.c: In function ‘asix_init’: asix.c:317:6: warning: variable ‘rx_ctl’ set but not used [-Wunused-but-set-variable] usb.c: In function ‘usb_parse_config’: usb.c:331:17: warning: variable ‘ch’ set but not used [-Wunused-but-set-variable] usb.c: In function ‘usb_hub_port_connect_change’: usb.c:1123:29: warning: variable ‘portchange’ set but not used [-Wunused-but-set-variable] usb.c: In function ‘usb_hub_configure’: usb.c:1183:25: warning: variable ‘hubsts’ set but not used [-Wunused-but-set-variable] usb_storage.c: In function ‘usb_stor_CB_reset’: usb_storage.c:466:6: warning: variable ‘result’ set but not used [-Wunused-but-set-variable] Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
2011-08-08USB: Move USB_PRINTF() out of ifdef in usb_scan_devices()Marek Vasut
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
2011-08-08USB: Set portnr so USB1.1 and 1.0 devices work on EHCI controllersMarek Vasut
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
2011-02-19Add USB host ethernet adapter supportSimon Glass
This adds support for using USB Ethernet dongles in host mode. This is just the framework - drivers will come later. A new config option called CONFIG_USB_HOST_ETHER can be defined in board config files to switch this on. The was originally written by NVIDIA and was cleaned up for release by the Chromium authors. Signed-off-by: Simon Glass <sjg@chromium.org>
2011-02-05USB: Change the necessary defines to get debug outputAlexander Holler
While debugging some USB stuff, I've first missed that there are actually two defines necessary to get usefull output. The one needed to get debug output for the communication with HUBs was burried somewhere deep inside the code. Change that so that a #define DEBUG is enough while still leaving the possibility to reduce unwanted debug output. Signed-off-by: Alexander Holler <holler@ahsoftware.de>
2011-02-05USB: Fix device stati for removable and powerctrl (typo)Alexander Holler
I currently don't know if the error could have other consequences than a wrong output when turning debug on. Signed-off-by: Alexander Holler <holler@ahsoftware.de>
2010-02-03USB: usb_control_msg wait for driver ISR to set status.Remy Bohmer
This patch changes usb_control_msg back to the state prior to commit 48867208444cb2a82e2af9c3249e90b7ed4a1751. The USB driver ISR routine may update the status. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
2009-12-20USB Consolidate descriptor definitionsTom Rix
The header files usb.h and usbdescriptors.h have the same nameed structure definitions for usb_config_descriptor usb_interface_descriptor usb_endpoint_descriptor usb_device_descriptor usb_string_descriptor These are out right duplicates in usb.h usb_device_descriptor usb_string_descriptor This one has extra unused elements usb_endpoint_descriptor unsigned char bRefresh unsigned char bSynchAddress; These in usb.h have extra elements at the end of the usb 2.0 specified descriptor and are used. usb_config_descriptor usb_interface_descriptor The change is to consolidate the definition of the descriptors to usbdescriptors.h. The dublicates in usb.h are removed. The extra element structure will have their name shorted by removing the '_descriptor' suffix. So usb_config_descriptor -> usb_config usb_interface_descriptor -> usb_interface For these, the common descriptor elements are accessed now by an element 'desc'. As an example - if (iface->bInterfaceClass != USB_CLASS_HUB) + if (iface->desc.bInterfaceClass != USB_CLASS_HUB) This has been compile tested on MAKEALL arm, ppc and mips. Signed-off-by: Tom Rix <Tom.Rix@windriver.com>
2009-01-28usb_scan_devices: fix output with no devicesBryan Wu
We should check the return of usb_new_device() so that if no USB device is found, we print out the right message rather than always saying "new usb device found". Signed-off-by: Bryan Wu <bryan.wu@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Remy Bohmer <linux@bohmer.net>
2009-01-28USB: Add high-speed (480Mb/s) to all USB related outputsStefan Roese
With this patch the USB related connection speed output ("usb tree" command and debug output) is now high-speed enabled. This patch also fixes a compilation warning when debugging is enabled. Signed-off-by: Stefan Roese <sr@denx.de> Signed-off-by: Remy Bohmer <linux@bohmer.net>
2009-01-28USB change speedMichael Trimarchi
USB changes the speed according to the port status Signed-off-by: Michael Trimarchi <trimarchimichael@yahoo.it> Signed-off-by: Remy Bohmer <linux@bohmer.net>
2009-01-28Prepare USB layer for ehciMichael Trimarchi
Prepare USB layer for ehci support Signed-off-by: Michael Trimarchi <trimarchi@gandalf.sssup.it> Signed-off-by: Remy Böhmer <linux@bohmer.net>
2008-11-28USB style patch, 80 chars strictMichael Trimarchi
USB Code style patch Signed-off-by: Michael Trimarchi <trimarchi@gandalf.sssup.it> Signed-off-by: Remy Böhmer <linux@bohmer.net>
2008-10-14fix USB initialisation procedureRemy Bohmer
The max packet size is encoded as 0,1,2,3 for 8,16,32,64 bytes. At some places directly 8,16,32,64 was used instead of the encoded value. Made a enum for the options to make this more clear and to help preventing similar errors in the future. After fixing this bug it became clear that another bug existed where the 'pipe' is and-ed with PIPE_* flags, where it should have been 'usb_pipetype(pipe)', or even better usb_pipeint(pipe). Also removed the triple 'get_device_descriptor' sequence, it has no use, and Windows nor Linux behaves that way. There is also a poll going on with a timeout when usb_control_msg() fails. However, the poll is useless, because the flag will never be set on a error, because there is no code that runs in a parallel that can set this flag. Changed this to something more logical. Tested on AT91SAM9261ek and compared the flow on the USB bus to what Linux is doing. There is no difference anymore in the early initialisation sequence. Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: Markus Klotzbuecher <mk@denx.de>
2008-09-17USB layer of U-Boot causes USB protocol errors while using USB memory sticksRemy Bohmer
There are several differences between Linux, Windows and U-boot for initialising the USB devices. While analysing the behaviour of U-boot it turned out that U-boot does things really different, and some are wrong (compared to the USB standard). This patch fixes some errors: * The NEW_init procedure that was already in the code is good, while the old procedure is wrong. See code comments for more info. * On a Control request the data returned by the device can be more than 8 bytes, while the host limits it to 8 bytes. This caused the host to generate a DataOverrun error. This results in a lot of USB sticks not being recognised, and the transmission ended frequently with a CTL:TIMEOUT Error. * Added a flag CONFIG_LEGACY_USB_INIT_SEQ to allow users to use the old init procedure. Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: Markus Klotzbuecher <mk@denx.de>
2008-09-17Refactoring parts of the common USB OHCI codeRemy Bohmer
This patch refactors some large routines of the USB OHCI code by making some routines smaller and more readable which helps debugging and understanding the code. (Makes the code looks somewhat more like the Linux implementation.) Also made entire file compliant to Linux Coding Rules (checkpatch.pl compliant) Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: Markus Klotzbuecher <mk@denx.de>
2008-09-17Fix for USB sticks not working on ARM while using GCC 4.x compilersRemy Bohmer
The GCC-compiler makes an optimisation error while optimising the routine usb_set_maxpacket(). This should be fixed in the compiler in the first place, but there lots of compilers out there that makes this error, that it is probably wiser to workaround it in U-boot itself. What happens is that the register r3 is used as loop-counter 'i', but gets overwritten later on. From there it starts using register r3 for several other things and the assembler code is becoming a big mess. This is clearly a compiler bug. This error occurs on at least several versions of Code Sourcery Lite compilers for ARM. Like the Edition 2008q1, and 2008q3, It has also been seen on other compilers, while compiling for armv4t, or armv5te with Os, O1 and O2. We work around it by splitting up this routine in 2 parts, and making sure that the split out part is NOT inlined any longer. This will make GCC spit out assembler that do not show this problem. Another possibility is to adapt the Makefile to stop optimisation for the complete file. I think this solution is nicer. Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: Markus Klotzbuecher <mk@denx.de>
2008-09-09Make usb-stop() safe to call multiple times in a row.Remy Bohmer
A recent commit (936897d4d1365452bbbdf8430db5e7769ef08d38) enabled the usb_stop() command in common/cmd_bootm.c which was not enabled for some time, because no board did actually set the CFG_CMD_USB flag. So, now the usb_stop() is executed before loading the linux kernel. However, the usb_ohci driver hangs up (at least on AT91SAM) if the driver is stopped twice (e.g. the peripheral clock is stopped on AT91). If some other piece of code calls usb_stop() before the bootm command, this command will hangup the system during boot. (usb start and stop is typically used while booting from usb memory stick) But, stopping the usb stack twice is useless anyway, and a flag already existed that kept track on the usb_init()/usb_stop() calls. So, we now check if the usb stack is really started before we stop it. This problem is now fixed in both the upper as low-level layer. Signed-off-by: Remy Bohmer <linux@bohmer.net> Acked-by: Markus Klotzbuecher <mk@denx.de>
2008-08-13common: Move conditional compilation to MakefileJean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-07-14Code cleanup: fix old style assignment ambiguities like "=-" etc.Wolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-05-22USB: replace old swap_ with proper endianess conversion macrosChristian Eggers
Signed-off-by: Christian Eggers <ceggers@gmx.de> Signed-off-by: Markus Klotzbuecher <mk@denx.de>
2008-05-21Big white-space cleanup.Wolfgang Denk
This commit gets rid of a huge amount of silly white-space issues. Especially, all sequences of SPACEs followed by TAB characters get removed (unless they appear in print statements). Also remove all embedded "vim:" and "vi:" statements which hide indentation problems. Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-05-20common/usb.c: fix incorrect escape sequenceHebbar
Signed off by: Gururaja Hebbar <gururajakr@sanyo.co.in>
2007-10-31ppc4xx: Rename 405gp_pci to 4xx_pci since its used on all 4xx platformsStefan Roese
These files were introduced with the IBM 405GP but are currently used on all 4xx PPC platforms. So the name doesn't match the content anymore. This patch renames the files to 4xx_pci.c/h. Signed-off-by: Stefan Roese <sr@denx.de>
2007-07-08common/* non-cmd*: Remove obsolete references to CONFIG_COMMANDSJon Loeliger
Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-07-04common/ non-cmd: Augment CONFIG_COMMANDS tests with defined(CONFIG_CMD_*).Jon Loeliger
This is a compatibility step that allows both the older form and the new form to co-exist for a while until the older can be removed entirely. All transformations are of the form: Before: #if (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT) After: #if (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT) Signed-off-by: Jon Loeliger <jdl@freescale.com>
2006-08-03Prevent USB commands from working when USB is stopped.Bartlomiej Sieka
2006-08-02Add rudimentary handling of alternate settings of USB interfaces - to fixBartlomiej Sieka
problems with some USB storage devices. Some code readability improvements.
2005-08-04(re)enabled scsi commands do_scsi() and do_scsiboot()Wolfgang Denk
Patch by Denis Peter, 06 Dec 2004
2005-08-02Coding style cleanupWolfgang Denk
2005-07-21Fix low-level OHCI transfers for ARM920t and MPC5xxxWolfgang Denk
A new, Windows compatible init sequence was also backported from Linux 2.6, but disabled with #undef NEW_INIT_SEQ as it wouldn't change the behaviour of the memopry sticks we tested. Maybe it's not relevant for mass storage devices. For recerence, see file common/usb.c, function usb_new_device(), section #ifdef NEW_INIT_SEQ.
2004-10-17Code cleanup for GCC-3.3.x compilerswdenk