]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'usb-for-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Nov 2019 07:24:12 +0000 (08:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Nov 2019 07:24:12 +0000 (08:24 +0100)
Felipe writes:

USB: changes for v5.5

We have TI's glue layer for the Cadence USB3 controller going
upstream. Tegra's XUDC driver is also going upstream with this pull
request.

Apart from these two big features, we have a bunch of patches switching
over to devm_platform_ioremap_resource() in order to simplify code a
little; and a non-critical fix for DWC3 usage via kexec.

* tag 'usb-for-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (44 commits)
  usb: dwc3: of-simple: add a shutdown
  usb: cdns3: Add TI specific wrapper driver
  dt-bindings: usb: Add binding for the TI wrapper for Cadence USB3 controller
  usb: mtu3: fix race condition about delayed_status
  usb: gadget: Add UDC driver for tegra XUSB device mode controller
  usb: dwc3: debug: Remove newline printout
  usb: dwc2: use a longer core rest timeout in dwc2_core_reset()
  usb: gadget: udc: lpc32xx: Use devm_platform_ioremap_resource() in lpc32xx_udc_probe()
  USB: gadget: udc: clean up an indentation issue
  usb: gadget: Quieten gadget config message
  phy: renesas: rcar-gen3-usb2: Use platform_get_irq_optional() for optional irq
  usb: gadget: Remove set but not used variable 'opts' in msg_do_config
  usb: gadget: Remove set but not used variable 'opts' in acm_ms_do_config
  usb: mtu3: add a new function to do status stage
  usb: gadget: configfs: fix concurrent issue between composite APIs
  usb: gadget: f_tcm: Provide support to get alternate setting in tcm function
  usb: gadget: Correct NULL pointer checking in fsl gadget
  usb: fsl: Remove unused variable
  USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein
  USB: dummy-hcd: increase max number of devices to 32
  ...

1  2 
drivers/usb/dwc3/core.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/udc/Kconfig
drivers/usb/gadget/udc/fsl_udc_core.c
drivers/usb/gadget/udc/lpc32xx_udc.c
drivers/usb/gadget/udc/renesas_usb3.c

