summaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_core.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: musb: Use shared irqAlexandre Bailon2017-04-181-1/+1
| | | | | | | | | In the DA8xx, USB and CPPI 4.1 are sharing the same interrupt line. Update the driver to request a shared irq. Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: fix possible spinlock deadlockBin Liu2017-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DSPS glue calls del_timer_sync() in its musb_platform_disable() implementation, which requires the caller to not hold a lock. But musb_remove() calls musb_platform_disable() will musb->lock held. This could causes spinlock deadlock. So change musb_remove() to call musb_platform_disable() without holds musb->lock. This doesn't impact the musb_platform_disable implementation in other glue drivers. root@am335x-evm:~# modprobe -r musb-dsps [ 126.134879] musb-hdrc musb-hdrc.1: remove, state 1 [ 126.140465] usb usb2: USB disconnect, device number 1 [ 126.146178] usb 2-1: USB disconnect, device number 2 [ 126.416985] musb-hdrc musb-hdrc.1: USB bus 2 deregistered [ 126.423943] [ 126.425525] ====================================================== [ 126.431997] [ INFO: possible circular locking dependency detected ] [ 126.438564] 4.11.0-rc1-00003-g1557f13bca04-dirty #77 Not tainted [ 126.444852] ------------------------------------------------------- [ 126.451414] modprobe/778 is trying to acquire lock: [ 126.456523] (((&glue->timer))){+.-...}, at: [<c01b8788>] del_timer_sync+0x0/0xd0 [ 126.464403] [ 126.464403] but task is already holding lock: [ 126.470511] (&(&musb->lock)->rlock){-.-...}, at: [<bf30b7f8>] musb_remove+0x50/0x1 30 [musb_hdrc] [ 126.479965] [ 126.479965] which lock already depends on the new lock. [ 126.479965] [ 126.488531] [ 126.488531] the existing dependency chain (in reverse order) is: [ 126.496368] [ 126.496368] -> #1 (&(&musb->lock)->rlock){-.-...}: [ 126.502968] otg_timer+0x80/0xec [musb_dsps] [ 126.507990] call_timer_fn+0xb4/0x390 [ 126.512372] expire_timers+0xf0/0x1fc [ 126.516754] run_timer_softirq+0x80/0x178 [ 126.521511] __do_softirq+0xc4/0x554 [ 126.525802] irq_exit+0xe8/0x158 [ 126.529735] __handle_domain_irq+0x58/0xb8 [ 126.534583] __irq_usr+0x54/0x80 [ 126.538507] [ 126.538507] -> #0 (((&glue->timer))){+.-...}: [ 126.544636] del_timer_sync+0x40/0xd0 [ 126.549066] musb_remove+0x6c/0x130 [musb_hdrc] [ 126.554370] platform_drv_remove+0x24/0x3c [ 126.559206] device_release_driver_internal+0x14c/0x1e0 [ 126.565225] bus_remove_device+0xd8/0x108 [ 126.569970] device_del+0x1e4/0x308 [ 126.574170] platform_device_del+0x24/0x8c [ 126.579006] platform_device_unregister+0xc/0x20 [ 126.584394] dsps_remove+0x14/0x30 [musb_dsps] [ 126.589595] platform_drv_remove+0x24/0x3c [ 126.594432] device_release_driver_internal+0x14c/0x1e0 [ 126.600450] driver_detach+0x38/0x6c [ 126.604740] bus_remove_driver+0x4c/0xa0 [ 126.609407] SyS_delete_module+0x11c/0x1e4 [ 126.614252] __sys_trace_return+0x0/0x10 Fixes: ea2f35c01d5ea ("usb: musb: Fix sleeping function called from invalid context for hdrc glue") Cc: <stable@vger.kernel.org> #4.9+ Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: add code comment for clarificationGustavo A. R. Silva2017-02-141-0/+1
| | | | | | | | | Add code comment to make it clear that the fall-through is intentional. Read the link for more details: https://lkml.org/lkml/2017/2/9/292 Addresses-Coverity-ID: 1397608 Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 4.10-rc7 into usb-nextGreg Kroah-Hartman2017-02-061-13/+13
|\ | | | | | | | | | | We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: musb: Fix external abort on non-linefetch for musb_irq_work()Tony Lindgren2017-01-251-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While testing musb host mode cable plugging on a BeagleBone, I came across this error: Unhandled fault: external abort on non-linefetch (0x1008) at 0xd1dcfc60 ... [<bf668390>] (musb_default_readb [musb_hdrc]) from [<bf668578>] (musb_irq_work+0x1c/0x180 [musb_hdrc]) [<bf668578>] (musb_irq_work [musb_hdrc]) from [<c0156554>] (process_one_work+0x2b4/0x808) [<c0156554>] (process_one_work) from [<c015767c>] (worker_thread+0x3c/0x550) [<c015767c>] (worker_thread) from [<c015d568>] (kthread+0x104/0x148) [<c015d568>] (kthread) from [<c01078d0>] (ret_from_fork+0x14/0x24) Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: musb: Fix host mode error -71 regressionTony Lindgren2017-01-251-13/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core") started implementing musb generic runtime PM support by introducing devctl register session bit based state control. This caused a regression where if a USB mass storage device is connected to a USB hub, we can get: usb 1-1: reset high-speed USB device number 2 using musb-hdrc usb 1-1: device descriptor read/64, error -71 usb 1-1.1: new high-speed USB device number 4 using musb-hdrc This is because before the USB storage device is connected, musb is in OTG_STATE_A_SUSPEND. And we currently only set need_finish_resume in musb_stage0_irq() and the related code calling finish_resume_work in musb_resume() and musb_runtime_resume() never gets called. To fix the issue, we can call schedule_delayed_work() directly in musb_stage0_irq() to have finish_resume_work run. And we should no longer never get interrupts when when suspended. We have changed musb to no longer need pm_runtime_irqsafe(). The need_finish_resume flag was added in commit 9298b4aad37e ("usb: musb: fix device hotplug behind hub") and no longer applies as far as I can tell. So let's just remove the earlier code that no longer is needed. Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core") Reported-by: Bin Liu <b-liu@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: musb: Add a quirk to preserve the session during suspendAlexandre Bailon2017-02-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | On da8xx, VBUS is not maintained during suspend when musb is in host mode. On resume, all the connected devices will be disconnected and then will be enumerated again. This happens because MUSB_DEVCTL is cleared during suspend. Add a quirk to not clear MUSB_DEVCTL and then preserve the session during a suspend. Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: musb: remove musb_generic_disable functionBin Liu2017-02-031-16/+10
|/ | | | | | | | musb_generic_disable() only has two lines of code. So remove it and let the callers directly call those two lines. Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: fix compilation warning on unused functionJérémy Lefaure2017-01-051-0/+2
| | | | | | | | | | | | | | | The function musb_run_resume_work is called only when CONFIG_PM is enabled. So this function should not be defined when CONFIG_PM is disabled. Otherwise the compiler issues a warning: drivers/usb/musb/musb_core.c:2057:12: error: ‘musb_run_resume_work’ defined but not used [-Werror=unused-function] static int musb_run_resume_work(struct musb *musb) ^~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 4.9-rc7 into usb-nextGreg Kroah-Hartman2016-11-281-18/+129
|\ | | | | | | | | | | We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: musb: Fix PM for hub disconnectTony Lindgren2016-11-171-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With a USB hub disconnected, devctl can be 0x19 for about a second on am335x and will stay forever on at least omap3. And we get no further interrupts when devctl session bit clears. This keeps PM runtime active. Let's fix the issue by polling devctl until the session bit clears or times out. We can do this by making musb->irq_work into delayed_work. And with the polling implemented, we can now also have the quirk for invalid VBUS it to avoid disconnecting too early while VBUS is ramping up. Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core") Fixes: 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS Tested-by: Ladislav Michl <ladis@linux-mips.org> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: musb: Fix sleeping function called from invalid context for hdrc glueTony Lindgren2016-11-171-4/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS glue layer") wrongly added a call for pm_runtime_get_sync to otg_timer that runs in softirq context. That causes a "BUG: sleeping function called from invalid context" every time when polling the cable status: [<c015ebb4>] (__might_sleep) from [<c0413d60>] (__pm_runtime_resume+0x9c/0xa0) [<c0413d60>] (__pm_runtime_resume) from [<c04d0bc4>] (otg_timer+0x3c/0x254) [<c04d0bc4>] (otg_timer) from [<c0191180>] (call_timer_fn+0xfc/0x41c) [<c0191180>] (call_timer_fn) from [<c01915c0>] (expire_timers+0x120/0x210) [<c01915c0>] (expire_timers) from [<c0191acc>] (run_timer_softirq+0xa4/0xdc) [<c0191acc>] (run_timer_softirq) from [<c010168c>] (__do_softirq+0x12c/0x594) I did not notice that as I did not have CONFIG_DEBUG_ATOMIC_SLEEP enabled. And looks like also musb_gadget_queue() suffers from the same problem. Let's fix the issue by using a list of delayed work then call it on resume. Note that we want to do this only when musb core and it's parent devices are awake, and we need to make sure the DSPS glue timer is stopped as noted by Johan Hovold <johan@kernel.org>. Note that we already are re-enabling the timer with mod_timer() in dsps_musb_enable(). Later on we may be able to remove other delayed work in the musb driver and just do it from pending_resume_work. But this should be done only for delayed work that does not have other timing requirements beyond just being run on resume. Fixes: 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS glue layer") Reported-by: Johan Hovold <johan@kernel.org> Reviewed-by: Johan Hovold <johan@kernel.org> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: musb: Fix broken use of static variable for multiple instancesTony Lindgren2016-11-171-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | We can't use static variable first for checking when musb is initialized when we have multiple musb instances like on am335x. Tested-by: Ladislav Michl <ladis@linux-mips.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: musb: core: added helper function for parsing DTPetr Kulhavy2016-11-211-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | This adds the function musb_get_mode() to get the DT property "dr_mode" Signed-off-by: Petr Kulhavy <petr@barix.com> Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Tested-by: David Lechner <david@lechnology.com> Reviewed-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: musb: don't complain on -EPROBE_DEFER when initializing controllerLadislav Michl2016-11-211-2/+3
| | | | | | | | | | | | | | | | | | | | Don't complain on -EPROBE_DEFER when initializing controller, the driver probe will be retried later. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | USB: musb: remove obsolete resume-signalling commentsJohan Hovold2016-11-211-4/+1
|/ | | | | | | | | | Remove comments about resume signalling being stopped from GetPortStatus, something which is no longer the case. Fixes: 8ed1fb790ea2 ("usb: musb: finish suspend/reset work...") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: remove duplicated actionsKirill Esipov2016-11-071-5/+0
| | | | | | | | | | | Removing unnecessary duplicated actions that we've got while merging: Commit 19915e623458 ("Merge 4.1-rc7 into usb-next") [ b-liu@ti.com: added 'Commit' in the commit message ] Signed-off-by: Kirill Esipov <yesipov@gmail.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Fix session based PM for first invalid VBUSTony Lindgren2016-09-231-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | With the session bit based PM runtime working on musb, we've implemented few quirks to attempt to detect the current state of the hardware. One of the quirks is for invalid VBUS as peripheral, but it is not working in all cases. If we start musb on dm3730 as a peripheral with no cable connected, we will get the devctl 91 state once and will never idle as there are not further interrupts from musb. So we need to ignore the first devctl 91 state as there will be more interrupts if we're connected. The invalid VBUS state also can happen always when connected to certain USB hubs. Looks like musb on dm3730 can claim invalid VBUS with some hubs while 3717-evm and BeagleBone don't. This causes session as peripheral to fail for dm3730 with some hubs. This too is fixed by ignoring only the first invalid VBUS. When connected, we can just look at the session bit as that will clear automatically when the session ends. Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core") Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: remove redundant stack buffersRasmus Villemoes2016-09-131-7/+5
| | | | | | | | | | aDate is always the empty string, so entirely pointless. The aRevision formatting might as well be done as part of the pr_debug() call - that also avoids it altogether if pr_debug is compiled out. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Implement session bit based runtime PM for musb-coreTony Lindgren2016-09-131-0/+66
| | | | | | | | | | | | | | | | | We want to keep musb enabled always when the session bit is set. This simplifies the PM runtime and allows making it more generic across the various glue layers. So far the only exception to just following the session bit is host mode disconnect where the session bit stays set. In that case, just allow PM and let the PM runtime autoidle timeout deal with it. Signed-off-by: Tony Lindgren <tony@atomide.com> [b-liu@ti.com: changed using dev_dbg() to musb_dbg()] Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: add tracepoints to dump interrupt eventsBin Liu2016-07-171-3/+1
| | | | | | | This adds tracepoints to dump musb interrupt events. Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: add tracepoints for register accessBin Liu2016-07-171-3/+16
| | | | | | | | | | | | | This adds tracepoints to musb register read/write wrappers to get trace log for register access. The default tacepoint log prefix here would be musb_readX/writeX(), which is not much helpful. So this patch let the tracepoints use __buildin_return_address(0) to print the caller funciton name to provide more context of the register access. Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: switch dev_dbg to tracepointsBin Liu2016-07-171-33/+31
| | | | | | | Switch dev_dbg() to tracepoint debug musb_dbg(). Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: only restore devctl when session was set in backupBin Liu2016-06-011-1/+2
| | | | | | | | | | | | | If the session bit was not set in the backup of devctl register, restoring devctl would clear the session bit. Therefor, only restore devctl register when the session bit was set in the backup. This solves the device enumeration failure in otg mode exposed by commit 56f487c (PM / Runtime: Update last_busy in rpm_resume). Cc: <stable@vger.kernel.org> # v4.2+ Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Remove pm_runtime_set_irq_safeTony Lindgren2016-06-011-6/+0
| | | | | | | | | | With the pull up being handled with delayed work, we can now finally remove pm_runtime_set_irq_safe that blocks the MUSB glue from idling. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Return error value from musb_mailboxTony Lindgren2016-06-011-3/+4
| | | | | | | | | | | | | | | | | | | At least on n900 we have phy-twl4030-usb only generating cable interrupts, and then have a separate USB PHY. In order for musb to know the real cable status, we need to clear any cached state until musb is ready. Otherwise the cable status interrupts will get just ignored if the status does not change from the initial state. To do this, let's add a return value to musb_mailbox(), and reset cached linkstat to MUSB_UNKNOWN on error. Sorry to cause a bit of churn here, I should have added that already last time patching musb_mailbox(). Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Split PM runtime between wrapper IP and musb coreTony Lindgren2016-06-011-22/+17
| | | | | | | | | | | | | | Let's not tinker with the PM runtime of musb core from the omap2430 wrapper. This allows us to initialize PM runtime for musb core later on instead of doing it in stages. And omap2430 wrapper has no need to for accessing musb core at this point. Note that this does not remove all the PM runtime calls from the glue layer, those will get removed in a later patch. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Update to use PM runtime autosuspendTony Lindgren2016-06-011-3/+6
| | | | | | | | | | | | | | | | Let's make the PM runtime use the standard autosuspend calls. Commit 5de85b9d57ab ("PM / runtime: Re-init runtime PM states at probe error and driver unbind") means we must pair use_autosuspend with dont_use_autosuspend and then use put_sync to properly idle the device. Note that we'll be removing the PM runtime calls from the glue layer to the MUSB core in the next patch. And we can also remove the pointless FIXME comment now. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Remove unnecessary shutdown functionTony Lindgren2016-06-011-25/+14
| | | | | | | | | | We have remove() already calling shutdown(), so let's drop it and move the code to remove(). No code changes, we'll drop the the FIXME in the following patch with more clean-up. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: Fix idling after host mode by increasing autosuspend delayTony Lindgren2016-06-011-2/+8
| | | | | | | | | | | | | | Looks like at least 2430 glue won't idle reliably with the 200 ms autosuspend delay. This causes deeper idle states being blocked for the whole SoC when disconnecting OTG A cable. Increasing the delay to 500 ms seems to idle both MUSB and the PHY reliably. This is probably because of time needed by the hardware based negotiation between MUSB and the PHY. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: musb: core: added missing const qualifier to ↵Petr Kulhavy2016-03-041-1/+1
| | | | | | | | | | | | | | | musb_hdrc_platform_data::config The musb_hdrc_platform_data::config was defined as a non-const pointer. However some drivers (e.g. the ux500) set up this pointer to point to a static structure, which is potentially dangerous. Since the musb core uses the pointer in a read-only manner the const qualifier was added to protect the content of the config. Signed-off-by: Petr Kulhavy <petr@barix.com> Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
* usb: musb: core: call init and shutdown for the usb phyUwe Kleine-König2015-12-221-0/+10
| | | | | | | | The phy's init routine must be called before it can be used. Do so in musb_init_controller and the matching shutdown in musb_remove. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: Fix handling of the phy notificationsTony Lindgren2015-12-161-0/+21
| | | | | | | | | | | | | | | | | | | | | We currently can't unload omap2430 MUSB platform glue driver module and this cause issues for fixing the MUSB code further. The reason we can't remove omap2430 is because it uses the PHY functions and also exports the omap_musb_mailbox function that some PHY drivers are using. Let's fix the issue by exporting a more generic musb_mailbox function from the MUSB core and allow platform glue layers to register phy_callback function as needed. And now we can now also get rid of the include/linux/musb-omap.h. Cc: Bin Liu <b-liu@ti.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: NeilBrown <neil@brown.name> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: convert printk to pr_*Rasmus Villemoes2015-12-151-10/+7
| | | | | | | | This file already uses pr_debug in a few places; this converts the remaining printks. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: fail with error when no DMA controller setAaro Koskinen2015-12-091-0/+1
| | | | | | | Fail with error when no DMA controller is set. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: Fix pm runtime for deferred probeTony Lindgren2015-12-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | If musb_init_controller fails at musb_platform_init, we have already called pm_runtime_irq_safe for musb and that causes the pm runtime count to be enabled for parent before the parent has completed initialization. This causes pm to stop working as on unload nothing gets idled. This issue can be reproduced at least with: # modprobe omap2430 HS USB OTG: no transceiver configured musb-hdrc musb-hdrc.0.auto: musb_init_controller failed with status -517 # modprobe phy-twl4030-usb # rmmod omap2430 And after the steps above omap2430 will block deeper idle states on omap3. To fix this, let's not enable pm runtime until we need to and the parent has been initialized. Note that this does not fix the issue of PM being broken for musb during runtime. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: enable usb_dma parameterBin Liu2015-11-171-1/+1
| | | | | | | | Change the permission of usb_dma parameter so it can be used for runtime debug without reboot. Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: fix order of arguments to ulpi write callbackUwe Kleine-König2015-11-161-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* usb: musb: core: add common method of getting vbus statusRoman Alyautdin2015-10-161-3/+10
| | | | | | | | | | Fix musb_platform_get_vbus_status return value in case of platform implementation is not defined, bringing expected behaviour of musb_platform_get wrapper. Add musb_vbus_show default method to determine VBUS status in case platform method is not defined. Signed-off-by: Roman Alyautdin <ralyautdin@dev.rtsoft.ru> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: set the controller speed based on the config settingBin Liu2015-09-271-6/+10
| | | | | | | | Set the Power register HSENAB bit based on musb->config->maximum_speed, so that the glue layer can control MUSB to work in high- or full-speed. Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: Disable interrupts on suspend, enable them on resumePascal Huerst2015-09-141-0/+6
| | | | | | | | | In certain situations, an interrupt triggers on resume, before musb_start() has been called. This has been observed to cause enumeration issues after suspend/resume cycles with AM335x. Signed-off-by: Pascal Huerst <pascal.huerst@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: ensure in peripheral mode when checking sessionBin Liu2015-09-141-0/+1
| | | | | | | | | | | | | | | The change ensures otg is not in a A- state when checking for VBUS in peripheral mode. musb_start() where VBUS checking is in can be called in many situations. One example is in babble recovery routine, in which otg is transitioning from A-HOST to A-WAIT-BCON, but VBUS discharge takes time, so musb->is_active could be set to 1 due to this improper checking, then it causes musb_bus_suspend() failed which leads to warning log message flooding. Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge 4.1-rc7 into usb-nextGreg Kroah-Hartman2015-06-081-1/+7
|\ | | | | | | | | | | | | This resolves a merge issue in musb_core.c and we want the fixes that were in Linus's tree in this branch as well for testing. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: musb: fix order of conditions for assigning end point operationsBen Hutchings2015-05-261-7/+7
| | | | | | | | | | | | | | | | | | | | 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>
* | usb: musb: Fix platform code being unable to override ep access opsHans de Goede2015-05-261-7/+6
| | | | | | | | | | | | | | | | | | musb-core was setting the ops to the default indexed or flat handlers after checking for platform overrides. Reverse the order of this so that platform overrides actually work. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: musb: Do not use musb_read[b|w] / _write[b|w] wrappers in generic fifo ↵Hans de Goede2015-05-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | functions The generic fifo functions already use non wrapped accesses in various cases through the iowrite#_rep functions, and all platforms which override the default musb_read[b|w] / _write[b|w] functions also provide their own fifo access functions, so we can safely drop the unnecessary indirection from the fifo access functions. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: musb: Make busctl_offset an io-op rather then a defineHans de Goede2015-05-261-12/+22
| | | | | | | | | | | | | | | | | | | | | | The Allwinner (sunxi) implementation of the musb has its busctl registers indexed by the MUSB_INDEX register rather then in a flat address space. This commit turns MUSB_BUSCTL_OFFSET from a macro into an io-op which can be overridden from the platform ops. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: musb: Make musb_write_rxfun* and musb_write_rxhub* work like their tx ↵Hans de Goede2015-05-261-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | versions For some reason the musb_write_rxfun* and musb_write_rxhub* functions had a different function prototype and some extra magic needed on the caller side compared to their tx counterparts, this commit makes them work the same as their tx counterparts. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: musb: Get rid of the DMA ifdefs for musb_core.cTony Lindgren2015-05-071-2/+0
| | | | | | | | | | | | | | | | | | For musb_core.c we can now just drop the DMA related ifdef and use the already existing runtime test for !is_cppi_enabled(musb) instead. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: musb: Set up function pointers for DMATony Lindgren2015-05-071-3/+22
| | | | | | | | | | | | | | | | Set up function pointers for DMA so get closer to being able to build in all the DMA engines. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>