Roman Bacik [Fri, 11 Sep 2015 01:13:43 +0000 (18:13 -0700)]
usb: dwc2: gadget: parity fix in isochronous mode
USB OTG driver in isochronous mode has to set the parity of the receiving
microframe. The parity is set to even by default. This causes problems for
an audio gadget, if the host starts transmitting on odd microframes.
This fix uses Incomplete Periodic Transfer interrupt to toggle between
even and odd parity until the Transfer Complete interrupt is received.
Signed-off-by: Roman Bacik <rbacik@broadcom.com>
Reviewed-by: Abhinav Ratna <aratna@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.mannam@broadcom.com>
Signed-off-by: Scott Branden <sbranden@broadcom.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 21 Sep 2015 10:16:11 +0000 (12:16 +0200)]
usb: dwc2: fix unbalanced phy control
Even when DWC2 is in (internal) suspended state, it should disable PHY
in suspend and then enable it in resume. This patch fixes unbalanced PHY
control sequence.
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 21 Sep 2015 10:16:10 +0000 (12:16 +0200)]
usb: dwc2: remove non-functional clock gating
During typical gadget operation, dwc2 clock was enabled 3 times: from
dwc2_gadget_init(), dwc2_hsotg_udc_start() and dwc2_hsotg_pullup(), and
then disabled in s3c_hsotg_pullup(), s3c_hsotg_udc_stop() and
dwc2_hsotg_remove(). This really makes no sense, so leave clock control
code only in dwc2_gadget_init/remove functions.
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 21 Sep 2015 10:16:09 +0000 (12:16 +0200)]
usb: dwc2: remove double call to dwc2_hsotg_of_probe
This patch removes doubled call to dwc2_hsotg_of_probe() function.
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Yunzhi Li [Tue, 29 Sep 2015 10:25:01 +0000 (12:25 +0200)]
usb: dwc2: gadget: fix a memory use-after-free bug
When dwc2_hsotg_handle_unaligned_buf_complete() hs_req->req.buf
already destroyed, in dwc2_hsotg_unmap_dma(), it touches
hs_req->req.dma again, so dwc2_hsotg_unmap_dma() should be called
before dwc2_hsotg_handle_unaligned_buf_complete(). Otherwise, it
will cause a bad_page BUG, when allocate this memory page next
time.
This bug led to the following crash:
BUG: Bad page state in process swapper/0 pfn:2bdbc
[ 26.820440] page:
eed76780 count:0 mapcount:0 mapping: (null) index:0x0
[ 26.854710] page flags: 0x200(arch_1)
[ 26.885836] page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set
[ 26.919179] bad because of flags:
[ 26.948917] page flags: 0x200(arch_1)
[ 26.979100] Modules linked in:
[ 27.008401] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W3.14.0 #17
[ 27.041816] [<
c010e1f8>] (unwind_backtrace) from [<
c010a704>] (show_stack+0x20/0x24)
[ 27.076108] [<
c010a704>] (show_stack) from [<
c087eea8>] (dump_stack+0x70/0x8c)
[ 27.110246] [<
c087eea8>] (dump_stack) from [<
c01ce0b8>] (bad_page+0xfc/0x12c)
[ 27.143958] [<
c01ce0b8>] (bad_page) from [<
c01ce65c>] (get_page_from_freelist+0x3e4/0x50c)
[ 27.179298] [<
c01ce65c>] (get_page_from_freelist) from [<
c01ce9a0>] (__alloc_pages_nodemask)
[ 27.216296] [<
c01ce9a0>] (__alloc_pages_nodemask) from [<
c01cf00c>] (__get_free_pages+0x20/)
[ 27.252326] [<
c01cf00c>] (__get_free_pages) from [<
c01e5bec>] (kmalloc_order_trace+0x34/0xa)
[ 27.288295] [<
c01e5bec>] (kmalloc_order_trace) from [<
c0203304>] (__kmalloc+0x40/0x1ac)
[ 27.323751] [<
c0203304>] (__kmalloc) from [<
c052abc0>] (dwc2_hsotg_ep_queue.isra.12+0x7c/0x1)
[ 27.359937] [<
c052abc0>] (dwc2_hsotg_ep_queue.isra.12) from [<
c052af88>] (dwc2_hsotg_ep_queue)
[ 27.397478] [<
c052af88>] (dwc2_hsotg_ep_queue_lock) from [<
c0554110>] (rx_submit+0xfc/0x164)
[ 27.433619] [<
c0554110>] (rx_submit) from [<
c05546e8>] (rx_complete+0x22c/0x230)
[ 27.468872] [<
c05546e8>] (rx_complete) from [<
c052b528>] (dwc2_hsotg_complete_request+0xfc/0)
[ 27.506240] [<
c052b528>] (dwc2_hsotg_complete_request) from [<
c052bba0>] (dwc2_hsotg_handle_o)
[ 27.545401] [<
c052bba0>] (dwc2_hsotg_handle_outdone) from [<
c052be70>] (dwc2_hsotg_epint+0x2c)
[ 27.583689] [<
c052be70>] (dwc2_hsotg_epint) from [<
c052c750>] (dwc2_hsotg_irq+0x1dc/0x4ac)
[ 27.621041] [<
c052c750>] (dwc2_hsotg_irq) from [<
c01682e0>] (handle_irq_event_percpu+0x70/0x)
[ 27.659066] [<
c01682e0>] (handle_irq_event_percpu) from [<
c01684ec>] (handle_irq_event+0x4c)
[ 27.697322] [<
c01684ec>] (handle_irq_event) from [<
c016bae0>] (handle_fasteoi_irq+0xc8/0x11)
[ 27.735451] [<
c016bae0>] (handle_fasteoi_irq) from [<
c0167b8c>] (generic_handle_irq+0x30/0x)
[ 27.773918] [<
c0167b8c>] (generic_handle_irq) from [<
c0167ca4>] (__handle_domain_irq+0x84/0)
[ 27.812018] [<
c0167ca4>] (__handle_domain_irq) from [<
c01003b0>] (gic_handle_irq+0x48/0x6c)
[ 27.849695] [<
c01003b0>] (gic_handle_irq) from [<
c010b340>] (__irq_svc+0x40/0x50)
[ 27.886907] Exception stack(0xc0d01ee0 to 0xc0d01f28)
Acked-by: John Youn <johnyoun@synopsys.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:30 +0000 (12:08 +0200)]
usb: dwc2: exit hibernation on session request
Controller enters hibernation through suspend interrupt on
disconnection. On connection, session request interrupt is generated.
dwc2 must exit hibernation and restore state from this interrupt
before continuing.
In host mode, exit from hibernation is handled by bus_resume function.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:29 +0000 (12:08 +0200)]
usb: dwc2: gadget: handle reset interrupt before endpoint interrupts
If system is loaded, reset, enum-done and setup interrupts can occur
at the same time. Current interrupt handling sequence will handle
setup packet's interrupt before handling reset interrupt. Which will
break the enumeration process. Correct sequence is to handle reset,
enum-done and then any other endpoint interrupts.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 29 Sep 2015 10:08:28 +0000 (12:08 +0200)]
usb: dwc2: gadget: exit hibernation before power down
When disconnecting cable, controller will detect a suspend condition
and enter partial power down. If vbus_session is called by the phy
driver during hibernation, make sure controller exit hibernation
before it is accessed.
Signed-off-by: Jianqiang Tang <jianqiang.tang@intel.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 29 Sep 2015 10:08:27 +0000 (12:08 +0200)]
usb: dwc2: gadget: unmask idstschng interrupt only if controller supports it
idstschng interrupt should not be used when id pin control is
external. This is already handled on dwc2 host part. Fix it on gadget
part as well.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:26 +0000 (12:08 +0200)]
usb: dwc2: gadget: only reset core after addressed state
There is a 200ms guard period to avoid unnecessary resets of the dwc2
ip. This delay sometimes prove to be too large when usbcv is run with
an ehci host. dwc2 only needs to be reset after addressed state.
Change the logic to reset ip after addressed state.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:25 +0000 (12:08 +0200)]
usb: dwc2: gadget: kill ep0 requests before reinitializing core
Make sure there are no requests pending on ep0 before reinitializing
core. Otherwise, dwc2_hsotg_enqueue_setup will fail afterwards.
Also, take hsotg->lock before calling
dwc2_hsotg_core_init_disconnected() from dwc2_conn_id_status_change()
as dwc2_hsotg_complete_request() expect lock to be held.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:24 +0000 (12:08 +0200)]
usb: dwc2: gadget: stop current transfer on dequeue
If the request being dequeued is already started, disable endpoint
to stop the transfer and then call dwc2_hsotg_complete_request().
Endpoint will be re-enabled on next call to dwc2_hsotg_start_req().
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:23 +0000 (12:08 +0200)]
usb: dwc2: gadget: print complete setup packet
wIndex field was missing. Also print in natural order instead of
Req first, so that its easier to compare for example against
bus analyzer logs.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:22 +0000 (12:08 +0200)]
usb: dwc2: gadget: ignore stall check for ep0
dwc2_hsotg_start_req starts a request only if endpoint is not stalled.
Ignore this check for ep0 as core will clear DOEPCTL0.Stall after
sending stall handshake. Prepare instead for receiving next setup
packet.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 29 Sep 2015 10:08:21 +0000 (12:08 +0200)]
usb: dwc2: gadget: abort core init if core_reset fails
No point of continue with initialization if core is not in a sane
state.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 29 Sep 2015 10:08:20 +0000 (12:08 +0200)]
usb: dwc2: gadget: set op_state in vbus_session call
Some device may have external id pin control enabled, so op_state
will not be set on id pin interrupt change.
Thus, ensure op_state is set to peripheral during vbus detection.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 29 Sep 2015 10:08:19 +0000 (12:08 +0200)]
usb: dwc2: gadget: don't modify pullup state in host mode
Modifying the pullup state during host mode trig a new enumeration
of attached device. Thus, avoid modifying pullup in host mode.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 29 Sep 2015 10:08:18 +0000 (12:08 +0200)]
usb: dwc2: force dr_mode in case of configuration mismatch
If dual role configuration is not selected, check and force dr_mode
based on the selected configuration.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Krzysztof Opasiak [Mon, 21 Sep 2015 19:51:14 +0000 (21:51 +0200)]
usb: gadget: SourceSink: Fix show methods for attributes
Most of USB functions place new line after attribute value.
Let's follow this convention also in source sink function
as it improves readability.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Krzysztof Opasiak [Mon, 21 Sep 2015 19:51:13 +0000 (21:51 +0200)]
usb: gadget: loopback: Fix show methods for attributes
Most of USB functions place new line after attribute value.
Let's follow this convention also in loopback function
as it improves readability.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Sat, 19 Sep 2015 17:12:58 +0000 (22:42 +0530)]
usb: gadget: at91_udc: mention proper dependency
While building allmodconfig on avr32 the build failed with the error:
"at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
On checking the code it turned out that if CONFIG_OF is defined then it
is using at91_pmc_read() which is using at91_pmc_base. And unless
COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
COMMON_CLK_AT91 is available with AT91 architecture.
Mention the dependency such that this driver builds with avr32 only if
OF is not enabled.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:37 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: NULL comparison
A NULL comparison can be written as if (var) or if (!var).
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:36 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove forward declaration of udc_basic_init
Rearrange the udc_basic_init function to remove the forward declaration.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:35 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove forward declaration of udc_pci_*
Remove the forward declarations of udc_pci_probe and udc_pci_remove.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:34 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove forward declaration of udc_free_dma_chain
Rearrange udc_free_dma_chain to remove the forward declaration. While at
it fixed all the relevant checkpatch warnings.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:33 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove forward declaration of udc_create_dma_chain
Rearrange udc_create_dma_chain to remove the forward declaration. While
rearranging fixed the relevant checkpatch warnings.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:32 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove forward declaration of udc_remote_wakeup
Rearrange the udc_remote_wakeup function to remove the forward
declaration.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:31 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove forward declaration of udc_probe
Rearrange the udc_probe function to remove the forward declarations.
While rearranging also fixed the relevant checkpatch warnings.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:30 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: remove unnecessary conditions
The condition checking for irq_registered, regs, mem_region and active
are not required as this is the remove function. And we are in the
remove means that probe was successful and they can never be NULL at
this point of code.
It was required in the original code as the remove function was part of
the error handler of probe function.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:29 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: use free_dma_pools
We have the function free_dma_pools() which frees all the dma pools. Use
it instead of calling all the functions separately. The if conditions
for data_requests and stp_requests are also not required here as this is
the remove function and we are here means probe has succeeded and dma
has been successfully allocated, so they cannot be NULL here.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:28 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: use WARN_ON
Use WARN_ON() instead of halting the kernel with BUG_ON() and also fix
the checkpatch warning.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:27 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: fix error path
Handle the error properly instead of calling the pci remove function.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sudip Mukherjee [Tue, 22 Sep 2015 13:24:26 +0000 (18:54 +0530)]
usb: gadget: amd5536udc: rewrite init_dma_pools
A rewrite of init_dma_pools() with proper error handling.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 22 Sep 2015 13:16:55 +0000 (15:16 +0200)]
usb: dwc2: gadget: initialize op_state for peripheral only configuration
ID status change interrupt will not be handled in peripheral only
configuration. So initialize op_state during gadget init.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:54 +0000 (15:16 +0200)]
usb: dwc2: gadget: ensure lx_state corresponds to current state
Correctly update lx_state on gadget connection and disconnection.
When usb cable is disconnected, lx_state must be updated to L3 as
controller could be in power off state.
When usb cable is connected, lx_state must be updated to L0 as
controller is powered.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:53 +0000 (15:16 +0200)]
usb: dwc2: host: kill remaining urbs using -ECONNRESET status
On a disconnect, dwc2 will kill all remaining urbs from qh list.
urbs are given back to hcd with -ETIMEDOUT status.
Some usb device driver, like mass storage, will unlink all urbs
using usb_hcd_unlink_urb when receiving a negative status different
from -ECONNRESET.
The following flow will then happen:
dwc2_hcd_disconnect()
-> dwc2_kill_all_urbs() try to kill first pending urb.
-> dwc2_host_complete(-ETIMEDOUT)
-> usb_hcd_giveback_urb(-ETIMEDOUT)
-> sg_complete()
-> usb_unlink_urb()
-> usb_put_dev(urb->dev)
-> dwc2_kill_all_urbs() try to kill next pending urb.
-> dwc2_host_complete(-ETIMEDOUT)
-> usb_hcd_giveback_urb(-ETIMEDOUT)
-> NULL pointer dereferencing because urb->dev has been freed for all
urbs of this device.
The root cause of this NULL pointer is to call call usb_unlink_urb()
while we are killing all urbs. To avoid this return urb with
-ECONNRESET status
This issue usually happens while removing mass storage device during
transfer.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:52 +0000 (15:16 +0200)]
usb: dwc2: host: use correct frame number during qh init
On first qh initialization, hsotg->frame_number is not corresponding
to reality. So read it from host controller to get correct value.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:51 +0000 (15:16 +0200)]
usb: dwc2: host: correctly dump urb isochronous descriptors
Print urb->iso_frame_desc.status after it has been updated using
dwc2_hcd_urb_get_iso_desc_status().
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:50 +0000 (15:16 +0200)]
usb: dwc2: host: wait 3ms for controller stabilization
Some high speed mass storage devices fail to enumerate with following
error:
Cannot enable port %i. Maybe the USB cable is bad?
This happens only when the device is plugged while the controller
is in hibernation state. After exiting hibernation, the controller
detects the device as a low speed device and fail to enumerate it.
Problem occurs only if HPRT0.PWR bit is programmed in a too short
delay after exiting hibernation. Dumping hprt register in
_dwc2_hcd_resume() directly after dwc2_exit_hibernation() shows that
HPRT0.LNSTS (D+/D- level) becomes valid approximately 2ms after
exiting hibernation.
Since dwc2_exit_hibernation() is called from atomic context, move the
delay out of this function.
Delay value is experimental and not mentioned in Synopsys
documentation. To be on the safe side 3ms delay is used.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:49 +0000 (15:16 +0200)]
usb: dwc2: host: clear pending interrupts prior hibernation
If an interrupt rises during hibernation process, dwc2 will assert
interrupt line to interrupt controller. If interrupt is level
sensitive, interrupt handler will be called in a loop because dwc2
will not be able to clear it while controller is hibernated.
Thus, clear all controller interrupts before hibernation entry.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:48 +0000 (15:16 +0200)]
usb: dwc2: host: disable interrupt during stop
Disable host interrupts before synchronising dwc2 irq.
So that interrupts are not generated once controller is stopped.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mian Yousaf Kaukab [Tue, 22 Sep 2015 13:16:47 +0000 (15:16 +0200)]
usb: dwc2: host: add disconnect interrupt to host only interrupts
GINTSTS.DisconnInt is host only interrupt and should be disable after
dwc2_disable_host_interrupts is called.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:46 +0000 (15:16 +0200)]
usb: dwc2: host: disconnect hcd prior stopping it
In case controller is asked to stop while devices are connected,
disconnect all devices and clean up before stopping.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:45 +0000 (15:16 +0200)]
usb: dwc2: host: reset frame number after suspend
Frame number is reset in hardware after exiting hibernation.
Thus, reset frame_number and ensure qh are queued with correct
sched_frame.
Otherwise, qh->sched_frame may be too high compared to
current frame number (which is 0). This can delay addition of qh in
the list of transfers until frame number reaches qh->sched_frame.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:44 +0000 (15:16 +0200)]
usb: dwc2: host: resume only if bus is suspended
Port can be resumed in bus_resume callback.
In this case, there is no need to drive resume a second time
when hcd ask for it.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:43 +0000 (15:16 +0200)]
usb: dwc2: host: ignore wakeup interrupt if hibernation supported
If hibernation is supported, resume of devices will be handled in
bus_resume callback.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:42 +0000 (15:16 +0200)]
usb: dwc2: host: avoid resetting lx_state to L3 during disconnect
When a device is disconnected, lx_state must not be changed since the
device may be disconnected whereas controller is still powered.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:41 +0000 (15:16 +0200)]
usb: dwc2: host: update hcd and lx_state during start/stop callbacks
During hcd initialization, hardware accessible flag and lx_state must
be reset to the working state since controller is powered at this stage.
Same logic applied for stop callback.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:40 +0000 (15:16 +0200)]
usb: dwc2: host: enter hibernation during bus suspend
Disable controller power and enter hibernation when usb bus is
suspended. A phy driver is required to disable the power of the
controller and detect remote-wakeup or disconnection since the
controller will not be able to detect these in this state.
Once the phy driver detects bus activity, it must call
usb_hcd_resume_root_hub.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:39 +0000 (15:16 +0200)]
usb: dwc2: host: add flag to reflect bus state
lx_state must be used to reflect controller power state only and not
bus state. Thus add a flag to track state during bus suspend.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:38 +0000 (15:16 +0200)]
usb: dwc2: host: create a function to handle port_resume
port resume sequence may be used in different places. Create a
function to handle it. Make hprt0 read-modify-write atomic and
clear HPRT0_SUSP for both writes as it is a "read, write-set,
and self-clear (R_WS_SC)" bit. Since the lock is released
between the writes, read hprt0 again.
Since the phy clock is stopped in dwc2_port_suspend(), enable it
here and remove the PCGCTL write from dwc2_hcd_hub_control()
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Gregory Herrero [Tue, 22 Sep 2015 13:16:37 +0000 (15:16 +0200)]
usb: dwc2: host: don't clear hprt0 status bits when exiting hibernation
When entering hibernation hprt0 must be read using dwc2_read_hprt0().
Otherwise, any set hprt0 status bits will be cleared when restoring
hprt0 on exit from hibernation.
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Mon, 28 Sep 2015 20:18:33 +0000 (15:18 -0500)]
usb: dwc3: gadget: remove unnecessary _irqsave()
We *know* our threads executes with our IRQs
disabled. We really don't need to use the _irqsave()
variant of spin_lock().
Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Mon, 28 Sep 2015 20:16:56 +0000 (15:16 -0500)]
usb: dwc3: gadget: use Update Transfer from Xfer In Progress
Instead of limiting __dwc3_gadget_kick_transfer() to
Xfer Complete, we can try to issue Update Transfer
command from Xfer In Progress too.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Mon, 28 Sep 2015 19:49:02 +0000 (14:49 -0500)]
usb: dwc3: gadget: use update transfer command
If we get a Xfer Not Ready event with reason
"Transfer Active" it means endpoint is still
transferring data and we can use that to issue
update transfer for this particular endpoint
in case we have pending requests in our queue.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Mon, 21 Sep 2015 19:32:00 +0000 (14:32 -0500)]
usb: dwc3: gadget: start transfer on XFER_COMPLETE
if by the time we get to XFER_COMPLETE we have
pending requests to be processed, instead of waiting
for a following XFER_NOT_READY, let's start the request
right away and, maybe, save the time of a few NAKs
due to lack of started transfers.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Mon, 28 Sep 2015 15:45:47 +0000 (10:45 -0500)]
usb: gadget: pch-udc: fix lock
gadget methods should be called without
spinlocks held.
Reported-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Heikki Krogerus [Mon, 21 Sep 2015 08:14:36 +0000 (11:14 +0300)]
usb: dwc3: pci: passing forward the ACPI companion
Sharing the ACPI companion with dwc3 core so it has access
to the properties defined for DWC3 in ACPI tables.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Heikki Krogerus [Mon, 21 Sep 2015 08:14:35 +0000 (11:14 +0300)]
usb: dwc3: core: convert to unified device property interface
No functional affect on existing platforms, but the driver
is now ready to extract the properties also from ACPI tables
as well as from DT.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Heikki Krogerus [Mon, 21 Sep 2015 08:14:34 +0000 (11:14 +0300)]
usb: common: of_usb_get_dr_mode to usb_get_dr_mode
By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Heikki Krogerus [Mon, 21 Sep 2015 08:14:33 +0000 (11:14 +0300)]
usb: dwc3: st: prepare the driver for generic usb_get_dr_mode function
of_usb_get_dr_mode will be converted into more generic
usb_get_dr_mode function that will take struct device
instead of struct device_node as its parameter.
To make the conversion possible later, waiting for the
platform device for dwc3 to be populated before calling
of_usb_get_dr_mode.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
CC: Giuseppe Cavallaro <peppe.cavallaro@st.com>
CC: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Heikki Krogerus [Mon, 21 Sep 2015 08:14:32 +0000 (11:14 +0300)]
usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed
By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 22 Sep 2015 07:31:34 +0000 (15:31 +0800)]
usb: phy: change some comments
- Replace all "transceiver" with "phy"
- Replace one "OTG controller" with "phy"
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:11:04 +0000 (12:11 +0200)]
usb: gadget: legacy: tcm: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of tcm, ep->driver_data was used only for endpoint claiming so
we can simplify code by reducing it. We also remove give_back_ep()
function which is not needed after all - when error code is returned
from bind() function, composite will release all endpoints anyway.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:11:03 +0000 (12:11 +0200)]
usb: gadget: legacy: dbgp: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of dbgp, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:11:02 +0000 (12:11 +0200)]
usb: gadget: u_serial: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of u_serial ep->driver_data stores pointer to struct gs_port,
which is referenced in many places in code. Code using ep->driver_data
to mark endpoint as enabled/disabled has been removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:11:01 +0000 (12:11 +0200)]
usb: gadget: u_ether: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of u_ether we only need to store in ep->driver_data pointer to
struct eth_dev, as it's used in rx_complete() and tx_complete() callbacks.
All other uses of ep->driver_data are now meaningless and can be safely
removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:11:00 +0000 (12:11 +0200)]
usb: gadget: f_uvc: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_uvc, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:59 +0000 (12:10 +0200)]
usb: gadget: f_uac2: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_uac2, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:58 +0000 (12:10 +0200)]
usb: gadget: f_uac1: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_uac1, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:57 +0000 (12:10 +0200)]
usb: gadget: f_subset: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_subset, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:56 +0000 (12:10 +0200)]
usb: gadget: f_sourcesink: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_sourcesink we only need to store in ep->driver_data pointer
to struct f_sourcesink, as it's used in source_sink_complete() callback.
All other uses of ep->driver_data are now meaningless and can be safely
removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:55 +0000 (12:10 +0200)]
usb: gadget: f_serial: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_serial, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:54 +0000 (12:10 +0200)]
usb: gadget: f_rndis: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_rndis, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:53 +0000 (12:10 +0200)]
usb: gadget: f_printer: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_printer we only need to store in ep->driver_data pointer to
struct printer_dev, as it's used in rx_complete() and tx_complete()
callbacks. All other uses of ep->driver_data are now meaningless and can
be safely removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:52 +0000 (12:10 +0200)]
usb: gadget: f_phonet: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_phonet we only need to store in ep->driver_data pointer to
struct f_phonet, as it's used in pn_tx_complete() and pn_rx_complete()
callbacks. All other uses of ep->driver_data are now meaningless and can
be safely removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:51 +0000 (12:10 +0200)]
usb: gadget: f_obex: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_obex, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:50 +0000 (12:10 +0200)]
usb: gadget: f_ncm: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_ncm, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:49 +0000 (12:10 +0200)]
usb: gadget: f_midi: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_midi we only need to store in ep->driver_data pointer to
struct f_midi, as it's used in f_midi_complete() callback and related
functions. All other uses of ep->driver_data are now meaningless and
can be safely removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:48 +0000 (12:10 +0200)]
usb: gadget: f_mass_storage: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_mass_storage we only need to store in ep->driver_data
pointer to struct fsg_common, which is used in bulk_in_complete() and
bulk_out_complete() callbacks. All other uses of ep->driver_data are now
meaningless and can be safely removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:47 +0000 (12:10 +0200)]
usb: gadget: f_loopback: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_hid we only need to store in ep->driver_data pointer to
struct f_loopback, as it's used in loopback_complete() callback. All
other uses of ep->driver_data are now meaningless and can be safely
removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:46 +0000 (12:10 +0200)]
usb: gadget: f_hid: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_hid we only need to store in ep->driver_data pointer to
struct f_hidg, as it's used in f_hidg_req_complete() callback. All
other uses of ep->driver_data are now meaningless and can be safely
removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:45 +0000 (12:10 +0200)]
usb: gadget: f_eem: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_ecm, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:44 +0000 (12:10 +0200)]
usb: gadget: f_acm: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_acm we only need to store in ep->driver_data pointer to
struct f_acm, as it's used in acm_complete_set_line_coding() callback.
All other uses of ep->driver_data are now meaningless and can be safely
removed.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:43 +0000 (12:10 +0200)]
usb: gadget: f_ecm: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for
enabled/disabled state storing, we can reduce number of places where
we read or modify it's value, as now it has no particular meaning for
function or framework logic.
In case of f_ecm, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:42 +0000 (12:10 +0200)]
usb: gadget: introduce 'enabled' flag in struct usb_ep
This patch introduces 'enabled' flag in struct usb_ep, and modifies
usb_ep_enable() and usb_ep_disable() functions to encapsulate endpoint
enabled/disabled state. It helps to avoid enabling endpoints which are
already enabled, and disabling endpoints which are already disables.
From now USB functions don't have to remember current endpoint
enable/disable state, as this state is now handled automatically which
makes this API less bug-prone.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:41 +0000 (12:10 +0200)]
usb: gadget: epautoconf: add usb_ep_autoconfig_release() function
This patch introduces usb_ep_autoconfig_release() function which allows
to release endpoint previously obtained from usb_ep_autoconfig() during
USB function bind.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:40 +0000 (12:10 +0200)]
usb: gadget: f_ncm: obtain cdev from function instead of driver_data
The 'driver_data' field in ep0 is never set to pointer to cdev, so we
have to obtain it from another source as in this context ep->driver_data
contains invalid data.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga [Wed, 16 Sep 2015 10:10:39 +0000 (12:10 +0200)]
usb: gadget: fix few outdated comments
Fix comments in code to make them up to date.
composite: claiming endpoint is now done by setting ep->claimed flag,
not ep->driver_data.
epautoconf: usb_ep_autoconfig() and usb_ep_autoconfig_ss() return
claimed endpoint with ep->claimed flag already set.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
WEN Pingbo [Fri, 18 Sep 2015 02:51:26 +0000 (10:51 +0800)]
usb: gadget: dummy_hcd: replace timeval with timespec64
The millisecond of the last second will be normal if tv_sec is
overflowed. But for y2038 consistency and demonstration purpose,
and avoiding further risks, we need to remove 'timeval' in this
driver, to avoid similair problems.
Signed-off-by: Pingbo Wen <pingbo.wen@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Sekhar Nori [Mon, 31 Aug 2015 15:39:08 +0000 (21:09 +0530)]
usb: dwc3: support for pinctrl state change during system sleep
Add support for USB DRVVBUS pinctrl state change during
suspend/resume. This helps is conserving power during
system sleep.
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 1 Sep 2015 01:48:04 +0000 (09:48 +0800)]
tools: usb: testusb: change the default value for length from 512 to 1024
For ctrl out test, it needs length > vary, so in order to run it with
default parameters, we do this change.
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 1 Sep 2015 01:48:03 +0000 (09:48 +0800)]
tools: usb: testusb: change the help text
The 'length' is the transfer length, not the packet size, so
change the help text.
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 1 Sep 2015 01:48:02 +0000 (09:48 +0800)]
usb: gadget: f_sourcesink: format data pattern according to max packet size
Since the host and gadget can't agree with transfer length before
each transfer, but they agree with max packet size for each
endpoint, we use max packet size to format data pattern.
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Alan Stern [Tue, 1 Sep 2015 01:48:01 +0000 (09:48 +0800)]
usb: misc: usbtest: format the data pattern according to max packet size
With this change, the host and gadget doesn't need to agree with transfer
length for comparing the data, since they doesn't know each other's
transfer size, but know max packet size.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
(Fixed the 'line over 80 characters warning' by Peter Chen)
Tested-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 1 Sep 2015 01:48:00 +0000 (09:48 +0800)]
usb: misc: usbtest: using the same data format among write/compare/output
Using the same data format "buf[j] = (u8)(i + j)" among
write, compare buf, and console output stage.
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 1 Sep 2015 01:47:59 +0000 (09:47 +0800)]
usb: misc: usbtest: delete useless memset for urbs array
The element of urbs array will be initialized at below code
at once.
for (i = 0; i < param->sglen; i++) {
urbs[i] = iso_alloc_urb(udev, pipe, desc,
param->length, offset);
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Peter Chen [Tue, 1 Sep 2015 01:47:58 +0000 (09:47 +0800)]
usb: misc: usbtest: allocate size of urb array according to user parameter
Allocate the size of urb pointer array according to testusb's
parameter sglen, and limits the length of sglen as MAX_SGLEN
(128 currently).
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Antti Seppälä [Thu, 20 Aug 2015 18:41:07 +0000 (21:41 +0300)]
usb: dwc2: Use platform endianness when accessing registers
This patch switches calls to readl/writel to their
dwc2_readl/dwc2_writel equivalents which preserve platform endianness.
This patch is necessary to access dwc2 registers correctly on big-endian
systems such as the mips based SoCs made by Lantiq. Then dwc2 can be
used to replace ifx-hcd driver for Lantiq platforms found e.g. in
OpenWrt.
The patch was autogenerated with the following commands:
$EDITOR core.h
sed -i "s/\<readl\>/dwc2_readl/g" *.c hcd.h hw.h
sed -i "s/\<writel\>/dwc2_writel/g" *.c hcd.h hw.h
Some files were then hand-edited to fix checkpatch.pl warnings about
too long lines.
Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mike Looijmans [Wed, 5 Aug 2015 06:54:55 +0000 (08:54 +0200)]
usb: gadget: ether: Allow jumbo frames
USB network adapters support Jumbo frames. The only thing blocking
that feature is the code in the gadget driver that disposes of
packets larger than 1518 bytes, and the limit on the ioctl to set
the mtu.
This patch relaxes these limits, and allows up to 15k frames sizes.
The 15k value was chosen because 16k does not work on all platforms,
and usingclose to 16k will result in allocating 5 or 8 4k pages to
store the skb, wasting pages at no measurable performance gain.
On a topic-miami board (Zynq-7000), iperf3 performance reports:
MTU= 1500, PC-to-gadget: 139 Mbps, Gadget-to-PC: 116 Mbps
MTU=15000, PC-to-gadget: 239 Mbps, Gadget-to-PC: 361 Mbps
On boards with slower CPUs the performance improvement will be
relatively much larger, e.g. an OMAP-L138 increased from 40 to
220 Mbps using a similar patch on an 2.6.37 kernel.
Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Felipe Balbi <balbi@ti.com>