diff --combined drivers/usb/dwc3/core.c
index 97d6ae3c4df2fc572f4fbae2f0d6aa9c513d1d88,2991e505660069fed0881f84d7663694249300c4..f561c6c9e8a9cf8aca635ed798d70ae116f4d895
@@@ -312,7 -312,8 +312,7 @@@ static void dwc3_frame_length_adjustmen
  
        reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
        dft = reg & DWC3_GFLADJ_30MHZ_MASK;
 -      if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj,
 -          "request value same as default, ignoring\n")) {
 +      if (dft != dwc->fladj) {
                reg &= ~DWC3_GFLADJ_30MHZ_MASK;
                reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj;
                dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
@@@ -566,8 -567,11 +566,11 @@@ static int dwc3_core_ulpi_init(struct d
   */
  static int dwc3_phy_setup(struct dwc3 *dwc)
  {
+       unsigned int hw_mode;
        u32 reg;
  
+       hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
        reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
  
        /*
        if (dwc->revision > DWC3_REVISION_194A)
                reg |= DWC3_GUSB3PIPECTL_SUSPHY;
  
+       /*
+        * For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be cleared after
+        * power-on reset, and it can be set after core initialization, which is
+        * after device soft-reset during initialization.
+        */
+       if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
+               reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
        if (dwc->u2ss_inp3_quirk)
                reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
  
        if (dwc->revision > DWC3_REVISION_194A)
                reg |= DWC3_GUSB2PHYCFG_SUSPHY;
  
+       /*
+        * For DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared after
+        * power-on reset, and it can be set after core initialization, which is
+        * after device soft-reset during initialization.
+        */
+       if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
+               reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
        if (dwc->dis_u2_susphy_quirk)
                reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
  
@@@ -902,9 -922,12 +921,12 @@@ static void dwc3_set_incr_burst_type(st
   */
  static int dwc3_core_init(struct dwc3 *dwc)
  {
+       unsigned int            hw_mode;
        u32                     reg;
        int                     ret;
  
+       hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
        /*
         * Write Linux Version Code to our GUID register so it's easy to figure
         * out which kernel version a bug was found.
        if (ret)
                goto err0a;
  
+       if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD &&
+           dwc->revision > DWC3_REVISION_194A) {
+               if (!dwc->dis_u3_susphy_quirk) {
+                       reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+                       reg |= DWC3_GUSB3PIPECTL_SUSPHY;
+                       dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+               }
+               if (!dwc->dis_u2_susphy_quirk) {
+                       reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
+                       reg |= DWC3_GUSB2PHYCFG_SUSPHY;
+                       dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
+               }
+       }
        dwc3_core_setup_global_control(dwc);
        dwc3_core_num_eps(dwc);
  
index 5ec54b69c29c58b1432b3c42b9d9bc58238db1d7,bb0c744d5b44440abc0e8c30886b3bcefd63ee53..3b4f67000315c952073068552669f2d10cc87d5d
@@@ -794,9 -794,9 +794,9 @@@ static int set_config(struct usb_compos
                result = 0;
        }
  
-       INFO(cdev, "%s config #%d: %s\n",
-            usb_speed_string(gadget->speed),
-            number, c ? c->label : "unconfigured");
+       DBG(cdev, "%s config #%d: %s\n",
+           usb_speed_string(gadget->speed),
+           number, c ? c->label : "unconfigured");
  
        if (!c)
                goto done;
@@@ -2170,18 -2170,14 +2170,18 @@@ void composite_dev_cleanup(struct usb_c
                        usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req);
  
                kfree(cdev->os_desc_req->buf);
 +              cdev->os_desc_req->buf = NULL;
                usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req);
 +              cdev->os_desc_req = NULL;
        }
        if (cdev->req) {
                if (cdev->setup_pending)
                        usb_ep_dequeue(cdev->gadget->ep0, cdev->req);
  
                kfree(cdev->req->buf);
 +              cdev->req->buf = NULL;
                usb_ep_free_request(cdev->gadget->ep0, cdev->req);
 +              cdev->req = NULL;
        }
        cdev->next_string_id = 0;
        device_remove_file(&cdev->gadget->dev, &dev_attr_suspended);
index f5a601a86af37cb100f2259b2f83bc601a6dff6c,c1f93647280c7bfa4e5f07e3b81cfa6799058482..acaec3ae6ad719acea1b33e7f61c5d40711b0f4c
@@@ -123,7 -123,7 +123,7 @@@ config USB_GR_UD
         tristate "Aeroflex Gaisler GRUSBDC USB Peripheral Controller Driver"
         depends on HAS_DMA
         help
 -          Select this to support Aeroflex Gaisler GRUSBDC cores from the GRLIB
 +        Select this to support Aeroflex Gaisler GRUSBDC cores from the GRLIB
          VHDL IP core library.
  
  config USB_OMAP
@@@ -441,6 -441,17 +441,17 @@@ config USB_GADGET_XILIN
          dynamically linked module called "udc-xilinx" and force all
          gadget drivers to also be dynamically linked.
  
+ config USB_TEGRA_XUDC
+       tristate "NVIDIA Tegra Superspeed USB 3.0 Device Controller"
+       depends on ARCH_TEGRA || COMPILE_TEST
+       depends on PHY_TEGRA_XUSB
+       help
+        Enables NVIDIA Tegra USB 3.0 device mode controller driver.
+        Say "y" to link the driver statically, or "m" to build a
+        dynamically linked module called "tegra_xudc" and force all
+        gadget drivers to also be dynamically linked.
  source "drivers/usb/gadget/udc/aspeed-vhub/Kconfig"
  
  #
index 7c8bea7c1695317e5dbcd14c8a127dcde27f0e01,334b160333a1c05dc3b61a2c380fb9b4a4bbf535..ec6eda4262230c5cf3e231cdd42891aea8b82d44
@@@ -1052,10 -1052,11 +1052,11 @@@ static int fsl_ep_fifo_status(struct us
        u32 bitmask;
        struct ep_queue_head *qh;
  
-       ep = container_of(_ep, struct fsl_ep, ep);
-       if (!_ep || (!ep->ep.desc && ep_index(ep) != 0))
+       if (!_ep || _ep->desc || !(_ep->desc->bEndpointAddress&0xF))
                return -ENODEV;
  
+       ep = container_of(_ep, struct fsl_ep, ep);
        udc = (struct fsl_udc *)ep->udc;
  
        if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN)
@@@ -1208,7 -1209,7 +1209,7 @@@ static int fsl_vbus_draw(struct usb_gad
  }
  
  /* Change Data+ pullup status
 - * this func is used by usb_gadget_connect/disconnet
 + * this func is used by usb_gadget_connect/disconnect
   */
  static int fsl_pullup(struct usb_gadget *gadget, int is_on)
  {
@@@ -1595,14 -1596,13 +1596,13 @@@ static int process_ep_req(struct fsl_ud
                struct fsl_req *curr_req)
  {
        struct ep_td_struct *curr_td;
-       int     td_complete, actual, remaining_length, j, tmp;
+       int     actual, remaining_length, j, tmp;
        int     status = 0;
        int     errors = 0;
        struct  ep_queue_head *curr_qh = &udc->ep_qh[pipe];
        int direction = pipe % 2;
  
        curr_td = curr_req->head;
-       td_complete = 0;
        actual = curr_req->req.length;
  
        for (j = 0; j < curr_req->dtd_count; j++) {
                                status = -EPROTO;
                                break;
                        } else {
-                               td_complete++;
                                break;
                        }
                } else {
-                       td_complete++;
                        VDBG("dTD transmitted successful");
                }
  
@@@ -2576,7 -2574,7 +2574,7 @@@ static int fsl_udc_remove(struct platfo
        dma_pool_destroy(udc_controller->td_pool);
        free_irq(udc_controller->irq, udc_controller);
        iounmap(dr_regs);
 -      if (pdata->operating_mode == FSL_USB2_DR_DEVICE)
 +      if (res && (pdata->operating_mode == FSL_USB2_DR_DEVICE))
                release_mem_region(res->start, resource_size(res));
  
        /* free udc --wait for the release() finished */
index bf6c81e2f8cccf9e2d6644d728141e7991749de9,4939343e8176115394c72d6df0df1d04e06e3490..d14b2bb3f67c7015d75343dd1bb7800d12a28146
@@@ -1177,11 -1177,11 +1177,11 @@@ static void udc_pop_fifo(struct lpc32xx
                        tmp = readl(USBD_RXDATA(udc->udp_baseaddr));
  
                        bl = bytes - n;
 -                      if (bl > 3)
 -                              bl = 3;
 +                      if (bl > 4)
 +                              bl = 4;
  
                        for (i = 0; i < bl; i++)
 -                              data[n + i] = (u8) ((tmp >> (n * 8)) & 0xFF);
 +                              data[n + i] = (u8) ((tmp >> (i * 8)) & 0xFF);
                }
                break;
  
@@@ -3000,7 -3000,6 +3000,6 @@@ static int lpc32xx_udc_probe(struct pla
        struct device *dev = &pdev->dev;
        struct lpc32xx_udc *udc;
        int retval, i;
-       struct resource *res;
        dma_addr_t dma_handle;
        struct device_node *isp1301_node;
  
         *  IORESOURCE_IRQ, USB device interrupt number
         *  IORESOURCE_IRQ, USB transceiver interrupt number
         */
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res)
-               return -ENXIO;
  
        spin_lock_init(&udc->lock);
  
                        return udc->udp_irq[i];
        }
  
-       udc->udp_baseaddr = devm_ioremap_resource(dev, res);
+       udc->udp_baseaddr = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(udc->udp_baseaddr)) {
                dev_err(udc->dev, "IO map failure\n");
                return PTR_ERR(udc->udp_baseaddr);
index 0895db5381b842b9e945b37a883999c659419ca3,3ba66a13d7891e393e692d982995d591bec7e948..c5c3c14df67acdd97903a2706c3b7777982fa7c8
@@@ -775,6 -775,18 +775,18 @@@ static void usb3_irq_epc_int_1_resume(s
        usb3_transition_to_default_state(usb3, false);
  }
  
+ static void usb3_irq_epc_int_1_suspend(struct renesas_usb3 *usb3)
+ {
+       usb3_disable_irq_1(usb3, USB_INT_1_B2_SPND);
+       if (usb3->gadget.speed != USB_SPEED_UNKNOWN &&
+           usb3->gadget.state != USB_STATE_NOTATTACHED) {
+               if (usb3->driver && usb3->driver->suspend)
+                       usb3->driver->suspend(&usb3->gadget);
+               usb_gadget_set_state(&usb3->gadget, USB_STATE_SUSPENDED);
+       }
+ }
  static void usb3_irq_epc_int_1_disable(struct renesas_usb3 *usb3)
  {
        usb3_stop_usb3_connection(usb3);
@@@ -860,6 -872,9 +872,9 @@@ static void usb3_irq_epc_int_1(struct r
        if (int_sta_1 & USB_INT_1_B2_RSUM)
                usb3_irq_epc_int_1_resume(usb3);
  
+       if (int_sta_1 & USB_INT_1_B2_SPND)
+               usb3_irq_epc_int_1_suspend(usb3);
        if (int_sta_1 & USB_INT_1_SPEED)
                usb3_irq_epc_int_1_speed(usb3);
  
@@@ -1544,10 -1559,10 +1559,10 @@@ static void usb3_set_device_address(str
  static bool usb3_std_req_set_address(struct renesas_usb3 *usb3,
                                     struct usb_ctrlrequest *ctrl)
  {
 -      if (ctrl->wValue >= 128)
 +      if (le16_to_cpu(ctrl->wValue) >= 128)
                return true;    /* stall */
  
 -      usb3_set_device_address(usb3, ctrl->wValue);
 +      usb3_set_device_address(usb3, le16_to_cpu(ctrl->wValue));
        usb3_set_p0_con_for_no_data(usb3);
  
        return false;
@@@ -1582,7 -1597,6 +1597,7 @@@ static bool usb3_std_req_get_status(str
        struct renesas_usb3_ep *usb3_ep;
        int num;
        u16 status = 0;
 +      __le16 tx_data;
  
        switch (ctrl->bRequestType & USB_RECIP_MASK) {
        case USB_RECIP_DEVICE:
        }
  
        if (!stall) {
 -              status = cpu_to_le16(status);
 +              tx_data = cpu_to_le16(status);
                dev_dbg(usb3_to_dev(usb3), "get_status: req = %p\n",
                        usb_req_to_usb3_req(usb3->ep0_req));
 -              usb3_pipe0_internal_xfer(usb3, &status, sizeof(status),
 +              usb3_pipe0_internal_xfer(usb3, &tx_data, sizeof(tx_data),
                                         usb3_pipe0_get_status_completion);
        }
  
@@@ -1773,7 -1787,7 +1788,7 @@@ static bool usb3_std_req_set_sel(struc
  static bool usb3_std_req_set_configuration(struct renesas_usb3 *usb3,
                                           struct usb_ctrlrequest *ctrl)
  {
 -      if (ctrl->wValue > 0)
 +      if (le16_to_cpu(ctrl->wValue) > 0)
                usb3_set_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON);
        else
                usb3_clear_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON);
@@@ -2536,7 -2550,7 +2551,7 @@@ static const struct file_operations ren
  static void renesas_usb3_debugfs_init(struct renesas_usb3 *usb3,
                                      struct device *dev)
  {
 -      usb3->dentry = debugfs_create_dir(dev_name(dev), NULL);
 +      usb3->dentry = debugfs_create_dir(dev_name(dev), usb_debug_root);
  
        debugfs_create_file("b_device", 0644, usb3->dentry, usb3,
                            &renesas_usb3_b_device_fops);