1. 25 May, 2020 40 commits
    • Macpaul Lin's avatar
      usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle · 402bcac4
      Macpaul Lin authored
      When receiving reset interrupt, FADDR need to be reset to zero in
      peripheral mode. Otherwise ep0 cannot do enumeration when re-plugging USB
      cable.
      Signed-off-by: default avatarMacpaul Lin <macpaul.lin@mediatek.com>
      Acked-by: default avatarMin Guo <min.guo@mediatek.com>
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Link: https://lore.kernel.org/r/20200525025049.3400-5-b-liu@ti.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      402bcac4
    • Jason Yan's avatar
      usb: musb: use true for 'use_dma' · e62361c7
      Jason Yan authored
      Fix the following coccicheck warning:
      
      drivers/usb/musb/musb_core.c:1798:12-19: WARNING: Assignment of 0/1 to
      bool variable
      Signed-off-by: default avatarJason Yan <yanaijie@huawei.com>
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Link: https://lore.kernel.org/r/20200525025049.3400-4-b-liu@ti.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e62361c7
    • Bin Liu's avatar
      usb: musb: start session in resume for host port · 7f88a5ac
      Bin Liu authored
      Commit 17539f2f ("usb: musb: fix enumeration after resume") replaced
      musb_start() in musb_resume() to not override softconnect bit, but it
      doesn't restart the session for host port which was done in musb_start().
      The session could be disabled in musb_suspend(), which leads the host
      port doesn't stay in host mode.
      
      So let's start the session specifically for host port in musb_resume().
      
      Fixes: 17539f2f ("usb: musb: fix enumeration after resume")
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Link: https://lore.kernel.org/r/20200525025049.3400-3-b-liu@ti.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f88a5ac
    • Bin Liu's avatar
      usb: musb: return -ESHUTDOWN in urb when three-strikes error happened · 1b967691
      Bin Liu authored
      When a USB device attached to a hub got disconnected, MUSB controller
      generates RXCSR_RX_ERROR interrupt for the 3-strikes-out error.
      
      Currently the MUSB host driver returns -EPROTO in current URB, then the
      USB device driver could immediately resubmit the URB which causes MUSB
      generate RXCSR_RX_ERROR interrupt again. This circle causes interrupt
      storm then the hub never got a chance to report the USB device detach.
      
      To fix the interrupt storm, change the URB return code to -ESHUTDOWN for
      MUSB_RXCSR_H_ERROR interrupt, so that the USB device driver will not
      immediately resubmit the URB.
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Link: https://lore.kernel.org/r/20200525025049.3400-2-b-liu@ti.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b967691
    • Greg Kroah-Hartman's avatar
      Merge tag 'usb-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next · ca681aa4
      Greg Kroah-Hartman authored
      Felipe writes:
      
      USB: changes for v5.8 merge window
      
      Rather busy cycle. We have a total 99 non-merge commits going into v5.8
      merge window. The majority of the changes are in dwc3 this around (31.7%
      of all changes). It's composed mostly Thinh's recent updates to get dwc3
      to behave correctly with stream transfers. We have also have Roger's for
      Keystone platforms and Neil's updates for the meson glue layer.
      
      Apart from those, we have the usual set of non-critical fixes, new
      device IDs, spelling fixes all over the place.
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      
      * tag 'usb-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (99 commits)
        usb: dwc3: keystone: Turn on USB3 PHY before controller
        dt-bindings: usb: ti,keystone-dwc3.yaml: Add USB3.0 PHY property
        dt-bindings: usb: convert keystone-usb.txt to YAML
        usb: dwc3: gadget: Check for prepared TRBs
        usb: gadget: Fix issue with config_ep_by_speed function
        usb: cdns3: ep0: delete the redundant status stage
        usb: dwc2: Update Core Reset programming flow.
        usb: gadget: fsl: Fix a wrong judgment in fsl_udc_probe()
        usb: gadget: fix potential double-free in m66592_probe.
        usb: cdns3: Fix runtime PM imbalance on error
        usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check
        usb: dwc3: Increase timeout for CmdAct cleared by device controller
        USB: dummy-hcd: use configurable endpoint naming scheme
        usb: cdns3: gadget: assign interrupt number to USB gadget structure
        usb: gadget: core: sync interrupt before unbind the udc
        arm64: dts: qcom: sc7180: Add interconnect properties for USB
        arm64: dts: qcom: sdm845: Add interconnect properties for USB
        dt-bindings: usb: qcom,dwc3: Introduce interconnect properties for Qualcomm DWC3 driver
        ARM: dts: at91: Remove the USB EP child node
        dt-bindings: usb: atmel: Mark EP child node as deprecated
        ...
      ca681aa4
    • Roger Quadros's avatar
      usb: dwc3: keystone: Turn on USB3 PHY before controller · 1c11e74e
      Roger Quadros authored
      The Local Power Sleep Controller (LPSC) dependency on AM65
      requires SERDES0 to be powered on before USB.
      
      We need to power up SERDES0 power domain and hold it on
      throughout the reset, init, power on sequence.
      Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      1c11e74e
    • Roger Quadros's avatar
      dt-bindings: usb: ti,keystone-dwc3.yaml: Add USB3.0 PHY property · 15aeb360
      Roger Quadros authored
      AM654 SoC requires USB3.0 PHY to be turned on before the USB controller.
      For this SoC, the 'phys' property is used to provide the USB3.0
      reference.
      Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      15aeb360
    • Roger Quadros's avatar
      dt-bindings: usb: convert keystone-usb.txt to YAML · 1883a934
      Roger Quadros authored
      Convert keystone-usb documentation to YAML format.
      Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      1883a934
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Check for prepared TRBs · 63c7bb29
      Thinh Nguyen authored
      There are cases where the endpoint needs to be restarted. For example,
      it may need to restart for NoStream rejection to reinitiate stream. If
      so, check and make sure we don't prepare beyond the current transfer
      when we restart the endpoint.
      
      DWC_usb32 internal burst transfer feature will look into TRBs beyond a
      transfer. Other controllers will stop on the last TRB, but not
      DWC_usb32. This may cause the controller to incorrectly process TRBs of
      a different transfer. Make sure to explicitly prevent preparing TRBs of
      a different transfer.
      
      This should only affect DWC_usb32 releases prior to v1.00a since it
      doesn't use SET_ENDPOINT_PRIME to reinitiate stream. However, it's
      better to be cautious in case users don't want to use SET_ENDPOINT_PRIME
      command. Also, it's possible other controller IPs may share the same
      features as DWC_usb32 in new releases.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      63c7bb29
    • Pawel Laszczak's avatar
      usb: gadget: Fix issue with config_ep_by_speed function · 5d363120
      Pawel Laszczak authored
      This patch adds new config_ep_by_speed_and_alt function which
      extends the config_ep_by_speed about alt parameter.
      This additional parameter allows to find proper usb_ss_ep_comp_descriptor.
      
      Problem has appeared during testing f_tcm (BOT/UAS) driver function.
      
      f_tcm function for SS use array of headers for both  BOT/UAS alternate
      setting:
      
      static struct usb_descriptor_header *uasp_ss_function_desc[] = {
              (struct usb_descriptor_header *) &bot_intf_desc,
              (struct usb_descriptor_header *) &uasp_ss_bi_desc,
              (struct usb_descriptor_header *) &bot_bi_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_ss_bo_desc,
              (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,
      
              (struct usb_descriptor_header *) &uasp_intf_desc,
              (struct usb_descriptor_header *) &uasp_ss_bi_desc,
              (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_bi_pipe_desc,
              (struct usb_descriptor_header *) &uasp_ss_bo_desc,
              (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_bo_pipe_desc,
              (struct usb_descriptor_header *) &uasp_ss_status_desc,
              (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_status_pipe_desc,
              (struct usb_descriptor_header *) &uasp_ss_cmd_desc,
              (struct usb_descriptor_header *) &uasp_cmd_comp_desc,
              (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
              NULL,
      };
      
      The first 5 descriptors are associated with BOT alternate setting,
      and others are associated with UAS.
      
      During handling UAS alternate setting f_tcm driver invokes
      config_ep_by_speed and this function sets incorrect companion endpoint
      descriptor in usb_ep object.
      
      Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this
      case set ep->comp_desc to uasp_ss_bi_desc.
      
      This is due to the fact that it searches endpoint based on endpoint
      address:
      
              for_each_ep_desc(speed_desc, d_spd) {
                      chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
                      if (chosen_desc->bEndpoitAddress == _ep->address)
                              goto ep_found;
              }
      
      And in result it uses the descriptor from BOT alternate setting
      instead UAS.
      
      Finally, it causes that controller driver during enabling endpoints
      detect that just enabled endpoint for bot.
      Signed-off-by: default avatarJayshri Pawar <jpawar@cadence.com>
      Signed-off-by: default avatarPawel Laszczak <pawell@cadence.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      5d363120
    • Peter Chen's avatar
      usb: cdns3: ep0: delete the redundant status stage · 8b5b9adb
      Peter Chen authored
      Each setup stage will prepare status stage at cdns3_ep0_setup_phase,
      it doesn't need to add extra status stage for test mode handling,
      otherwise, the controller can't enter the test mode. Through the Lecroy
      bus analyzer log, the controller will always wait status stage
      even it is prepared by software later than the test mode is set
      by software. If we comment out the status stage at cdns3_ep0_setup_phase,
      the controller will not enter test mode even the test mode is set
      beforehand.
      Reviewed-by: default avatarPawel Laszczak <pawell@cadence.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      8b5b9adb
    • Minas Harutyunyan's avatar
      usb: dwc2: Update Core Reset programming flow. · 65dc2e72
      Minas Harutyunyan authored
      Starting from core version 4.20a Core Reset flow is changed.
      Introduced new bit in GRSTCTL register - GRSTCTL_CSFTRST_DONE.
      Core Reset new programming flow steps are follow:
      1. Set GRSTCTL_CSFTRST bit.
      2. Wait for bit GRSTCTL_CSFTRST_DONE is set.
      3. Clear GRSTCTL_CSFTRST and GRSTCTL_CSFTRST_DONE bits.
      
      Check core version functionality separated from dwc2_get_hwparams() to
      new dwc2_check_core_version() function because Core Reset flow depend
      on SNPSID.
      Signed-off-by: default avatarMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      65dc2e72
    • Tang Bin's avatar
      usb: gadget: fsl: Fix a wrong judgment in fsl_udc_probe() · 4cda340a
      Tang Bin authored
      If the function "platform_get_irq()" failed, the negative value
      returned will not be detected here, including "-EPROBE_DEFER", which
      causes the application to fail to get the correct error message.
      Thus it must be fixed.
      Acked-by: default avatarLi Yang <leoyang.li@nxp.com>
      Signed-off-by: default avatarTang Bin <tangbin@cmss.chinamobile.com>
      Signed-off-by: default avatarShengju Zhang <zhangshengju@cmss.chinamobile.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      4cda340a
    • Qiushi Wu's avatar
      usb: gadget: fix potential double-free in m66592_probe. · 44734a59
      Qiushi Wu authored
      m66592_free_request() is called under label "err_add_udc"
      and "clean_up", and m66592->ep0_req is not set to NULL after
      first free, leading to a double-free. Fix this issue by
      setting m66592->ep0_req to NULL after the first free.
      
      Fixes: 0f91349b ("usb: gadget: convert all users to the new udc infrastructure")
      Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      44734a59
    • Dinghao Liu's avatar
      usb: cdns3: Fix runtime PM imbalance on error · e5b91349
      Dinghao Liu authored
      pm_runtime_get_sync() increments the runtime PM usage counter even
      when it returns an error code. Thus a pairing decrement is needed on
      the error handling path to keep the counter balanced.
      Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      e5b91349
    • Colin Ian King's avatar
      usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check · eafa8004
      Colin Ian King authored
      Currently pointer ep is being dereferenced before it is null checked
      leading to a null pointer dereference issue.  Fix this by only assigning
      pointer udc once ep is known to be not null.  Also remove a debug
      message that requires a valid udc which may not be possible at that
      point.
      
      Addresses-Coverity: ("Dereference before null check")
      Fixes: 24a28e42 ("USB: gadget driver for LPC32xx")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      eafa8004
    • Yu Chen's avatar
      usb: dwc3: Increase timeout for CmdAct cleared by device controller · 1c0e69ae
      Yu Chen authored
      If the SS PHY is in P3, there is no pipe_clk, HW may use suspend_clk
      for function, as suspend_clk is slow so EP command need more time to
      complete, e.g, imx8M suspend_clk is 32K, set ep configuration will
      take about 380us per below trace time stamp(44.286278 - 44.285897
      = 0.000381):
      
      configfs_acm.sh-822   [000] d..1    44.285896: dwc3_writel: addr
      000000006d59aae1 value 00000401
      configfs_acm.sh-822   [000] d..1    44.285897: dwc3_readl: addr
      000000006d59aae1 value 00000401
      ... ...
      configfs_acm.sh-822   [000] d..1    44.286278: dwc3_readl: addr
      000000006d59aae1 value 00000001
      configfs_acm.sh-822   [000] d..1    44.286279: dwc3_gadget_ep_cmd:
      ep0out: cmd 'Set Endpoint Configuration' [401] params 00001000
      00000500 00000000 --> status: Successful
      
      This was originally found on Hisilicon Kirin Soc that need more time
      for the device controller to clear the CmdAct of DEPCMD.
      Signed-off-by: default avatarYu Chen <chenyu56@huawei.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      1c0e69ae
    • Andrey Konovalov's avatar
      USB: dummy-hcd: use configurable endpoint naming scheme · eccba1ed
      Andrey Konovalov authored
      USB gadget subsystem uses the following naming convention for UDC
      endpoints:
      
      - "ep-a" names for fully configurable endpoints (address, direction and
        transfer type can be changed);
      
      - "ep1in", "ep12out-bulk" names for fixed function endpoints (fixed
        address, direction and/or transfer type).
      
      Dummy UDC endpoints are capable of full configuration, but named using
      the second scheme.
      
      This patch changes the names of generic Dummy UDC endpoints to "ep-aout",
      "ep-bin", etc., to advertise that they have configurable addresses and
      transfer types (except that Dummy UDC doesn't support ISO transfers), but
      fixed direction.
      
      This is required for Raw Gadget (and perhaps for some other drivers),
      that reasons about whether an endpoint has configurable address based
      on its name.
      Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      eccba1ed
    • Peter Chen's avatar
      usb: cdns3: gadget: assign interrupt number to USB gadget structure · 77f30ff4
      Peter Chen authored
      Assign interrupt number to USB gadget structure.
      Reviewed-by: default avatarJun Li <jun.li@nxp.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      77f30ff4
    • Peter Chen's avatar
      usb: gadget: core: sync interrupt before unbind the udc · 3c73bc52
      Peter Chen authored
      The threaded interrupt handler may still be called after the
      usb_gadget_disconnect is called, it causes the structures used
      at interrupt handler was freed before it uses, eg the
      usb_request. This issue usually occurs we remove the udc function
      during the transfer. Below is the example when doing stress
      test for android switch function, the EP0's request is freed
      by .unbind (configfs_composite_unbind -> composite_dev_cleanup),
      but the threaded handler accesses this request during handling
      setup packet request.
      
      In fact, there is no protection between unbind the udc
      and udc interrupt handling, so we have to avoid the interrupt
      handler is occurred or scheduled during the .unbind flow.
      
      init: Sending signal 9 to service 'adbd' (pid 18077) process group...
      android_work: did not send uevent (0 0 000000007bec2039)
      libprocessgroup: Successfully killed process cgroup uid 0 pid 18077 in 6ms
      init: Service 'adbd' (pid 18077) received signal 9
      init: Sending signal 9 to service 'adbd' (pid 18077) process group...
      libprocessgroup: Successfully killed process cgroup uid 0 pid 18077 in 0ms
      init: processing action (init.svc.adbd=stopped) from (/init.usb.configfs.rc:14)
      init: Received control message 'start' for 'adbd' from pid: 399 (/vendor/bin/hw/android.hardware.usb@1.
      
      init: starting service 'adbd'...
      read descriptors
      read strings
      Unable to handle kernel read from unreadable memory at virtual address 000000000000002a
      android_work: sent uevent USB_STATE=CONNECTED
      Mem abort info:
        ESR = 0x96000004
        EC = 0x25: DABT (current EL), IL = 32 bits
        SET = 0, FnV = 0
        EA = 0, S1PTW = 0
      Data abort info:
        ISV = 0, ISS = 0x00000004
        CM = 0, WnR = 0
      user pgtable: 4k pages, 48-bit VAs, pgdp=00000000e97f1000
      using random self ethernet address
      [000000000000002a] pgd=0000000000000000
      Internal error: Oops: 96000004 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 232 Comm: irq/68-5b110000 Not tainted 5.4.24-06075-g94a6b52b5815 #92
      Hardware name: Freescale i.MX8QXP MEK (DT)
      pstate: 00400085 (nzcv daIf +PAN -UAO)
      using random host ethernet address
      pc : composite_setup+0x5c/0x1730
      lr : android_setup+0xc0/0x148
      sp : ffff80001349bba0
      x29: ffff80001349bba0 x28: ffff00083a50da00
      x27: ffff8000124e6000 x26: ffff800010177950
      x25: 0000000000000040 x24: ffff000834e18010
      x23: 0000000000000000 x22: 0000000000000000
      x21: ffff00083a50da00 x20: ffff00082e75ec40
      x19: 0000000000000000 x18: 0000000000000000
      x17: 0000000000000000 x16: 0000000000000000
      x15: 0000000000000000 x14: 0000000000000000
      x13: 0000000000000000 x12: 0000000000000001
      x11: ffff80001180fb58 x10: 0000000000000040
      x9 : ffff8000120fc980 x8 : 0000000000000000
      x7 : ffff00083f98df50 x6 : 0000000000000100
      x5 : 00000307e8978431 x4 : ffff800011386788
      x3 : 0000000000000000 x2 : ffff800012342000
      x1 : 0000000000000000 x0 : ffff800010c6d3a0
      Call trace:
       composite_setup+0x5c/0x1730
       android_setup+0xc0/0x148
       cdns3_ep0_delegate_req+0x64/0x90
       cdns3_check_ep0_interrupt_proceed+0x384/0x738
       cdns3_device_thread_irq_handler+0x124/0x6e0
       cdns3_thread_irq+0x94/0xa0
       irq_thread_fn+0x30/0xa0
       irq_thread+0x150/0x248
       kthread+0xfc/0x128
       ret_from_fork+0x10/0x18
      Code: 910e8000 f9400693 12001ed7 79400f79 (3940aa61)
      ---[ end trace c685db37f8773fba ]---
      Kernel panic - not syncing: Fatal exception
      SMP: stopping secondary CPUs
      Kernel Offset: disabled
      CPU features: 0x0002,20002008
      Memory Limit: none
      Rebooting in 5 seconds..
      Reviewed-by: default avatarJun Li <jun.li@nxp.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      3c73bc52
    • Sandeep Maheswaram's avatar
      arm64: dts: qcom: sc7180: Add interconnect properties for USB · 5d48fe61
      Sandeep Maheswaram authored
      Populate USB DT nodes with interconnect properties.
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarSandeep Maheswaram <sanm@codeaurora.org>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      5d48fe61
    • Sandeep Maheswaram's avatar
      arm64: dts: qcom: sdm845: Add interconnect properties for USB · 11a8b115
      Sandeep Maheswaram authored
      Populate USB DT nodes with interconnect properties.
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarSandeep Maheswaram <sanm@codeaurora.org>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      11a8b115
    • Sandeep Maheswaram's avatar
      dt-bindings: usb: qcom,dwc3: Introduce interconnect properties for Qualcomm DWC3 driver · 1805cdde
      Sandeep Maheswaram authored
      Add documentation for the interconnects and interconnect-names
      properties for USB.
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarSandeep Maheswaram <sanm@codeaurora.org>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      1805cdde
    • Gregory CLEMENT's avatar
      ARM: dts: at91: Remove the USB EP child node · a5c4c29d
      Gregory CLEMENT authored
      The endpoint configuration used to be stored in the device tree,
      however the configuration depend on the "version" of the controller
      itself.
      
      Then the EP child node are useless and describe as deprecated in the
      documentation binding: remove all the nodes from the SoC device tree
      file. Remove also the #address-cells and #size-cells properties that
      are no longer needed.
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      a5c4c29d
    • Gregory CLEMENT's avatar
      dt-bindings: usb: atmel: Mark EP child node as deprecated · 4db120d9
      Gregory CLEMENT authored
      There is no need to describe the end point in the deice tree. These
      properties won't be use anymore, so mark them as deprecated to keep
      the old device tree documented.
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      4db120d9
    • Gregory CLEMENT's avatar
      usb: gadget: udc: atmel: Don't use DT to configure end point · e78355b5
      Gregory CLEMENT authored
      The endpoint configuration used to be stored in the device tree,
      however the configuration depend on the "version" of the controller
      itself.
      
      This information is already documented by the compatible string. It
      then possible to just rely on the compatible string and completely
      remove the full ep configuration done in the device tree as it was
      already the case for all the other USB device controller.
      Acked-by: default avatarCristian Birsan <cristian.birsan@microchip.com>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      e78355b5
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Use SET_EP_PRIME for NoStream · b10e1c25
      Thinh Nguyen authored
      DWC_usb32 v1.00a and later can use SET_EP_PRIME command to reinitiate a
      stream. Use the command to handle NoStream rejection instead of ending
      and restarting the endpoint.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      b10e1c25
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Handle stream transfers · 140ca4cf
      Thinh Nguyen authored
      Overview of stream transfer requirement:
       * A transfer will have a set of TRBs of the same stream ID.
       * A transfer is started with a stream ID in START_TRANSFER command.
       * A new stream will only start when the previous completes.
      
      Overview of stream events:
       * A "prime" from host indicates that its endpoints are active
         (buffers prepared and ready to receive/transmit data). The controller
         automatically initiates stream if it sees this.
       * A "NoStream" rejection event indicates that the host isn't ready.
         Host will put the endpoint back to idle state. Device may need to
         reinitiate the stream to start transfer again.
       * A Stream Found event means host accepted device initiated stream.
         Nothing needs to be done from driver.
      
      To initiate a stream, the driver will issue START_TRANSFER command with
      a stream ID. To reinitiate the stream, the driver must issue
      END_TRANSFER and restart the transfer with START_TRANSFER command with
      the same stream ID.
      
      This implementation handles device-initated streams (e.g. UASP driver).
      It also handles some hosts' quirky behavior where they only prime each
      endpoint once.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      140ca4cf
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Don't prepare beyond a transfer · aefe3d23
      Thinh Nguyen authored
      Don't prepare TRBs beyond a transfer. In DWC_usb32, its transfer burst
      capability may try to read and use TRBs beyond the active transfer. For
      other controllers, they don't process the next transfer TRBs until the
      current transfer is completed. Explicitly prevent preparing TRBs ahead
      for all controllers.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      aefe3d23
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Wait for transfer completion · e0d19563
      Thinh Nguyen authored
      If a transfer is in-progress, any new request should not kick off
      another transfer. The driver needs to wait for the current transfer to
      complete before starting off the next transfer. Introduce a new flag
      DWC3_EP_WAIT_TRANSFER_COMPLETE for this.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      e0d19563
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Handle XferComplete for streams · 3eaecd0c
      Thinh Nguyen authored
      In DWC3, to prepare TRBs for streams, all the TRBs of a transfer will
      use the same stream ID. To start a new stream, the driver needs to wait
      for the current transfer to complete or ended (by END_TRANFER command).
      As a result, inform the controller of the last TRB of a transfer so that
      it knows when a transfer completes and start a new transfer of a new
      stream.
      
      Even though the transfer completion handling can be applied for other
      non-isoc endpoints, only do it for streams due to its requirement.
      It's better to keep the controller's TRB cache full than waiting for
      transfer completion and starting a new transfer.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      3eaecd0c
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Enable XferComplete event · 548f8b31
      Thinh Nguyen authored
      To switch from one stream to another, this requires the driver to start
      a new transfer with a specific stream ID. For a transfer to complete,
      the driver needs to indicate the last TRB of a transfer, and it needs to
      enable XferComplete event to handle completed TRBs of a transfer. Let's
      enable this event only for stream capable endpoints.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      548f8b31
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Refactor TRB completion handler · 2e6e9e4b
      Thinh Nguyen authored
      To prepare for handling of XferComplete event, let's refactor and split
      up dwc3_gadget_endpoint_transfer_in_progress() to handle TRBs completion
      for different events. The handling of TRBs completion will be the same,
      but the status of XferComplete event is different than XferInProgress.
      No functional change in this commit.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      2e6e9e4b
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Check for in-progress END_TRANSFER · b6842d49
      Thinh Nguyen authored
      While handling TRBs completion, if a END_TRANSFER command isn't
      completed, don't kick new transfer or issue END_TRANSFER command.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      b6842d49
    • Thinh Nguyen's avatar
      usb: gadget: f_tcm: Inform last stream request · 27b31b91
      Thinh Nguyen authored
      Set the request->is_last to each stream request to indicate that the
      request is the last stream request of a transfer. The DWC3 controller
      needs to know this info to properly switch streams. The current
      implementation of f_tcm uses a single request per transfer, so every
      stream request is the last of its stream.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      27b31b91
    • Thinh Nguyen's avatar
      usb: gadget: Introduce usb_request->is_last · 5469fd64
      Thinh Nguyen authored
      To take advantage of DWC3 internal TRB prefetch and cache for
      performance, inform the controller the last request with stream_id
      before switching to a different stream transfer. This allows the
      controller to maintain its transfer burst within the stream ID.
      
      Introduce the usb-request is_last field to help inform the DWC3
      controller of this.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      5469fd64
    • Thinh Nguyen's avatar
      usb: dwc3: Get MDWIDTH for DWC_usb32 · 4244ba02
      Thinh Nguyen authored
      DWC_usb32 supports MDWIDTH value larger than 255 and up to 1023. The
      field HWPARAMS6[9:8] stores the upper 2-bit values of the DWC_usb32's
      MDWIDTH. Check that parameter and properly get the MDWIDTH for
      DWC_usb32.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      4244ba02
    • Thinh Nguyen's avatar
      usb: dwc3: Add support for DWC_usb32 IP · 9af21dd6
      Thinh Nguyen authored
      Synopsys introduces a new controller DWC_usb32. It supports dual-lane
      and speed up to 20 Gbps, and the DWC3 driver will drive this controller.
      Currently the driver uses a single field dwc->revision to ID both
      DWC_usb3 and DWC_usb31 and their version number. This was sufficient for
      two IPs, but this method doesn't work with additional IPs. As a result,
      let's separate the dwc->revision field to 2 separate fields: ip and
      revision. The ip field now stores the ID of the controller's IP while
      the revision field stores the controller's version number.
      
      This new scheme enforces DWC3 to compare the revision within the same IP
      only. As a result, we must update all the revision check of the
      controller to check its corresponding IP.
      
      To help with this enforcement, we create a few macros to help with
      the common version checks:
      
      DWC3_IP_IS(IP)
      DWC3_VER_IS(IP, VERSION)
      DWC3_VER_IS_PRIOR(IP, VERSION)
      DWC3_VER_IS_WITHIN(IP, LOWER_VERSION, UPPER_VERSION)
      DWC3_VER_TYPE_IS_WITHIN(IP, VERSION,
      			LOWER_VERSION_TYPE,
      			UPPER_VERSION_TYPE)
      
      The DWC_usb32 controller operates using the same programming model and
      with very similar configurations as its previous controllers. Please
      note that the various IP and revision checks in this patch match the
      current checks for DWC_usb31 version 1.90a. Additional configurations
      that are unique to DWC_usb32 are applied separately.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      9af21dd6
    • Nagarjuna Kristam's avatar
      usb: gadget: tegra-xudc: add port_speed_quirk · 88607a82
      Nagarjuna Kristam authored
      OTG port on Tegra194 supports GEN1 speeds when in device mode and GEN2
      speeds when in host mode. dd port_speed_quirk that configures port to
      GEN1/GEN2 speds, corresponding to the mode.
      
      Based on work by WayneChang <waynec@nvidia.com>
      Signed-off-by: default avatarNagarjuna Kristam <nkristam@nvidia.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      88607a82
    • Nagarjuna Kristam's avatar
      usb: gadget: tegra-xudc: Add Tegra194 support · 9584a60a
      Nagarjuna Kristam authored
      This commit adds support for XUSB device mode controller support on
      Tegra194 SoC. This is very similar to the existing Tegra186 XUDC, with lpm
      support added in addition.
      Signed-off-by: default avatarNagarjuna Kristam <nkristam@nvidia.com>
      Acked-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      9584a60a