summaryrefslogtreecommitdiff
path: root/drivers/usb/musb
AgeCommit message (Collapse)Author
2015-12-09usb: musb: core: fix order of arguments to ulpi write callbackUwe Kleine-König
commit 705e63d2b29c8bbf091119084544d353bda70393 upstream. There is a bit of a mess in the order of arguments to the ulpi write callback. There is int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) in drivers/usb/common/ulpi.c; struct usb_phy_io_ops { ... int (*write)(struct usb_phy *x, u32 val, u32 reg); } in include/linux/usb/phy.h. The callback registered by the musb driver has to comply to the latter, but up to now had "offset" first which effectively made the function broken for correct users. So flip the order and while at it also switch to the parameter names of struct usb_phy_io_ops's write. Fixes: ffb865b1e460 ("usb: musb: add ulpi access operations") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-22usb: musb: cppi41: allow it to work againFelipe Balbi
commit b0a688ddcc5015eb26000c63841db7c46cfb380a upstream. since commit 33c300cb90a6 ("usb: musb: dsps: don't fake of_node to musb core") we have been preventing CPPI 4.1 from probing due to NULL of_node. We can't revert said commit otherwise a different regression would show up, so the fix is to look for the parent device's (glue layer's) of_node instead, since that's the thing which is actually described in DTS. Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-22usb: musb: dsps: fix polling in device-only modeBin Liu
commit b8239dcc03afbd0886c1d9b91ba8fee7c6c9a6cb upstream. Fix the regression caused by commit ad78c918602 ("usb: musb: dsps: just start polling already") which causes polling the ID pin status even in device-only mode. Fixes: ad78c918602c ("usb: musb: dsps: just start polling already") Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-03usb: musb: host: rely on port_mode to call musb_start()Felipe Balbi
commit be9d39881fc4fa39a64b6eed6bab5d9ee5125344 upstream. Currently, we're calling musb_start() twice for DRD ports in some situations. This has been observed to cause enumeration issues after suspend/resume cycles with AM335x. In order to fix the problem, we just have to fix the check on musb_has_gadget() so that it only returns true if current mode is Host and ignore the fact that we have or not a gadget driver loaded. Fixes: ae44df2e21b5 (usb: musb: call musb_start() only once in OTG mode) Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Tested-by: Sekhar Nori <nsekhar@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-26usb: musb: fix order of conditions for assigning end point operationsBen Hutchings
Currently we always assign one of the two common implementations of ep_offset and ep_select operations, overwriting any platform-specific implementations. Fixes: d026e9c76aac ("usb: musb: Change end point selection to use ...") Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-04-10Merge tag 'usb-for-v4.1-part2' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-testing Felipe writes: usb: generic resume timeout for v4.1 This part 2 pull request contains only the patches which make sure everybody on linux uses the same resume timeout value. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-04-07usb: musb: use new USB_RESUME_TIMEOUTFelipe Balbi
Make sure we're using the new macro, so our resume signaling will always pass certification. Based on original work by Bin Liu <Bin Liu <b-liu@ti.com>> Cc: Bin Liu <b-liu@ti.com> Cc: <stable@vger.kernel.org> # v3.10+ Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-04-03usb: musb: dsps: fix build on i386 when COMPILE_TEST is setTony Lindgren
Commit 3e457371f436 ("usb: musb: Fix fifo reads for dm816x with musb_dsps") fixed a USB error on dm816x, but introduced a new build error on i386 when COMPILE_TEST is set: drivers/usb/musb/musb_dsps.c: In function ‘dsps_read_fifo32’: drivers/usb/musb/musb_dsps.c:624:3: error: implicit declaration of function ‘readsl’ [-Werror=implicit-function-declaration] readsl(fifo, dst, len >> 2); Let's fix this by using ioread32_rep() instead of readsl() as that's more portable. Fixes: 3e457371f436 ("usb: musb: Fix fifo reads for dm816x with musb_dsps") Reported-by: Fengguang Wu <fengguang.wu@intel.com> Cc: Bin Liu <binmlist@gmail.com> Cc: Brian Hutchinson <b.hutchman@gmail.com> Cc: George Cherian <george.cherian@ti.com> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-03musb_virthub: use USB_DT_HUBSergei Shtylyov
Fix using the bare number to set the 'bDescriptorType' field of the Hub Descriptor while the value is #define'd in <linux/usb/ch11.h>. Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-24Merge tag 'usb-for-v4.1' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: usb: patches for v4.1 merge window As usual, a big pile of commits. This time a total of 111 non-merge commits. Other than the usual set of cleanups and non-critical fixes, we have some interesting work for AM335x's MUSB babble recovery. Now that takes a lot less time and we don't have to Reset MUSB all the time. The printer gadget has been converted to configfs interface and the atmel udc has learned suspend/resume with wakeup. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-24usb: musb: Fix fifo reads for dm816x with musb_dspsTony Lindgren
Looks like dm81xx can only do 32-bit fifo reads like am35x. Let's set up musb-dsps with a custom read_fifo function based on the compatible flag. Otherwise we can get the following errors when starting dhclient on a asix USB Ethernet adapter: asix 2-1:1.0 eth2: asix_rx_fixup() Bad Header Length 0xffff003c, offset 4 While at it, let's also remove pointless cast of the driver data. Cc: Bin Liu <binmlist@gmail.com> Cc: Brian Hutchinson <b.hutchman@gmail.com> Cc: George Cherian <george.cherian@ti.com> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-11usb: musb: cppi41: fix condition to call cppi41_trans_done().Takeyoshi Kikuchi
connect AR9271(USB wifi) to AM335x, and send a flood ping from Mac OSX, AR9271 is stopped. on USB bus, the following occurs. - OUT transaction is ACKed (NYET). - IN transaction is ACKed (512bytes). - PING-NAK transaction is continued for about 2 seconds (AR9271 timeout?). In current imprementation, IN-transaction is not completed because it checks the empty of TX-FIFO in cppi41_dma_callback(). As a result, communication to AR9271 stops. This patch modified to check the empty of TX-FIFO only when OUT-transaction. Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-11usb: musb: dsps: don't fake of_node to musb coreFelipe Balbi
If we pass our own of_node to musb_core, at least pinctrl settings will be duplicated, meaning that pinctrl framework will try to select default pin state for musb_core when they were already requested by musb-dsps. A Warning will be printed however things will still work. Reported-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-11usb: musb: dsps: request phy using our device pointerFelipe Balbi
musb shouldn't have of_node and phy phandle is passed to dsps device, not musb's. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: just start polling alreadyFelipe Balbi
there's no need to fake an IRQ, just check if VBUS is valid already. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: use msecs_to_jiffies insteadFelipe Balbi
when polling, we were using n * HZ (where n is an integer in seconds), however HZ isn't always correct if we're using cpufreq. A better way is to use msecs_to_jiffies(n) (where n is now an integer in miliseconds). while at that, also rename poll_seconds to poll_timeout and change its type to unsigned int. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: cppi41: do not call udelay()Felipe Balbi
according to comment in code, HS completion will happen pretty fast, instead of using udelay(), let's just busy loop and drop a cpu_relax() where udelay() was. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: cppi41: exit early when tx fifo is emptyFelipe Balbi
as soon as we find out tx fifo is empty, there's no need to break out of the loop just to have another branch to complete the transfer. We can just complete transfer and exit early. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: cppi41: decrease indentation levelFelipe Balbi
no functional changes, clean up only. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: always try to recover from babbleFelipe Balbi
we can also have babble conditions with LS/FS and we also want to recover in that case. Because of that we will drop the check of HSMODE and always try to run babble recovery. Suggested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: disable irqs inside babble recoveryFelipe Balbi
There's no point is splitting those anymore. We're now also able to drop another forward declaration. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: remove unnecessary forward declarationFelipe Balbi
no functional changes, cleanup only. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: drop recover_workFelipe Balbi
that's not needed anymore. Everything that we call is irq-safe, so we might as well not have a delayed work for babble recovery. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: rename ->reset() to ->recover()Felipe Balbi
recover is a much better name than reset, considering we don't really reset the IP, just run platform-specific babble recovery algorithm. while at that, also fix a typo in comment and add kdoc for recover memeber of platform_ops. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: simplify musb_recover_work()Felipe Balbi
we're not resetting musb at all, just restarting the session. This means we don't need to touch PHYs or VBUS or anything like that. Just make sure session bit is reenabled after MUSB dropped it. while at that, make sure to tell usbcore that we're dropping the session and, thus, disconnecting the device. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: do not reset musb on babbleFelipe Balbi
All we have to do is, really, drop session bit and let the session restart. Big thanks goes to Bin Liu <b-liu@ti.com> for inspiring this work. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: decrease delayed_work timeFelipe Balbi
When babble IRQ happens, we need to wait only 5.3us (320 cycles of 60MHz clock), we will give it some slack and schedule our work a 10 usecs into the future. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: don't touch devctl from babble recoveryFelipe Balbi
We do *not* want to touch devctl at all when trying to recover from babble. All we want to do is mask IRQs until we're done without our babble recovery, at which point we will unmask IRQs. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: refactor IRQ enable/disable to separate functionsFelipe Balbi
sometimes we want to just mask/unmask interrupts without touching devctl register. For those cases, let's introduce musb_enable_interrupts and musb_disable_interrupts() Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: add dsps_ prefix to sw_babble_controlFelipe Balbi
this makes it easier to filter function traces. No functional changes. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: controller drops session automaticallyFelipe Balbi
Whenever babble happens, MUSB controller will drop session automatically. The only case where it won't drop the session, is when we're running on AM335x and SW_SESSION_CTRL bit has been set. In that case, controller will not touch session bit so SW has a chance to recover from babble condition. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: check for the single bitFelipe Balbi
We want to check if that particular bit is set. It could very well be that bootloader (or romcode) has fiddled with MUSB before us which could leave other bits set in this register. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: remove babble check from dsps irq handlerFelipe Balbi
musb->int_usb already contains the correct information for musb-core to handle babble. In fact, this very check was just causing a nonsensical babble interrupt storm. With this I can get test.sh to run and, even though all tests fail with timeout, that's still better than locking up the system due to IRQ storm. Also, if I remove g_zero and load g_mass_storage, then everything works fine again. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: there is no connect interrupt in peripheral modeFelipe Balbi
MUSB does not generate a connect IRQ when working in peripheral mode. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: remove unnecessary reg access from resume IRQFelipe Balbi
when musb is operating as host and a remote wakeup fires up, a resume interrupt will be raised. At that point SUSPENDM bit is automatically cleared and RESUME bit is automatically set. Remove those two from IRQ handler. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: break long lineFelipe Balbi
no functional changes, clean up only. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: move babble recovery inside babble checkFelipe Balbi
There was already a proper place where we were checking for babble interrupts, move babble recovery there. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: dsps: return error code if reset failsFelipe Balbi
if reset fails, we should return a *negative* error code, not a positive value. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: fix highspeed checkFelipe Balbi
FSDEV is set for both HIGH and FULL speeds, the correct HIGHSPEED check is done through power register's HSMODE bit. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: add missing curly bracesFelipe Balbi
no functional changes, clean up only. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-10usb: musb: core: remove unnecessary logical comparisonFelipe Balbi
devctl & MUSB_DEVCTL_HM represents a single bit, just check for the bit, there's really no need to compare the result against 0. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-09usb: musb: fix Kconfig regressionArnd Bergmann
A recent bug fix I did that was marked for stable backports introduced a slightly wrong dependency on CONFIG_OMAP_CONTROL_PHY. I was missing the fact that the PHY driver already stubs out the omap_control_usb_set_mode, and we only need to add a dependency to prevent the musb-omap2430 driver from being built-in when the phy driver is a loadable module, but we should not prevent it from being built altogether when the phy driver is disabled. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: ca784be36cc725 ("usb: start using the control module driver") Cc: <stable@vger.kernel.org> # v3.9+ Acked-by: Acked-by: Pavel Machek <pavel@ucw.cz> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-09usb: musb: core: improve musb_interrupt() a bitFelipe Balbi
instead of using manually spelled out bit-shits and iterate over each of the 16-bits (one for each endpoint) on each direction, we can make use of for_each_set_bit() which internally uses find_first_bit(). This makes the code slightly more readable while also making we only iterate over bits which are actually set. Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-09usb: musb: core: fix TX/RX endpoint orderFelipe Balbi
As per Mentor Graphics' documentation, we should always handle TX endpoints before RX endpoints. This patch fixes that error while also updating some hard-to-read comments which were scattered around musb_interrupt(). This patch should be backported as far back as possible since this error has been in the driver since it's conception. Cc: <stable@vger.kernel.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-09usb: musb: gadget: get rid of stop_activity()Felipe Balbi
that function is pretty close to a no-op by now, all we need is a call to musb_stop(). Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-02-23usb: musb: Fix getting a generic phy for musb_dspsTony Lindgren
We still have a combination of legacy phys and generic phys in use so we need to support both types of phy for musb_dsps.c. Cc: Brian Hutchinson <b.hutchman@gmail.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-02-23usb: musb: Fix use for of_property_read_bool for disabled multipointTony Lindgren
The value for the multipoint dts property is ignored when parsing with of_property_read_bool, so we currently have multipoint always set as 1 even if value 0 is specified in the dts file. Let's fix this to read the value too instead of just the property like the binding documentation says as otherwise MUSB will fail to work on devices with Mentor configuration that does not support multipoint. Cc: Brian Hutchinson <b.hutchman@gmail.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-02-23usb: musb: core: add pm_runtime_irq_safe()Felipe Balbi
We need a pm_runtime_get_sync() call from within musb_gadget_pullup() to make sure registers are accessible at that time. The problem is that musb_gadget_pullup() is called with IRQs disabled and, because of that, we need to tell pm_runtime that this pm_runtime_get_sync() is IRQ safe. We can simply add pm_runtime_irq_safe(), however, because we need to make our read/write accessor function pointers have been initialized before trying to use them. This means that all pm_runtime initialization for musb_core needs to be moved down so that when we call pm_runtime_irq_safe(), the pm_runtime_get_sync() that it calls on the parent, won't cause a crash due to NULL musb_read/write accessors. Reported-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-02-23usb: musb: musb_host: Enable HCD_BH flag to handle urb return in bottom halfGeorge Cherian
Enable HCD_BH flag for musb host controller driver. This improves the MSC/UVC through put. With this enabled even 640x480@30fps webcam streaming is also supported. Signed-off-by: George Cherian <george.cherian@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-02-04usb: musb: fix device hotplug behind hubBin Liu
The commit 889ad3b "usb: musb: try a race-free wakeup" breaks device hotplug enumeraitonn when the device is connected behind a hub while usb autosuspend is enabled. Adding finish_resume_work into runtime resume callback fixes the issue. Also resume root hub is required to resume the bus from runtime suspend, so move musb_host_resume_root_hub() back to its original location, where handles RESUME interrupt. Signed-off-by: Bin Liu <b-liu@ti.com> Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>