summaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'usb-for-v4.11' of ↵Greg Kroah-Hartman2017-01-2615-1860/+1465Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: USB: changes for v4.11 Here's the big pull request for the Gadget API. Again the majority of changes sit in dwc2 driver. Most important changes contain a workaround for GOTGCTL being wrong, a sleep-inside-spinlock fix and the big series of cleanups on dwc2. One important thing on dwc3 is that we don't anymore need gadget drivers to cope with unaligned OUT transfers for us. We have support for appending one extra chained TRB to align transfer ourselves. Apart from these, the usual set of typos, non-critical fixes, etc.
| * usb: dwc2: eliminate irq parameter from dwc2_hcd_initHeiner Kallweit2017-01-264-5/+5
| | | | | | | | | | | | | | | | | | The irq is available in hsotg already, so there's no need to pass it as separate function parameter. Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: fix "iomem 0x00000000" messageHeiner Kallweit2017-01-261-0/+7
| | | | | | | | | | | | | | | | | | | | Set the iomem parameters in the usb_hcd to fix this misleading message during driver load: dwc2 c9100000.usb: irq 22, io mem 0x00000000 Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: gadget: Add checking for g-tx-fifo-size parameterSevak Arakelyan2017-01-241-0/+35
| | | | | | | | | | | | | | | | | | | | | | Add dwc2_check_param_tx_fifo_sizes function which validates the members of g_tx_fifo_size array and sets to average or default values if it is needed. Cc: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: gadget: Set TX FIFO depths to calculated defaultsSevak Arakelyan2017-01-243-11/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove legacy DWC2_G_P_LEGACY_TX_FIFO_SIZE array for TX FIFOs. Update dwc2_set_param_tx_fifo_sizes function to calculate and assign default average FIFO depth to each member of g_tx_fifo_size array. Total FIFO size, EP Info block's size, FIFO operation mode and device operation mode are taken into consideration during the calculation. Cc: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: host: Correct snpsid checking for GDFIFOCFGSevak Arakelyan2017-01-242-1/+3
| | | | | | | | | | | | | | | | | | GDFIFOCFG is available from IP version 2.91a. Fix the code to reflect this. Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: host: use msleep() for long delayNicholas Mc Guire2017-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. Fix up the 100ms delays here passing the adjusted "min" value to msleep(). This helps reduce the load on the hrtimer subsystem. Link: http://lkml.org/lkml/2017/1/11/377 Fixes: commit 2938fc63e0c2 ("usb: dwc2: Properly account for the force mode delays") Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220Chen Yu2017-01-243-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Hi6220's usb controller is limited in that it does not support "Split Transactions", so it does not support communicating with low-speed and full-speed devices behind a high-speed hub. Thus it requires a quirk so that we can manually drop the usb speed when low/full-speed are attached, and bump back to high speed when they are removed. Cc: Wei Xu <xuwei5@hisilicon.com> Cc: Guodong Xu <guodong.xu@linaro.org> Cc: Amit Pundir <amit.pundir@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: John Youn <johnyoun@synopsys.com> Cc: Douglas Anderson <dianders@chromium.org> Cc: Chen Yu <chenyu56@huawei.com> Cc: Vardan Mikayelyan <mvardan@synopsys.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Felipe Balbi <felipe.balbi@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu <chenyu56@huawei.com> [jstultz: Reworked to simplify the patch, and made commit log to be more specific about the issue] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Force port resume on switching to device modeChen Yu2017-01-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've seen failures when switching between host and gadget mode, which was diagnosed as being caused due to the bus being auto-suspended when we switched. So this patch forces a port resume when switching to device mode if the bus is suspended. Cc: Wei Xu <xuwei5@hisilicon.com> Cc: Guodong Xu <guodong.xu@linaro.org> Cc: Amit Pundir <amit.pundir@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: John Youn <johnyoun@synopsys.com> Cc: Douglas Anderson <dianders@chromium.org> Cc: Chen Yu <chenyu56@huawei.com> Cc: Vardan Mikayelyan <mvardan@synopsys.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Felipe Balbi <felipe.balbi@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu <chenyu56@huawei.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Workaround case where GOTGCTL state is wrongJohn Stultz2017-01-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When removing a USB-A to USB-otg adapter cable, we get a change status irq, and then in dwc2_conn_id_status_change, we erroneously see the GOTGCTL_CONID_B flag set. This causes us to get stuck in the "while (!dwc2_is_device_mode(hsotg))" loop, spitting out "Waiting for Peripheral Mode, Mode=Host" warnings until it fails out many seconds later. This patch works around the issue by re-reading the GOTGCTL state to check if the GOTGCTL_CONID_B is still set and if not restarting the change status logic. Cc: Wei Xu <xuwei5@hisilicon.com> Cc: Guodong Xu <guodong.xu@linaro.org> Cc: Amit Pundir <amit.pundir@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: John Youn <johnyoun@synopsys.com> Cc: Douglas Anderson <dianders@chromium.org> Cc: Chen Yu <chenyu56@huawei.com> Cc: Vardan Mikayelyan <mvardan@synopsys.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Felipe Balbi <felipe.balbi@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org Reviewed-by: Vardan Mikayelyan <mvardan@synopsys.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Avoid sleeping while holding hsotg->lockJohn Stultz2017-01-243-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Basically when plugging in various cables in different orders, I'm occasionally seeing the following BUG splat: [ 86.215403] BUG: scheduling while atomic: kworker/u16:2/53/0x00000002 [ 86.219164] usb 1-1: USB disconnect, device number 9 [ 86.226845] Preemption disabled at:[ 86.230218] [<ffffff8008673558>] dwc2_conn_id_status_change+0x120/0x250 [ 86.236894] CPU: 0 PID: 53 Comm: kworker/u16:2 Tainted: G W 4.9.0-rc8-00051-gd5a7979-dirty #1702 [ 86.246836] Hardware name: HiKey Development Board (DT) [ 86.252100] Workqueue: dwc2 dwc2_conn_id_status_change [ 86.257279] Call trace: [ 86.259771] [<ffffff8008087c28>] dump_backtrace+0x0/0x1a0 [ 86.265210] [<ffffff8008087ddc>] show_stack+0x14/0x20 [ 86.270308] [<ffffff80084343f0>] dump_stack+0x90/0xb0 [ 86.275401] [<ffffff80080d8d94>] __schedule_bug+0x6c/0xb8 [ 86.280841] [<ffffff8008a07220>] __schedule+0x4f8/0x5b0 [ 86.286099] [<ffffff8008a073e8>] schedule+0x38/0xa0 [ 86.291017] [<ffffff8008a0a6cc>] schedule_hrtimeout_range_clock+0x8c/0xf0 [ 86.297846] [<ffffff8008a0a740>] schedule_hrtimeout_range+0x10/0x18 [ 86.304150] [<ffffff8008a0a4a0>] usleep_range+0x50/0x58 [ 86.309418] [<ffffff800866d8dc>] dwc2_wait_for_mode.isra.4+0x54/0xd0 [ 86.315815] [<ffffff800866f058>] dwc2_core_reset+0xe0/0x168 [ 86.321431] [<ffffff800867e364>] dwc2_hsotg_core_init_disconnected+0x2c/0x310 [ 86.328602] [<ffffff8008673568>] dwc2_conn_id_status_change+0x130/0x250 [ 86.335254] [<ffffff80080ccd48>] process_one_work+0x118/0x370 [ 86.341035] [<ffffff80080ccfe8>] worker_thread+0x48/0x498 [ 86.346473] [<ffffff80080d2eb0>] kthread+0xd0/0xe8 [ 86.351299] [<ffffff8008082e80>] ret_from_fork+0x10/0x50 This seems to be caused by the dwc2_wait_for_mode() calling usleep_range() while the hstog->lock spinlock is held, since we take that before calling dwc2_hsotg_core_init_disconnected(). This patch avoids the issue by adding an extra argument to dwc2_core_reset(), as suggested by John Youn, which allows us to skip the waiting, which should be unnecessary when calling from dwc2_hsotg_core_init_disconnected(). Cc: Wei Xu <xuwei5@hisilicon.com> Cc: Guodong Xu <guodong.xu@linaro.org> Cc: Amit Pundir <amit.pundir@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: John Youn <johnyoun@synopsys.com> Cc: Douglas Anderson <dianders@chromium.org> Cc: Chen Yu <chenyu56@huawei.com> Cc: Vardan Mikayelyan <mvardan@synopsys.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Felipe Balbi <felipe.balbi@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Show dr_mode via debugfsJohn Youn2017-01-241-0/+29
| | | | | | | | | | | | | | Show the value of dr_mode via a debufs file. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Remove debug prints in params.cJohn Youn2017-01-241-56/+0Star
| | | | | | | | | | | | | | Remove debugging prints to show params. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Add debugfs file to show paramsJohn Youn2017-01-241-0/+127
| | | | | | | | | | | | | | Show the core params and hardware params. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Remove unnecessary parametersJohn Youn2017-01-241-11/+0Star
| | | | | | | | | | | | | | | | | | Further reduce the set of parameters set by platforms. Many of them are unnecessary as they should be reported by hardware. They should only need to be overridden if there is a problem. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix usage of bool paramsJohn Youn2017-01-249-100/+93Star
| | | | | | | | | | | | | | | | Check these parameters only for true or false. There is no need to check for greater or less than 0. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Remove platform static paramsJohn Youn2017-01-241-154/+108Star
| | | | | | | | | | | | | | | | Remove the platform-specific static param structs and set only those params that are necessary for each platform. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Check core parametersJohn Youn2017-01-241-0/+185
| | | | | | | | | | | | | | | | Check that core parameters have valid values and adjust them if they aren't. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Rearrange param structure membersJohn Youn2017-01-241-28/+23Star
| | | | | | | | | | | | | | | | Group the members by global, host, and gadget params. Formatting and organizational change only. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Update parameter typesJohn Youn2017-01-241-26/+26
| | | | | | | | | | | | | | Update the param types to appropriately sized ints and bools. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Get device propertiesJohn Youn2017-01-241-0/+35
| | | | | | | | | | | | | | | | After setting the default core parameter values, read in the device properties and modify core parameter values if needed. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Set core parameters to default valuesJohn Youn2017-01-242-919/+75Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initialize the core parameters to their default, auto-detected values. Remove all the previous dwc2_set_param* methods. Most of what this code is doing is handling defaults for "not set" values and other trivial checks. The checking can be simplified and will be done in a later commit. This allows us to change only those parameters that won't work with default settings. It also allows us to use non-int parameters. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Remove unused otg_ver parameterJohn Youn2017-01-244-40/+0Star
| | | | | | | | | | | | | | | | The otg_ver parameter only controls the SRP pulsing method and defaults to the 1.3 behavior. It is unused and can be removed. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: gadget: Set GDFIFOCFGSevak Arakelyan2017-01-241-0/+3
| | | | | | | | | | | | | | | | | | | | Add programming of GDFIFOCFG register in device mode. It must contain start address for EP Info block and total FIFO depth. Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix sizeof in kzallocJohn Youn2017-01-241-1/+1
| | | | | | | | | | | | | | Take the sizeof '*req' instead of 'struct dwc2_hsotg_req'. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Remove 'return' from void functionJohn Youn2017-01-241-1/+0Star
| | | | | | | | | | | | | | The function returns void so a return is unnecessary. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix code indentation after conditionalsJohn Youn2017-01-241-3/+3
| | | | | | | | | | | | | | The indent should be only one tab. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix lines over 80 charactersJohn Youn2017-01-245-24/+34
| | | | | | | | | | | | | | Fix lines over 80 characters. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix brace usageJohn Youn2017-01-242-12/+10Star
| | | | | | | | | | | | | | | | * Remove braces for one-line statements * Add missing braces where another arm in if-statement uses braces Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix logical continuationsJohn Youn2017-01-243-10/+8Star
| | | | | | | | | | | | | | | | Fix the formatting of logical statements to end the line with the logical operator. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Fix comment alignment and formatJohn Youn2017-01-244-46/+55
| | | | | | | | | | | | | | Fix misaligned and over 80-character comments. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Add identifier in prototypesJohn Youn2017-01-241-2/+2
| | | | | | | | | | | | | | | | | | | | Fixes checkpatch warning: WARNING: function definition argument 'struct dwc2_hsotg *' should also have an identifier name Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: Cleanup some checkpatch issuesJohn Youn2017-01-2415-527/+521Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commmit is the result of running checkpatch --fix. The results were verified for correctness. Some of the fixes result in line over 80 char which we will fix manually later. The following is a summary of what was done by checkpatch: * Remove externs on function prototypes. * Replace symbolic permissions with octal. * Align code to open parens. * Replace 'unsigned' with 'unsigned int'. * Remove unneccessary blank lines. * Add blank lines after declarations. * Add spaces around operators. * Remove unnecessary spaces after casts. * Replace 'x == NULL' with '!x'. * Replace kzalloc() with kcalloc(). * Concatenate multi-line strings. * Use the BIT() macro. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: host: use true/false for booleanNicholas Mc Guire2017-01-241-6/+6
| | | | | | | | | | | | | | | | For boolean variables true/false is preferred over 1/0 for readability. Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: host: use msleep() for long delaysNicholas Mc Guire2017-01-241-6/+6
| | | | | | | | | | | | | | | | | | | | ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. Fix up the 20+ ms delays here passing the adjusted "min" value to msleep(). This helps reduce the load on the hrtimer subsystem. Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
| * usb: dwc2: use u32 for DT binding parametersLeo Yan2017-01-242-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 05ee799f2021 ("usb: dwc2: Move gadget settings into core_params") changes to type u16 for DT binding "g-rx-fifo-size" and "g-np-tx-fifo-size" but use type u32 for "g-tx-fifo-size". Finally the the first two parameters cannot be passed successfully with wrong data format. This is found the data transferring broken on 96boards Hikey. This patch is to change all parameters to u32 type, and verified on Hikey board the DT parameters can pass successfully. [johnyoun: minor rebase] Signed-off-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Tested-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* | usb: dwc2: host: fix Wmaybe-uninitialized warningNicholas Mc Guire2017-01-161-2/+2
| | | | | | | | | | | | | | | | | | Uninitialized char* causes a sparse build-warning, fix it up by initializing it to NULL. Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* | usb: dwc2: gadget: Fix GUSBCFG.USBTRDTIM valueAmelie Delaunay2017-01-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | USBTrdTim must be programmed to 0x5 when phy has a UTMI+ 16-bit wide interface or 0x9 when it has a 8-bit wide interface. GUSBCFG reset value (Value After Reset: 0x1400) sets USBTrdTim to 0x5. In case of 8-bit UTMI+, without clearing GUSBCFG.USBTRDTIM mask, USBTrdTim results in 0xD (0x5 | 0x9). That's why we need to clear GUSBCFG.USBTRDTIM mask before setting USBTrdTim value, to ensure USBTrdTim is correctly set in case of 8-bit UTMI+. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* | usb: dwc2: Avoid suspending if we're in gadget modeJohn Stultz2017-01-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've found when booting HiKey with the usb gadget cable attached if I then try to connect via adb, I get an infinite spew of: dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790ecb18 ep1out, 0) dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790eca18 ep1in, 0) It seems that the usb autosuspend is suspending the bus shortly after bootup when the gadget cable is attached. So when adbd then tries to use the device, it doesn't work and it then tries to restart it over and over via the ep_sethalt calls (via FUNCTIONFS_CLEAR_HALT ioctl). Chen Yu suggested this patch to avoid suspending if we're in device mode, and it avoids the problem. Cc: Wei Xu <xuwei5@hisilicon.com> Cc: Guodong Xu <guodong.xu@linaro.org> Cc: Amit Pundir <amit.pundir@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: John Youn <johnyoun@synopsys.com> Cc: Douglas Anderson <dianders@chromium.org> Cc: Chen Yu <chenyu56@huawei.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Felipe Balbi <felipe.balbi@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org Suggested-by: Chen Yu <chenyu56@huawei.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* | usb: dwc2: use u32 for DT binding parametersLeo Yan2017-01-122-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 05ee799f2021 ("usb: dwc2: Move gadget settings into core_params") changes to type u16 for DT binding "g-rx-fifo-size" and "g-np-tx-fifo-size" but use type u32 for "g-tx-fifo-size". Finally the the first two parameters cannot be passed successfully with wrong data format. This is found the data transferring broken on 96boards Hikey. This patch is to change all parameters to u32 type, and verified on Hikey board the DT parameters can pass successfully. [johnyoun: minor rebase] Signed-off-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Tested-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* | usb: dwc2: gadget: Fix DMA memory freeingVardan Mikayelyan2017-01-121-11/+3Star
|/ | | | | | | | | | Remove DMA memory free from EP disable flow by replacing dma_alloc_coherent with dmam_alloc_coherent. Tested-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Vardan Mikayelyan <mvardan@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: fix flags for DMA descriptor allocation in dwc2_hsotg_ep_enableMarek Szyprowski2017-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dwc2_hsotg_ep_enable can be called from interrupt context, so all allocations should be done with GFP_ATOMIC flags. This fixes following issue on ARM architecture: [<c010d830>] (unwind_backtrace) from [<c010a51c>] (show_stack+0x10/0x14) [<c010a51c>] (show_stack) from [<c032930c>] (dump_stack+0x74/0x94) [<c032930c>] (dump_stack) from [<c011cd30>] (__warn+0xd4/0x100) [<c011cd30>] (__warn) from [<c011cd7c>] (warn_slowpath_null+0x20/0x28) [<c011cd7c>] (warn_slowpath_null) from [<c0187e04>] (smp_call_function_many+0xcc/0x2a4) [<c0187e04>] (smp_call_function_many) from [<c0188014>] (on_each_cpu_mask+0x38/0xa8) [<c0188014>] (on_each_cpu_mask) from [<c01ddfe0>] (start_isolate_page_range+0x134/0x1b8) [<c01ddfe0>] (start_isolate_page_range) from [<c01a3c14>] (alloc_contig_range+0xac/0x2f8) [<c01a3c14>] (alloc_contig_range) from [<c01de3e4>] (cma_alloc+0xe0/0x1a8) [<c01de3e4>] (cma_alloc) from [<c0110acc>] (__alloc_from_contiguous+0x38/0xe0) [<c0110acc>] (__alloc_from_contiguous) from [<c0110ba4>] (cma_allocator_alloc+0x30/0x38) [<c0110ba4>] (cma_allocator_alloc) from [<c0111034>] (__dma_alloc+0x1c0/0x2c8) [<c0111034>] (__dma_alloc) from [<c01111b4>] (arm_dma_alloc+0x3c/0x48) [<c01111b4>] (arm_dma_alloc) from [<c04ad800>] (dwc2_hsotg_ep_enable+0xec/0x46c) [<c04ad800>] (dwc2_hsotg_ep_enable) from [<c04da610>] (usb_ep_enable+0x2c/0x3c) [<c04da610>] (usb_ep_enable) from [<c04dc0c0>] (ecm_set_alt+0xa8/0x154) [<c04dc0c0>] (ecm_set_alt) from [<c04d678c>] (composite_setup+0xd74/0x1540) [<c04d678c>] (composite_setup) from [<c04ae048>] (dwc2_hsotg_complete_setup+0xb8/0x370) [<c04ae048>] (dwc2_hsotg_complete_setup) from [<c04d987c>] (usb_gadget_giveback_request+0xc/0x10) [<c04d987c>] (usb_gadget_giveback_request) from [<c04acafc>] (dwc2_hsotg_complete_request+0x78/0x128) [<c04acafc>] (dwc2_hsotg_complete_request) from [<c04aed28>] (dwc2_hsotg_epint+0x69c/0x81c) [<c04aed28>] (dwc2_hsotg_epint) from [<c04af6c4>] (dwc2_hsotg_irq+0xfc/0x748) [<c04af6c4>] (dwc2_hsotg_irq) from [<c0163264>] (__handle_irq_event_percpu+0x58/0x140) [<c0163264>] (__handle_irq_event_percpu) from [<c0163368>] (handle_irq_event_percpu+0x1c/0x58) [<c0163368>] (handle_irq_event_percpu) from [<c01633dc>] (handle_irq_event+0x38/0x5c) [<c01633dc>] (handle_irq_event) from [<c01666e4>] (handle_fasteoi_irq+0xc4/0x19c) [<c01666e4>] (handle_fasteoi_irq) from [<c0162a2c>] (generic_handle_irq+0x18/0x28) [<c0162a2c>] (generic_handle_irq) from [<c0162b40>] (__handle_domain_irq+0x6c/0xe4) [<c0162b40>] (__handle_domain_irq) from [<c0101470>] (gic_handle_irq+0x50/0x9c) [<c0101470>] (gic_handle_irq) from [<c010b00c>] (__irq_svc+0x6c/0xa8) Fixes: 5f54c54b0ba83 ("usb: dwc2: gadget: Add DDMA chain pointers to dwc2_hsotg_ep structure") Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: gadget: fix default value for gadget-dma-descStefan Wahren2017-01-021-1/+1
| | | | | | | | | | | | | | The current default for gadget DMA descriptor results on bcm2835 in a unnecessary error message: Invalid value 1 for param gadget-dma-desc So fix this by using hw->dma_desc_enable as default value. Fixes: dec4b55677e ("usb: dwc2: gadget: Add descriptor DMA parameter") Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: fix default value for DMA supportStefan Wahren2017-01-021-2/+2
| | | | | | | | | | | | | | The current defaults for DMA results on a non-DMA platform in a unnecessary error message: Invalid value 0 for param gadget-dma So fix this by using dma_capable as default value. Fixes: 9962b62f1be ("usb: dwc2: Deprecate g-use-dma binding") Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: fix dwc2_get_device_property for u8 and u16Stefan Wahren2017-01-021-12/+0Star
| | | | | | | | | | | | | | | | | | | According to the Devicetree ePAPR [1] the datatypes u8 and u16 are not defined. So using device_property_read_u16() would result in a partial read of a 32-bit big-endian integer which is not intended. So we better read the complete 32-bit value. This fixes a regression on bcm2835 where the values for g-rx-fifo-size and g-np-tx-fifo-size always read as zero: Invalid value 0 for param g-rx-fifo-size Invalid value 0 for param g-np-tx-fifo-size [1] - http://elinux.org/images/c/cf/Power_ePAPR_APPROVED_v1.1.pdf Fixes: 05ee799f202 ("usb: dwc2: Move gadget settings into core_params") Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: Do not set host parameter in peripheral modeStefan Wahren2017-01-021-6/+6
| | | | | | | | | | | | | | | Since commit "usb: dwc2: Improve handling of host and device hwparams" the host mode specific hardware parameter aren't initialized in peripheral mode from the register settings anymore. So we better do not set them in this case which avoids the following warnings on bcm2835: 256 invalid for host_nperio_tx_fifo_size. Check HW configuration. 512 invalid for host_perio_tx_fifo_size. Check HW configuration. Fixes: 55e1040e424b ("usb: dwc2: Improve handling of host and device hwparams") Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: Move functions from header to sourceRazmik Karapetyan2016-11-182-34/+29Star
| | | | | | | | | | Removed extern specifier from dwc2_host_start(), dwc2_host_disconnect() and dwc2_host_hub_info() functions. Moved those functions from header to source. Then make them static. Signed-off-by: Razmik Karapetyan <razmik@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: Fix fifo_show() functionalityRazmik Karapetyan2016-11-181-1/+1
| | | | | | | | | | NPTXFIFO's start address is showing 0x03000000 instead of 0x00000800. Replaced val & FIFOSIZE_DEPTH_MASK by val & FIFOSIZE_STARTADDR_MASK in fifo_show() function. Signed-off-by: Razmik Karapetyan <razmik@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: Remove unnecessary request length checkingRazmik Karapetyan2016-11-181-10/+0Star
| | | | | | | | | | | Remove request length checking from dwc2_hsotg_unmap_dma() and dwc2_hsotg_map_dma(). That checking is done in functions called from those functions, usb_gadget_unmap_request_by_dev() and usb_gadget_map_request_by_dev() respectively, so it's unnecessary. Signed-off-by: Razmik Karapetyan <razmik@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: dwc2: Fix Control Write issue in DMA modeRazmik Karapetyan2016-11-181-0/+7
| | | | | | | | | | | | While sending zlp for DWC2_EP0_STATUS_IN EP direction was changed to IN. Change it back to complete OUT transfer request. This affects only on DMA mode, because DMA buffer map/unmap function is direction sensitive. Signed-off-by: Razmik Karapetyan <razmik@synopsys.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>