summaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/gadget.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'usb-for-v3.16' of ↵Greg Kroah-Hartman2014-05-231-6/+77
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: usb: patches for v3.16 merge window Not a lot here during this merge window. Mostly we just have the usual miscellaneous patches (removal of unnecessary prints, proper dependencies being added to Kconfig, build warning fixes, new device ID, etc. Other than those, the only important new features are the new support for OS Strings which should help Linux Gadget Drivers behave better under MS Windows. Also Babble Recovery implementation for MUSB on AM335x. Lastly, we also have ARCH_QCOM PHY support though phy-msm. Signed-of-by: Felipe Balbi <balbi@ti.com> Conflicts: drivers/usb/phy/phy-mv-u3d-usb.c
| * usb: dwc3: no need to initialize ret variableAndy Shevchenko2014-05-151-1/+1
| | | | | | | | | | | | | | | | First usage of ret variable will re-write initial value. Thus, there is no need to initialize it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * usb: dwc3: gadget: pretty print Generic CMDsFelipe Balbi2014-04-251-0/+29
| | | | | | | | | | | | | | | | this makes it slightly easier to read generic CMD logs. It also helps make sure we're sending proper parameters for each command. Signed-off-by: Felipe Balbi <balbi@ti.com>
| * usb: dwc3: gadget: pretty print link statesFelipe Balbi2014-04-251-3/+41
| | | | | | | | | | | | | | this makes it slightly easier to read link state change interrupt logs. Signed-off-by: Felipe Balbi <balbi@ti.com>
| * usb: dwc3: gadget: print both cmd string and numberFelipe Balbi2014-04-251-2/+2
| | | | | | | | | | | | | | That way it's easy for humans looking at dmesg and humans(?) looking at Databooks. Signed-off-by: Felipe Balbi <balbi@ti.com>
| * usb: dwc3: gadget: clear stall when disabling endpointFelipe Balbi2014-04-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | so it seems like DWC3 IP doesn't clear stalls automatically when we disable an endpoint, because of that, we _must_ make sure stalls are cleared before clearing the proper bit in DALEPENA register. Cc: <stable@vger.kernel.org> # v3.4+ Reported-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: dwc3: gadget: Iterate only over valid endpointsJack Pham2014-04-161-8/+4
|/ | | | | | | | | | | Make dwc3_gadget_resize_tx_fifos() iterate only over IN endpoints that are actually present, based on the num_in_eps parameter. This terminates the loop so as to prevent dereferencing a potential NULL dwc->eps[i] where i >= (num_in_eps + num_out_eps). Signed-off-by: Jack Pham <jackp@codeaurora.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: remove known conditionsDan Carpenter2014-03-071-4/+2
| | | | | | | | We know what "value" is and it upsets static checkers that we appear to have doubts about it. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: cut and paste fixups in suspend/resumeDan Carpenter2014-03-071-2/+2
| | | | | | | | | | These were cut and paste from the ->disconnect function. Fixes commit 30d577b9bcc4 ('usb: dwc3: gadget: call gadget driver's ->suspend/->resume') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: pre-start Stream transfers when they're queuedFelipe Balbi2014-03-051-0/+17
| | | | | | | we need to pre-start stream transfers otherwise we will never know when to start them. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: call gadget driver's ->suspend/->resumeFelipe Balbi2014-03-051-0/+35
| | | | | | | | | When going into bus suspend/resume we _must_ call gadget driver's ->suspend/->resume callbacks accordingly. This patch implements that very feature which has been missing forever. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: add 'force' argument to stop_active_transferPaul Zimmerman2014-03-051-7/+8
| | | | | | | | | It's not always we need to force a transfer to be removed from the core's internal cache. This extra argument will help differentiating those two cases. Signed-off-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: make sure HIRD threshold is 0 in superspeedFelipe Balbi2014-03-051-0/+4
| | | | | | | | During superspeed, HIRD threshold should always be zero. Curent driver wasn't making sure that was the case. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: set KEEP_CONNECT in case of hibernationFelipe Balbi2014-03-051-4/+14
| | | | | | | | | if we have hibernation configured, Databook instructs us to set KEEP_CONNECT bit together with RUN_STOP bit, in step 9 of section 12.3.6.1 Initialization for Hibernation Support. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: add a 'restore' argument to set_ep_configPaul Zimmerman2014-03-051-10/+22
| | | | | | | | | | | | | | | | | That argument will be used in later patches when we have working hibernation support. For now, always pass it as false. The idea of this patch is to decrease to size of following patches and slowly add hibernation building blocks to the gadget side of dwc3 so that it becomes very easy to review the actual hibernation code. [ balbi@ti.com : rewrote patch on top of current tree. Added commit log. ] Signed-off-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: implement dwc3_gadget_get_link_statePaul Zimmerman2014-03-051-0/+16
| | | | | | | | | This function will be used during hibernation to get the current link state. It will be needed at least for Hibernation support. Signed-off-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: workaround: bogus hibernation eventsFelipe Balbi2014-03-051-0/+31
| | | | | | | | | | | | | Revision 2.20a of the core has a known issue which would generate bogus hibernation events _and_ random failures on USB CV TD.9.23 test case. The suggested workaround is to ignore hibernation events which don't match currently connected speed. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: always enable IOC on bulk/interrupt transfersFelipe Balbi2014-03-051-6/+3
| | | | | | | | | | | | | by setting IOC always, we can recycle TRBs a lot sooner at the expense of some increased CPU load. The extra load seems to be quite minimal on OMAP5 devices (instead of 1 IRQ for one MSC transfer, we get CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS). Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge tag 'v3.13-rc4' into nextFelipe Balbi2013-12-191-4/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux 3.13-rc4 * tag 'v3.13-rc4': (1001 commits) Linux 3.13-rc4 null_blk: mem garbage on NUMA systems during init radeon_pm: fix oops in hwmon_attributes_visible() and radeon_hwmon_show_temp_thresh() Revert "selinux: consider filesystem subtype in policies" igb: Fix for issue where values could be too high for udelay function. i40e: fix null dereference ARM: fix asm/memory.h build error dm array: fix a reference counting bug in shadow_ablock dm space map: disallow decrementing a reference count below zero mm: memcg: do not allow task about to OOM kill to bypass the limit mm: memcg: fix race condition between memcg teardown and swapin thp: move preallocated PTE page table on move_huge_pmd() mfd/rtc: s5m: fix register updating by adding regmap for RTC rtc: s5m: enable IRQ wake during suspend rtc: s5m: limit endless loop waiting for register update rtc: s5m: fix unsuccesful IRQ request during probe drivers/rtc/rtc-s5m.c: fix info->rtc assignment include/linux/kernel.h: make might_fault() a nop for !MMU drivers/rtc/rtc-at91rm9200.c: correct alarm over day/month wrap procfs: also fix proc_reg_get_unmapped_area() for !MMU case ... Signed-off-by: Felipe Balbi <balbi@ti.com>
| * usb: dwc3: fix implementation of endpoint wedgeAlan Stern2013-11-251-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The dwc3 UDC driver doesn't implement endpoint wedging correctly. When an endpoint is wedged, the gadget driver should be allowed to clear the wedge by calling usb_ep_clear_halt(). Only the host is prevented from resetting the endpoint. This patch fixes the implementation. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Pratyush Anand <pratyush.anand@st.com> Cc: <stable@vger.kernel.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: add "maxpacket_limit" field to struct usb_epRobert Baldyga2013-12-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds "maxpacket_limit" to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field "maxpacket" is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, "maxpacket" value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint. For this reason this patch adds new field "maxpacket_limit" which contains value of maximum packet size (which defines maximum endpoint capabilities). This value is used in ep_matches() function used by autoconfig(). Value of "maxpacket_limit" should be set in UDC driver probe function, using usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function set choosen value to both "maxpacket_limit" and "maxpacket" fields. This patch modifies UDC drivers by adding support for maxpacket_limit. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: dwc3: set gadget's quirk ep_out_align_sizeDavid Cohen2013-12-091-0/+6
|/ | | | | | | | DWC3 requires epout to have buffer size aligned to MaxPacketSize value. This patch sets necessary quirk for it. Signed-off-by: David Cohen <david.a.cohen@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: avoid memory leak when failing to allocate all epsDavid Cohen2013-09-171-4/+2
| | | | | | | | If dwc3_gadget_init_endpoint() fails after allocate some of the eps, we need to free their memory to avoid leak. Signed-off-by: David Cohen <david.a.cohen@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: introduce dwc3_process_event_bufFelipe Balbi2013-07-291-37/+44
| | | | | | | | in order to make our IRQ handler thread easier to read, we re-factor the inner loop to a separate function. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: rename dwc3_process_event_bufFelipe Balbi2013-07-291-2/+2
| | | | | | | | | | | that function isn't really processing any event buffer, rather just checking whether it contains events to be processed. Due to that reason, we're reaning it to dwc3_check_event_buf() instead. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: get rid of IRQF_ONESHOTFelipe Balbi2013-07-291-1/+13
| | | | | | | | | | | | | | | We can make use of bit 31 of the GEVNTSIZ(n) registers to mask/unmask interrupts from that particular interrupter. With that feature, we can easily drop IRQF_ONESHOT from our driver which makes it possible to properly change IRQ priorities when using RT patchset *and* it allows us to make use of the scheduler to choose the proper time to handle this IRQ thread. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: don't enable LPM earlyFelipe Balbi2013-07-291-5/+0
| | | | | | | LPM is enabled in Connection Done interrupt, there's no need to enable it early. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: add a debugging print when initializing endpointsFelipe Balbi2013-07-291-0/+2
| | | | | | | | | that way we get debugging information when enabling verbose debug of the driver. It will be no-op otherwise. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: move direction setting upFelipe Balbi2013-07-291-1/+1
| | | | | | | no functional changes, just grouping dep initialization. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: move debugging print aroundFelipe Balbi2013-07-291-2/+2
| | | | | | | | | by moving that dev_vdbg() to the internal __dwc3_gadget_ep_enable() we get the print even when enable ep0, which calls the internal function directly. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: drop dwc3 manual phy controlFelipe Balbi2013-07-291-61/+0
| | | | | | | | | | | | | | | | | Recent versions of the core, can suspend and resume the PHYs automatically, so we don't need to fiddle with dwc3's Global PHY registers at all. On versions prior to 1.94a this patch will mean that we will never ask dwc3 to suspend the PHY. This is an acceptable behavior or such old versions of the core, specially considering that the only chip known to have a version prior to 1.94a was OMAP5 ES1.0 and that's not supported in mainline kernel, because it was just a test spin of OMAP5. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: make maximum-speed a per-instance attributeFelipe Balbi2013-07-291-3/+18
| | | | | | | | | | in order to allow different instances of the core work in different maximum speeds, we will move the maximum_speed module_parameter to both DeviceTree (making use the new maximum-speed DT property) and platform_data. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: switch to GPL v2 onlyFelipe Balbi2013-07-291-27/+7
| | | | | | | | | | | | | | | | This is a Linux-only driver which makes use of GPL-only symbols. It makes no sense to maintain Dual BSD/GPL licensing for this driver. Considering that the amount of work to use this driver in any different operating system would likely be as large as developing the driver from scratch and considering that we depend on GPL-only symbols, we will switch over to a GPL v2-only license. Cc: Anton Tikhomirov <av.tikhomirov@samsung.com> Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: don't request IRQs in atomicFelipe Balbi2013-07-291-17/+22
| | | | | | | | | | We cannot request an IRQ with spinlocks held as that would trigger a sleeping inside spinlock warning. Cc: <stable@vger.kernel.org> # v3.10 Reported-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: don't prevent gadget from being probed if we failFelipe Balbi2013-07-151-0/+1
| | | | | | | | | | | | | In case we fail our ->udc_start() callback, we should be ready to accept another modprobe following the failed one. We had forgotten to clear dwc->gadget_driver back to NULL and, because of that, we were preventing gadget driver modprobe from being retried. Cc: <stable@vger.kernel.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: free trb pool only from epnum 2George Cherian2013-05-281-4/+12
| | | | | | | | | | | | | | we never allocate a TRB pool for physical endpoints 0 and 1 so trying to free it (a invalid TRB pool pointer) will lead us in a warning while removing dwc3.ko module. In order to fix the situation, all we have to do is skip dwc3_free_trb_pool() for physical endpoints 0 and 1 just as we while deleting endpoints from the endpoints list. Cc: stable@vger.kernel.org Signed-off-by: George Cherian <george.cherian@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: use num_(in|out)_eps from HW paramsFelipe Balbi2013-03-181-4/+35
| | | | | | | that way we will only tell gadget framework about the endpoints we actually have. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: workaround: unexpected transtion U3 -> RESUMEFelipe Balbi2013-03-181-0/+28
| | | | | | | | | | | | | In DWC3 versions < 2.50a configured without Hibernation mode enabled, there will be an extra link status change interrupt if device detects host-initiated U3 exit. In that case, core will generate an unnecessary U3 -> RESUME transition which should be ignored by the driver. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: don't assign gadget.dev.release directlyFelipe Balbi2013-03-181-6/+1
| | | | | | | udc-core provides a better way to handle release methods, let's use it. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: don't touch gadget.dev.driverFelipe Balbi2013-03-181-2/+0
| | | | | | | udc-core now handles that for us, which means we can remove it from our driver. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: remove unnecessary initializationsFelipe Balbi2013-03-181-6/+0
| | | | | | | udc-core now sets dma-related and parent fields for us, we don't need to do it ourselves. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: implement gadget state trackingFelipe Balbi2013-03-181-1/+1
| | | | | | | make use of the previously introduced gadget->state field. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: move to threaded IRQFelipe Balbi2013-03-181-26/+60
| | | | | | | | | | | by moving to threaded IRQs, we allow our IRQ priorities to be configurable when running with realtime patch. Also, since we're running in thread context, we can call functions which might sleep, such as sysfs_notify() without problems. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: core: add power management supportFelipe Balbi2013-03-181-0/+61
| | | | | | | | | | | | | Add support for basic power management on the dwc3 driver. While there is still lots to improve for full PM support, this minimal patch will already make sure that we survive suspend-to-ram and suspend-to-disk without major issues. Cc: Vikas C Sajjan <vikas.sajjan@linaro.org> Tested-by: Vivek Gautam <gautam.vivek@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: save state of pullupsFelipe Balbi2013-03-181-0/+2
| | | | | | | | This will be used during resume to verify if we should reconnect our pullups or not. Tested-by: Vivek Gautam <gautam.vivek@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: introduce and use enable/disable irq methodsFelipe Balbi2013-03-181-35/+45
| | | | | | | | | | | | | we don't need to enable IRQs until we have a gadget driver loaded and ready to work, so let's delay IRQ enable to ->udc_start() and IRQ disable to ->udc_stop(). While at that, also move the related use of request_irq() and free_irq(). Tested-by: Vivek Gautam <gautam.vivek@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: drop now unnecessary flagFelipe Balbi2013-03-181-1/+0
| | | | | | | | | | We don't need the ->register_my_device flag anymore because all UDC drivers have been properly converted. Let's remove every history of it. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: let udc-core manage gadget->devFelipe Balbi2013-03-181-15/+2
| | | | | | | We don't need to register that device ourselves if we simply set gadget->register_my_device. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: gadget: remove unnecessary codeFelipe Balbi2013-03-041-3/+0
| | | | | | | | | the params variables on dwc3_gadget_conndone_interrupt() is only memset() to zero but never used in that function, so we can safely drop the variable and memset() call. Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge 3.8-rc5 into usb-nextGreg Kroah-Hartman2013-01-251-0/+1
|\ | | | | | | | | | | | | This fixes up a conflict with drivers/usb/serial/io_ti.c that came up in linux-next. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>