usb: dwc3: sync code with Linux v6.16
Subsystems (9)
v5 cover usb: dwc3: sync code with Linux v6.16
Hi,
This series syncs the DWC3 USB driver with Linux v6.16.
The driver was forked from the kernel v3.19-rc1 eleven years ago, in commit 85d5e7075f33 ("usb: dwc3: add dwc3 folder from linux kernel to u-boot"). After that almost no kernel changes came back to U-Boot.
I split the work in three steps, so it is easy to follow:
1. Restore drivers/usb/dwc3 to a clean v3.19-rc1 state.
2. Import the dwc3 directory once per major kernel version, from v3.19 up to v6.16. Each commit is a raw snapshot from that kernel.
3. Add back the U-Boot glue, the XHCI/UDC updates and the build fixes. This part builds on Jerome's work.
The import commits are raw kernel snapshots. They do not build on their own, only the full series builds. This is on purpose. It makes it easy to see what comes from which kernel version, and to compare each import with the matching kernel release. The commit messages say this too.
This is compile-tested only.
The series needs the dwc2 endpoint fixes from Mattijs [3]. They are already on the list and should go in first.
The branch is also available at [4].
[1] v4: https://lore.kernel.org/u-boot/[email protected]/
[2] Jerome's adaptation work: https://lore.kernel.org/all/[email protected]/
[3] dwc2 prep: https://lore.kernel.org/all/[email protected]/
[4] https://github.com/roxell/u-boot/tree/usb_dwc3_sync_v5
v4 -> v5:
- Split the big "fix build after resync" patch into smaller patches, one per area, so it is easier to review. Marek and Mattijs asked for this.
- Dropped the Tested-by tags from the import patches. They were only tested as a full series, not one by one.
- Removed the merge commits from the "import from kernel vN" changelogs.
- Some small cleanups in the new helpers: dropped a dead function, added a missing NULL check and changed spaces to tabs.
- Rebased on latest master.
Older changes are listed in v4 [1].
Cheers,
Anders
Anders Roxell (12):
usb: add helpers needed by the resynced DWC3 code
usb: gadget: trim the gadget API after the resync
usb: gadget: udc: make udc-core build in u-boot
usb: dwc3: make the core driver build in u-boot
usb: dwc3: make gadget and ep0 build in u-boot
usb: dwc3: make the am62 glue build in u-boot
usb: gadget: ci_udc: drop code we do not use
usb: gadget: dwc2_udc_otg: fix up after the resync
usb: gadget: fix up the function drivers after the resync
usb: gadget: fix up the last UDC drivers after the resync
usb: fix up musb-new and mtu3 after the resync
usb: host: fix up xhci and cdns3 after the resync
Jens Wiklander (60):
usb: dwc3: restore to original v3.19-rc1 kernel import
usb: dwc3: import from kernel v3.19
usb: dwc3: import from kernel v4.0
usb: dwc3: import from kernel v4.1
usb: dwc3: import from kernel v4.2
usb: dwc3: import from kernel v4.3
usb: dwc3: import from kernel v4.4
usb: dwc3: import from kernel v4.5
usb: dwc3: import from kernel v4.6
usb: dwc3: import from kernel v4.7
usb: dwc3: import from kernel v4.8
usb: dwc3: import from kernel v4.9
usb: dwc3: import from kernel v4.10
usb: dwc3: import from kernel v4.11
usb: dwc3: import from kernel v4.12
usb: dwc3: import from kernel v4.13
usb: dwc3: import from kernel v4.14
usb: dwc3: import from kernel v4.15
usb: dwc3: import from kernel v4.16
usb: dwc3: import from kernel v4.17
usb: dwc3: import from kernel v4.18
usb: dwc3: import from kernel v4.19
usb: dwc3: import from kernel v4.20
usb: dwc3: import from kernel v5.0
usb: dwc3: import from kernel v5.1
usb: dwc3: import from kernel v5.2
usb: dwc3: import from kernel v5.3
usb: dwc3: import from kernel v5.4
usb: dwc3: import from kernel v5.5
usb: dwc3: import from kernel v5.6
usb: dwc3: import from kernel v5.7
usb: dwc3: import from kernel v5.8
usb: dwc3: import from kernel v5.9
usb: dwc3: import from kernel v5.10
usb: dwc3: import from kernel v5.11
usb: dwc3: import from kernel v5.12
usb: dwc3: import from kernel v5.13
usb: dwc3: import from kernel v5.14
usb: dwc3: import from kernel v5.15
usb: dwc3: import from kernel v5.16
usb: dwc3: import from kernel v5.17
usb: dwc3: import from kernel v5.18
usb: dwc3: import from kernel v5.19
usb: dwc3: import from kernel v6.0
usb: dwc3: import from kernel v6.1
usb: dwc3: import from kernel v6.2
usb: dwc3: import from kernel v6.3
usb: dwc3: import from kernel v6.4
usb: dwc3: import from kernel v6.5
usb: dwc3: import from kernel v6.6
usb: dwc3: import from kernel v6.7
usb: dwc3: import from kernel v6.8
usb: dwc3: import from kernel v6.9
usb: dwc3: import from kernel v6.10
usb: dwc3: import from kernel v6.11
usb: dwc3: import from kernel v6.12
usb: dwc3: import from kernel v6.13
usb: dwc3: import from kernel v6.14
usb: dwc3: import from kernel v6.15
usb: dwc3: import from kernel v6.16
Jerome Forissier (3):
usb: host: re-import xhci-ext-caps.h from kernel v6.16
usb: gadget: re-import epautoconf.c from kernel v6.16
usb: udc: re-import udc-core.c from kernel v6.16
drivers/usb/cdns3/ep0.c | 8 +- drivers/usb/dwc3/Makefile | 57 +- drivers/usb/dwc3/core.c | 1710 ++++++---- drivers/usb/dwc3/core.h | 1060 ++++-- drivers/usb/dwc3/debug.h | 432 +++ drivers/usb/dwc3/dwc3-omap.c | 2 - drivers/usb/dwc3/ep0.c | 737 ++-- drivers/usb/dwc3/gadget.c | 4256 ++++++++++++++++-------- drivers/usb/dwc3/gadget.h | 112 +- drivers/usb/dwc3/glue.h | 36 + drivers/usb/dwc3/io.h | 29 +- drivers/usb/dwc3/linux-compat.h | 16 - drivers/usb/dwc3/samsung_usb_phy.c | 77 - drivers/usb/dwc3/ti_usb_phy.c | 2 - drivers/usb/gadget/at91_udc.c | 46 - drivers/usb/gadget/atmel_usba_udc.c | 102 +- drivers/usb/gadget/ci_udc.c | 470 --- drivers/usb/gadget/composite.c | 2 +- drivers/usb/gadget/dwc2_udc_otg.c | 174 +- drivers/usb/gadget/epautoconf.c | 289 +- drivers/usb/gadget/ether.c | 21 +- drivers/usb/gadget/f_acm.c | 20 +- drivers/usb/gadget/f_fastboot.c | 10 +- drivers/usb/gadget/f_mass_storage.c | 5 +- drivers/usb/gadget/f_rockusb.c | 11 +- drivers/usb/gadget/f_sdp.c | 12 +- drivers/usb/gadget/f_thor.c | 19 +- drivers/usb/gadget/udc/Makefile | 1 + drivers/usb/gadget/udc/udc-core.c | 1099 +++++- drivers/usb/host/xhci-dwc3.c | 4 +- drivers/usb/host/xhci-ext-caps.h | 158 + drivers/usb/host/xhci-exynos5.c | 2 +- drivers/usb/mtu3/mtu3_gadget_ep0.c | 16 +- drivers/usb/musb-new/musb_gadget_ep0.c | 24 +- drivers/usb/musb-new/musb_uboot.c | 39 - include/dm/device_compat.h | 13 + include/dm/read.h | 51 + include/linux/compat.h | 15 + include/linux/usb/ch9.h | 25 +- include/linux/usb/gadget.h | 520 +-- include/linux/usb/phy.h | 56 + 41 files changed, 7563 insertions(+), 4175 deletions(-) create mode 100644 drivers/usb/dwc3/debug.h create mode 100644 drivers/usb/dwc3/glue.h delete mode 100644 drivers/usb/dwc3/linux-compat.h delete mode 100644 drivers/usb/dwc3/samsung_usb_phy.c create mode 100644 drivers/usb/host/xhci-ext-caps.h
Signature · 1 line
2.53.0
PATCH v5 1/75 usb: dwc3: restore to original v3.19-rc1 kernel import
From: Jens Wiklander <[email protected]>
Restore the dwc3 source files to the state of the original import in commit 85d5e7075f33 ("usb: dwc3: add dwc3 folder from linux kernel to u-boot").
[Anders: rebased on origin/master. dwc3-am62.c conflicted here - this commit deletes it but upstream had changed it. Kept the delete, the file comes back in a later commit.]
--- drivers/usb/dwc3/core.c | 1090 ++++++++++++---------------- drivers/usb/dwc3/core.h | 231 ++---- drivers/usb/dwc3/debug.c | 32 + drivers/usb/dwc3/debug.h | 228 ++++++ drivers/usb/dwc3/dwc3-am62.c | 125 ---- drivers/usb/dwc3/ep0.c | 217 +++--- drivers/usb/dwc3/gadget.c | 502 +++++++------ drivers/usb/dwc3/gadget.h | 30 +- drivers/usb/dwc3/io.h | 54 +- drivers/usb/dwc3/linux-compat.h | 16 - drivers/usb/dwc3/platform_data.h | 47 ++ drivers/usb/dwc3/samsung_usb_phy.c | 77 -- 12 files changed, 1250 insertions(+), 1399 deletions(-) create mode 100644 drivers/usb/dwc3/debug.c create mode 100644 drivers/usb/dwc3/debug.h delete mode 100644 drivers/usb/dwc3/dwc3-am62.c delete mode 100644 drivers/usb/dwc3/linux-compat.h create mode 100644 drivers/usb/dwc3/platform_data.h delete mode 100644 drivers/usb/dwc3/samsung_usb_phy.c
drivers/usb/dwc3/core.c +476 -614
@@ -1,48 +1,55 @@ -// SPDX-License-Identifier: GPL-2.0 /** * core.c - DesignWare USB3 DRD Controller Core file * -* Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/core.c) and ported -* to uboot. +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 of +* the License as published by the Free Software Foundation. * -* commit cd72f890d2 : usb: dwc3: core: enable phy suspend quirk on non-FPGA +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <clk.h> -#include <cpu_func.h> -#include <malloc.h> -#include <dwc3-uboot.h> -#include <dm/device_compat.h> -#include <dm/devres.h> -#include <linux/bug.h> +#include <linux/version.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/spinlock.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include <linux/interrupt.h> +#include <linux/ioport.h> +#include <linux/io.h> +#include <linux/list.h> #include <linux/delay.h> #include <linux/dma-mapping.h> -#include <linux/err.h> -#include <linux/iopoll.h> -#include <linux/ioport.h> -#include <dm.h> -#include <generic-phy.h> +#include <linux/of.h> +#include <linux/acpi.h> +#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> -#include <linux/bitfield.h> -#include <linux/math64.h> -#include <linux/time.h> +#include <linux/usb/of.h> +#include <linux/usb/otg.h> +#include "platform_data.h" #include "core.h" #include "gadget.h" #include "io.h" -#include "linux-compat.h" +#include "debug.h" -static LIST_HEAD (dwc3_list);/* -------------------------------------------------------------------------- */ -static void dwc3_set_mode (struct dwc3 *dwc,u32 mode) +void dwc3_set_mode (struct dwc3 *dwc,u32 mode) {u32 reg;
@@ -59,144 +66,54 @@ static void dwc3_set_mode(struct dwc3 *dwc, u32 mode)static int dwc3_core_soft_reset (struct dwc3 *dwc) {u32 reg; -int retries =1000 ; +int ret; -/* -* We're resetting only the device side because, if we're in host mode, -* XHCI driver will reset the host block. If dwc3 was configured for -* host-only mode, then we can return early. -*/ -if (dwc->dr_mode ==USB_DR_MODE_HOST ) -return 0 ; - - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); - reg |=DWC3_DCTL_CSFTRST ; - reg &= ~DWC3_DCTL_RUN_STOP ; -dwc3_gadget_dctl_write_safe (dwc, reg); - -/* -* For DWC_usb31 controller 1.90a and later, the DCTL.CSFRST bit -* is cleared only after all the clocks are synchronized. This can -* take a little more than 50ms. Set the polling rate at 20ms -* for 10 times instead. -*/ - if (DWC3_VER_IS_WITHIN(DWC31, 190A, ANY) || DWC3_IP_IS(DWC32)) - retries =10 ; - -do { - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); -if (!(reg &DWC3_DCTL_CSFTRST )) - goto done; +/* Before Resetting PHY, put Core in Reset */ + reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg |=DWC3_GCTL_CORESOFTRESET ; +dwc3_writel (dwc->regs,DWC3_GCTL , reg); - if (DWC3_VER_IS_WITHIN(DWC31, 190A, ANY) || DWC3_IP_IS(DWC32)) -mdelay (20 ); -else -udelay (1 ); - }while (--retries); +/* Assert USB3 PHY reset */ + reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); + reg |=DWC3_GUSB3PIPECTL_PHYSOFTRST ; +dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); -dev_warn (dwc->dev,"DWC3 controller soft reset failed.\n" ); -return -ETIMEDOUT ; +/* Assert USB2 PHY reset */ + reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); + reg |=DWC3_GUSB2PHYCFG_PHYSOFTRST ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -done: -/* -* For DWC_usb31 controller 1.80a and prior, once DCTL.CSFRST bit -* is cleared, we must wait at least 50ms before accessing the PHY -* domain (synchronization delay). -*/ - if (DWC3_VER_IS_WITHIN(DWC31, ANY, 180A)) -mdelay (50 ); +usb_phy_init (dwc->usb2_phy); +usb_phy_init (dwc->usb3_phy); + ret =phy_init (dwc->usb2_generic_phy); +if (ret <0 ) +return ret; + ret =phy_init (dwc->usb3_generic_phy); +if (ret <0 ) { +phy_exit (dwc->usb2_generic_phy); +return ret; + }mdelay (100 ); -return 0 ; -} - -/* -* dwc3_frame_length_adjustment - Adjusts frame length if required -* @dwc3: Pointer to our controller context structure -* @fladj: Value of GFLADJ_30MHZ to adjust frame length -*/ -static void dwc3_frame_length_adjustment (struct dwc3 *dwc,u32 fladj) -{ -u32 reg; - -if (dwc->revision <DWC3_REVISION_250A ) -return ; - -if (fladj ==0 ) -return ; - - reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); - reg &= ~DWC3_GFLADJ_30MHZ_MASK ; - reg |=DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj; -dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); -} - -/** -* dwc3_ref_clk_period - Reference clock period configuration -* Default reference clock period depends on hardware -* configuration. For systems with reference clock that differs -* from the default, this will set clock period in DWC3_GUCTL -* register. -* @dwc: Pointer to our controller context structure -* @ref_clk_per: reference clock period in ns -*/ -static void dwc3_ref_clk_period (struct dwc3 *dwc) -{ -unsigned long period; -unsigned long fladj; -unsigned long decr; -unsigned long rate; -u32 reg; - -if (dwc->ref_clk) { - rate =clk_get_rate (dwc->ref_clk); -if (!rate) -return ; - period =NSEC_PER_SEC / rate; - }else { -return ; - } +/* Clear USB3 PHY reset */ + reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); + reg &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST ; +dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); - reg =dwc3_readl (dwc->regs,DWC3_GUCTL ); - reg &= ~DWC3_GUCTL_REFCLKPER_MASK ; - reg |=FIELD_PREP (DWC3_GUCTL_REFCLKPER_MASK , period); -dwc3_writel (dwc->regs,DWC3_GUCTL , reg); +/* Clear USB2 PHY reset */ + reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); + reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -if (dwc->revision <=DWC3_REVISION_250A ) -return ; +mdelay (100 ); -/* -* The calculation below is -* -* 125000 * (NSEC_PER_SEC / (rate * period) - 1) -* -* but rearranged for fixed-point arithmetic. The division must be -* 64-bit because 125000 * NSEC_PER_SEC doesn't fit in 32 bits (and -* neither does rate * period). -* -* Note that rate * period ~= NSEC_PER_SECOND, minus the number of -* nanoseconds of error caused by the truncation which happened during -* the division when calculating rate or period (whichever one was -* derived from the other). We first calculate the relative error, then -* scale it to units of 8 ppm. -*/ - fladj =div64_u64 (125000ULL *NSEC_PER_SEC , (u64 )rate * period); - fladj -=125000 ; +/* After PHYs are stable we can take Core out of reset state */ + reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg &= ~DWC3_GCTL_CORESOFTRESET ; +dwc3_writel (dwc->regs,DWC3_GCTL , reg); -/* -* The documented 240MHz constant is scaled by 2 to get PLS1 as well. -*/ - decr =480000000 / rate; - - reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); - reg &= ~DWC3_GFLADJ_REFCLK_FLADJ_MASK - & ~DWC3_GFLADJ_240MHZDECR - & ~DWC3_GFLADJ_240MHZDECR_PLS1 ; - reg |=FIELD_PREP (DWC3_GFLADJ_REFCLK_FLADJ_MASK , fladj) - |FIELD_PREP (DWC3_GFLADJ_240MHZDECR , decr >>1 ) - |FIELD_PREP (DWC3_GFLADJ_240MHZDECR_PLS1 , decr &1 ); -dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); +return 0 ; }/**
@@ -207,7 +124,7 @@ static void dwc3_ref_clk_period(struct dwc3 *dwc)static void dwc3_free_one_event_buffer (struct dwc3 *dwc,struct dwc3_event_buffer *evt) { -dma_free_coherent (evt->buf); +dma_free_coherent (dwc->dev, evt->length, evt->buf, evt->dma); }/**
@@ -223,20 +140,17 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, {struct dwc3_event_buffer *evt; - evt =devm_kzalloc ((struct udevice *)dwc->dev,sizeof (*evt), -GFP_KERNEL ); + evt =devm_kzalloc (dwc->dev,sizeof (*evt),GFP_KERNEL );if (!evt)return ERR_PTR (-ENOMEM ); evt->dwc = dwc; evt->length = length; - evt->buf =dma_alloc_coherent (length, - (unsigned long *)&evt->dma); + evt->buf =dma_alloc_coherent (dwc->dev, length, + &evt->dma,GFP_KERNEL );if (!evt->buf)return ERR_PTR (-ENOMEM ); -dwc3_flush_cache ((uintptr_t )evt->buf, evt->length); -return evt; }
@@ -254,8 +168,6 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)if (evt)dwc3_free_one_event_buffer (dwc, evt); } - -free (dwc->ev_buffs); }/**
@@ -274,8 +186,8 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) num =DWC3_NUM_INT (dwc->hwparams.hwparams1); dwc->num_event_buffers = num; - dwc->ev_buffs =memalign (CONFIG_SYS_CACHELINE_SIZE , -sizeof (*dwc->ev_buffs) * num); + dwc->ev_buffs =devm_kzalloc (dwc->dev,sizeof (*dwc->ev_buffs) * num, +GFP_KERNEL );if (!dwc->ev_buffs)return -ENOMEM ;
@@ -370,9 +282,13 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)if (!dwc->nr_scratch)return 0 ; - scratch_addr =dma_map_single (dwc->scratchbuf, - dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE , -DMA_BIDIRECTIONAL ); +/* should never fall here */ +if (!WARN_ON (dwc->scratchbuf)) +return 0 ; + + scratch_addr =dma_map_single (dwc->dev, dwc->scratchbuf, + dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE , +DMA_BIDIRECTIONAL );if (dma_mapping_error (dwc->dev, scratch_addr)) {dev_err (dwc->dev,"failed to map scratch buffer\n" ); ret = -EFAULT ;
@@ -398,8 +314,8 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)return 0 ; err1: -dma_unmap_single (scratch_addr, dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE , -DMA_BIDIRECTIONAL ); +dma_unmap_single (dwc->dev, dwc->scratch_addr, dwc->nr_scratch * +DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); err0:return ret;
@@ -413,8 +329,12 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)if (!dwc->nr_scratch)return ; -dma_unmap_single (dwc->scratch_addr, dwc->nr_scratch * -DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); +/* should never fall here */ +if (!WARN_ON (dwc->scratchbuf)) +return ; + +dma_unmap_single (dwc->dev, dwc->scratch_addr, dwc->nr_scratch * +DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL );kfree (dwc->scratchbuf); }
@@ -444,34 +364,6 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc) parms->hwparams8 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS8 ); } -static void dwc3_hsphy_mode_setup (struct dwc3 *dwc) -{ -enum usb_phy_interface hsphy_mode = dwc->hsphy_mode; -u32 reg; - -/* Set dwc3 usb2 phy config */ - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); - -switch (hsphy_mode) { -case USBPHY_INTERFACE_MODE_UTMI : - reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | -DWC3_GUSB2PHYCFG_USBTRDTIM_MASK ); - reg |=DWC3_GUSB2PHYCFG_PHYIF (UTMI_PHYIF_8_BIT ) | -DWC3_GUSB2PHYCFG_USBTRDTIM (USBTRDTIM_UTMI_8_BIT ); -break ; -case USBPHY_INTERFACE_MODE_UTMIW : - reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | -DWC3_GUSB2PHYCFG_USBTRDTIM_MASK ); - reg |=DWC3_GUSB2PHYCFG_PHYIF (UTMI_PHYIF_16_BIT ) | -DWC3_GUSB2PHYCFG_USBTRDTIM (USBTRDTIM_UTMI_16_BIT ); -break ; -default : -break ; - } - -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -} -/** * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -515,13 +407,8 @@ static void dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_u3_susphy_quirk) reg &= ~DWC3_GUSB3PIPECTL_SUSPHY ; -if (dwc->dis_del_phy_power_chg_quirk) - reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE ; -dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); -dwc3_hsphy_mode_setup (dwc); -mdelay (100 ); reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 ));
@@ -538,84 +425,11 @@ static void dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_u2_susphy_quirk) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ; -if (dwc->dis_enblslpm_quirk) - reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; - -if (dwc->dis_u2_freeclk_exists_quirk) - reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg);mdelay (100 ); } -/* set global incr burst type configuration registers */ -static void dwc3_set_incr_burst_type (struct dwc3 *dwc) -{ -struct udevice *dev = dwc->dev; -u32 cfg; - -if (!dwc->incrx_size) -return ; - - cfg =dwc3_readl (dwc->regs,DWC3_GSBUSCFG0 ); - -/* Enable Undefined Length INCR Burst and Enable INCRx Burst */ - cfg &= ~DWC3_GSBUSCFG0_INCRBRST_MASK ; -if (dwc->incrx_mode) - cfg |=DWC3_GSBUSCFG0_INCRBRSTENA ; -switch (dwc->incrx_size) { -case 256 : - cfg |=DWC3_GSBUSCFG0_INCR256BRSTENA ; -break ; -case 128 : - cfg |=DWC3_GSBUSCFG0_INCR128BRSTENA ; -break ; -case 64 : - cfg |=DWC3_GSBUSCFG0_INCR64BRSTENA ; -break ; -case 32 : - cfg |=DWC3_GSBUSCFG0_INCR32BRSTENA ; -break ; -case 16 : - cfg |=DWC3_GSBUSCFG0_INCR16BRSTENA ; -break ; -case 8 : - cfg |=DWC3_GSBUSCFG0_INCR8BRSTENA ; -break ; -case 4 : - cfg |=DWC3_GSBUSCFG0_INCR4BRSTENA ; -break ; -case 1 : -break ; -default : -dev_err (dev,"Invalid property\n" ); -break ; - } - -dwc3_writel (dwc->regs,DWC3_GSBUSCFG0 , cfg); -} - -static bool dwc3_core_is_valid (struct dwc3 *dwc) -{ -u32 reg; - - reg =dwc3_readl (dwc->regs,DWC3_GSNPSID ); - dwc->ip =DWC3_GSNPS_ID (reg); - -/* This should read as U3 followed by revision number */ -if (DWC3_IP_IS (DWC3 )) { - dwc->revision = reg; - }else if (DWC3_IP_IS (DWC31 ) ||DWC3_IP_IS (DWC32 )) { - dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); - dwc->version_type =dwc3_readl (dwc->regs,DWC3_VER_TYPE ); - }else { -return false; - } - -return true; -} -/** * dwc3_core_init - Low-level initialization of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -624,15 +438,25 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc)*/ static int dwc3_core_init (struct dwc3 *dwc) { +unsigned long timeout;u32 hwparams4 = dwc->hwparams.hwparams4;u32 reg;int ret; -if (!dwc3_core_is_valid (dwc)) { + reg =dwc3_readl (dwc->regs,DWC3_GSNPSID ); +/* This should read as U3 followed by revision number */ +if ((reg &DWC3_GSNPSID_MASK ) !=0x55330000 ) {dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); ret = -ENODEV ; goto err0; } + dwc->revision = reg; + +/* +* Write Linux Version Code to our GUID register so it's easy to figure +* out which kernel version a bug was found. +*/ +dwc3_writel (dwc->regs,DWC3_GUID ,LINUX_VERSION_CODE );/* Handle USB2.0-only core configuration */ if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
@@ -642,17 +466,21 @@ static int dwc3_core_init(struct dwc3 *dwc) }/* issue device SoftReset too */ + timeout = jiffies +msecs_to_jiffies (500 );dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); - ret =read_poll_timeout (dwc3_readl, reg, - !(reg &DWC3_DCTL_CSFTRST ), -1 ,5000 , dwc->regs,DWC3_DCTL ); -if (ret) { -dev_err (dwc->dev,"Reset Timed Out\n" ); - ret = -ETIMEDOUT ; - goto err0; - } +do { + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); +if (!(reg &DWC3_DCTL_CSFTRST )) +break ; -dwc3_phy_setup (dwc); +if (time_after (jiffies, timeout)) { +dev_err (dwc->dev,"Reset Timed Out\n" ); + ret = -ETIMEDOUT ; + goto err0; + } + +cpu_relax (); + }while (true); ret =dwc3_core_soft_reset (dwc);if (ret)
@@ -703,9 +531,8 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc->is_fpga = true; } -if (dwc->disable_scramble_quirk && !dwc->is_fpga) -WARN (true, -"disable_scramble cannot be used on non-FPGA builds\n" ); +WARN_ONCE (dwc->disable_scramble_quirk && !dwc->is_fpga, +"disable_scramble cannot be used on non-FPGA builds\n" );if (dwc->disable_scramble_quirk && dwc->is_fpga) reg |=DWC3_GCTL_DISSCRAMBLE ;
@@ -728,27 +555,27 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GCTL , reg); +dwc3_phy_setup (dwc); + ret =dwc3_alloc_scratch_buffers (dwc);if (ret) - goto err0; + goto err1; ret =dwc3_setup_scratch_buffers (dwc);if (ret) - goto err1; - -/* Adjust Frame Length */ -dwc3_frame_length_adjustment (dwc, dwc->fladj); - -/* Adjust Reference Clock Period */ -dwc3_ref_clk_period (dwc); - -dwc3_set_incr_burst_type (dwc); + goto err2;return 0 ; -err1: +err2:dwc3_free_scratch_buffers (dwc); +err1: +usb_phy_shutdown (dwc->usb2_phy); +usb_phy_shutdown (dwc->usb3_phy); +phy_exit (dwc->usb2_generic_phy); +phy_exit (dwc->usb3_generic_phy); + err0:return ret; }
@@ -756,10 +583,82 @@ err0:static void dwc3_core_exit (struct dwc3 *dwc) {dwc3_free_scratch_buffers (dwc); +usb_phy_shutdown (dwc->usb2_phy); +usb_phy_shutdown (dwc->usb3_phy); +phy_exit (dwc->usb2_generic_phy); +phy_exit (dwc->usb3_generic_phy); +} + +static int dwc3_core_get_phy (struct dwc3 *dwc) +{ +struct device *dev = dwc->dev; +struct device_node *node = dev->of_node; +int ret; + +if (node) { + dwc->usb2_phy =devm_usb_get_phy_by_phandle (dev,"usb-phy" ,0 ); + dwc->usb3_phy =devm_usb_get_phy_by_phandle (dev,"usb-phy" ,1 ); + }else { + dwc->usb2_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 ); + dwc->usb3_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB3 ); + } + +if (IS_ERR (dwc->usb2_phy)) { + ret =PTR_ERR (dwc->usb2_phy); +if (ret == -ENXIO || ret == -ENODEV ) { + dwc->usb2_phy =NULL ; + }else if (ret == -EPROBE_DEFER ) { +return ret; + }else { +dev_err (dev,"no usb2 phy configured\n" ); +return ret; + } + } + +if (IS_ERR (dwc->usb3_phy)) { + ret =PTR_ERR (dwc->usb3_phy); +if (ret == -ENXIO || ret == -ENODEV ) { + dwc->usb3_phy =NULL ; + }else if (ret == -EPROBE_DEFER ) { +return ret; + }else { +dev_err (dev,"no usb3 phy configured\n" ); +return ret; + } + } + + dwc->usb2_generic_phy =devm_phy_get (dev,"usb2-phy" ); +if (IS_ERR (dwc->usb2_generic_phy)) { + ret =PTR_ERR (dwc->usb2_generic_phy); +if (ret == -ENOSYS || ret == -ENODEV ) { + dwc->usb2_generic_phy =NULL ; + }else if (ret == -EPROBE_DEFER ) { +return ret; + }else { +dev_err (dev,"no usb2 phy configured\n" ); +return ret; + } + } + + dwc->usb3_generic_phy =devm_phy_get (dev,"usb3-phy" ); +if (IS_ERR (dwc->usb3_generic_phy)) { + ret =PTR_ERR (dwc->usb3_generic_phy); +if (ret == -ENOSYS || ret == -ENODEV ) { + dwc->usb3_generic_phy =NULL ; + }else if (ret == -EPROBE_DEFER ) { +return ret; + }else { +dev_err (dev,"no usb3 phy configured\n" ); +return ret; + } + } + +return 0 ; }static int dwc3_core_init_mode (struct dwc3 *dwc) { +struct device *dev = dwc->dev;int ret;switch (dwc->dr_mode) {
@@ -767,7 +666,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE ); ret =dwc3_gadget_init (dwc);if (ret) { -dev_err (dwc->dev,"failed to initialize gadget\n" ); +dev_err (dev,"failed to initialize gadget\n" );return ret; }break ;
@@ -775,7 +674,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_HOST ); ret =dwc3_host_init (dwc);if (ret) { -dev_err (dwc->dev,"failed to initialize host\n" ); +dev_err (dev,"failed to initialize host\n" );return ret; }break ;
@@ -783,39 +682,24 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_OTG ); ret =dwc3_host_init (dwc);if (ret) { -dev_err (dwc->dev,"failed to initialize host\n" ); +dev_err (dev,"failed to initialize host\n" );return ret; } ret =dwc3_gadget_init (dwc);if (ret) { -dev_err (dwc->dev,"failed to initialize gadget\n" ); +dev_err (dev,"failed to initialize gadget\n" );return ret; }break ;default : -dev_err (dwc->dev, -"Unsupported mode of operation %d\n" , dwc->dr_mode); +dev_err (dev,"Unsupported mode of operation %d\n" , dwc->dr_mode);return -EINVAL ; }return 0 ; } -static void dwc3_gadget_run (struct dwc3 *dwc) -{ -dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_RUN_STOP ); -mdelay (100 ); -} - -static void dwc3_core_stop (struct dwc3 *dwc) -{ -u32 reg; - - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); -dwc3_writel (dwc->regs,DWC3_DCTL , reg & ~(DWC3_DCTL_RUN_STOP )); -} -static void dwc3_core_exit_mode (struct dwc3 *dwc) {switch (dwc->dr_mode) {
@@ -833,50 +717,74 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)/* do nothing */ break ; } - -/* -* switch back to peripheral mode -* This enables the phy to enter idle and then, if enabled, suspend. -*/ -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE ); -dwc3_gadget_run (dwc); }#define DWC3_ALIGN_MASK (16 - 1) -/** -* dwc3_uboot_init - dwc3 core uboot initialization code -* @dwc3_dev: struct dwc3_device containing initialization data -* -* Entry point for dwc3 driver (equivalent to dwc3_probe in linux -* kernel driver). Pointer to dwc3_device should be passed containing -* base address and other initialization data. Returns '0' on success and -* a negative value on failure. -* -* Generally called from board_usb_init() implemented in board file. -*/ -int dwc3_uboot_init (struct dwc3_device *dwc3_dev) +static int dwc3_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev; +struct dwc3_platform_data *pdata =dev_get_platdata (dev); +struct device_node *node = dev->of_node; +struct resource *res;struct dwc3 *dwc; -struct device *dev =NULL ;u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold;int ret; +void __iomem *regs;void *mem; - mem =devm_kzalloc ((struct udevice *)dev, -sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL ); + mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );if (!mem)return -ENOMEM ; dwc =PTR_ALIGN (mem,DWC3_ALIGN_MASK +1 ); dwc->mem = mem; + dwc->dev = dev; + + res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (!res) { +dev_err (dev,"missing IRQ\n" ); +return -ENODEV ; + } + dwc->xhci_resources[1 ].start = res->start; + dwc->xhci_resources[1 ].end = res->end; + dwc->xhci_resources[1 ].flags = res->flags; + dwc->xhci_resources[1 ].name = res->name; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (dev,"missing memory resource\n" ); +return -ENODEV ; + } + + dwc->xhci_resources[0 ].start = res->start; + dwc->xhci_resources[0 ].end = dwc->xhci_resources[0 ].start + +DWC3_XHCI_REGS_END ; + dwc->xhci_resources[0 ].flags = res->flags; + dwc->xhci_resources[0 ].name = res->name; - dwc->regs = (void *)(uintptr_t )(dwc3_dev->base + -DWC3_GLOBALS_REGS_START ); + res->start +=DWC3_GLOBALS_REGS_START ; + +/* +* Request memory region but exclude xHCI regs, +* since it will be requested by the xhci-plat driver. +*/ + regs =devm_ioremap_resource (dev, res); +if (IS_ERR (regs)) +return PTR_ERR (regs); + + dwc->regs = regs; + dwc->regs_size =resource_size (res); +/* +* restore res->start back to its original value so that, +* in case the probe is deferred, we don't end up getting error in +* request the memory region the next time probe is called. +*/ + res->start -=DWC3_GLOBALS_REGS_START ;/* default to highest possible threshold */ lpm_nyet_threshold =0xff ;
@@ -890,35 +798,73 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev)*/ hird_threshold =12 ; - dwc->maximum_speed = dwc3_dev->maximum_speed; - dwc->has_lpm_erratum = dwc3_dev->has_lpm_erratum; -if (dwc3_dev->lpm_nyet_threshold) - lpm_nyet_threshold = dwc3_dev->lpm_nyet_threshold; - dwc->is_utmi_l1_suspend = dwc3_dev->is_utmi_l1_suspend; -if (dwc3_dev->hird_threshold) - hird_threshold = dwc3_dev->hird_threshold; - - dwc->needs_fifo_resize = dwc3_dev->tx_fifo_resize; - dwc->dr_mode = dwc3_dev->dr_mode; - - dwc->disable_scramble_quirk = dwc3_dev->disable_scramble_quirk; - dwc->u2exit_lfps_quirk = dwc3_dev->u2exit_lfps_quirk; - dwc->u2ss_inp3_quirk = dwc3_dev->u2ss_inp3_quirk; - dwc->req_p1p2p3_quirk = dwc3_dev->req_p1p2p3_quirk; - dwc->del_p1p2p3_quirk = dwc3_dev->del_p1p2p3_quirk; - dwc->del_phy_power_chg_quirk = dwc3_dev->del_phy_power_chg_quirk; - dwc->lfps_filter_quirk = dwc3_dev->lfps_filter_quirk; - dwc->rx_detect_poll_quirk = dwc3_dev->rx_detect_poll_quirk; - dwc->dis_u3_susphy_quirk = dwc3_dev->dis_u3_susphy_quirk; - dwc->dis_u2_susphy_quirk = dwc3_dev->dis_u2_susphy_quirk; - dwc->dis_del_phy_power_chg_quirk = dwc3_dev->dis_del_phy_power_chg_quirk; - dwc->dis_tx_ipgap_linecheck_quirk = dwc3_dev->dis_tx_ipgap_linecheck_quirk; - dwc->dis_enblslpm_quirk = dwc3_dev->dis_enblslpm_quirk; - dwc->dis_u2_freeclk_exists_quirk = dwc3_dev->dis_u2_freeclk_exists_quirk; - - dwc->tx_de_emphasis_quirk = dwc3_dev->tx_de_emphasis_quirk; -if (dwc3_dev->tx_de_emphasis) - tx_de_emphasis = dwc3_dev->tx_de_emphasis; +if (node) { + dwc->maximum_speed =of_usb_get_maximum_speed (node); + dwc->has_lpm_erratum =of_property_read_bool (node, +"snps,has-lpm-erratum" ); +of_property_read_u8 (node,"snps,lpm-nyet-threshold" , + &lpm_nyet_threshold); + dwc->is_utmi_l1_suspend =of_property_read_bool (node, +"snps,is-utmi-l1-suspend" ); +of_property_read_u8 (node,"snps,hird-threshold" , + &hird_threshold); + + dwc->needs_fifo_resize =of_property_read_bool (node, +"tx-fifo-resize" ); + dwc->dr_mode =of_usb_get_dr_mode (node); + + dwc->disable_scramble_quirk =of_property_read_bool (node, +"snps,disable_scramble_quirk" ); + dwc->u2exit_lfps_quirk =of_property_read_bool (node, +"snps,u2exit_lfps_quirk" ); + dwc->u2ss_inp3_quirk =of_property_read_bool (node, +"snps,u2ss_inp3_quirk" ); + dwc->req_p1p2p3_quirk =of_property_read_bool (node, +"snps,req_p1p2p3_quirk" ); + dwc->del_p1p2p3_quirk =of_property_read_bool (node, +"snps,del_p1p2p3_quirk" ); + dwc->del_phy_power_chg_quirk =of_property_read_bool (node, +"snps,del_phy_power_chg_quirk" ); + dwc->lfps_filter_quirk =of_property_read_bool (node, +"snps,lfps_filter_quirk" ); + dwc->rx_detect_poll_quirk =of_property_read_bool (node, +"snps,rx_detect_poll_quirk" ); + dwc->dis_u3_susphy_quirk =of_property_read_bool (node, +"snps,dis_u3_susphy_quirk" ); + dwc->dis_u2_susphy_quirk =of_property_read_bool (node, +"snps,dis_u2_susphy_quirk" ); + + dwc->tx_de_emphasis_quirk =of_property_read_bool (node, +"snps,tx_de_emphasis_quirk" ); +of_property_read_u8 (node,"snps,tx_de_emphasis" , + &tx_de_emphasis); + }else if (pdata) { + dwc->maximum_speed = pdata->maximum_speed; + dwc->has_lpm_erratum = pdata->has_lpm_erratum; +if (pdata->lpm_nyet_threshold) + lpm_nyet_threshold = pdata->lpm_nyet_threshold; + dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend; +if (pdata->hird_threshold) + hird_threshold = pdata->hird_threshold; + + dwc->needs_fifo_resize = pdata->tx_fifo_resize; + dwc->dr_mode = pdata->dr_mode; + + dwc->disable_scramble_quirk = pdata->disable_scramble_quirk; + dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk; + dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk; + dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk; + dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk; + dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk; + dwc->lfps_filter_quirk = pdata->lfps_filter_quirk; + dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; + dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; + dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; + + dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; +if (pdata->tx_de_emphasis) + tx_de_emphasis = pdata->tx_de_emphasis; + }/* default to superspeed if no maximum_speed passed */ if (dwc->maximum_speed ==USB_SPEED_UNKNOWN )
@@ -930,21 +876,35 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); - dwc->hsphy_mode = dwc3_dev->hsphy_mode; + ret =dwc3_core_get_phy (dwc); +if (ret) +return ret; - dwc->index = dwc3_dev->index; +spin_lock_init (&dwc->lock); +platform_set_drvdata (pdev, dwc); + +if (!dev->dma_mask) { + dev->dma_mask = dev->parent->dma_mask; + dev->dma_parms = dev->parent->dma_parms; +dma_set_coherent_mask (dev, dev->parent->coherent_dma_mask); + } + +pm_runtime_enable (dev); +pm_runtime_get_sync (dev); +pm_runtime_forbid (dev);dwc3_cache_hwparams (dwc); ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );if (ret) {dev_err (dwc->dev,"failed to allocate event buffers\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto err0; } -if (!IS_ENABLED (CONFIG_USB_DWC3_GADGET )) +if (IS_ENABLED (CONFIG_USB_DWC3_HOST )) dwc->dr_mode =USB_DR_MODE_HOST ; -else if (!IS_ENABLED (CONFIG_USB_HOST )) +else if (IS_ENABLED (CONFIG_USB_DWC3_GADGET )) dwc->dr_mode =USB_DR_MODE_PERIPHERAL ;if (dwc->dr_mode ==USB_DR_MODE_UNKNOWN )
@@ -952,28 +912,55 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) ret =dwc3_core_init (dwc);if (ret) { -dev_err (dwc->dev,"failed to initialize core\n" ); +dev_err (dev,"failed to initialize core\n" ); goto err0; } +usb_phy_set_suspend (dwc->usb2_phy,0 ); +usb_phy_set_suspend (dwc->usb3_phy,0 ); + ret =phy_power_on (dwc->usb2_generic_phy); +if (ret <0 ) + goto err1; + + ret =phy_power_on (dwc->usb3_generic_phy); +if (ret <0 ) + goto err_usb2phy_power; + ret =dwc3_event_buffers_setup (dwc);if (ret) {dev_err (dwc->dev,"failed to setup event buffers\n" ); - goto err1; + goto err_usb3phy_power; } ret =dwc3_core_init_mode (dwc);if (ret) goto err2; -list_add_tail (&dwc->list, &dwc3_list); + ret =dwc3_debugfs_init (dwc); +if (ret) { +dev_err (dev,"failed to initialize debugfs\n" ); + goto err3; + } + +pm_runtime_allow (dev);return 0 ; +err3: +dwc3_core_exit_mode (dwc); + err2:dwc3_event_buffers_cleanup (dwc); +err_usb3phy_power: +phy_power_off (dwc->usb3_generic_phy); + +err_usb2phy_power: +phy_power_off (dwc->usb2_generic_phy); + err1: +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 );dwc3_core_exit (dwc); err0:
@@ -982,276 +969,151 @@ err0:return ret; } -/** -* dwc3_uboot_exit - dwc3 core uboot cleanup code -* @index: index of this controller -* -* Performs cleanup of memory allocated in dwc3_uboot_init and other misc -* cleanups (equivalent to dwc3_remove in linux). index of _this_ controller -* should be passed and should match with the index passed in -* dwc3_device during init. -* -* Generally called from board file. -*/ -void dwc3_uboot_exit (int index) +static int dwc3_remove (struct platform_device *pdev) { -struct dwc3 *dwc; - -list_for_each_entry (dwc, &dwc3_list, list) { -if (dwc->index != index) -continue ; +struct dwc3 *dwc =platform_get_drvdata (pdev); -dwc3_core_exit_mode (dwc); -dwc3_event_buffers_cleanup (dwc); -dwc3_free_event_buffers (dwc); -dwc3_core_exit (dwc); -list_del (&dwc->list); -kfree (dwc->mem); -break ; - } -} - -MODULE_ALIAS ("platform:dwc3" ); -MODULE_AUTHOR ("Felipe Balbi <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); -MODULE_DESCRIPTION ("DesignWare USB3 DRD Controller Driver" ); - -#if !CONFIG_IS_ENABLED (DM_USB_GADGET ) -__weak int dwc3_uboot_interrupt_status (struct udevice *dev) -{ -return 1 ; -} - -/** -* dm_usb_gadget_handle_interrupts - handle dwc3 core interrupt -* @dev: device of this controller -* -* Invokes dwc3 gadget interrupts. -* -* Generally called from board file. -*/ -int dm_usb_gadget_handle_interrupts (struct udevice *dev) -{ -struct dwc3 *dwc =NULL ; +dwc3_debugfs_exit (dwc); +dwc3_core_exit_mode (dwc); +dwc3_event_buffers_cleanup (dwc); +dwc3_free_event_buffers (dwc); -if (!dwc3_uboot_interrupt_status (dev)) -return 0 ; +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 ); +phy_power_off (dwc->usb2_generic_phy); +phy_power_off (dwc->usb3_generic_phy); -list_for_each_entry (dwc, &dwc3_list, list) { -if (dwc->dev != dev) -continue ; +dwc3_core_exit (dwc); -dwc3_gadget_uboot_handle_interrupt (dwc); -break ; - } +pm_runtime_put_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev);return 0 ; } -#endif -#if CONFIG_IS_ENABLED (PHY ) &&CONFIG_IS_ENABLED (DM_USB ) -int dwc3_setup_phy (struct udevice *dev,struct phy_bulk *phys) +#ifdef CONFIG_PM_SLEEP +static int dwc3_suspend (struct device *dev) { -int ret; - - ret =generic_phy_get_bulk (dev, phys); -if (ret) -return ret; +struct dwc3 *dwc =dev_get_drvdata (dev); +unsigned long flags; - ret =generic_phy_init_bulk (phys); -if (ret) -return ret; +spin_lock_irqsave (&dwc->lock, flags); - ret =generic_phy_power_on_bulk (phys); -if (ret) -generic_phy_exit_bulk (phys); +switch (dwc->dr_mode) { +case USB_DR_MODE_PERIPHERAL : +case USB_DR_MODE_OTG : +dwc3_gadget_suspend (dwc); +/* FALLTHROUGH */ +case USB_DR_MODE_HOST : +default : +dwc3_event_buffers_cleanup (dwc); +break ; + } -return ret; -} + dwc->gctl =dwc3_readl (dwc->regs,DWC3_GCTL ); +spin_unlock_irqrestore (&dwc->lock, flags); -int dwc3_shutdown_phy (struct udevice *dev,struct phy_bulk *phys) -{ -int ret; +usb_phy_shutdown (dwc->usb3_phy); +usb_phy_shutdown (dwc->usb2_phy); +phy_exit (dwc->usb2_generic_phy); +phy_exit (dwc->usb3_generic_phy); - ret =generic_phy_power_off_bulk (phys); - ret |=generic_phy_exit_bulk (phys); -return ret; +return 0 ; } -#endif -#if CONFIG_IS_ENABLED (DM_USB ) -void dwc3_of_parse (struct dwc3 *dwc) +static int dwc3_resume (struct device *dev) { -const u8 *tmp; -struct udevice *dev = dwc->dev; -u8 lpm_nyet_threshold; -u8 tx_de_emphasis; -u8 hird_threshold; -u32 val; -int i; +struct dwc3 *dwc =dev_get_drvdata (dev); +unsigned long flags; +int ret; -/* default to highest possible threshold */ - lpm_nyet_threshold =0xff ; - -/* default to -3.5dB de-emphasis */ - tx_de_emphasis =1 ; - -/* -* default to assert utmi_sleep_n and use maximum allowed HIRD -* threshold value of 0b1100 -*/ - hird_threshold =12 ; - - dwc->hsphy_mode =usb_get_phy_mode (dev_ofnode (dev)); - - dwc->has_lpm_erratum =dev_read_bool (dev, -"snps,has-lpm-erratum" ); - tmp =dev_read_u8_array_ptr (dev,"snps,lpm-nyet-threshold" ,1 ); -if (tmp) - lpm_nyet_threshold = *tmp; - - dwc->is_utmi_l1_suspend =dev_read_bool (dev, -"snps,is-utmi-l1-suspend" ); - tmp =dev_read_u8_array_ptr (dev,"snps,hird-threshold" ,1 ); -if (tmp) - hird_threshold = *tmp; - - dwc->disable_scramble_quirk =dev_read_bool (dev, -"snps,disable_scramble_quirk" ); - dwc->u2exit_lfps_quirk =dev_read_bool (dev, -"snps,u2exit_lfps_quirk" ); - dwc->u2ss_inp3_quirk =dev_read_bool (dev, -"snps,u2ss_inp3_quirk" ); - dwc->req_p1p2p3_quirk =dev_read_bool (dev, -"snps,req_p1p2p3_quirk" ); - dwc->del_p1p2p3_quirk =dev_read_bool (dev, -"snps,del_p1p2p3_quirk" ); - dwc->del_phy_power_chg_quirk =dev_read_bool (dev, -"snps,del_phy_power_chg_quirk" ); - dwc->lfps_filter_quirk =dev_read_bool (dev, -"snps,lfps_filter_quirk" ); - dwc->rx_detect_poll_quirk =dev_read_bool (dev, -"snps,rx_detect_poll_quirk" ); - dwc->dis_u3_susphy_quirk =dev_read_bool (dev, -"snps,dis_u3_susphy_quirk" ); - dwc->dis_u2_susphy_quirk =dev_read_bool (dev, -"snps,dis_u2_susphy_quirk" ); - dwc->dis_del_phy_power_chg_quirk =dev_read_bool (dev, -"snps,dis-del-phy-power-chg-quirk" ); - dwc->dis_tx_ipgap_linecheck_quirk =dev_read_bool (dev, -"snps,dis-tx-ipgap-linecheck-quirk" ); - dwc->dis_enblslpm_quirk =dev_read_bool (dev, -"snps,dis_enblslpm_quirk" ); - dwc->dis_u2_freeclk_exists_quirk =dev_read_bool (dev, -"snps,dis-u2-freeclk-exists-quirk" ); - dwc->tx_de_emphasis_quirk =dev_read_bool (dev, -"snps,tx_de_emphasis_quirk" ); - tmp =dev_read_u8_array_ptr (dev,"snps,tx_de_emphasis" ,1 ); -if (tmp) - tx_de_emphasis = *tmp; - - dwc->lpm_nyet_threshold = lpm_nyet_threshold; - dwc->tx_de_emphasis = tx_de_emphasis; - - dwc->hird_threshold = hird_threshold - | (dwc->is_utmi_l1_suspend <<4 ); - -dev_read_u32 (dev,"snps,quirk-frame-length-adjustment" , &dwc->fladj); - -/* -* Handle property "snps,incr-burst-type-adjustment". -* Get the number of value from this property: -* result <= 0, means this property is not supported. -* result = 1, means INCRx burst mode supported. -* result > 1, means undefined length burst mode supported. -*/ - dwc->incrx_mode =INCRX_BURST_MODE ; - dwc->incrx_size =0 ; -for (i =0 ; i <8 ; i++) { -if (dev_read_u32_index (dev,"snps,incr-burst-type-adjustment" , - i, &val)) -break ; - - dwc->incrx_mode =INCRX_UNDEF_LENGTH_BURST_MODE ; - dwc->incrx_size =max (dwc->incrx_size, val); - } -} - -int dwc3_init (struct dwc3 *dwc) -{ -int ret; -u32 reg; +usb_phy_init (dwc->usb3_phy); +usb_phy_init (dwc->usb2_phy); + ret =phy_init (dwc->usb2_generic_phy); +if (ret <0 ) +return ret; -dwc3_cache_hwparams (dwc); + ret =phy_init (dwc->usb3_generic_phy); +if (ret <0 ) + goto err_usb2phy_init; - ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE ); -if (ret) { -dev_err (dwc->dev,"failed to allocate event buffers\n" ); -return -ENOMEM ; - } +spin_lock_irqsave (&dwc->lock, flags); - ret =dwc3_core_init (dwc); -if (ret) { -dev_err (dwc->dev,"failed to initialize core\n" ); - goto core_fail; - } +dwc3_event_buffers_setup (dwc); +dwc3_writel (dwc->regs,DWC3_GCTL , dwc->gctl); - ret =dwc3_event_buffers_setup (dwc); -if (ret) { -dev_err (dwc->dev,"failed to setup event buffers\n" ); - goto event_fail; +switch (dwc->dr_mode) { +case USB_DR_MODE_PERIPHERAL : +case USB_DR_MODE_OTG : +dwc3_gadget_resume (dwc); +/* FALLTHROUGH */ +case USB_DR_MODE_HOST : +default : +/* do nothing */ +break ; } -if (dwc->revision >=DWC3_REVISION_250A ) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL1 ); +spin_unlock_irqrestore (&dwc->lock, flags); -/* -* Enable hardware control of sending remote wakeup -* in HS when the device is in the L1 state. -*/ -if (dwc->revision >=DWC3_REVISION_290A ) - reg |=DWC3_GUCTL1_DEV_L1_EXIT_BY_HW ; +pm_runtime_disable (dev); +pm_runtime_set_active (dev); +pm_runtime_enable (dev); -if (dwc->dis_tx_ipgap_linecheck_quirk) - reg |=DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS ; +return 0 ; -dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); - } +err_usb2phy_init: +phy_exit (dwc->usb2_generic_phy); -if (dwc->dr_mode ==USB_DR_MODE_HOST || - dwc->dr_mode ==USB_DR_MODE_OTG ) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL ); +return ret; +} - reg |=DWC3_GUCTL_HSTINAUTORETRY ; +static const struct dev_pm_ops dwc3_dev_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (dwc3_suspend, dwc3_resume) +}; -dwc3_writel (dwc->regs,DWC3_GUCTL , reg); - } +#define DWC3_PM_OPS &(dwc3_dev_pm_ops) +#else +#define DWC3_PM_OPS NULL +#endif - ret =dwc3_core_init_mode (dwc); -if (ret) - goto mode_fail; +#ifdef CONFIG_OF +static const struct of_device_id of_dwc3_match[] = { + { + .compatible ="snps,dwc3" + }, + { + .compatible ="synopsys,dwc3" + }, + { }, +}; +MODULE_DEVICE_TABLE (of, of_dwc3_match); +#endif -return 0 ; +#ifdef CONFIG_ACPI -mode_fail: -dwc3_event_buffers_cleanup (dwc); +#define ACPI_ID_INTEL_BSW "808622B7" -event_fail: -dwc3_core_exit (dwc); +static const struct acpi_device_id dwc3_acpi_match[] = { + {ACPI_ID_INTEL_BSW ,0 }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, dwc3_acpi_match); +#endif -core_fail: -dwc3_free_event_buffers (dwc); +static struct platform_driver dwc3_driver = { + .probe = dwc3_probe, + .remove = dwc3_remove, + .driver = { + .name ="dwc3" , + .of_match_table =of_match_ptr (of_dwc3_match), + .acpi_match_table =ACPI_PTR (dwc3_acpi_match), + .pm =DWC3_PM_OPS , + }, +}; -return ret; -} +module_platform_driver (dwc3_driver); -void dwc3_remove (struct dwc3 *dwc) -{ -dwc3_core_exit_mode (dwc); -dwc3_event_buffers_cleanup (dwc); -dwc3_free_event_buffers (dwc); -dwc3_core_stop (dwc); -dwc3_core_exit (dwc); -kfree (dwc->mem); -} -#endif +MODULE_ALIAS ("platform:dwc3" ); +MODULE_AUTHOR ("Felipe Balbi <[email protected]>" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("DesignWare USB3 DRD Controller Driver" );
drivers/usb/dwc3/core.h +56 -175
415 lines not on this page · raw message
drivers/usb/dwc3/debug.c new file +32 -0
@@ -0,0 +1,32 @@ +/** +* debug.c - DesignWare USB3 DRD Controller Debug/Trace Support +* +* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com +* +* Author: Felipe Balbi <[email protected]> +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 of +* the License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include "debug.h" + +void dwc3_trace (void (*trace)(struct va_format *),const char *fmt, ...) +{ +struct va_format vaf; +va_list args; + +va_start (args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + +trace (&vaf); + +va_end (args); +}
drivers/usb/dwc3/debug.h new file +228 -0
228 lines not on this page · raw message
drivers/usb/dwc3/dwc3-am62.c deleted +0 -125
125 lines not on this page · raw message
drivers/usb/dwc3/ep0.c +98 -119
501 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +276 -226
291 lines not on this page · raw message
drivers/usb/dwc3/io.h +29 -25
54 lines not on this page · raw message
drivers/usb/dwc3/linux-compat.h deleted +0 -16
Lines of this file are not shown. View the raw message.
drivers/usb/dwc3/platform_data.h new file +47 -0
47 lines not on this page · raw message
drivers/usb/dwc3/samsung_usb_phy.c deleted +0 -77
77 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.53.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH v5 01/75] usb: dwc3: restore to original v3.19-rc1 kernel import
Hi Anders,
Thank you for the patch.
Quoted 6 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Restore the dwc3 source files to the state of the original import in commit
85d5e7075f33("usb: dwc3: add dwc3 folder from linux kernel to u-boot").
Quoted 6 lines
[Anders: rebased on origin/master.
dwc3-am62.cconflicted here - this commit deletes it but upstream had changed it. Kept the delete, the file comes back in a later commit.]Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I see that the Makefile/Kconfig are not modified and still have USB_DWC3_AM62 in there.
I don't think it's a big deal but I wanted to point it out anyways.
PATCH v5 2/75 usb: dwc3: import from kernel v3.19
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v3.19-rc1 to v3.19.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v3.19-rc1..v3.19
Commits imported:39e60635a015 usb: dwc3: gadget: Stop TRB preparation after limit is reached ec512fb8e561 usb: dwc3: gadget: Fix TRB preparation during SG 84a2b61b6eb9 usb: dwc3: pci: add support for Intel Sunrise Point PCH
--- drivers/usb/dwc3/gadget.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/dwc3/gadget.c +4 -2
@@ -882,8 +882,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)if (i == (request->num_mapped_sgs -1 ) ||sg_is_last (s)) { -if (list_is_last (&req->list, - &dep->request_list)) +if (list_empty (&dep->request_list)) last_one = true; chain = false; }
@@ -901,6 +900,9 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)if (last_one)break ; } + +if (last_one) +break ; }else { dma = req->request.dma; length = req->request.length;
Signature · 1 line
2.53.0
Re: [PATCH v5 02/75] usb: dwc3: import from kernel v3.19
Hi Anders,
Thank you for the patch.
Quoted 23 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v3.19-rc1 to v3.19.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v3.19-rc1..v3.19
Commits imported:39e60635a015usb: dwc3: gadget: Stop TRB preparation after limit is reachedec512fb8e561usb: dwc3: gadget: Fix TRB preparation during SG84a2b61b6eb9usb: dwc3: pci: add support for Intel Sunrise Point PCH
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
Compared this commit with v3.19 in linux. I don't see anything odd here, so:
PATCH v5 3/75 usb: dwc3: import from kernel v4.0
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v3.19 to v4.0.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v3.19..v4.0
Commits imported:96e5d31244c5 usb: dwc3: dwc3-omap: Fix disable IRQbcdea50312b2 usb: dwc3: gadget: use common is_selfpowered 5c7b3b02de76 usb: dwc3: gadget: add missing spin_lock()73815280a5af usb: dwc3: remove reliance on dev_vdbg()6bac4ff0a522 usb: dwc3: trace: add trace logs for core and gadget e9f2aa871c73 usb: dwc3: gadget: WARN() in case of unknown IRQ 4cd8f6d05599 usb: dwc3: gadget: avoid variable shadowing 2cd9ddf77e0d usb: dwc3: pci: code cleanup3b44ed90cdb2 usb: dwc3: pci: rely on default PM callbacks from PCI driver utility d3fdcc78b2d6 usb: dwc3: pci: remove registration of NOP PHYs 3cd0e29d5e28 usb: dwc3: Remove current_trb as it is unused 110381e11b5f usb: dwc3: gadget: Remove redundant checkdc93b41a1561 usb: dwc3: Fixed a typo in comments
--- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 5 --- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/dwc3/gadget.c | 82 ++++++++++++++++++++------------------- 4 files changed, 45 insertions(+), 46 deletions(-)
drivers/usb/dwc3/core.c +1 -1
@@ -345,7 +345,7 @@ static void dwc3_core_num_eps(struct dwc3 *dwc) dwc->num_in_eps =DWC3_NUM_IN_EPS (parms); dwc->num_out_eps =DWC3_NUM_EPS (parms) - dwc->num_in_eps; -dev_vdbg (dwc->dev,"found %d IN and %d OUT endpoints\n" , +dwc3_trace (trace_dwc3_core,"found %d IN and %d OUT endpoints" , dwc->num_in_eps, dwc->num_out_eps); }
drivers/usb/dwc3/core.h +0 -5
@@ -431,7 +431,6 @@ struct dwc3_event_buffer {* @dwc: pointer to DWC controller * @saved_state: ep state saved during hibernation * @flags: endpoint flags (wedged, stalled, ...) -* @current_trb: index of current used trb * @number: endpoint number (1 - 15) * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK * @resource_index: Resource transfer index
@@ -464,8 +463,6 @@ struct dwc3_ep {/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN (1 << 31) -unsigned current_trb; -u8 number;u8 type;u8 resource_index;
@@ -685,7 +682,6 @@ struct dwc3_scratchpad_array {* @is_utmi_l1_suspend: the core asserts output signal * 0 - utmi_sleep_n * 1 - utmi_l1_suspend_n -* @is_selfpowered: true when we are selfpowered * @is_fpga: true when we are using the FPGA board * @needs_fifo_resize: not all users might want fifo resizing, flag it * @pullups_connected: true when Run/Stop bit is set
@@ -809,7 +805,6 @@ struct dwc3 { unsigned has_hibernation:1; unsigned has_lpm_erratum:1; unsigned is_utmi_l1_suspend:1; - unsigned is_selfpowered:1; unsigned is_fpga:1; unsigned needs_fifo_resize:1; unsigned pullups_connected:1;
drivers/usb/dwc3/ep0.c +1 -1
@@ -344,7 +344,7 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,/* * LTM will be set once we know how to set this in HW. */ - usb_status |= dwc->is_selfpowered <<USB_DEVICE_SELF_POWERED ; + usb_status |= dwc->gadget.is_selfpowered;if (dwc->speed ==DWC3_DSTS_SUPERSPEED ) { reg =dwc3_readl (dwc->regs,DWC3_DCTL );
drivers/usb/dwc3/gadget.c +43 -39
248 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 03/75] usb: dwc3: import from kernel v4.0
Hi Anders,
Thank you for the patch.
Quoted 33 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v3.19 to v4.0.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v3.19..v4.0
Commits imported:96e5d31244c5usb: dwc3: dwc3-omap: Fix disable IRQbcdea50312b2usb: dwc3: gadget: use commonis_selfpowered5c7b3b02de76usb: dwc3: gadget: add missingspin_lock()73815280a5afusb: dwc3: remove reliance ondev_vdbg()6bac4ff0a522usb: dwc3: trace: add trace logs for core and gadgete9f2aa871c73usb: dwc3: gadget:WARN()in case of unknown IRQ4cd8f6d05599usb: dwc3: gadget: avoid variable shadowing2cd9ddf77e0dusb: dwc3: pci: code cleanup3b44ed90cdb2usb: dwc3: pci: rely on default PM callbacks from PCI driver utilityd3fdcc78b2d6usb: dwc3: pci: remove registration of NOP PHYs3cd0e29d5e28usb: dwc3: Removecurrent_trbas it is unused110381e11b5fusb: dwc3: gadget: Remove redundant checkdc93b41a1561usb: dwc3: Fixed a typo in comments
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 4/75 usb: dwc3: import from kernel v4.1
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.0 to v4.1.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.0..v4.1
Commits imported:459e210c4fd0 usb: dwc3: gadget: Fix incorrect DEPCMD and DGCMD status macros 228321904089 usb: dwc3: dwc3-omap: correct the register macros eac68e8f979b usb: dwc3: make LPM configurable in DTadf9c3c85615 usb: move definition of PCI_VENDOR_ID_SYNOPSYS to linux/pci_ids.h 8f2c9544aba6 usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs 3d0184d08757 usb: dwc3: omap: call of_platform_depopulate() instead 3da1f6ee3563 usb: dwc3: core: only reset res->start in case of error
--- drivers/usb/dwc3/core.c | 59 ++++++++++++++++++++------------ drivers/usb/dwc3/core.h | 6 ++-- drivers/usb/dwc3/gadget.c | 37 +++++++++----------- drivers/usb/dwc3/platform_data.h | 1 + 4 files changed, 58 insertions(+), 45 deletions(-)
drivers/usb/dwc3/core.c +37 -22
@@ -774,17 +774,13 @@ static int dwc3_probe(struct platform_device *pdev)* since it will be requested by the xhci-plat driver. */ regs =devm_ioremap_resource (dev, res); -if (IS_ERR (regs)) -return PTR_ERR (regs); +if (IS_ERR (regs)) { + ret =PTR_ERR (regs); + goto err0; + } dwc->regs = regs; dwc->regs_size =resource_size (res); -/* -* restore res->start back to its original value so that, -* in case the probe is deferred, we don't end up getting error in -* request the memory region the next time probe is called. -*/ - res->start -=DWC3_GLOBALS_REGS_START ;/* default to highest possible threshold */ lpm_nyet_threshold =0xff ;
@@ -808,6 +804,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,is-utmi-l1-suspend");of_property_read_u8 (node,"snps,hird-threshold" , &hird_threshold); + dwc->usb3_lpm_capable =of_property_read_bool (node, +"snps,usb3_lpm_capable" ); dwc->needs_fifo_resize =of_property_read_bool (node,"tx-fifo-resize" );
@@ -848,6 +846,7 @@ static int dwc3_probe(struct platform_device *pdev) hird_threshold = pdata->hird_threshold; dwc->needs_fifo_resize = pdata->tx_fifo_resize; + dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; dwc->dr_mode = pdata->dr_mode; dwc->disable_scramble_quirk = pdata->disable_scramble_quirk;
@@ -878,7 +877,7 @@ static int dwc3_probe(struct platform_device *pdev) ret =dwc3_core_get_phy (dwc);if (ret) -return ret; + goto err0;spin_lock_init (&dwc->lock);platform_set_drvdata (pdev, dwc);
@@ -899,7 +898,7 @@ static int dwc3_probe(struct platform_device *pdev)if (ret) {dev_err (dwc->dev,"failed to allocate event buffers\n" ); ret = -ENOMEM ; - goto err0; + goto err1; }if (IS_ENABLED (CONFIG_USB_DWC3_HOST ))
@@ -913,65 +912,81 @@ static int dwc3_probe(struct platform_device *pdev) ret =dwc3_core_init (dwc);if (ret) {dev_err (dev,"failed to initialize core\n" ); - goto err0; + goto err1; }usb_phy_set_suspend (dwc->usb2_phy,0 );usb_phy_set_suspend (dwc->usb3_phy,0 ); ret =phy_power_on (dwc->usb2_generic_phy);if (ret <0 ) - goto err1; + goto err2; ret =phy_power_on (dwc->usb3_generic_phy);if (ret <0 ) - goto err_usb2phy_power; + goto err3; ret =dwc3_event_buffers_setup (dwc);if (ret) {dev_err (dwc->dev,"failed to setup event buffers\n" ); - goto err_usb3phy_power; + goto err4; } ret =dwc3_core_init_mode (dwc);if (ret) - goto err2; + goto err5; ret =dwc3_debugfs_init (dwc);if (ret) {dev_err (dev,"failed to initialize debugfs\n" ); - goto err3; + goto err6; }pm_runtime_allow (dev);return 0 ; -err3: +err6:dwc3_core_exit_mode (dwc); -err2: +err5:dwc3_event_buffers_cleanup (dwc); -err_usb3phy_power: +err4:phy_power_off (dwc->usb3_generic_phy); -err_usb2phy_power: +err3:phy_power_off (dwc->usb2_generic_phy); -err1: +err2:usb_phy_set_suspend (dwc->usb2_phy,1 );usb_phy_set_suspend (dwc->usb3_phy,1 );dwc3_core_exit (dwc); -err0: +err1:dwc3_free_event_buffers (dwc); +err0: +/* +* restore res->start back to its original value so that, in case the +* probe is deferred, we don't end up getting error in request the +* memory region the next time probe is called. +*/ + res->start -=DWC3_GLOBALS_REGS_START ; +return ret; }static int dwc3_remove (struct platform_device *pdev) {struct dwc3 *dwc =platform_get_drvdata (pdev); +struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + +/* +* restore res->start back to its original value so that, in case the +* probe is deferred, we don't end up getting error in request the +* memory region the next time probe is called. +*/ + res->start -=DWC3_GLOBALS_REGS_START ;dwc3_debugfs_exit (dwc);dwc3_core_exit_mode (dwc);
drivers/usb/dwc3/core.h +4 -2
@@ -339,7 +339,7 @@#define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c#define DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK 0x10 -#define DWC3_DGCMD_STATUS (n) (((n) >> 15) & 1) +#define DWC3_DGCMD_STATUS (n) (((n) >> 12) & 0x0F)#define DWC3_DGCMD_CMDACT (1 << 10)#define DWC3_DGCMD_CMDIOC (1 << 8)
@@ -355,7 +355,7 @@#define DWC3_DEPCMD_PARAM_SHIFT 16#define DWC3_DEPCMD_PARAM (x) ((x) << DWC3_DEPCMD_PARAM_SHIFT)#define DWC3_DEPCMD_GET_RSC_IDX (x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) -#define DWC3_DEPCMD_STATUS (x) (((x) >> 15) & 1) +#define DWC3_DEPCMD_STATUS (x) (((x) >> 12) & 0x0F)#define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11)#define DWC3_DEPCMD_CMDACT (1 << 10)#define DWC3_DEPCMD_CMDIOC (1 << 8)
@@ -689,6 +689,7 @@ struct dwc3_scratchpad_array {* @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround * @start_config_issued: true when StartConfig command has been issued * @three_stage_setup: set if we perform a three phase setup +* @usb3_lpm_capable: set if hadrware supports Link Power Management * @disable_scramble_quirk: set if we enable the disable scramble quirk * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk * @u2ss_inp3_quirk: set if we enable P3 OK for U2/SS Inactive quirk
@@ -812,6 +813,7 @@ struct dwc3 { unsigned setup_packet_pending:1; unsigned start_config_issued:1; unsigned three_stage_setup:1; + unsigned usb3_lpm_capable:1; unsigned disable_scramble_quirk:1; unsigned u2exit_lfps_quirk:1;
drivers/usb/dwc3/gadget.c +16 -21
@@ -1855,32 +1855,27 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,unsigned int i;int ret; + req =next_request (&dep->req_queued); +if (!req) { +WARN_ON_ONCE (1 ); +return 1 ; + } + i =0 ;do { - req =next_request (&dep->req_queued); -if (!req) { -WARN_ON_ONCE (1 ); -return 1 ; - } - i =0 ; -do { - slot = req->start_slot + i; -if ((slot ==DWC3_TRB_NUM -1 ) && + slot = req->start_slot + i; +if ((slot ==DWC3_TRB_NUM -1 ) &&usb_endpoint_xfer_isoc (dep->endpoint.desc)) - slot++; - slot %=DWC3_TRB_NUM ; - trb = &dep->trb_pool[slot]; - - ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, - event, status); -if (ret) -break ; - }while (++i < req->request.num_mapped_sgs); - -dwc3_gadget_giveback (dep, req, status); + slot++; + slot %=DWC3_TRB_NUM ; + trb = &dep->trb_pool[slot]; + ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, + event, status);if (ret)break ; - }while (1 ); + }while (++i < req->request.num_mapped_sgs); + +dwc3_gadget_giveback (dep, req, status);if (usb_endpoint_xfer_isoc (dep->endpoint.desc) &&list_empty (&dep->req_queued)) {
drivers/usb/dwc3/platform_data.h +1 -0
@@ -24,6 +24,7 @@ struct dwc3_platform_data {enum usb_device_speed maximum_speed;enum usb_dr_mode dr_mode;bool tx_fifo_resize; +bool usb3_lpm_capable; unsigned is_utmi_l1_suspend:1;u8 hird_threshold;
Signature · 1 line
2.53.0
Re: [PATCH v5 04/75] usb: dwc3: import from kernel v4.1
Hi Anders,
Thank you for the patch.
Quoted 27 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.0 to v4.1.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.0..v4.1
Commits imported:459e210c4fd0usb: dwc3: gadget: Fix incorrect DEPCMD and DGCMD status macros 228321904089 usb: dwc3: dwc3-omap: correct the register macroseac68e8f979busb: dwc3: make LPM configurable in DTadf9c3c85615usb: move definition ofPCI_VENDOR_ID_SYNOPSYStolinux/pci_ids.h8f2c9544aba6usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs3d0184d08757usb: dwc3: omap: callof_platform_depopulate()instead3da1f6ee3563usb: dwc3: core: only resetres->startin case of error
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 5/75 usb: dwc3: import from kernel v4.2
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.1 to v4.2.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.1..v4.2
Commits imported:aebda6187181 usb: dwc3: Reset the transfer resource index on SET_INTERFACE 43cacb03aabe usb: dwc3: core: avoid NULL pointer dereference 50641056d833 usb: dwc3: Use ASCII space in Kconfige18b7975c885 usb: dwc3: gadget: don't clear EP_BUSY too early 76e838c9f776 usb: dwc3: gadget: return error if command sent to DEPCMD register fails 891b1dc02295 usb: dwc3: gadget: return error if command sent to DGCMD register fails 88bc9d194ff6 usb: dwc3: add ULPI interface supporta89d977cc04c usb: dwc3: pci: add quirk for Baytrails3e10a2ce98d1 usb: dwc3: add hsphy_interface property45bb7de213d8 usb: dwc3: setup phys earlierc5cc74e8c12b usb: dwc3: soft reset to it's own function2917e7181589 usb: dwc3: cache hwparams earlier6c89cce0476f usb: dwc3: store driver data earlierf699b94789a6 usb: dwc3: ULPI or UTMI+ selectb5699eeee68f usb: dwc3: USB2 PHY register access bits
--- drivers/usb/dwc3/core.c | 110 ++++++++++++++++++++++++------- drivers/usb/dwc3/core.h | 26 ++++++++ drivers/usb/dwc3/ep0.c | 4 ++ drivers/usb/dwc3/gadget.c | 10 ++- drivers/usb/dwc3/platform_data.h | 2 + 5 files changed, 126 insertions(+), 26 deletions(-)
drivers/usb/dwc3/core.c +85 -25
@@ -116,6 +116,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)return 0 ; } +/** +* dwc3_soft_reset - Issue soft reset +* @dwc: Pointer to our controller context structure +*/ +static int dwc3_soft_reset (struct dwc3 *dwc) +{ +unsigned long timeout; +u32 reg; + + timeout = jiffies +msecs_to_jiffies (500 ); +dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); +do { + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); +if (!(reg &DWC3_DCTL_CSFTRST )) +break ; + +if (time_after (jiffies, timeout)) { +dev_err (dwc->dev,"Reset Timed Out\n" ); +return -ETIMEDOUT ; + } + +cpu_relax (); + }while (true); + +return 0 ; +} +/** * dwc3_free_one_event_buffer - Frees one event buffer * @dwc: Pointer to our controller context structure
@@ -367,10 +394,15 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)/** * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure +* +* Returns 0 on success. The USB PHY interfaces are configured but not +* initialized. The PHY interfaces and the PHYs get initialized together with +* the core in dwc3_core_init. */ -static void dwc3_phy_setup (struct dwc3 *dwc) +static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; +int ret; reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 ));
@@ -409,10 +441,43 @@ static void dwc3_phy_setup(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); -mdelay (100 ); - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); +/* Select the HS PHY interface */ +switch (DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3)) { +case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI : +if (dwc->hsphy_interface && + !strncmp (dwc->hsphy_interface,"utmi" ,4 )) { + reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; +break ; + }else if (dwc->hsphy_interface && + !strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { + reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); + }else { +dev_warn (dwc->dev,"HSPHY Interface not defined\n" ); + +/* Relying on default value. */ +if (!(reg &DWC3_GUSB2PHYCFG_ULPI_UTMI )) +break ; + } +/* FALLTHROUGH */ +case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : +/* Making sure the interface and PHY are operational */ + ret =dwc3_soft_reset (dwc); +if (ret) +return ret; + +udelay (1 ); + + ret =dwc3_ulpi_init (dwc); +if (ret) +return ret; +/* FALLTHROUGH */ +default : +break ; + } +/* * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to * '0' during coreConsultant configuration. So default value will
@@ -427,7 +492,7 @@ static void dwc3_phy_setup(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -mdelay (100 ); +return 0 ; }/**
@@ -438,7 +503,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)*/ static int dwc3_core_init (struct dwc3 *dwc) { -unsigned long timeout;u32 hwparams4 = dwc->hwparams.hwparams4;u32 reg;int ret;
@@ -466,21 +530,9 @@ static int dwc3_core_init(struct dwc3 *dwc) }/* issue device SoftReset too */ - timeout = jiffies +msecs_to_jiffies (500 ); -dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); -do { - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); -if (!(reg &DWC3_DCTL_CSFTRST )) -break ; - -if (time_after (jiffies, timeout)) { -dev_err (dwc->dev,"Reset Timed Out\n" ); - ret = -ETIMEDOUT ; - goto err0; - } - -cpu_relax (); - }while (true); + ret =dwc3_soft_reset (dwc); +if (ret) + goto err0; ret =dwc3_core_soft_reset (dwc);if (ret)
@@ -555,8 +607,6 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GCTL , reg); -dwc3_phy_setup (dwc); - ret =dwc3_alloc_scratch_buffers (dwc);if (ret) goto err1;
@@ -836,6 +886,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,tx_de_emphasis_quirk");of_property_read_u8 (node,"snps,tx_de_emphasis" , &tx_de_emphasis); +of_property_read_string (node,"snps,hsphy_interface" , + &dwc->hsphy_interface); }else if (pdata) { dwc->maximum_speed = pdata->maximum_speed; dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -863,6 +915,8 @@ static int dwc3_probe(struct platform_device *pdev) dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;if (pdata->tx_de_emphasis) tx_de_emphasis = pdata->tx_de_emphasis; + + dwc->hsphy_interface = pdata->hsphy_interface; }/* default to superspeed if no maximum_speed passed */
@@ -875,12 +929,18 @@ static int dwc3_probe(struct platform_device *pdev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); +platform_set_drvdata (pdev, dwc); +dwc3_cache_hwparams (dwc); + + ret =dwc3_phy_setup (dwc); +if (ret) + goto err0; + ret =dwc3_core_get_phy (dwc);if (ret) goto err0;spin_lock_init (&dwc->lock); -platform_set_drvdata (pdev, dwc);if (!dev->dma_mask) { dev->dma_mask = dev->parent->dma_mask;
@@ -892,8 +952,6 @@ static int dwc3_probe(struct platform_device *pdev)pm_runtime_get_sync (dev);pm_runtime_forbid (dev); -dwc3_cache_hwparams (dwc); - ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );if (ret) {dev_err (dwc->dev,"failed to allocate event buffers\n" );
@@ -964,6 +1022,7 @@ err2: err1:dwc3_free_event_buffers (dwc); +dwc3_ulpi_exit (dwc); err0:/*
@@ -999,6 +1058,7 @@ static int dwc3_remove(struct platform_device *pdev)phy_power_off (dwc->usb3_generic_phy);dwc3_core_exit (dwc); +dwc3_ulpi_exit (dwc);pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);
drivers/usb/dwc3/core.h +26 -0
@@ -30,6 +30,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> +#include <linux/ulpi/interface.h> #include <linux/phy/phy.h>
@@ -173,6 +174,15 @@/* Global USB2 PHY Configuration Register */ #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6) +#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4) + +/* Global USB2 PHY Vendor Control Register */ +#define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25) +#define DWC3_GUSB2PHYACC_BUSY (1 << 23) +#define DWC3_GUSB2PHYACC_WRITE (1 << 22) +#define DWC3_GUSB2PHYACC_ADDR (n) (n << 16) +#define DWC3_GUSB2PHYACC_EXTEND_ADDR (n) (n << 8) +#define DWC3_GUSB2PHYACC_DATA (n) (n & 0xff)/* Global USB3 PIPE Control Register */ #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31)
@@ -652,6 +662,7 @@ struct dwc3_scratchpad_array {* @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY * @usb3_generic_phy: pointer to USB3 PHY +* @ulpi: pointer to ulpi interface * @dcfg: saved contents of DCFG register * @gctl: saved contents of GCTL register * @isoch_delay: wValue from Set Isochronous Delay request;
@@ -673,6 +684,7 @@ struct dwc3_scratchpad_array {* @test_mode_nr: test feature selector * @lpm_nyet_threshold: LPM NYET response threshold * @hird_threshold: HIRD threshold +* @hsphy_interface: "utmi" or "ulpi" * @delayed_status: true when gadget driver asks for delayed status * @ep0_bounced: true when we used bounce buffer * @ep0_expect_in: true when we expect a DATA IN transfer
@@ -739,6 +751,8 @@ struct dwc3 {struct phy *usb2_generic_phy;struct phy *usb3_generic_phy; +struct ulpi *ulpi; +void __iomem *regs;size_t regs_size;
@@ -800,6 +814,8 @@ struct dwc3 {u8 lpm_nyet_threshold;u8 hird_threshold; +const char *hsphy_interface; + unsigned delayed_status:1; unsigned ep0_bounced:1; unsigned ep0_expect_in:1;
@@ -1035,4 +1051,14 @@ static inline int dwc3_gadget_resume(struct dwc3 *dwc) }#endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */ +#if IS_ENABLED (CONFIG_USB_DWC3_ULPI ) +int dwc3_ulpi_init (struct dwc3 *dwc); +void dwc3_ulpi_exit (struct dwc3 *dwc); +#else +static inline int dwc3_ulpi_init (struct dwc3 *dwc) +{return 0 ; } +static inline void dwc3_ulpi_exit (struct dwc3 *dwc) +{ } +#endif +#endif /* __DRIVERS_USB_DWC3_CORE_H */
drivers/usb/dwc3/ep0.c +4 -0
@@ -727,6 +727,10 @@ static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)dwc3_trace (trace_dwc3_ep0,"USB_REQ_SET_ISOCH_DELAY" ); ret =dwc3_ep0_set_isoch_delay (dwc, ctrl);break ; +case USB_REQ_SET_INTERFACE : +dwc3_trace (trace_dwc3_ep0,"USB_REQ_SET_INTERFACE" ); + dwc->start_config_issued = false; +/* Fall through */ default :dwc3_trace (trace_dwc3_ep0,"Forwarding to gadget driver" ); ret =dwc3_ep0_delegate_req (dwc, ctrl);
drivers/usb/dwc3/gadget.c +9 -1
@@ -291,6 +291,8 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)dwc3_trace (trace_dwc3_gadget,"Command Complete --> %d" ,DWC3_DGCMD_STATUS (reg)); +if (DWC3_DGCMD_STATUS (reg)) +return -EINVAL ;return 0 ; }
@@ -328,6 +330,8 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,dwc3_trace (trace_dwc3_gadget,"Command Complete --> %d" ,DWC3_DEPCMD_STATUS (reg)); +if (DWC3_DEPCMD_STATUS (reg)) +return -EINVAL ;return 0 ; }
@@ -1902,12 +1906,16 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, {unsigned status =0 ;int clean_busy; +u32 is_xfer_complete; + + is_xfer_complete = (event->endpoint_event ==DWC3_DEPEVT_XFERCOMPLETE );if (event->status &DEPEVT_STATUS_BUSERR ) status = -ECONNRESET ; clean_busy =dwc3_cleanup_done_reqs (dwc, dep, event, status); -if (clean_busy) +if (clean_busy && (is_xfer_complete || +usb_endpoint_xfer_isoc (dep->endpoint.desc))) dep->flags &= ~DWC3_EP_BUSY ;/*
drivers/usb/dwc3/platform_data.h +2 -0
@@ -45,4 +45,6 @@ struct dwc3_platform_data { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + +const char *hsphy_interface; };
Signature · 1 line
2.53.0
Re: [PATCH v5 05/75] usb: dwc3: import from kernel v4.2
Hi Anders,
Thank you for the patch.
Quoted 35 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.1 to v4.2.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.1..v4.2
Commits imported:aebda6187181usb: dwc3: Reset the transfer resource index onSET_INTERFACE43cacb03aabeusb: dwc3: core: avoid NULL pointer dereference50641056d833usb: dwc3: Use ASCII space inKconfige18b7975c885usb: dwc3: gadget: don't clearEP_BUSYtoo early76e838c9f776usb: dwc3: gadget: return error if command sent to DEPCMD register fails891b1dc02295usb: dwc3: gadget: return error if command sent to DGCMD register fails88bc9d194ff6usb: dwc3: add ULPI interface supporta89d977cc04cusb: dwc3: pci: add quirk for Baytrails3e10a2ce98d1usb: dwc3: addhsphy_interfaceproperty45bb7de213d8usb: dwc3: setup phys earlierc5cc74e8c12busb: dwc3: soft reset to it's own function2917e7181589usb: dwc3: cache hwparams earlier6c89cce0476fusb: dwc3: store driver data earlierf699b94789a6usb: dwc3: ULPI or UTMI+ selectb5699eeee68fusb: dwc3: USB2 PHY register access bits
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 6/75 usb: dwc3: import from kernel v4.3
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.2 to v4.3.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.2..v4.3
Commits imported:a66c275b3d5d usb: dwc3: gadget: Fix BUG in RT confige2ae0692bf6f usb: dwc3: omap: enable irqs latelya474d3b73ba7 usb: dwc3: gadget: add ep capabilities supportc0bd5456a470 usb: dwc3: ep0: handle non maxpacket aligned transfers > 512 2abd9d5fa60f usb: dwc3: ep0: Add chained TRB support368ca113ca0a usb: dwc3; ep0: Modify _dwc3_ep0_start_trans_ API to take 'chain' parameter 8a3442205630 usb: dwc3: ep0: preparation for handling non maxpacket aligned transfers > 512 2e5464da4e7d usb: dwc3: ep0: use _roundup_ to calculate the transfer size b2fb5b1a0f50 usb: dwc3: ep0: Fix mem corruption on OUT transfers of more than 512 bytes aa7399744dd0 usb: dwc3: gadget: defer endpoint name change7eaeac5c0e44 usb: dwc3: gadget: add a trace when disabling EPsd9972f470bcb usb: dwc3: core: remove unnecessary dev_warn()2df033ca39b5 usb: dwc3: pci: make better use of gpiod API5960387a2fb8 usb: dwc3: omap: Replace deprecated API of extcon9fcfa463e17a usb: dwc3: drop CONFIG_USB_DWC3_DEBUGe746b06cc76a usb: dwc3: st: remove two unnecessary messages2babd0d148a3 usb: dwc3: qcom: switch dev_dbg() to dev_info()42f69a02e7ab usb: dwc3: exynos: switch dev_dbg() to dev_info()9ff0fdca3b62 usb: dwc3: keystone: convert dev_dbg() to dev_err() e4f756675467 usb: dwc3: omap: drop dev_dbg() usage
--- drivers/usb/dwc3/core.c | 2 - drivers/usb/dwc3/ep0.c | 92 ++++++++++++++++++++++++++++----------- drivers/usb/dwc3/gadget.c | 61 +++++++++++++++----------- 3 files changed, 101 insertions(+), 54 deletions(-)
drivers/usb/dwc3/core.c +0 -2
@@ -455,8 +455,6 @@ static int dwc3_phy_setup(struct dwc3 *dwc) reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ;dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); }else { -dev_warn (dwc->dev,"HSPHY Interface not defined\n" ); -/* Relying on default value. */ if (!(reg &DWC3_GUSB2PHYCFG_ULPI_UTMI ))break ;
drivers/usb/dwc3/ep0.c +66 -26
173 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +35 -26
115 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 06/75] usb: dwc3: import from kernel v4.3
Hi Anders,
Thank you for the patch.
Quoted 40 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.2 to v4.3.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.2..v4.3
Commits imported:a66c275b3d5dusb: dwc3: gadget: Fix BUG in RT confige2ae0692bf6fusb: dwc3: omap: enable irqs latelya474d3b73ba7usb: dwc3: gadget: add ep capabilities supportc0bd5456a470usb: dwc3: ep0: handle non maxpacket aligned transfers > 5122abd9d5fa60fusb: dwc3: ep0: Add chained TRB support368ca113ca0ausb: dwc3; ep0: Modify _dwc3_ep0_start_trans_ API to take 'chain' parameter8a3442205630usb: dwc3: ep0: preparation for handling non maxpacket aligned transfers > 5122e5464da4e7dusb: dwc3: ep0: use _roundup_ to calculate the transfer sizeb2fb5b1a0f50usb: dwc3: ep0: Fix mem corruption on OUT transfers of more than 512 bytesaa7399744dd0usb: dwc3: gadget: defer endpoint name change7eaeac5c0e44usb: dwc3: gadget: add a trace when disabling EPsd9972f470bcbusb: dwc3: core: remove unnecessarydev_warn()2df033ca39b5usb: dwc3: pci: make better use of gpiod API5960387a2fb8usb: dwc3: omap: Replace deprecated API of extcon9fcfa463e17ausb: dwc3: dropCONFIG_USB_DWC3_DEBUGe746b06cc76ausb: dwc3: st: remove two unnecessary messages2babd0d148a3usb: dwc3: qcom: switchdev_dbg()todev_info()42f69a02e7abusb: dwc3: exynos: switchdev_dbg()todev_info()9ff0fdca3b62usb: dwc3: keystone: convertdev_dbg()todev_err()e4f756675467usb: dwc3: omap: dropdev_dbg()usage
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 7/75 usb: dwc3: import from kernel v4.4
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.3 to v4.4.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.3..v4.4
Commits imported:62e345ae5b6e usb: dwc3: gadget: don't prestart interrupt endpoints b9e51b2b1fda usb: dwc3: gadget: let us set lower max_speed b4c580a43d52 usb: dwc3: pci: add support for Intel Broxton SOC d115d7050a0d Revert "usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs" e5f68b4a3e7b Revert "usb: dwc3: gadget: remove unnecessary _irqsave()" 94218ee31ba5 usb: dwc3: pci: Set enblslpm quirk for Synopsys platforms ec791d149bca usb: dwc3: Add dis_enblslpm_quirkbb7f3d6d323a usb: dwc3: pci: Add platform data for Synopsys HAPS 9a5a0783e491 usb: dwc3: pci: trivial: Formatting690fb3718a70 usb: dwc3: Support Synopsys USB 3.1 IPe8095a25364a usb: dwc3: pci: Add the PCI Product ID for Synopsys USB 3.1 41adc59caece usb: dwc3: pci: Add the Synopsys HAPS AXI Product ID 70f3a9caa116 usb: dwc3: gadget: remove unnecessary _irqsave() e6e709b7ab89 usb: dwc3: gadget: use Update Transfer from Xfer In Progress 6bb4fe12ea08 usb: dwc3: gadget: use update transfer command 8a1a9c9e4503 usb: dwc3: gadget: start transfer on XFER_COMPLETE 9caeb06ebd46 usb: dwc3: pci: passing forward the ACPI companion 3d128919b7e5 usb: dwc3: core: convert to unified device property interface 06e7114f0d82 usb: common: of_usb_get_dr_mode to usb_get_dr_mode 666472733b8c usb: dwc3: st: prepare the driver for generic usb_get_dr_mode function 63863b988eec usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed 6344475f5397 usb: dwc3: support for pinctrl state change during system sleep db2be4e9e30c usb: dwc3: Add frame length adjustment quirka8f32817eeb0 usb: dwc3: gadget: improve ep_queue's error reporting 89185916d229 usb: dwc3: gadget: clear DWC3_PENDING_REQUEST when request is queued 1d6a39186b37 usb: dwc3: gadget: start requests as soon as they come fe84f522ed6d usb: dwc3: gadget: move trace_dwc3_ep_queue()
--- drivers/usb/dwc3/core.c | 104 ++++++++++++++++++------- drivers/usb/dwc3/core.h | 27 +++++++ drivers/usb/dwc3/gadget.c | 125 +++++++++++++++++++++---------- drivers/usb/dwc3/platform_data.h | 3 + 4 files changed, 194 insertions(+), 65 deletions(-)
drivers/usb/dwc3/core.c +77 -27
@@ -34,6 +34,7 @@#include <linux/dma-mapping.h> #include <linux/of.h> #include <linux/acpi.h> +#include <linux/pinctrl/consumer.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
@@ -143,6 +144,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)return 0 ; } +/* +* dwc3_frame_length_adjustment - Adjusts frame length if required +* @dwc3: Pointer to our controller context structure +* @fladj: Value of GFLADJ_30MHZ to adjust frame length +*/ +static void dwc3_frame_length_adjustment (struct dwc3 *dwc,u32 fladj) +{ +u32 reg; +u32 dft; + +if (dwc->revision <DWC3_REVISION_250A ) +return ; + +if (fladj ==0 ) +return ; + + reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); + dft = reg &DWC3_GFLADJ_30MHZ_MASK ; +if (!dev_WARN_ONCE (dwc->dev, dft == fladj, +"request value same as default, ignoring\n" )) { + reg &= ~DWC3_GFLADJ_30MHZ_MASK ; + reg |=DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj; +dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); + } +} +/** * dwc3_free_one_event_buffer - Frees one event buffer * @dwc: Pointer to our controller context structure
@@ -488,6 +515,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_u2_susphy_quirk) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ; +if (dwc->dis_enblslpm_quirk) + reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg);return 0 ;
@@ -507,12 +537,18 @@ static int dwc3_core_init(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_GSNPSID );/* This should read as U3 followed by revision number */ -if ((reg &DWC3_GSNPSID_MASK ) !=0x55330000 ) { +if ((reg &DWC3_GSNPSID_MASK ) ==0x55330000 ) { +/* Detected DWC_usb3 IP */ + dwc->revision = reg; + }else if ((reg &DWC3_GSNPSID_MASK ) ==0x33310000 ) { +/* Detected DWC_usb31 IP */ + dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); + dwc->revision |=DWC3_REVISION_IS_DWC31 ; + }else {dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); ret = -ENODEV ; goto err0; } - dwc->revision = reg;/* * Write Linux Version Code to our GUID register so it's easy to figure
@@ -773,12 +809,12 @@ static int dwc3_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct dwc3_platform_data *pdata =dev_get_platdata (dev); -struct device_node *node = dev->of_node;struct resource *res;struct dwc3 *dwc;u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold; +u32 fladj =0 ;int ret;
@@ -842,51 +878,56 @@ static int dwc3_probe(struct platform_device *pdev)*/ hird_threshold =12 ; -if (node) { - dwc->maximum_speed =of_usb_get_maximum_speed (node); - dwc->has_lpm_erratum =of_property_read_bool (node, + dwc->maximum_speed =usb_get_maximum_speed (dev); + dwc->dr_mode =usb_get_dr_mode (dev); + + dwc->has_lpm_erratum =device_property_read_bool (dev,"snps,has-lpm-erratum" ); -of_property_read_u8 (node,"snps,lpm-nyet-threshold" , +device_property_read_u8 (dev,"snps,lpm-nyet-threshold" , &lpm_nyet_threshold); - dwc->is_utmi_l1_suspend =of_property_read_bool (node, + dwc->is_utmi_l1_suspend =device_property_read_bool (dev,"snps,is-utmi-l1-suspend" ); -of_property_read_u8 (node,"snps,hird-threshold" , +device_property_read_u8 (dev,"snps,hird-threshold" , &hird_threshold); - dwc->usb3_lpm_capable =of_property_read_bool (node, + dwc->usb3_lpm_capable =device_property_read_bool (dev,"snps,usb3_lpm_capable" ); - dwc->needs_fifo_resize =of_property_read_bool (node, + dwc->needs_fifo_resize =device_property_read_bool (dev,"tx-fifo-resize" ); - dwc->dr_mode =of_usb_get_dr_mode (node); - dwc->disable_scramble_quirk =of_property_read_bool (node, + dwc->disable_scramble_quirk =device_property_read_bool (dev,"snps,disable_scramble_quirk" ); - dwc->u2exit_lfps_quirk =of_property_read_bool (node, + dwc->u2exit_lfps_quirk =device_property_read_bool (dev,"snps,u2exit_lfps_quirk" ); - dwc->u2ss_inp3_quirk =of_property_read_bool (node, + dwc->u2ss_inp3_quirk =device_property_read_bool (dev,"snps,u2ss_inp3_quirk" ); - dwc->req_p1p2p3_quirk =of_property_read_bool (node, + dwc->req_p1p2p3_quirk =device_property_read_bool (dev,"snps,req_p1p2p3_quirk" ); - dwc->del_p1p2p3_quirk =of_property_read_bool (node, + dwc->del_p1p2p3_quirk =device_property_read_bool (dev,"snps,del_p1p2p3_quirk" ); - dwc->del_phy_power_chg_quirk =of_property_read_bool (node, + dwc->del_phy_power_chg_quirk =device_property_read_bool (dev,"snps,del_phy_power_chg_quirk" ); - dwc->lfps_filter_quirk =of_property_read_bool (node, + dwc->lfps_filter_quirk =device_property_read_bool (dev,"snps,lfps_filter_quirk" ); - dwc->rx_detect_poll_quirk =of_property_read_bool (node, + dwc->rx_detect_poll_quirk =device_property_read_bool (dev,"snps,rx_detect_poll_quirk" ); - dwc->dis_u3_susphy_quirk =of_property_read_bool (node, + dwc->dis_u3_susphy_quirk =device_property_read_bool (dev,"snps,dis_u3_susphy_quirk" ); - dwc->dis_u2_susphy_quirk =of_property_read_bool (node, + dwc->dis_u2_susphy_quirk =device_property_read_bool (dev,"snps,dis_u2_susphy_quirk" ); + dwc->dis_enblslpm_quirk =device_property_read_bool (dev, +"snps,dis_enblslpm_quirk" ); - dwc->tx_de_emphasis_quirk =of_property_read_bool (node, + dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" ); -of_property_read_u8 (node,"snps,tx_de_emphasis" , +device_property_read_u8 (dev,"snps,tx_de_emphasis" , &tx_de_emphasis); -of_property_read_string (node,"snps,hsphy_interface" , - &dwc->hsphy_interface); - }else if (pdata) { +device_property_read_string (dev,"snps,hsphy_interface" , + &dwc->hsphy_interface); +device_property_read_u32 (dev,"snps,quirk-frame-length-adjustment" , + &fladj); + +if (pdata) { dwc->maximum_speed = pdata->maximum_speed; dwc->has_lpm_erratum = pdata->has_lpm_erratum;if (pdata->lpm_nyet_threshold)
@@ -909,12 +950,14 @@ static int dwc3_probe(struct platform_device *pdev) dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; + dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;if (pdata->tx_de_emphasis) tx_de_emphasis = pdata->tx_de_emphasis; dwc->hsphy_interface = pdata->hsphy_interface; + fladj = pdata->fladj_value; }/* default to superspeed if no maximum_speed passed */
@@ -971,6 +1014,9 @@ static int dwc3_probe(struct platform_device *pdev) goto err1; } +/* Adjust Frame Length */ +dwc3_frame_length_adjustment (dwc, fladj); +usb_phy_set_suspend (dwc->usb2_phy,0 );usb_phy_set_suspend (dwc->usb3_phy,0 ); ret =phy_power_on (dwc->usb2_generic_phy);
@@ -1091,6 +1137,8 @@ static int dwc3_suspend(struct device *dev)phy_exit (dwc->usb2_generic_phy);phy_exit (dwc->usb3_generic_phy); +pinctrl_pm_select_sleep_state (dev); +return 0 ; }
@@ -1100,6 +1148,8 @@ static int dwc3_resume(struct device *dev)unsigned long flags;int ret; +pinctrl_pm_select_default_state (dev); +usb_phy_init (dwc->usb3_phy);usb_phy_init (dwc->usb2_phy); ret =phy_init (dwc->usb2_generic_phy);
drivers/usb/dwc3/core.h +27 -0
@@ -108,6 +108,9 @@#define DWC3_GPRTBIMAP_FS0 0xc188#define DWC3_GPRTBIMAP_FS1 0xc18c +#define DWC3_VER_NUMBER 0xc1a0 +#define DWC3_VER_TYPE 0xc1a4 +#define DWC3_GUSB2PHYCFG (n) (0xc200 + (n * 0x04))#define DWC3_GUSB2I2CCTL (n) (0xc240 + (n * 0x04))
@@ -124,6 +127,7 @@#define DWC3_GEVNTCOUNT (n) (0xc40c + (n * 0x10))#define DWC3_GHWPARAMS8 0xc600 +#define DWC3_GFLADJ 0xc630/* Device Registers */ #define DWC3_DCFG 0xc700
@@ -175,6 +179,7 @@#define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6)#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4) +#define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8)/* Global USB2 PHY Vendor Control Register */ #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
@@ -234,6 +239,10 @@/* Global HWPARAMS6 Register */ #define DWC3_GHWPARAMS6_EN_FPGA (1 << 7) +/* Global Frame Length Adjustment Register */ +#define DWC3_GFLADJ_30MHZ_SDBND_SEL (1 << 7) +#define DWC3_GFLADJ_30MHZ_MASK 0x3f +/* Device Configuration Register */ #define DWC3_DCFG_DEVADDR (addr) ((addr) << 3)#define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
@@ -712,6 +721,8 @@ struct dwc3_scratchpad_array {* @rx_detect_poll_quirk: set if we enable rx_detect to polling lfps quirk * @dis_u3_susphy_quirk: set if we disable usb3 suspend phy * @dis_u2_susphy_quirk: set if we disable usb2 suspend phy +* @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG, +* disabling the suspend signal to the PHY. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk * @tx_de_emphasis: Tx de-emphasis value * 0 - -6dB de-emphasis
@@ -766,6 +777,14 @@ struct dwc3 {u32 num_event_buffers;u32 u1u2;u32 maximum_speed; + +/* +* All 3.1 IP version constants are greater than the 3.0 IP +* version constants. This works for most version checks in +* dwc3. However, in the future, this may not apply as +* features may be developed on newer versions of the 3.0 IP +* that are not in the 3.1 IP. +*/ u32 revision;#define DWC3_REVISION_173A 0x5533173a
@@ -788,6 +807,13 @@ struct dwc3 {#define DWC3_REVISION_270A 0x5533270a#define DWC3_REVISION_280A 0x5533280a +/* +* NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really +* just so dwc31 revisions are always larger than dwc3. +*/ +#define DWC3_REVISION_IS_DWC31 0x80000000 +#define DWC3_USB31_REVISION_110A (0x3131302a | DWC3_REVISION_IS_USB31) +enum dwc3_ep0_next ep0_next_event;enum dwc3_ep0_state ep0state;enum dwc3_link_state link_state;
@@ -841,6 +867,7 @@ struct dwc3 { unsigned rx_detect_poll_quirk:1; unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; + unsigned dis_enblslpm_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;
drivers/usb/dwc3/gadget.c +87 -38
207 lines not on this page · raw message
drivers/usb/dwc3/platform_data.h +3 -0
@@ -42,9 +42,12 @@ struct dwc3_platform_data { unsigned rx_detect_poll_quirk:1; unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; + unsigned dis_enblslpm_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; +u32 fladj_value; +const char *hsphy_interface; };
Signature · 1 line
2.53.0
Re: [PATCH v5 07/75] usb: dwc3: import from kernel v4.4
Hi Anders,
Thank you for the patch.
Quoted 47 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.3 to v4.4.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.3..v4.4
Commits imported:62e345ae5b6eusb: dwc3: gadget: don't prestart interrupt endpointsb9e51b2b1fdausb: dwc3: gadget: let us set lowermax_speedb4c580a43d52usb: dwc3: pci: add support for Intel Broxton SOCd115d7050a0dRevert "usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs"e5f68b4a3e7bRevert "usb: dwc3: gadget: remove unnecessary_irqsave()"94218ee31ba5usb: dwc3: pci: Set enblslpm quirk for Synopsys platformsec791d149bcausb: dwc3: Adddis_enblslpm_quirkbb7f3d6d323ausb: dwc3: pci: Add platform data for Synopsys HAPS9a5a0783e491usb: dwc3: pci: trivial: Formatting690fb3718a70usb: dwc3: Support Synopsys USB 3.1 IPe8095a25364ausb: dwc3: pci: Add the PCI Product ID for Synopsys USB 3.141adc59caeceusb: dwc3: pci: Add the Synopsys HAPS AXI Product ID70f3a9caa116usb: dwc3: gadget: remove unnecessary_irqsave()e6e709b7ab89usb: dwc3: gadget: use Update Transfer from Xfer In Progress6bb4fe12ea08usb: dwc3: gadget: use update transfer command8a1a9c9e4503usb: dwc3: gadget: start transfer onXFER_COMPLETE9caeb06ebd46usb: dwc3: pci: passing forward the ACPI companion3d128919b7e5usb: dwc3: core: convert to unified device property interface06e7114f0d82usb: common:of_usb_get_dr_modetousb_get_dr_mode666472733b8cusb: dwc3: st: prepare the driver for genericusb_get_dr_modefunction63863b988eecusb: common:of_usb_get_maximum_speedtousb_get_maximum_speed6344475f5397usb: dwc3: support for pinctrl state change during system sleepdb2be4e9e30cusb: dwc3: Add frame length adjustment quirka8f32817eeb0usb: dwc3: gadget: improve ep_queue's error reporting89185916d229usb: dwc3: gadget: clearDWC3_PENDING_REQUESTwhen request is queued1d6a39186b37usb: dwc3: gadget: start requests as soon as they comefe84f522ed6dusb: dwc3: gadget: movetrace_dwc3_ep_queue()
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
Quoted 549 lines
--- drivers/usb/dwc3/core.c | 104 ++++++++++++++++++------- drivers/usb/dwc3/core.h | 27 +++++++ drivers/usb/dwc3/gadget.c | 125 +++++++++++++++++++++---------- drivers/usb/dwc3/platform_data.h | 3 + 4 files changed, 194 insertions(+), 65 deletions(-)drivers/usb/dwc3/core.c +77
-27@@ -34,6 +34,7 @@#include <linux/dma-mapping.h> #include <linux/of.h> #include <linux/acpi.h> +#include <linux/pinctrl/consumer.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> @@ -143,6 +144,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)return 0 ; } +/* +* dwc3_frame_length_adjustment - Adjusts frame length if required +* @dwc3: Pointer to our controller context structure +* @fladj: Value of GFLADJ_30MHZ to adjust frame length +*/ +static void dwc3_frame_length_adjustment (struct dwc3 *dwc,u32 fladj) +{ +u32 reg; +u32 dft; + +if (dwc->revision <DWC3_REVISION_250A ) +return ; + +if (fladj ==0 ) +return ; + + reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); + dft = reg &DWC3_GFLADJ_30MHZ_MASK ; +if (!dev_WARN_ONCE (dwc->dev, dft == fladj, +"request value same as default, ignoring\n" )) { + reg &= ~DWC3_GFLADJ_30MHZ_MASK ; + reg |=DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj; +dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); + } +} +/** * dwc3_free_one_event_buffer - Frees one event buffer * @dwc: Pointer to our controller context structure @@ -488,6 +515,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_u2_susphy_quirk) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ; +if (dwc->dis_enblslpm_quirk) + reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg);return 0 ;@@ -507,12 +537,18 @@ static int dwc3_core_init(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_GSNPSID );/* This should read as U3 followed by revision number */ -if ((reg &DWC3_GSNPSID_MASK ) !=0x55330000 ) { +if ((reg &DWC3_GSNPSID_MASK ) ==0x55330000 ) { +/* Detected DWC_usb3 IP */ + dwc->revision = reg; + }else if ((reg &DWC3_GSNPSID_MASK ) ==0x33310000 ) { +/* Detected DWC_usb31 IP */ + dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); + dwc->revision |=DWC3_REVISION_IS_DWC31 ; + }else {dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); ret = -ENODEV ; goto err0; } - dwc->revision = reg;/* * Write Linux Version Code to our GUID register so it's easy to figure @@ -773,12 +809,12 @@ static int dwc3_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct dwc3_platform_data *pdata =dev_get_platdata (dev); -struct device_node *node = dev->of_node;struct resource *res;struct dwc3 *dwc;u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold; +u32 fladj =0 ;int ret;@@ -842,51 +878,56 @@ static int dwc3_probe(struct platform_device *pdev)*/ hird_threshold =12 ; -if (node) { - dwc->maximum_speed =of_usb_get_maximum_speed (node); - dwc->has_lpm_erratum =of_property_read_bool (node, + dwc->maximum_speed =usb_get_maximum_speed (dev); + dwc->dr_mode =usb_get_dr_mode (dev); + + dwc->has_lpm_erratum =device_property_read_bool (dev,"snps,has-lpm-erratum" ); -of_property_read_u8 (node,"snps,lpm-nyet-threshold" , +device_property_read_u8 (dev,"snps,lpm-nyet-threshold" , &lpm_nyet_threshold); - dwc->is_utmi_l1_suspend =of_property_read_bool (node, + dwc->is_utmi_l1_suspend =device_property_read_bool (dev,"snps,is-utmi-l1-suspend" ); -of_property_read_u8 (node,"snps,hird-threshold" , +device_property_read_u8 (dev,"snps,hird-threshold" , &hird_threshold); - dwc->usb3_lpm_capable =of_property_read_bool (node, + dwc->usb3_lpm_capable =device_property_read_bool (dev,"snps,usb3_lpm_capable" ); - dwc->needs_fifo_resize =of_property_read_bool (node, + dwc->needs_fifo_resize =device_property_read_bool (dev,"tx-fifo-resize" ); - dwc->dr_mode =of_usb_get_dr_mode (node); - dwc->disable_scramble_quirk =of_property_read_bool (node, + dwc->disable_scramble_quirk =device_property_read_bool (dev,"snps,disable_scramble_quirk" ); - dwc->u2exit_lfps_quirk =of_property_read_bool (node, + dwc->u2exit_lfps_quirk =device_property_read_bool (dev,"snps,u2exit_lfps_quirk" ); - dwc->u2ss_inp3_quirk =of_property_read_bool (node, + dwc->u2ss_inp3_quirk =device_property_read_bool (dev,"snps,u2ss_inp3_quirk" ); - dwc->req_p1p2p3_quirk =of_property_read_bool (node, + dwc->req_p1p2p3_quirk =device_property_read_bool (dev,"snps,req_p1p2p3_quirk" ); - dwc->del_p1p2p3_quirk =of_property_read_bool (node, + dwc->del_p1p2p3_quirk =device_property_read_bool (dev,"snps,del_p1p2p3_quirk" ); - dwc->del_phy_power_chg_quirk =of_property_read_bool (node, + dwc->del_phy_power_chg_quirk =device_property_read_bool (dev,"snps,del_phy_power_chg_quirk" ); - dwc->lfps_filter_quirk =of_property_read_bool (node, + dwc->lfps_filter_quirk =device_property_read_bool (dev,"snps,lfps_filter_quirk" ); - dwc->rx_detect_poll_quirk =of_property_read_bool (node, + dwc->rx_detect_poll_quirk =device_property_read_bool (dev,"snps,rx_detect_poll_quirk" ); - dwc->dis_u3_susphy_quirk =of_property_read_bool (node, + dwc->dis_u3_susphy_quirk =device_property_read_bool (dev,"snps,dis_u3_susphy_quirk" ); - dwc->dis_u2_susphy_quirk =of_property_read_bool (node, + dwc->dis_u2_susphy_quirk =device_property_read_bool (dev,"snps,dis_u2_susphy_quirk" ); + dwc->dis_enblslpm_quirk =device_property_read_bool (dev, +"snps,dis_enblslpm_quirk" ); - dwc->tx_de_emphasis_quirk =of_property_read_bool (node, + dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" ); -of_property_read_u8 (node,"snps,tx_de_emphasis" , +device_property_read_u8 (dev,"snps,tx_de_emphasis" , &tx_de_emphasis); -of_property_read_string (node,"snps,hsphy_interface" , - &dwc->hsphy_interface); - }else if (pdata) { +device_property_read_string (dev,"snps,hsphy_interface" , + &dwc->hsphy_interface); +device_property_read_u32 (dev,"snps,quirk-frame-length-adjustment" , + &fladj); + +if (pdata) { dwc->maximum_speed = pdata->maximum_speed; dwc->has_lpm_erratum = pdata->has_lpm_erratum;if (pdata->lpm_nyet_threshold)@@ -909,12 +950,14 @@ static int dwc3_probe(struct platform_device *pdev) dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; + dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;if (pdata->tx_de_emphasis) tx_de_emphasis = pdata->tx_de_emphasis; dwc->hsphy_interface = pdata->hsphy_interface; + fladj = pdata->fladj_value; }/* default to superspeed if no maximum_speed passed */ @@ -971,6 +1014,9 @@ static int dwc3_probe(struct platform_device *pdev) goto err1; } +/* Adjust Frame Length */ +dwc3_frame_length_adjustment (dwc, fladj); +usb_phy_set_suspend (dwc->usb2_phy,0 );usb_phy_set_suspend (dwc->usb3_phy,0 ); ret =phy_power_on (dwc->usb2_generic_phy);@@ -1091,6 +1137,8 @@ static int dwc3_suspend(struct device *dev)phy_exit (dwc->usb2_generic_phy);phy_exit (dwc->usb3_generic_phy); +pinctrl_pm_select_sleep_state (dev); +return 0 ; }@@ -1100,6 +1148,8 @@ static int dwc3_resume(struct device *dev)unsigned long flags;int ret; +pinctrl_pm_select_default_state (dev); +usb_phy_init (dwc->usb3_phy);usb_phy_init (dwc->usb2_phy); ret =phy_init (dwc->usb2_generic_phy);drivers/usb/dwc3/core.h +27
-0@@ -108,6 +108,9 @@#define DWC3_GPRTBIMAP_FS0 0xc188#define DWC3_GPRTBIMAP_FS1 0xc18c +#define DWC3_VER_NUMBER 0xc1a0 +#define DWC3_VER_TYPE 0xc1a4 +#define DWC3_GUSB2PHYCFG (n) (0xc200 + (n * 0x04))#define DWC3_GUSB2I2CCTL (n) (0xc240 + (n * 0x04))@@ -124,6 +127,7 @@#define DWC3_GEVNTCOUNT (n) (0xc40c + (n * 0x10))#define DWC3_GHWPARAMS8 0xc600 +#define DWC3_GFLADJ 0xc630/* Device Registers */ #define DWC3_DCFG 0xc700@@ -175,6 +179,7 @@#define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6)#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4) +#define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8)/* Global USB2 PHY Vendor Control Register */ #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)@@ -234,6 +239,10 @@/* Global HWPARAMS6 Register */ #define DWC3_GHWPARAMS6_EN_FPGA (1 << 7) +/* Global Frame Length Adjustment Register */ +#define DWC3_GFLADJ_30MHZ_SDBND_SEL (1 << 7) +#define DWC3_GFLADJ_30MHZ_MASK 0x3f +/* Device Configuration Register */ #define DWC3_DCFG_DEVADDR (addr) ((addr) << 3)#define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)@@ -712,6 +721,8 @@ struct dwc3_scratchpad_array {* @rx_detect_poll_quirk: set if we enable rx_detect to polling lfps quirk * @dis_u3_susphy_quirk: set if we disable usb3 suspend phy * @dis_u2_susphy_quirk: set if we disable usb2 suspend phy +* @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG, +* disabling the suspend signal to the PHY. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk * @tx_de_emphasis: Tx de-emphasis value * 0 - -6dB de-emphasis @@ -766,6 +777,14 @@ struct dwc3 {u32 num_event_buffers;u32 u1u2;u32 maximum_speed; + +/* +* All 3.1 IP version constants are greater than the 3.0 IP +* version constants. This works for most version checks in +* dwc3. However, in the future, this may not apply as +* features may be developed on newer versions of the 3.0 IP +* that are not in the 3.1 IP. +*/ u32 revision;#define DWC3_REVISION_173A 0x5533173a@@ -788,6 +807,13 @@ struct dwc3 {#define DWC3_REVISION_270A 0x5533270a#define DWC3_REVISION_280A 0x5533280a +/* +* NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really +* just so dwc31 revisions are always larger than dwc3. +*/ +#define DWC3_REVISION_IS_DWC31 0x80000000 +#define DWC3_USB31_REVISION_110A (0x3131302a | DWC3_REVISION_IS_USB31) +enum dwc3_ep0_next ep0_next_event;enum dwc3_ep0_state ep0state;enum dwc3_link_state link_state;@@ -841,6 +867,7 @@ struct dwc3 { unsigned rx_detect_poll_quirk:1; unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; + unsigned dis_enblslpm_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;drivers/usb/dwc3/gadget.c +87
-38@@ -948,7 +948,6 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param,dwc3_trace (trace_dwc3_gadget,"%s: endpoint busy" , dep->name);return -EBUSY ; } - dep->flags &= ~DWC3_EP_PENDING_REQUEST ;/* * If we are getting here after a short-out-packet we don't enqueue any @@ -1050,6 +1049,8 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) req->direction = dep->direction; req->epnum = dep->number; +trace_dwc3_ep_queue (req); +/* * We only add to our list of requests now and * start consuming the list once we get XferNotReady @@ -1069,6 +1070,20 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)list_add_tail (&req->list, &dep->request_list); +/* +* If there are no pending requests and the endpoint isn't already +* busy, we will just start the request straight away. +* +* This will save one IRQ (XFER_NOT_READY) and possibly make it a +* little bit faster. +*/ +if (!usb_endpoint_xfer_isoc (dep->endpoint.desc) && + !usb_endpoint_xfer_int (dep->endpoint.desc) && + !(dep->flags &DWC3_EP_BUSY )) { + ret =__dwc3_gadget_kick_transfer (dep,0 , true); + goto out; + } +/* * There are a few special cases: * @@ -1096,10 +1111,10 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) } ret =__dwc3_gadget_kick_transfer (dep,0 , true); -if (ret && ret != -EBUSY ) -dev_dbg (dwc->dev,"%s: failed to kick transfers\n" , - dep->name); -return ret; +if (!ret) + dep->flags &= ~DWC3_EP_PENDING_REQUEST ; + + goto out; }/* @@ -1113,10 +1128,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)WARN_ON_ONCE (!dep->resource_index); ret =__dwc3_gadget_kick_transfer (dep, dep->resource_index, false); -if (ret && ret != -EBUSY ) -dev_dbg (dwc->dev,"%s: failed to kick transfers\n" , - dep->name); -return ret; + goto out; }/* @@ -1124,14 +1136,17 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)* right away, otherwise host will not know we have streams to be * handled. */ -if (dep->stream_capable) { +if (dep->stream_capable) ret =__dwc3_gadget_kick_transfer (dep,0 , true); -if (ret && ret != -EBUSY ) -dev_dbg (dwc->dev,"%s: failed to kick transfers\n" , - dep->name); - } -return 0 ; +out: +if (ret && ret != -EBUSY ) +dev_dbg (dwc->dev,"%s: failed to kick transfers\n" , + dep->name); +if (ret == -EBUSY ) + ret =0 ; + +return ret; } static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,@@ -1159,8 +1174,6 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, goto out; } -trace_dwc3_ep_queue (req); - ret =__dwc3_gadget_ep_queue (dep, req); out:@@ -1872,27 +1885,32 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,unsigned int i;int ret; - req =next_request (&dep->req_queued); -if (!req) { -WARN_ON_ONCE (1 ); -return 1 ; - } - i =0 ;do { - slot = req->start_slot + i; -if ((slot ==DWC3_TRB_NUM -1 ) && + req =next_request (&dep->req_queued); +if (!req) { +WARN_ON_ONCE (1 ); +return 1 ; + } + i =0 ; +do { + slot = req->start_slot + i; +if ((slot ==DWC3_TRB_NUM -1 ) &&usb_endpoint_xfer_isoc (dep->endpoint.desc)) - slot++; - slot %=DWC3_TRB_NUM ; - trb = &dep->trb_pool[slot]; + slot++; + slot %=DWC3_TRB_NUM ; + trb = &dep->trb_pool[slot]; + + ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, + event, status); +if (ret) +break ; + }while (++i < req->request.num_mapped_sgs); + +dwc3_gadget_giveback (dep, req, status); - ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, - event, status);if (ret)break ; - }while (++i < req->request.num_mapped_sgs); - -dwc3_gadget_giveback (dep, req, status); + }while (1 );if (usb_endpoint_xfer_isoc (dep->endpoint.desc) &&list_empty (&dep->req_queued)) {@@ -1955,6 +1973,14 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, dwc->u1u2 =0 ; } + +if (!usb_endpoint_xfer_isoc (dep->endpoint.desc)) { +int ret; + + ret =__dwc3_gadget_kick_transfer (dep,0 , is_xfer_complete); +if (!ret || ret == -EBUSY ) +return ; + } } static void dwc3_endpoint_interrupt(struct dwc3 *dwc,@@ -1992,15 +2018,16 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,if (usb_endpoint_xfer_isoc (dep->endpoint.desc)) {dwc3_gadget_start_isoc (dwc, dep, event); }else { +int active;int ret; + active = event->status &DEPEVT_STATUS_TRANSFER_ACTIVE ; +dwc3_trace (trace_dwc3_gadget,"%s: reason %s" , - dep->name, event->status & -DEPEVT_STATUS_TRANSFER_ACTIVE - ?"Transfer Active" + dep->name, active ?"Transfer Active" :"Transfer Not Active" ); - ret =__dwc3_gadget_kick_transfer (dep,0 ,1 ); + ret =__dwc3_gadget_kick_transfer (dep,0 , !active);if (!ret || ret == -EBUSY )return ;@@ -2718,11 +2745,33 @@ int dwc3_gadget_init(struct dwc3 *dwc) } dwc->gadget.ops = &dwc3_gadget_ops; - dwc->gadget.max_speed =USB_SPEED_SUPER ; dwc->gadget.speed =USB_SPEED_UNKNOWN ; dwc->gadget.sg_supported = true; dwc->gadget.name ="dwc3-gadget" ; +/* +* FIXME We might be setting max_speed to <SUPER, however versions +* <2.20a of dwc3 have an issue with metastability (documented +* elsewhere in this driver) which tells us we can't set max speed to +* anything lower than SUPER. +* +* Because gadget.max_speed is only used by composite.c and function +* drivers (i.e. it won't go into dwc3's registers) we are allowing this +* to happen so we avoid sending SuperSpeed Capability descriptor +* together with our BOS descriptor as that could confuse host into +* thinking we can handle super speed. +* +* Note that, in fact, we won't even support GetBOS requests when speed +* is less than super speed because we don't have means, yet, to tell +* composite.c that we are USB 2.0 + LPM ECN. +*/ +if (dwc->revision <DWC3_REVISION_220A ) +dwc3_trace (trace_dwc3_gadget, +"Changing max_speed on rev %08x\n" , + dwc->revision); + + dwc->gadget.max_speed = dwc->maximum_speed; +/* * Per databook, DWC3 needs buffer size to be aligned to MaxPacketSize * on ep out. drivers/usb/dwc3/platform_data.h +3
-0@@ -42,9 +42,12 @@ struct dwc3_platform_data { unsigned rx_detect_poll_quirk:1; unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; + unsigned dis_enblslpm_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; +u32 fladj_value; +const char *hsphy_interface; };Signature · 1 line
2.53.0
PATCH v5 8/75 usb: dwc3: import from kernel v4.5
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.4 to v4.5.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.4..v4.5
Commits imported:c450960187f4 usb: dwc3: Fix assignment of EP transfer resources 6a4290cc28be usb: dwc3: gadget: set the OTG flag in dwc3 gadget driver. 5072cfc40a80 usb: dwc3: of-simple: fix build warning on !PM d9261898a4b2 usb: dwc3: gadget: don't send extra ZLP 95ca961c758c usb: dwc3: gadget: pass a condition to dev_WARN_ONCE() 46a01427e969 usb: dwc3: trace: show request flags 04c03d10e507 usb: dwc3: gadget: handle request->zero b084662776be usb: dwc3: remove dwc3-qcom in favor of dwc3-of-simple 16adc674d0d6 usb: dwc3: add generic OF glue layer b5d335e5ea6a usb: dwc3: ep0: fix setup_packet_pending initialization ac7bdcc1b3ad usb: dwc3: gadget: simplify next_request() return check acc38c4970ca usb: dwc3: ep0: purge dev_dbg() calls 1407bf13e3bf usb: dwc3: core: purge dev_dbg() calls ec5e795cdefb usb: dwc3: gadget: purge dev_dbg() calls bb423984c28e usb: dwc3: gadget: simplify dwc3_gadget_ep_queue()
--- drivers/usb/dwc3/core.c | 8 +- drivers/usb/dwc3/core.h | 4 +- drivers/usb/dwc3/ep0.c | 17 ++-- drivers/usb/dwc3/gadget.c | 204 ++++++++++++++++++++++++++------------ 4 files changed, 157 insertions(+), 76 deletions(-)
drivers/usb/dwc3/core.c +5 -3
@@ -272,7 +272,8 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc)for (n =0 ; n < dwc->num_event_buffers; n++) { evt = dwc->ev_buffs[n]; -dev_dbg (dwc->dev,"Event buf %p dma %08llx length %d\n" , +dwc3_trace (trace_dwc3_core, +"Event buf %p dma %08llx length %d\n" , evt->buf, (unsigned long long ) evt->dma, evt->length);
@@ -608,12 +609,13 @@ static int dwc3_core_init(struct dwc3 *dwc) reg |=DWC3_GCTL_GBLHIBERNATIONEN ;break ;default : -dev_dbg (dwc->dev,"No power optimization available\n" ); +dwc3_trace (trace_dwc3_core,"No power optimization available\n" ); }/* check if current dwc3 is on simulation board */ if (dwc->hwparams.hwparams6 &DWC3_GHWPARAMS6_EN_FPGA ) { -dev_dbg (dwc->dev,"it is on FPGA board\n" ); +dwc3_trace (trace_dwc3_core, +"running on FPGA platform\n" ); dwc->is_fpga = true; }
drivers/usb/dwc3/core.h +3 -1
@@ -37,6 +37,7 @@#define DWC3_MSG_MAX 500/* Global constants */ +#define DWC3_ZLP_BUF_SIZE 1024/* size of a superspeed bulk */ #define DWC3_EP0_BOUNCE_SIZE 512#define DWC3_ENDPOINTS_NUM 32#define DWC3_XHCI_RESOURCES_NUM 2
@@ -647,6 +648,7 @@ struct dwc3_scratchpad_array {* @ctrl_req: usb control request which is used for ep0 * @ep0_trb: trb which is used for the ctrl_req * @ep0_bounce: bounce buffer for ep0 +* @zlp_buf: used when request->zero is set * @setup_buf: used while precessing STD USB requests * @ctrl_req_addr: dma address of ctrl_req * @ep0_trb: dma address of ep0_trb
@@ -734,6 +736,7 @@ struct dwc3 {struct usb_ctrlrequest *ctrl_req;struct dwc3_trb *ep0_trb;void *ep0_bounce; +void *zlp_buf;void *scratchbuf;u8 *setup_buf;dma_addr_t ctrl_req_addr;
@@ -853,7 +856,6 @@ struct dwc3 { unsigned pullups_connected:1; unsigned resize_fifos:1; unsigned setup_packet_pending:1; - unsigned start_config_issued:1; unsigned three_stage_setup:1; unsigned usb3_lpm_capable:1;
drivers/usb/dwc3/ep0.c +7 -10
@@ -555,7 +555,6 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)int ret;u32 reg; - dwc->start_config_issued = false; cfg =le16_to_cpu (ctrl->wValue);switch (state) {
@@ -737,10 +736,6 @@ static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)dwc3_trace (trace_dwc3_ep0,"USB_REQ_SET_ISOCH_DELAY" ); ret =dwc3_ep0_set_isoch_delay (dwc, ctrl);break ; -case USB_REQ_SET_INTERFACE : -dwc3_trace (trace_dwc3_ep0,"USB_REQ_SET_INTERFACE" ); - dwc->start_config_issued = false; -/* Fall through */ default :dwc3_trace (trace_dwc3_ep0,"Forwarding to gadget driver" ); ret =dwc3_ep0_delegate_req (dwc, ctrl);
@@ -817,6 +812,8 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, status =DWC3_TRB_SIZE_TRBSTS (trb->size);if (status ==DWC3_TRBSTS_SETUP_PENDING ) { + dwc->setup_packet_pending = true; +dwc3_trace (trace_dwc3_ep0,"Setup Pending received" );if (r)
@@ -916,8 +913,10 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc, } status =DWC3_TRB_SIZE_TRBSTS (trb->size); -if (status ==DWC3_TRBSTS_SETUP_PENDING ) +if (status ==DWC3_TRBSTS_SETUP_PENDING ) { + dwc->setup_packet_pending = true;dwc3_trace (trace_dwc3_ep0,"Setup Pending received" ); + } dwc->ep0state =EP0_SETUP_PHASE ;dwc3_ep0_out_start (dwc);
@@ -971,7 +970,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ret =usb_gadget_map_request (&dwc->gadget, &req->request, dep->number);if (ret) { -dev_dbg (dwc->dev,"failed to map request\n" ); +dwc3_trace (trace_dwc3_ep0,"failed to map request\n" );return ; }
@@ -999,7 +998,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ret =usb_gadget_map_request (&dwc->gadget, &req->request, dep->number);if (ret) { -dev_dbg (dwc->dev,"failed to map request\n" ); +dwc3_trace (trace_dwc3_ep0,"failed to map request\n" );return ; }
@@ -1063,8 +1062,6 @@ static void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep)static void dwc3_ep0_xfernotready (struct dwc3 *dwc,const struct dwc3_event_depevt *event) { - dwc->setup_packet_pending = true; -switch (event->status) {case DEPEVT_STATUS_CONTROL_DATA :dwc3_trace (trace_dwc3_ep0,"Control Data" );
drivers/usb/dwc3/gadget.c +142 -62
382 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 08/75] usb: dwc3: import from kernel v4.5
Hi Anders,
Thank you for the patch.
Quoted 35 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.4 to v4.5.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.4..v4.5
Commits imported:c450960187f4usb: dwc3: Fix assignment of EP transfer resources6a4290cc28beusb: dwc3: gadget: set the OTG flag in dwc3 gadget driver.5072cfc40a80usb: dwc3: of-simple: fix build warning on !PMd9261898a4b2usb: dwc3: gadget: don't send extra ZLP95ca961c758cusb: dwc3: gadget: pass a condition todev_WARN_ONCE()46a01427e969usb: dwc3: trace: show request flags04c03d10e507usb: dwc3: gadget: handlerequest->zerob084662776beusb: dwc3: remove dwc3-qcom in favor of dwc3-of-simple16adc674d0d6usb: dwc3: add generic OF glue layerb5d335e5ea6ausb: dwc3: ep0: fixsetup_packet_pendinginitializationac7bdcc1b3adusb: dwc3: gadget: simplifynext_request()return checkacc38c4970causb: dwc3: ep0: purgedev_dbg()calls1407bf13e3bfusb: dwc3: core: purgedev_dbg()callsec5e795cdefbusb: dwc3: gadget: purgedev_dbg()callsbb423984c28eusb: dwc3: gadget: simplifydwc3_gadget_ep_queue()
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 9/75 usb: dwc3: import from kernel v4.6
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.5 to v4.6.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.5..v4.6
Commits imported:9772b47a4c29 usb: dwc3: gadget: Fix suspend/resume during device mode e6bdf8195b4a usb: dwc3: fix memory leak of dwc->regset5c4ad318de3b usb: dwc3: core: fix PHY handling during suspend 45d49cb706e5 usb: dwc3: omap: fix up error path on probe() adf9a3ab90eb usb: dwc3: keystone: drop dma_mask configuration 1ffb4d5cc78a usb: dwc3: pci: add ID for one more Intel Broxton platform e901aa159dac usb: dwc3: gadget: fix endpoint renamingad14d4e0308a usb: dwc3: gadget: release spin lock during gadget resume f59dcab17629 usb: dwc3: core: improve reset sequence77966eb85e6d usb: dwc3: Validate the maximum_speed parameter 7580862b3e80 usb: dwc3: Enable SuperSpeedPlus2c7f1bd9127a usb: dwc3: Update maximum_speed for SuperSpeedPlus ee5cd41c9117 usb: dwc3: Update speed checks for SuperSpeedPlus 1f38f88a24c8 usb: dwc3: Update register fields for SuperSpeedPlus c4137a9c841e usb: dwc3: DWC_usb31 controller check3d755dcc20dd usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0
--- drivers/usb/dwc3/core.c | 102 +++++++++++++++++++++++++------------- drivers/usb/dwc3/core.h | 11 +++- drivers/usb/dwc3/ep0.c | 9 ++-- drivers/usb/dwc3/gadget.c | 47 ++++++++++++++---- 4 files changed, 119 insertions(+), 50 deletions(-)
drivers/usb/dwc3/core.c +67 -35
@@ -67,23 +67,9 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)static int dwc3_core_soft_reset (struct dwc3 *dwc) {u32 reg; +int retries =1000 ;int ret; -/* Before Resetting PHY, put Core in Reset */ - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); - reg |=DWC3_GCTL_CORESOFTRESET ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); - -/* Assert USB3 PHY reset */ - reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); - reg |=DWC3_GUSB3PIPECTL_PHYSOFTRST ; -dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); - -/* Assert USB2 PHY reset */ - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); - reg |=DWC3_GUSB2PHYCFG_PHYSOFTRST ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -usb_phy_init (dwc->usb2_phy);usb_phy_init (dwc->usb3_phy); ret =phy_init (dwc->usb2_generic_phy);
@@ -95,26 +81,28 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)phy_exit (dwc->usb2_generic_phy);return ret; } -mdelay (100 ); -/* Clear USB3 PHY reset */ - reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); - reg &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST ; -dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); +/* +* We're resetting only the device side because, if we're in host mode, +* XHCI driver will reset the host block. If dwc3 was configured for +* host-only mode, then we can return early. +*/ +if (dwc->dr_mode ==USB_DR_MODE_HOST ) +return 0 ; -/* Clear USB2 PHY reset */ - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); - reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg |=DWC3_DCTL_CSFTRST ; +dwc3_writel (dwc->regs,DWC3_DCTL , reg); -mdelay (100 ); +do { + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); +if (!(reg &DWC3_DCTL_CSFTRST )) +return 0 ; -/* After PHYs are stable we can take Core out of reset state */ - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); - reg &= ~DWC3_GCTL_CORESOFTRESET ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +udelay (1 ); + }while (--retries); -return 0 ; +return -ETIMEDOUT ; }/**
@@ -962,10 +950,6 @@ static int dwc3_probe(struct platform_device *pdev) fladj = pdata->fladj_value; } -/* default to superspeed if no maximum_speed passed */ -if (dwc->maximum_speed ==USB_SPEED_UNKNOWN ) - dwc->maximum_speed =USB_SPEED_SUPER ; - dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis;
@@ -1016,6 +1000,33 @@ static int dwc3_probe(struct platform_device *pdev) goto err1; } +/* Check the maximum_speed parameter */ +switch (dwc->maximum_speed) { +case USB_SPEED_LOW : +case USB_SPEED_FULL : +case USB_SPEED_HIGH : +case USB_SPEED_SUPER : +case USB_SPEED_SUPER_PLUS : +break ; +default : +dev_err (dev,"invalid maximum_speed parameter %d\n" , + dwc->maximum_speed); +/* fall through */ +case USB_SPEED_UNKNOWN : +/* default to superspeed */ + dwc->maximum_speed =USB_SPEED_SUPER ; + +/* +* default to superspeed plus if we are capable. +*/ +if (dwc3_is_usb31 (dwc) && + (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == +DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 )) + dwc->maximum_speed =USB_SPEED_SUPER_PLUS ; + +break ; + } +/* Adjust Frame Length */ dwc3_frame_length_adjustment (dwc, fladj);
@@ -1139,6 +1150,11 @@ static int dwc3_suspend(struct device *dev)phy_exit (dwc->usb2_generic_phy);phy_exit (dwc->usb3_generic_phy); +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 ); +WARN_ON (phy_power_off (dwc->usb2_generic_phy) <0 ); +WARN_ON (phy_power_off (dwc->usb3_generic_phy) <0 ); +pinctrl_pm_select_sleep_state (dev);return 0 ;
@@ -1152,11 +1168,21 @@ static int dwc3_resume(struct device *dev)pinctrl_pm_select_default_state (dev); +usb_phy_set_suspend (dwc->usb2_phy,0 ); +usb_phy_set_suspend (dwc->usb3_phy,0 ); + ret =phy_power_on (dwc->usb2_generic_phy); +if (ret <0 ) +return ret; + + ret =phy_power_on (dwc->usb3_generic_phy); +if (ret <0 ) + goto err_usb2phy_power; +usb_phy_init (dwc->usb3_phy);usb_phy_init (dwc->usb2_phy); ret =phy_init (dwc->usb2_generic_phy);if (ret <0 ) -return ret; + goto err_usb3phy_power; ret =phy_init (dwc->usb3_generic_phy);if (ret <0 )
@@ -1189,6 +1215,12 @@ static int dwc3_resume(struct device *dev) err_usb2phy_init:phy_exit (dwc->usb2_generic_phy); +err_usb3phy_power: +phy_power_off (dwc->usb3_generic_phy); + +err_usb2phy_power: +phy_power_off (dwc->usb2_generic_phy); +return ret; }
drivers/usb/dwc3/core.h +10 -1
@@ -223,7 +223,8 @@/* Global HWPARAMS3 Register */ #define DWC3_GHWPARAMS3_SSPHY_IFC (n) ((n) & 3)#define DWC3_GHWPARAMS3_SSPHY_IFC_DIS 0 -#define DWC3_GHWPARAMS3_SSPHY_IFC_ENA 1 +#define DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 1 +#define DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 2/* DWC_usb31 only */ #define DWC3_GHWPARAMS3_HSPHY_IFC (n) (((n) & (3 << 2)) >> 2)#define DWC3_GHWPARAMS3_HSPHY_IFC_DIS 0#define DWC3_GHWPARAMS3_HSPHY_IFC_UTMI 1
@@ -249,6 +250,7 @@#define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)#define DWC3_DCFG_SPEED_MASK (7 << 0) +#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0)/* DWC_usb31 only */ #define DWC3_DCFG_SUPERSPEED (4 << 0)#define DWC3_DCFG_HIGHSPEED (0 << 0)#define DWC3_DCFG_FULLSPEED2 (1 << 0)
@@ -339,6 +341,7 @@#define DWC3_DSTS_CONNECTSPD (7 << 0) +#define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0)/* DWC_usb31 only */ #define DWC3_DSTS_SUPERSPEED (4 << 0)#define DWC3_DSTS_HIGHSPEED (0 << 0)#define DWC3_DSTS_FULLSPEED2 (1 << 0)
@@ -1024,6 +1027,12 @@ struct dwc3_gadget_ep_cmd_params {void dwc3_set_mode (struct dwc3 *dwc,u32 mode);int dwc3_gadget_resize_tx_fifos (struct dwc3 *dwc); +/* check whether we are on the DWC_usb31 core */ +static inline bool dwc3_is_usb31 (struct dwc3 *dwc) +{ +return !!(dwc->revision &DWC3_REVISION_IS_DWC31 ); +} +#if IS_ENABLED (CONFIG_USB_DWC3_HOST ) ||IS_ENABLED (CONFIG_USB_DWC3_DUAL_ROLE )int dwc3_host_init (struct dwc3 *dwc);void dwc3_host_exit (struct dwc3 *dwc);
drivers/usb/dwc3/ep0.c +6 -3
@@ -356,7 +356,8 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,*/ usb_status |= dwc->gadget.is_selfpowered; -if (dwc->speed ==DWC3_DSTS_SUPERSPEED ) { +if ((dwc->speed ==DWC3_DSTS_SUPERSPEED ) || + (dwc->speed ==DWC3_DSTS_SUPERSPEED_PLUS )) { reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (reg &DWC3_DCTL_INITU1ENA ) usb_status |=1 <<USB_DEV_STAT_U1_ENABLED ;
@@ -426,7 +427,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,case USB_DEVICE_U1_ENABLE :if (state !=USB_STATE_CONFIGURED )return -EINVAL ; -if (dwc->speed !=DWC3_DSTS_SUPERSPEED ) +if ((dwc->speed !=DWC3_DSTS_SUPERSPEED ) && + (dwc->speed !=DWC3_DSTS_SUPERSPEED_PLUS ))return -EINVAL ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );
@@ -440,7 +442,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,case USB_DEVICE_U2_ENABLE :if (state !=USB_STATE_CONFIGURED )return -EINVAL ; -if (dwc->speed !=DWC3_DSTS_SUPERSPEED ) +if ((dwc->speed !=DWC3_DSTS_SUPERSPEED ) && + (dwc->speed !=DWC3_DSTS_SUPERSPEED_PLUS ))return -EINVAL ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );
drivers/usb/dwc3/gadget.c +36 -11
116 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 09/75] usb: dwc3: import from kernel v4.6
Hi Anders,
Thank you for the patch.
Quoted 36 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.5 to v4.6.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.5..v4.6
Commits imported:9772b47a4c29usb: dwc3: gadget: Fix suspend/resume during device modee6bdf8195b4ausb: dwc3: fix memory leak ofdwc->regset5c4ad318de3busb: dwc3: core: fix PHY handling during suspend45d49cb706e5usb: dwc3: omap: fix up error path onprobe()adf9a3ab90ebusb: dwc3: keystone: dropdma_maskconfiguration1ffb4d5cc78ausb: dwc3: pci: add ID for one more Intel Broxton platforme901aa159dacusb: dwc3: gadget: fix endpoint renamingad14d4e0308ausb: dwc3: gadget: release spin lock during gadget resumef59dcab17629usb: dwc3: core: improve reset sequence77966eb85e6dusb: dwc3: Validate themaximum_speedparameter7580862b3e80usb: dwc3: Enable SuperSpeedPlus2c7f1bd9127ausb: dwc3: Updatemaximum_speedfor SuperSpeedPlusee5cd41c9117usb: dwc3: Update speed checks for SuperSpeedPlus1f38f88a24c8usb: dwc3: Update register fields for SuperSpeedPlusc4137a9c841eusb: dwc3:DWC_usb31controller check3d755dcc20ddusb: dwc3: Remove impossible check forof_clk_get_parent_count()< 0
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 10/75 usb: dwc3: import from kernel v4.7
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.6 to v4.7.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.6..v4.7
Commits imported:5baaf3b9efe1 usb: dwc3: st: Use explicit reset_control_get_exclusive() API 002f17bc54ff usb: dwc3: st: Inform the reset framework that our reset line may be shared 50c763f8c1ba usb: dwc3: Set the ClearPendIN bit on Clear Stall EP command 27a0faafdca5 usb: dwc3: st: Fix USB_DR_MODE_PERIPHERAL configuration. 4879efb34f7d usb: dwc3: exynos: Fix deferred probing storm.973986126a41 usb: dwc3: gadget: fix mask and shift order in DWC3_DCFG_NUMP() 2a58f9c12bb3 usb: dwc3: gadget: disable automatic calculation of ACK TP NUMP 676e34974481 usb: dwc3: gadget: update DCFG.NumP to max burst size 7b9cc7a2b101 usb: dwc3: gadget: give better command return code ce046d323d74 usb: dwc3: pci: pass the platform device as a parameter to dwc3_pci_quirks() 474799f07376 usb: dwc3: pci: make build-in device properties available ae4114137607 usb: dwc3: ep0: sanity check test mode selector818ec3aba883 usb: dwc3: debugfs: dump out endpoint detailsb058f3e8a399 usb: dwc3: core: add helper to extract trb typecf6d867d3b57 usb: dwc3: core: add fifo space helper4e9f311833a9 usb: dwc3: make dwc3_debugfs_init return value be void af566a0be6e4 usb: dwc3: omap: get rid of dma_status8e7046b71dae usb: dwc3: gadget: don't interrupt when chained052ba52efa17 usb: dwc3: gadget: remove newline from trace36b68aae8e39 usb: dwc3: gadget: use link TRB for all endpoint types 4faf75504a7d usb: dwc3: gadget: move % operation to increment helpers ef966b9d3353 usb: dwc3: gadget: add trb enqueue/dequeue helpers 70fdb273db37 usb: dwc3: get rid of DWC3_TRB_MASKc28f82595dde usb: dwc3: switch trb enqueue/dequeue and first_trb_index to u8 5ef68c56e169 usb: dwc3: core: document struct dwc3_request53fd88189e08 usb: dwc3: gadget: rename busy/free_slot to trb_enqueue/dequeue 495dd5f78145 usb: dwc3: omap: drop dma_mask configuratione58dd357741b usb: dwc3: add disable receiver detection in P3 quirk c36d8e947a56 usb: dwc3: gadget: put link to U0 before Start Transfer 218ef7b647e3 usb: dwc3: gadget: extract unlocked dwc3_gadget_wakeup() 2b0f11df84bb usb: dwc3: gadget: clear SUSPHY bit before ep cmds c0ca324d09a0 usb: dwc3: gadget: combine return points into a single one dea520a4a283 usb: dwc3: gadget: pass ev_buff as cookie to irq handler 696c8b128220 usb: dwc3: drop ev_buffs array660e9bde74d6 usb: dwc3: remove num_event_buffersaa3342c8bb61 usb: dwc3: better name for our request management lists 8495036e986b usb: dwc3: increase maximum number of TRBs per endpoint ca4d44ea2a91 usb: dwc3: gadget: always enable CSPbc5081617fae usb: dwc3: drop FIFO resizing logic
--- drivers/usb/dwc3/core.c | 118 ++++---- drivers/usb/dwc3/core.h | 85 ++++-- drivers/usb/dwc3/debug.h | 6 +- drivers/usb/dwc3/ep0.c | 43 +-- drivers/usb/dwc3/gadget.c | 457 +++++++++++++++---------------- drivers/usb/dwc3/gadget.h | 6 +- drivers/usb/dwc3/platform_data.h | 2 +- 7 files changed, 374 insertions(+), 343 deletions(-)
drivers/usb/dwc3/core.c +52 -66
@@ -60,6 +60,20 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)dwc3_writel (dwc->regs,DWC3_GCTL , reg); } +u32 dwc3_core_fifo_space (struct dwc3_ep *dep,u8 type) +{ +struct dwc3 *dwc = dep->dwc; +u32 reg; + +dwc3_writel (dwc->regs,DWC3_GDBGFIFOSPACE , +DWC3_GDBGFIFOSPACE_NUM (dep->number) | +DWC3_GDBGFIFOSPACE_TYPE (type)); + + reg =dwc3_readl (dwc->regs,DWC3_GDBGFIFOSPACE ); + +return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE (reg); +} +/** * dwc3_core_soft_reset - Issues core soft reset and PHY reset * @dwc: pointer to our context structure
@@ -203,13 +217,10 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,static void dwc3_free_event_buffers (struct dwc3 *dwc) {struct dwc3_event_buffer *evt; -int i; -for (i =0 ; i < dwc->num_event_buffers; i++) { - evt = dwc->ev_buffs[i]; -if (evt) -dwc3_free_one_event_buffer (dwc, evt); - } + evt = dwc->ev_buf; +if (evt) +dwc3_free_one_event_buffer (dwc, evt); }/**
@@ -222,27 +233,14 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)*/ static int dwc3_alloc_event_buffers (struct dwc3 *dwc,unsigned length) { -int num; -int i; - - num =DWC3_NUM_INT (dwc->hwparams.hwparams1); - dwc->num_event_buffers = num; - - dwc->ev_buffs =devm_kzalloc (dwc->dev,sizeof (*dwc->ev_buffs) * num, -GFP_KERNEL ); -if (!dwc->ev_buffs) -return -ENOMEM ; - -for (i =0 ; i < num; i++) { -struct dwc3_event_buffer *evt; +struct dwc3_event_buffer *evt; - evt =dwc3_alloc_one_event_buffer (dwc, length); -if (IS_ERR (evt)) { -dev_err (dwc->dev,"can't allocate event buffer\n" ); -return PTR_ERR (evt); - } - dwc->ev_buffs[i] = evt; + evt =dwc3_alloc_one_event_buffer (dwc, length); +if (IS_ERR (evt)) { +dev_err (dwc->dev,"can't allocate event buffer\n" ); +return PTR_ERR (evt); } + dwc->ev_buf = evt;return 0 ; }
@@ -256,25 +254,22 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)static int dwc3_event_buffers_setup (struct dwc3 *dwc) {struct dwc3_event_buffer *evt; -int n; -for (n =0 ; n < dwc->num_event_buffers; n++) { - evt = dwc->ev_buffs[n]; -dwc3_trace (trace_dwc3_core, -"Event buf %p dma %08llx length %d\n" , - evt->buf, (unsigned long long ) evt->dma, - evt->length); - - evt->lpos =0 ; - -dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (n), -lower_32_bits (evt->dma)); -dwc3_writel (dwc->regs,DWC3_GEVNTADRHI (n), -upper_32_bits (evt->dma)); -dwc3_writel (dwc->regs,DWC3_GEVNTSIZ (n), -DWC3_GEVNTSIZ_SIZE (evt->length)); -dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (n),0 ); - } + evt = dwc->ev_buf; +dwc3_trace (trace_dwc3_core, +"Event buf %p dma %08llx length %d\n" , + evt->buf, (unsigned long long ) evt->dma, + evt->length); + + evt->lpos =0 ; + +dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (0 ), +lower_32_bits (evt->dma)); +dwc3_writel (dwc->regs,DWC3_GEVNTADRHI (0 ), +upper_32_bits (evt->dma)); +dwc3_writel (dwc->regs,DWC3_GEVNTSIZ (0 ), +DWC3_GEVNTSIZ_SIZE (evt->length)); +dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (0 ),0 );return 0 ; }
@@ -282,19 +277,16 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc)static void dwc3_event_buffers_cleanup (struct dwc3 *dwc) {struct dwc3_event_buffer *evt; -int n; -for (n =0 ; n < dwc->num_event_buffers; n++) { - evt = dwc->ev_buffs[n]; + evt = dwc->ev_buf; - evt->lpos =0 ; + evt->lpos =0 ; -dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (n),0 ); -dwc3_writel (dwc->regs,DWC3_GEVNTADRHI (n),0 ); -dwc3_writel (dwc->regs,DWC3_GEVNTSIZ (n),DWC3_GEVNTSIZ_INTMASK - |DWC3_GEVNTSIZ_SIZE (0 )); -dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (n),0 ); - } +dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (0 ),0 ); +dwc3_writel (dwc->regs,DWC3_GEVNTADRHI (0 ),0 ); +dwc3_writel (dwc->regs,DWC3_GEVNTSIZ (0 ),DWC3_GEVNTSIZ_INTMASK + |DWC3_GEVNTSIZ_SIZE (0 )); +dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (0 ),0 ); }static int dwc3_alloc_scratch_buffers (struct dwc3 *dwc)
@@ -434,6 +426,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (dwc->u2ss_inp3_quirk) reg |=DWC3_GUSB3PIPECTL_U2SSINP3OK ; +if (dwc->dis_rxdet_inp3_quirk) + reg |=DWC3_GUSB3PIPECTL_DISRXDETINP3 ; +if (dwc->req_p1p2p3_quirk) reg |=DWC3_GUSB3PIPECTL_REQP1P2P3 ;
@@ -882,9 +877,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->usb3_lpm_capable =device_property_read_bool (dev,"snps,usb3_lpm_capable" ); - dwc->needs_fifo_resize =device_property_read_bool (dev, -"tx-fifo-resize" ); - dwc->disable_scramble_quirk =device_property_read_bool (dev,"snps,disable_scramble_quirk" ); dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
@@ -907,6 +899,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,dis_u2_susphy_quirk"); dwc->dis_enblslpm_quirk =device_property_read_bool (dev,"snps,dis_enblslpm_quirk" ); + dwc->dis_rxdet_inp3_quirk =device_property_read_bool (dev, +"snps,dis_rxdet_inp3_quirk" ); dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" );
@@ -926,7 +920,6 @@ static int dwc3_probe(struct platform_device *pdev)if (pdata->hird_threshold) hird_threshold = pdata->hird_threshold; - dwc->needs_fifo_resize = pdata->tx_fifo_resize; dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; dwc->dr_mode = pdata->dr_mode;
@@ -941,6 +934,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; + dwc->dis_rxdet_inp3_quirk = pdata->dis_rxdet_inp3_quirk; dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;if (pdata->tx_de_emphasis)
@@ -1050,19 +1044,11 @@ static int dwc3_probe(struct platform_device *pdev)if (ret) goto err5; - ret =dwc3_debugfs_init (dwc); -if (ret) { -dev_err (dev,"failed to initialize debugfs\n" ); - goto err6; - } - +dwc3_debugfs_init (dwc);pm_runtime_allow (dev);return 0 ; -err6: -dwc3_core_exit_mode (dwc); - err5:dwc3_event_buffers_cleanup (dwc);
drivers/usb/dwc3/core.h +65 -20
209 lines not on this page · raw message
drivers/usb/dwc3/debug.h +3 -3
@@ -217,11 +217,11 @@ static inline const char *dwc3_gadget_event_type_string(u8 event)void dwc3_trace (void (*trace)(struct va_format *),const char *fmt, ...);#ifdef CONFIG_DEBUG_FS -extern int dwc3_debugfs_init (struct dwc3 *); +extern void dwc3_debugfs_init (struct dwc3 *);extern void dwc3_debugfs_exit (struct dwc3 *);#else -static inline int dwc3_debugfs_init (struct dwc3 *d) -{return 0 ; } +static inline void dwc3_debugfs_init (struct dwc3 *d) +{ }static inline void dwc3_debugfs_exit (struct dwc3 *d) { }#endif
drivers/usb/dwc3/ep0.c +22 -21
107 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +228 -229
828 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +3 -3
@@ -68,12 +68,12 @@ static inline struct dwc3_request *next_request(struct list_head *list) return list_first_entry(list, struct dwc3_request, list); } -static inline void dwc3_gadget_move_request_queued (struct dwc3_request *req) +static inline void dwc3_gadget_move_started_request (struct dwc3_request *req) {struct dwc3_ep *dep = req->dep; - req->queued = true; -list_move_tail (&req->list, &dep->req_queued); + req->started = true; +list_move_tail (&req->list, &dep->started_list); } void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
drivers/usb/dwc3/platform_data.h +1 -1
@@ -23,7 +23,6 @@struct dwc3_platform_data {enum usb_device_speed maximum_speed;enum usb_dr_mode dr_mode; -bool tx_fifo_resize;bool usb3_lpm_capable;unsigned is_utmi_l1_suspend:1 ;
@@ -43,6 +42,7 @@ struct dwc3_platform_data { unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; unsigned dis_enblslpm_quirk:1; + unsigned dis_rxdet_inp3_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;
Signature · 1 line
2.53.0
Re: [PATCH v5 10/75] usb: dwc3: import from kernel v4.7
Hi Anders,
Thank you for the patch.
Quoted 59 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.6 to v4.7.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.6..v4.7
Commits imported:5baaf3b9efe1usb: dwc3: st: Use explicitreset_control_get_exclusive()API002f17bc54ffusb: dwc3: st: Inform the reset framework that our reset line may be shared50c763f8c1bausb: dwc3: Set the ClearPendIN bit on Clear Stall EP command27a0faafdca5usb: dwc3: st: FixUSB_DR_MODE_PERIPHERALconfiguration.4879efb34f7dusb: dwc3: exynos: Fix deferred probing storm.973986126a41usb: dwc3: gadget: fix mask and shift order inDWC3_DCFG_NUMP()2a58f9c12bb3usb: dwc3: gadget: disable automatic calculation of ACK TP NUMP676e34974481usb: dwc3: gadget: update DCFG.NumP to max burst size7b9cc7a2b101usb: dwc3: gadget: give better command return codece046d323d74usb: dwc3: pci: pass the platform device as a parameter todwc3_pci_quirks()474799f07376usb: dwc3: pci: make build-in device properties availableae4114137607usb: dwc3: ep0: sanity check test mode selector818ec3aba883usb: dwc3: debugfs: dump out endpoint detailsb058f3e8a399usb: dwc3: core: add helper to extract trb typecf6d867d3b57usb: dwc3: core: add fifo space helper4e9f311833a9usb: dwc3: makedwc3_debugfs_initreturn value be voidaf566a0be6e4usb: dwc3: omap: get rid ofdma_status8e7046b71daeusb: dwc3: gadget: don't interrupt when chained052ba52efa17usb: dwc3: gadget: remove newline from trace36b68aae8e39usb: dwc3: gadget: use link TRB for all endpoint types4faf75504a7dusb: dwc3: gadget: move % operation to increment helpersef966b9d3353usb: dwc3: gadget: add trb enqueue/dequeue helpers70fdb273db37usb: dwc3: get rid ofDWC3_TRB_MASKc28f82595ddeusb: dwc3: switch trb enqueue/dequeue andfirst_trb_indexto u85ef68c56e169usb: dwc3: core: document structdwc3_request53fd88189e08usb: dwc3: gadget: rename busy/free_slot to trb_enqueue/dequeue495dd5f78145usb: dwc3: omap: dropdma_maskconfiguratione58dd357741busb: dwc3: add disable receiver detection in P3 quirkc36d8e947a56usb: dwc3: gadget: put link to U0 before Start Transfer218ef7b647e3usb: dwc3: gadget: extract unlockeddwc3_gadget_wakeup()2b0f11df84bbusb: dwc3: gadget: clear SUSPHY bit before ep cmdsc0ca324d09a0usb: dwc3: gadget: combine return points into a single onedea520a4a283usb: dwc3: gadget: passev_buffas cookie to irq handler696c8b128220usb: dwc3: dropev_buffsarray660e9bde74d6usb: dwc3: removenum_event_buffersaa3342c8bb61usb: dwc3: better name for our request management lists8495036e986busb: dwc3: increase maximum number of TRBs per endpointca4d44ea2a91usb: dwc3: gadget: always enable CSPbc5081617faeusb: dwc3: drop FIFO resizing logic
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 11/75 usb: dwc3: import from kernel v4.8
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.7 to v4.8.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.7..v4.8
Commits imported:696118c016dd usb: dwc3: pci: fix build warning on !PM_SLEEP 9d7aba7786b6 Revert "usb: dwc3: gadget: always decrement by 1" 6f8245b4e37c usb: dwc3: gadget: always decrement by 1696fe69d7e63 usb: dwc3: debug: fix ep name on trace output d6011f6fc21b usb: dwc3: gadget: don't rely on jiffies while holding spinlock b74c2d875baa usb: dwc3: core: allow device to runtime_suspend several times f6c274e11e3b usb: dwc3: pci: runtime_resume child devicea0ad85ae866f usb: dwc3: gadget: stop processing on HWO set 79d17482a409 usb: dwc3: don't set last bit for ISOC endpoints 4c4f106c032f usb: dwc3: fix missing platform_set_drvdata() in dwc3_of_simple_probe() 4491ed5042f0 usb: dwc3: pci: add Intel Kabylake PCI ID7c705dfe2ebe usb: dwc3: gadget: always cleanup all TRBse5b36ae2f851 usb: dwc3: gadget: fix for short pkts during chained xfers c7de57347183 usb: dwc3: gadget: increment request->actual once 322832f2f19e usb: dwc3: host: Fix broken XHCI host95b57df45062 usb: dwc3: host: use build-in property instead of platform data 72704f876f50 dwc3: gadget: Implement the suspend entry event handler 9522def40065 usb: dwc3: core: cleanup IRQ resourcesda1410be21bf usb: dwc3: gadget: Add the suspend state checking when stopping gadget 0e146028eebf usb: dwc3: gadget: issue ENDTRANSFER conditional on resource_index 328082376aea usb: dwc3: fix runtime PM in error pathb6d4e16e8313 usb: dwc3: gadget: simplify run_stop() break condition f2df679b6c55 usb: dwc3: gadget: avoid while(1) in run_stop() d807bdd02845 usb: dwc3: gadget: remove udelay() from run_stop() 5f82279a0c76 usb: dwc3: core: fixup dr_mode fallback selection e6fe66fe08cd usb: dwc3: pci: add dr-mode for Intel dwc321e64bf20df5 usb: dwc3: gadget: rename 'ignore' argument to 'modify' d6dc2e76a860 usb: dwc3: gadget: decrement trbs_left for each sg entry ba62c09d5cc2 usb: dwc3: gadget: start Bulk endpoints more frequently 13fa2e69b1dd usb: dwc3: gadget: disable XFER_NOT_READY55a0237f8f47 usb: dwc3: gadget: use allocated/queued reqs for LST bit 69450c4dc164 usb: dwc3: gadget: halt and stop based HWO bit 68d34c8a744d usb: dwc3: gadget: keep track of allocated and queued reqs b6b1c6db4c7f usb: dwc3: gadget: update transfer needs transfer resource d18e65470a4d usb: dwc3: remove handling of platform datacf48305de0c6 usb: dwc3: pci: use build-in properties instead of platform data 60cfb37ac9bc usb: dwc3: remove trailing newline from dwc3_trace d2728fb3e01f usb: dwc3: omap: Pass VBUS and ID events transparently 9ab330bf4dfd usb: dwc3: omap: Don't set POWERPRESENT12da8eae208d usb: dwc3: omap: Mark the interrupt handler as shared 3f586c92d877 usb: dwc3: omap: use request_threaded_irq()475c8beb35e1 usb: dwc3: add DWC3_GUCTL1 reg for debuge77c561432bc usb: dwc3: Fix DWC3_USB31_REVISION_110A definition 2da9ad761e70 usb: dwc3: Use the correct speed macros for DSTS/DCFG 3de2685f0c39 usb: dwc3: gadget: Fix truncated cast issue361572b5f7a9 usb: dwc3: gadget: Handle TRB index 0 when full or empty 7d0a038b130c usb: dwc3: gadget: Account for link TRB in TRBs left 32db3d9437b6 usb: dwc3: gadget: Account for max size in TRB space 89bc856e5a74 usb: dwc3: gadget: Don't prepare TRBs if no space 0d25744ad107 usb: dwc3: gadget: Initialize the TRB ringdca0119c3ab6 usb: dwc3: gadget: Simplify skipping of link TRBs 96bedb637a1e usb: dwc3: Endianness issue on dwc3_log_ctrld07fa665c79d usb: dwc3: gadget: Fix usage of bitwise operator 501058edebf9 usb: dwc3: ep0: Use the correct type for SET_SEL data 958b9fa7f8cf usb: dwc3: ep0: Fix endianness of wIndex passed to dwc3_wIndex_to_dep 71f7e7027028 usb: dwc3: gadget: improve gcmd trace88811f7b722c usb: dwc3: gadget: remove udelay() from generic cmd 0fe886cdb07a usb: dwc3: gadget: single return point on generic commands 0933df159c5c usb: dwc3: trace: print ep cmd status with a single trace f6bb225bb3ca usb: dwc3: gadget: loop while (timeout)ba1598410eff usb: dwc3: gadget: fix trace output when command fails f75cacc468ed usb: dwc3: trace: fully decode IRQ events7ab373aadbd0 usb: dwc3: gadget: no more tracking endpoint type with its name 22f2c619a116 usb: dwc3: trace: pretty-print TRB's ctrl field 74674cbf858f usb: dwc3: gadget: add a per-endpoint request queue lock e9af9229098d usb: dwc3: pci: add Power Management dummy hooks fc8bb91bc83e usb: dwc3: implement runtime PM4cb4221764ef usb: dwc3: gadget: fix for possible endpoint disable race 9cad39fe4e4a usb: dwc3: fix for the isoc transfer EP_BUSY flag ab2a92e7a608 usb: dwc3: gadget: only resume USB2 PHY in <=HIGHSPEED 3f308d17d7ab usb: dwc3: gadget: hold gadget IRQ in dwc->irq_gadget 51f5d49ad6f0 usb: dwc3: core: simplify suspend/resume operations c499ff71ff2a usb: dwc3: core: re-factor init and exit paths bcdb3272e889 usb: dwc3: core: move fladj to dwc3 structure 2eb8801650b3 usb: dwc3: gadget: add a pointer to endpoint registers 2cd4718d0bbe usb: dwc3: gadget: pass dep as argument to endpoint command 4e99472bc10b usb: dwc3: gadget: initialize NUMP based on RxFIFO Size 5ee85d890f8d usb: dwc3: gadget: split __dwc3_gadget_kick_transfer() 6b74289937f6 usb: dwc3: gadget: return 0 if we try to Wakeup in superspeed b43bba96b903 usb: dwc3: gadget: remove udelay(1) when sending ep cmds 6aff48329595 usb: dwc3: gadget: rely on sg_is_last() and list_is_last() 4fae2e3e1515 usb: dwc3: gadget: simplify __dwc3_gadget_kick_transfer() c4233573f6ee usb: dwc3: gadget: prepare TRBs on update transfers too 7f370ed0cfe9 usb: dwc3: core: get rid of DWC3_PM_OPS macro 9f8a67b65a49 usb: dwc3: gadget: fix gadget suspend/resumed7be295243bb usb: dwc3: gadget: re-factor ->udc_start and ->udc_stop
--- drivers/usb/dwc3/core.c | 389 +++++++------ drivers/usb/dwc3/core.h | 59 +- drivers/usb/dwc3/debug.h | 140 ++++- drivers/usb/dwc3/ep0.c | 26 +- drivers/usb/dwc3/gadget.c | 924 ++++++++++++++++++------------- drivers/usb/dwc3/gadget.h | 4 +- drivers/usb/dwc3/io.h | 7 +- drivers/usb/dwc3/platform_data.h | 53 -- 8 files changed, 926 insertions(+), 676 deletions(-) delete mode 100644 drivers/usb/dwc3/platform_data.h
drivers/usb/dwc3/core.c +215 -174
@@ -41,14 +41,13 @@#include <linux/usb/of.h> #include <linux/usb/otg.h> -#include "platform_data.h" #include "core.h" #include "gadget.h" #include "io.h" #include "debug.h" -/* -------------------------------------------------------------------------- */ +#define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000/* ms */ void dwc3_set_mode (struct dwc3 *dwc,u32 mode) {
@@ -149,9 +148,8 @@ static int dwc3_soft_reset(struct dwc3 *dwc)/* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure -* @fladj: Value of GFLADJ_30MHZ to adjust frame length */ -static void dwc3_frame_length_adjustment (struct dwc3 *dwc,u32 fladj) +static void dwc3_frame_length_adjustment (struct dwc3 *dwc) {u32 reg;u32 dft;
@@ -159,15 +157,15 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)if (dwc->revision <DWC3_REVISION_250A )return ; -if (fladj ==0 ) +if (dwc->fladj ==0 )return ; reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); dft = reg &DWC3_GFLADJ_30MHZ_MASK ; -if (!dev_WARN_ONCE (dwc->dev, dft == fladj, +if (!dev_WARN_ONCE (dwc->dev, dft == dwc->fladj,"request value same as default, ignoring\n" )) { reg &= ~DWC3_GFLADJ_30MHZ_MASK ; - reg |=DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj; + reg |=DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj;dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); } }
@@ -507,6 +505,21 @@ static int dwc3_phy_setup(struct dwc3 *dwc)return 0 ; } +static void dwc3_core_exit (struct dwc3 *dwc) +{ +dwc3_event_buffers_cleanup (dwc); + +usb_phy_shutdown (dwc->usb2_phy); +usb_phy_shutdown (dwc->usb3_phy); +phy_exit (dwc->usb2_generic_phy); +phy_exit (dwc->usb3_generic_phy); + +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 ); +phy_power_off (dwc->usb2_generic_phy); +phy_power_off (dwc->usb3_generic_phy); +} +/** * dwc3_core_init - Low-level initialization of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -556,6 +569,10 @@ static int dwc3_core_init(struct dwc3 *dwc)if (ret) goto err0; + ret =dwc3_phy_setup (dwc); +if (ret) + goto err0; + reg =dwc3_readl (dwc->regs,DWC3_GCTL ); reg &= ~DWC3_GCTL_SCALEDOWN_MASK ;
@@ -622,22 +639,45 @@ static int dwc3_core_init(struct dwc3 *dwc)if (dwc->revision <DWC3_REVISION_190A ) reg |=DWC3_GCTL_U2RSTECN ; -dwc3_core_num_eps (dwc); -dwc3_writel (dwc->regs,DWC3_GCTL , reg); - ret =dwc3_alloc_scratch_buffers (dwc); -if (ret) - goto err1; +dwc3_core_num_eps (dwc); ret =dwc3_setup_scratch_buffers (dwc);if (ret) + goto err1; + +/* Adjust Frame Length */ +dwc3_frame_length_adjustment (dwc); + +usb_phy_set_suspend (dwc->usb2_phy,0 ); +usb_phy_set_suspend (dwc->usb3_phy,0 ); + ret =phy_power_on (dwc->usb2_generic_phy); +if (ret <0 ) goto err2; + ret =phy_power_on (dwc->usb3_generic_phy); +if (ret <0 ) + goto err3; + + ret =dwc3_event_buffers_setup (dwc); +if (ret) { +dev_err (dwc->dev,"failed to setup event buffers\n" ); + goto err4; + } +return 0 ; +err4: +phy_power_off (dwc->usb2_generic_phy); + +err3: +phy_power_off (dwc->usb3_generic_phy); + err2: -dwc3_free_scratch_buffers (dwc); +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 ); +dwc3_core_exit (dwc); err1:usb_phy_shutdown (dwc->usb2_phy);
@@ -649,15 +689,6 @@ err0:return ret; } -static void dwc3_core_exit (struct dwc3 *dwc) -{ -dwc3_free_scratch_buffers (dwc); -usb_phy_shutdown (dwc->usb2_phy); -usb_phy_shutdown (dwc->usb3_phy); -phy_exit (dwc->usb2_generic_phy); -phy_exit (dwc->usb3_generic_phy); -} -static int dwc3_core_get_phy (struct dwc3 *dwc) {struct device *dev = dwc->dev;
@@ -735,7 +766,8 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE ); ret =dwc3_gadget_init (dwc);if (ret) { -dev_err (dev,"failed to initialize gadget\n" ); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"failed to initialize gadget\n" );return ret; }break ;
@@ -743,7 +775,8 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_HOST ); ret =dwc3_host_init (dwc);if (ret) { -dev_err (dev,"failed to initialize host\n" ); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"failed to initialize host\n" );return ret; }break ;
@@ -751,13 +784,15 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_OTG ); ret =dwc3_host_init (dwc);if (ret) { -dev_err (dev,"failed to initialize host\n" ); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"failed to initialize host\n" );return ret; } ret =dwc3_gadget_init (dwc);if (ret) { -dev_err (dev,"failed to initialize gadget\n" ); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"failed to initialize gadget\n" );return ret; }break ;
@@ -793,13 +828,11 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)static int dwc3_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct dwc3_platform_data *pdata =dev_get_platdata (dev);struct resource *res;struct dwc3 *dwc;u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold; -u32 fladj =0 ;int ret;
@@ -814,16 +847,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->mem = mem; dwc->dev = dev; - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (!res) { -dev_err (dev,"missing IRQ\n" ); -return -ENODEV ; - } - dwc->xhci_resources[1 ].start = res->start; - dwc->xhci_resources[1 ].end = res->end; - dwc->xhci_resources[1 ].flags = res->flags; - dwc->xhci_resources[1 ].name = res->name; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) {dev_err (dev,"missing memory resource\n" );
@@ -909,40 +932,7 @@ static int dwc3_probe(struct platform_device *pdev)device_property_read_string (dev,"snps,hsphy_interface" , &dwc->hsphy_interface);device_property_read_u32 (dev,"snps,quirk-frame-length-adjustment" , - &fladj); - -if (pdata) { - dwc->maximum_speed = pdata->maximum_speed; - dwc->has_lpm_erratum = pdata->has_lpm_erratum; -if (pdata->lpm_nyet_threshold) - lpm_nyet_threshold = pdata->lpm_nyet_threshold; - dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend; -if (pdata->hird_threshold) - hird_threshold = pdata->hird_threshold; - - dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; - dwc->dr_mode = pdata->dr_mode; - - dwc->disable_scramble_quirk = pdata->disable_scramble_quirk; - dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk; - dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk; - dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk; - dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk; - dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk; - dwc->lfps_filter_quirk = pdata->lfps_filter_quirk; - dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; - dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; - dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; - dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; - dwc->dis_rxdet_inp3_quirk = pdata->dis_rxdet_inp3_quirk; - - dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; -if (pdata->tx_de_emphasis) - tx_de_emphasis = pdata->tx_de_emphasis; - - dwc->hsphy_interface = pdata->hsphy_interface; - fladj = pdata->fladj_value; - } + &dwc->fladj); dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis;
@@ -953,10 +943,6 @@ static int dwc3_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc); - ret =dwc3_phy_setup (dwc); -if (ret) - goto err0; - ret =dwc3_core_get_phy (dwc);if (ret) goto err0;
@@ -969,29 +955,43 @@ static int dwc3_probe(struct platform_device *pdev)dma_set_coherent_mask (dev, dev->parent->coherent_dma_mask); } +pm_runtime_set_active (dev); +pm_runtime_use_autosuspend (dev); +pm_runtime_set_autosuspend_delay (dev,DWC3_DEFAULT_AUTOSUSPEND_DELAY );pm_runtime_enable (dev); -pm_runtime_get_sync (dev); + ret =pm_runtime_get_sync (dev); +if (ret <0 ) + goto err1; +pm_runtime_forbid (dev); ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );if (ret) {dev_err (dwc->dev,"failed to allocate event buffers\n" ); ret = -ENOMEM ; - goto err1; + goto err2; } -if (IS_ENABLED (CONFIG_USB_DWC3_HOST )) +if (IS_ENABLED (CONFIG_USB_DWC3_HOST ) && + (dwc->dr_mode ==USB_DR_MODE_OTG || + dwc->dr_mode ==USB_DR_MODE_UNKNOWN )) dwc->dr_mode =USB_DR_MODE_HOST ; -else if (IS_ENABLED (CONFIG_USB_DWC3_GADGET )) +else if (IS_ENABLED (CONFIG_USB_DWC3_GADGET ) && + (dwc->dr_mode ==USB_DR_MODE_OTG || + dwc->dr_mode ==USB_DR_MODE_UNKNOWN )) dwc->dr_mode =USB_DR_MODE_PERIPHERAL ;if (dwc->dr_mode ==USB_DR_MODE_UNKNOWN ) dwc->dr_mode =USB_DR_MODE_OTG ; + ret =dwc3_alloc_scratch_buffers (dwc); +if (ret) + goto err3; + ret =dwc3_core_init (dwc);if (ret) {dev_err (dev,"failed to initialize core\n" ); - goto err1; + goto err4; }/* Check the maximum_speed parameter */
@@ -1021,31 +1021,12 @@ static int dwc3_probe(struct platform_device *pdev)break ; } -/* Adjust Frame Length */ -dwc3_frame_length_adjustment (dwc, fladj); - -usb_phy_set_suspend (dwc->usb2_phy,0 ); -usb_phy_set_suspend (dwc->usb3_phy,0 ); - ret =phy_power_on (dwc->usb2_generic_phy); -if (ret <0 ) - goto err2; - - ret =phy_power_on (dwc->usb3_generic_phy); -if (ret <0 ) - goto err3; - - ret =dwc3_event_buffers_setup (dwc); -if (ret) { -dev_err (dwc->dev,"failed to setup event buffers\n" ); - goto err4; - } - ret =dwc3_core_init_mode (dwc);if (ret) goto err5;dwc3_debugfs_init (dwc); -pm_runtime_allow (dev); +pm_runtime_put (dev);return 0 ;
@@ -1053,19 +1034,18 @@ err5:dwc3_event_buffers_cleanup (dwc); err4: -phy_power_off (dwc->usb3_generic_phy); +dwc3_free_scratch_buffers (dwc); err3: -phy_power_off (dwc->usb2_generic_phy); +dwc3_free_event_buffers (dwc); +dwc3_ulpi_exit (dwc); err2: -usb_phy_set_suspend (dwc->usb2_phy,1 ); -usb_phy_set_suspend (dwc->usb3_phy,1 ); -dwc3_core_exit (dwc); +pm_runtime_allow (&pdev->dev); err1: -dwc3_free_event_buffers (dwc); -dwc3_ulpi_exit (dwc); +pm_runtime_put_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); err0:/*
@@ -1083,6 +1063,7 @@ static int dwc3_remove(struct platform_device *pdev)struct dwc3 *dwc =platform_get_drvdata (pdev);struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +pm_runtime_get_sync (&pdev->dev);/* * restore res->start back to its original value so that, in case the * probe is deferred, we don't end up getting error in request the
@@ -1092,133 +1073,193 @@ static int dwc3_remove(struct platform_device *pdev)dwc3_debugfs_exit (dwc);dwc3_core_exit_mode (dwc); -dwc3_event_buffers_cleanup (dwc); -dwc3_free_event_buffers (dwc); - -usb_phy_set_suspend (dwc->usb2_phy,1 ); -usb_phy_set_suspend (dwc->usb3_phy,1 ); -phy_power_off (dwc->usb2_generic_phy); -phy_power_off (dwc->usb3_generic_phy);dwc3_core_exit (dwc);dwc3_ulpi_exit (dwc);pm_runtime_put_sync (&pdev->dev); +pm_runtime_allow (&pdev->dev);pm_runtime_disable (&pdev->dev); +dwc3_free_event_buffers (dwc); +dwc3_free_scratch_buffers (dwc); +return 0 ; } -#ifdef CONFIG_PM_SLEEP -static int dwc3_suspend (struct device *dev) +#ifdef CONFIG_PM +static int dwc3_suspend_common (struct dwc3 *dwc) { -struct dwc3 *dwc =dev_get_drvdata (dev);unsigned long flags; -spin_lock_irqsave (&dwc->lock, flags); -switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL :case USB_DR_MODE_OTG : +spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_suspend (dwc); -/* FALLTHROUGH */ +spin_unlock_irqrestore (&dwc->lock, flags); +break ;case USB_DR_MODE_HOST :default : -dwc3_event_buffers_cleanup (dwc); +/* do nothing */ break ; } - dwc->gctl =dwc3_readl (dwc->regs,DWC3_GCTL ); -spin_unlock_irqrestore (&dwc->lock, flags); +dwc3_core_exit (dwc); -usb_phy_shutdown (dwc->usb3_phy); -usb_phy_shutdown (dwc->usb2_phy); -phy_exit (dwc->usb2_generic_phy); -phy_exit (dwc->usb3_generic_phy); +return 0 ; +} -usb_phy_set_suspend (dwc->usb2_phy,1 ); -usb_phy_set_suspend (dwc->usb3_phy,1 ); -WARN_ON (phy_power_off (dwc->usb2_generic_phy) <0 ); -WARN_ON (phy_power_off (dwc->usb3_generic_phy) <0 ); +static int dwc3_resume_common (struct dwc3 *dwc) +{ +unsigned long flags; +int ret; -pinctrl_pm_select_sleep_state (dev); + ret =dwc3_core_init (dwc); +if (ret) +return ret; + +switch (dwc->dr_mode) { +case USB_DR_MODE_PERIPHERAL : +case USB_DR_MODE_OTG : +spin_lock_irqsave (&dwc->lock, flags); +dwc3_gadget_resume (dwc); +spin_unlock_irqrestore (&dwc->lock, flags); +/* FALLTHROUGH */ +case USB_DR_MODE_HOST : +default : +/* do nothing */ +break ; + }return 0 ; } -static int dwc3_resume (struct device *dev) +static int dwc3_runtime_checks (struct dwc3 *dwc) { -struct dwc3 *dwc =dev_get_drvdata (dev); -unsigned long flags; +switch (dwc->dr_mode) { +case USB_DR_MODE_PERIPHERAL : +case USB_DR_MODE_OTG : +if (dwc->connected) +return -EBUSY ; +break ; +case USB_DR_MODE_HOST : +default : +/* do nothing */ +break ; + } + +return 0 ; +} + +static int dwc3_runtime_suspend (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev);int ret; -pinctrl_pm_select_default_state (dev); +if (dwc3_runtime_checks (dwc)) +return -EBUSY ; -usb_phy_set_suspend (dwc->usb2_phy,0 ); -usb_phy_set_suspend (dwc->usb3_phy,0 ); - ret =phy_power_on (dwc->usb2_generic_phy); -if (ret <0 ) + ret =dwc3_suspend_common (dwc); +if (ret)return ret; - ret =phy_power_on (dwc->usb3_generic_phy); -if (ret <0 ) - goto err_usb2phy_power; +device_init_wakeup (dev, true); -usb_phy_init (dwc->usb3_phy); -usb_phy_init (dwc->usb2_phy); - ret =phy_init (dwc->usb2_generic_phy); -if (ret <0 ) - goto err_usb3phy_power; +return 0 ; +} - ret =phy_init (dwc->usb3_generic_phy); -if (ret <0 ) - goto err_usb2phy_init; +static int dwc3_runtime_resume (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); +int ret; -spin_lock_irqsave (&dwc->lock, flags); +device_init_wakeup (dev, false); -dwc3_event_buffers_setup (dwc); -dwc3_writel (dwc->regs,DWC3_GCTL , dwc->gctl); + ret =dwc3_resume_common (dwc); +if (ret) +return ret;switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL :case USB_DR_MODE_OTG : -dwc3_gadget_resume (dwc); -/* FALLTHROUGH */ +dwc3_gadget_process_pending_events (dwc); +break ;case USB_DR_MODE_HOST :default :/* do nothing */ break ; } -spin_unlock_irqrestore (&dwc->lock, flags); +pm_runtime_mark_last_busy (dev); +pm_runtime_put (dev); -pm_runtime_disable (dev); -pm_runtime_set_active (dev); -pm_runtime_enable (dev); +return 0 ; +} + +static int dwc3_runtime_idle (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); + +switch (dwc->dr_mode) { +case USB_DR_MODE_PERIPHERAL : +case USB_DR_MODE_OTG : +if (dwc3_runtime_checks (dwc)) +return -EBUSY ; +break ; +case USB_DR_MODE_HOST : +default : +/* do nothing */ +break ; + } + +pm_runtime_mark_last_busy (dev); +pm_runtime_autosuspend (dev);return 0 ; +} +#endif /* CONFIG_PM */ -err_usb2phy_init: -phy_exit (dwc->usb2_generic_phy); +#ifdef CONFIG_PM_SLEEP +static int dwc3_suspend (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); +int ret; -err_usb3phy_power: -phy_power_off (dwc->usb3_generic_phy); + ret =dwc3_suspend_common (dwc); +if (ret) +return ret; -err_usb2phy_power: -phy_power_off (dwc->usb2_generic_phy); +pinctrl_pm_select_sleep_state (dev); -return ret; +return 0 ; } +static int dwc3_resume (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); +int ret; + +pinctrl_pm_select_default_state (dev); + + ret =dwc3_resume_common (dwc); +if (ret) +return ret; + +pm_runtime_disable (dev); +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + +return 0 ; +} +#endif /* CONFIG_PM_SLEEP */ +static const struct dev_pm_ops dwc3_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) +SET_RUNTIME_PM_OPS (dwc3_runtime_suspend, dwc3_runtime_resume, + dwc3_runtime_idle) }; -#define DWC3_PM_OPS &(dwc3_dev_pm_ops) -#else -#define DWC3_PM_OPS NULL -#endif - #ifdef CONFIG_OF static const struct of_device_id of_dwc3_match[] = { {
@@ -1250,7 +1291,7 @@ static struct platform_driver dwc3_driver = { .name = "dwc3", .of_match_table = of_match_ptr(of_dwc3_match), .acpi_match_table = ACPI_PTR(dwc3_acpi_match), - .pm = DWC3_PM_OPS, + .pm = &dwc3_dev_pm_ops, }, };
drivers/usb/dwc3/core.h +46 -13
173 lines not on this page · raw message
drivers/usb/dwc3/debug.h +118 -22
180 lines not on this page · raw message
drivers/usb/dwc3/ep0.c +10 -16
@@ -98,8 +98,7 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,trace_dwc3_prepare_trb (dep, trb); - ret =dwc3_send_gadget_ep_cmd (dwc, dep->number, -DWC3_DEPCMD_STARTTRANSFER , ¶ms); + ret =dwc3_send_gadget_ep_cmd (dep,DWC3_DEPCMD_STARTTRANSFER , ¶ms);if (ret <0 ) {dwc3_trace (trace_dwc3_ep0,"%s STARTTRANSFER failed" , dep->name);
@@ -107,9 +106,7 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, } dep->flags |=DWC3_EP_BUSY ; - dep->resource_index =dwc3_gadget_ep_get_transfer_index (dwc, - dep->number); - + dep->resource_index =dwc3_gadget_ep_get_transfer_index (dep); dwc->ep0_next_event =DWC3_EP0_COMPLETE ;return 0 ;
@@ -499,7 +496,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,case USB_RECIP_ENDPOINT :switch (wValue) {case USB_ENDPOINT_HALT : - dep =dwc3_wIndex_to_dep (dwc, wIndex); + dep =dwc3_wIndex_to_dep (dwc, ctrl->wIndex);if (!dep)return -EINVAL ;if (set ==0 && (dep->flags &DWC3_EP_WEDGE ))
@@ -622,8 +619,8 @@ static void dwc3_ep0_set_sel_cmpl(struct usb_ep *ep, struct usb_request *req)struct timing {u8 u1sel;u8 u1pel; -u16 u2sel; -u16 u2pel; +__le16 u2sel; +__le16 u2pel; } __packed timing;int ret;
@@ -980,7 +977,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ret =usb_gadget_map_request (&dwc->gadget, &req->request, dep->number);if (ret) { -dwc3_trace (trace_dwc3_ep0,"failed to map request\n" ); +dwc3_trace (trace_dwc3_ep0,"failed to map request" );return ; }
@@ -1008,7 +1005,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ret =usb_gadget_map_request (&dwc->gadget, &req->request, dep->number);if (ret) { -dwc3_trace (trace_dwc3_ep0,"failed to map request\n" ); +dwc3_trace (trace_dwc3_ep0,"failed to map request" );return ; }
@@ -1058,7 +1055,7 @@ static void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) cmd |=DWC3_DEPCMD_CMDIOC ; cmd |=DWC3_DEPCMD_PARAM (dep->resource_index);memset (¶ms,0 ,sizeof (params)); - ret =dwc3_send_gadget_ep_cmd (dwc, dep->number, cmd, ¶ms); + ret =dwc3_send_gadget_ep_cmd (dep, cmd, ¶ms);WARN_ON_ONCE (ret); dep->resource_index =0 ; }
@@ -1112,11 +1109,8 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,void dwc3_ep0_interrupt (struct dwc3 *dwc,const struct dwc3_event_depevt *event) { -u8 epnum = event->endpoint_number; - -dwc3_trace (trace_dwc3_ep0,"%s while ep%d%s in state '%s'" , -dwc3_ep_event_string (event->endpoint_event), - epnum >>1 , (epnum &1 ) ?"in" :"out" , +dwc3_trace (trace_dwc3_ep0,"%s: state '%s'" , +dwc3_ep_event_string (event),dwc3_ep0_state_string (dwc->ep0state));switch (event->endpoint_event) {
drivers/usb/dwc3/gadget.c +533 -391
1,590 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +2 -2
@@ -95,11 +95,11 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol);* * Caller should take care of locking */ -static inline u32 dwc3_gadget_ep_get_transfer_index (struct dwc3 *dwc,u8 number) +static inline u32 dwc3_gadget_ep_get_transfer_index (struct dwc3_ep *dep) {u32 res_id; - res_id =dwc3_readl (dwc->regs,DWC3_DEPCMD (number)); + res_id =dwc3_readl (dep->regs,DWC3_DEPCMD );return DWC3_DEPCMD_GET_RSC_IDX (res_id); }
drivers/usb/dwc3/io.h +2 -5
@@ -26,7 +26,6 @@static inline u32 dwc3_readl (void __iomem *base,u32 offset) { -u32 offs = offset -DWC3_GLOBALS_REGS_START ;u32 value;/*
@@ -34,7 +33,7 @@ static inline u32 dwc3_readl(void __iomem *base, u32 offset)* space, see dwc3_probe in core.c. * However, the offsets are given starting from xHCI address space. */ - value =readl (base + offs); + value =readl (base + offset -DWC3_GLOBALS_REGS_START );/* * When tracing we want to make it easy to find the correct address on
@@ -49,14 +48,12 @@ static inline u32 dwc3_readl(void __iomem *base, u32 offset)static inline void dwc3_writel (void __iomem *base,u32 offset,u32 value) { -u32 offs = offset -DWC3_GLOBALS_REGS_START ; -/* * We requested the mem region starting from the Globals address * space, see dwc3_probe in core.c. * However, the offsets are given starting from xHCI address space. */ -writel (value, base + offs); +writel (value, base + offset -DWC3_GLOBALS_REGS_START );/* * When tracing we want to make it easy to find the correct address on
drivers/usb/dwc3/platform_data.h deleted +0 -53
53 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 11/75] usb: dwc3: import from kernel v4.8
Hi Anders,
Thank you for the patch.
Quoted 106 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.7 to v4.8.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.7..v4.8
Commits imported:696118c016ddusb: dwc3: pci: fix build warning on !PM_SLEEP9d7aba7786b6Revert "usb: dwc3: gadget: always decrement by 1"6f8245b4e37cusb: dwc3: gadget: always decrement by 1696fe69d7e63usb: dwc3: debug: fix ep name on trace outputd6011f6fc21busb: dwc3: gadget: don't rely on jiffies while holding spinlockb74c2d875baausb: dwc3: core: allow device toruntime_suspendseveral timesf6c274e11e3busb: dwc3: pci:runtime_resumechild devicea0ad85ae866fusb: dwc3: gadget: stop processing on HWO set79d17482a409usb: dwc3: don't set last bit for ISOC endpoints4c4f106c032fusb: dwc3: fix missingplatform_set_drvdata()indwc3_of_simple_probe()4491ed5042f0usb: dwc3: pci: add Intel Kabylake PCI ID7c705dfe2ebeusb: dwc3: gadget: always cleanup all TRBse5b36ae2f851usb: dwc3: gadget: fix for short pkts during chained xfersc7de57347183usb: dwc3: gadget: incrementrequest->actualonce322832f2f19eusb: dwc3: host: Fix broken XHCI host95b57df45062usb: dwc3: host: use build-in property instead of platform data72704f876f50dwc3: gadget: Implement the suspend entry event handler9522def40065usb: dwc3: core: cleanup IRQ resourcesda1410be21bfusb: dwc3: gadget: Add the suspend state checking when stopping gadget0e146028eebfusb: dwc3: gadget: issue ENDTRANSFER conditional onresource_index328082376aeausb: dwc3: fix runtime PM in error pathb6d4e16e8313usb: dwc3: gadget: simplifyrun_stop()break conditionf2df679b6c55usb: dwc3: gadget: avoid while(1) inrun_stop()d807bdd02845usb: dwc3: gadget: removeudelay()fromrun_stop()5f82279a0c76usb: dwc3: core: fixupdr_modefallback selectione6fe66fe08cdusb: dwc3: pci: add dr-mode for Intel dwc321e64bf20df5usb: dwc3: gadget: rename 'ignore' argument to 'modify'd6dc2e76a860usb: dwc3: gadget: decrementtrbs_leftfor each sg entryba62c09d5cc2usb: dwc3: gadget: start Bulk endpoints more frequently13fa2e69b1ddusb: dwc3: gadget: disableXFER_NOT_READY55a0237f8f47usb: dwc3: gadget: use allocated/queued reqs for LST bit69450c4dc164usb: dwc3: gadget: halt and stop based HWO bit68d34c8a744dusb: dwc3: gadget: keep track of allocated and queued reqsb6b1c6db4c7fusb: dwc3: gadget: update transfer needs transfer resourced18e65470a4dusb: dwc3: remove handling of platform datacf48305de0c6usb: dwc3: pci: use build-in properties instead of platform data60cfb37ac9bcusb: dwc3: remove trailing newline fromdwc3_traced2728fb3e01fusb: dwc3: omap: Pass VBUS and ID events transparently9ab330bf4dfdusb: dwc3: omap: Don't set POWERPRESENT12da8eae208dusb: dwc3: omap: Mark the interrupt handler as shared3f586c92d877usb: dwc3: omap: userequest_threaded_irq()475c8beb35e1usb: dwc3: addDWC3_GUCTL1reg for debuge77c561432bcusb: dwc3: FixDWC3_USB31_REVISION_110Adefinition2da9ad761e70usb: dwc3: Use the correct speed macros for DSTS/DCFG3de2685f0c39usb: dwc3: gadget: Fix truncated cast issue361572b5f7a9usb: dwc3: gadget: Handle TRB index 0 when full or empty7d0a038b130cusb: dwc3: gadget: Account for link TRB in TRBs left32db3d9437b6usb: dwc3: gadget: Account for max size in TRB space89bc856e5a74usb: dwc3: gadget: Don't prepare TRBs if no space0d25744ad107usb: dwc3: gadget: Initialize the TRB ringdca0119c3ab6usb: dwc3: gadget: Simplify skipping of link TRBs96bedb637a1eusb: dwc3: Endianness issue ondwc3_log_ctrld07fa665c79dusb: dwc3: gadget: Fix usage of bitwise operator501058edebf9usb: dwc3: ep0: Use the correct type forSET_SELdata958b9fa7f8cfusb: dwc3: ep0: Fix endianness of wIndex passed todwc3_wIndex_to_dep71f7e7027028usb: dwc3: gadget: improve gcmd trace88811f7b722cusb: dwc3: gadget: removeudelay()from generic cmd0fe886cdb07ausb: dwc3: gadget: single return point on generic commands0933df159c5cusb: dwc3: trace: print ep cmd status with a single tracef6bb225bb3causb: dwc3: gadget: loop while (timeout)ba1598410effusb: dwc3: gadget: fix trace output when command failsf75cacc468edusb: dwc3: trace: fully decode IRQ events7ab373aadbd0usb: dwc3: gadget: no more tracking endpoint type with its name22f2c619a116usb: dwc3: trace: pretty-print TRB's ctrl field74674cbf858fusb: dwc3: gadget: add a per-endpoint request queue locke9af9229098dusb: dwc3: pci: add Power Management dummy hooksfc8bb91bc83eusb: dwc3: implement runtime PM4cb4221764efusb: dwc3: gadget: fix for possible endpoint disable race9cad39fe4e4ausb: dwc3: fix for the isoc transferEP_BUSYflagab2a92e7a608usb: dwc3: gadget: only resume USB2 PHY in <=HIGHSPEED3f308d17d7abusb: dwc3: gadget: hold gadget IRQ indwc->irq_gadget51f5d49ad6f0usb: dwc3: core: simplify suspend/resume operationsc499ff71ff2ausb: dwc3: core: re-factor init and exit pathsbcdb3272e889usb: dwc3: core: move fladj to dwc3 structure2eb8801650b3usb: dwc3: gadget: add a pointer to endpoint registers2cd4718d0bbeusb: dwc3: gadget: pass dep as argument to endpoint command4e99472bc10busb: dwc3: gadget: initialize NUMP based on RxFIFO Size5ee85d890f8dusb: dwc3: gadget: split__dwc3_gadget_kick_transfer()6b74289937f6usb: dwc3: gadget: return 0 if we try to Wakeup in superspeedb43bba96b903usb: dwc3: gadget: remove udelay(1) when sending ep cmds6aff48329595usb: dwc3: gadget: rely onsg_is_last()andlist_is_last()4fae2e3e1515usb: dwc3: gadget: simplify__dwc3_gadget_kick_transfer()c4233573f6eeusb: dwc3: gadget: prepare TRBs on update transfers too7f370ed0cfe9usb: dwc3: core: get rid ofDWC3_PM_OPSmacro9f8a67b65a49usb: dwc3: gadget: fix gadget suspend/resumed7be295243bbusb: dwc3: gadget: re-factor ->udc_start and ->udc_stop
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 12/75 usb: dwc3: import from kernel v4.9
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.8 to v4.9.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.8..v4.9
Commits imported:4accb8a1ee7d usb: dwc3: st: add missing <linux/pinctrl/consumer.h> include 9b9d7cdd0a20 usb: dwc3: Fix error handling for core init 51fbc7c06c89 usb: dwc3: Fix size used in dma_free_coherent() d889c23ce4e3 usb: dwc3: gadget: never pre-start Isochronous endpoints a9c3ca5fae6b usb: dwc3: gadget: properly account queued requests b281dc630b41 usb: dwc3: of-simple: add compatible for Cavium 26c9cac402c4 usb: dwc3: of-simple: allow glues without clocks 8d53e6267594 usb: dwc3: of-simple: Fix warning during unbind 5e6c88d28ccb usb: dwc3: fix Clear Stall EP command failure d6e10bf2ba47 usb: dwc3: avoid -Wmaybe-uninitialized warning 9d6173e125d9 usb: dwc3: Fix dr_mode validation073c47aca7b7 usb: dwc3: ulpi: make dwc3_ulpi_ops constant e6f74849784c usb: ulpi: rename operations {read|write}_dev to simply {read|write} b7cf1dc3414d usb: dwc3: ulpi: use new api594e121f2568 usb: dwc3: gadget: stop kicking if we run out of space 7ae7df4982af usb: dwc3: gadget: abolish trbs_left06281d460fc5 usb: dwc3: Add ENDXFER command polling512e47572f7d usb: dwc3: Add revision numbers for the USB 3.0 IP 00af62330c39 usb: dwc3: core: Move the mode setting to the right place f652191be3f6 usb: dwc3: of-simple: add compatible for rockchip rk3399 00fe081dc3a3 usb: dwc3: add dis_del_phy_power_chg_quirk32f2ed864dd5 usb: dwc3: make usb2 phy utmi interface configurable 16199f338939 usb: dwc3: add dis_u2_freeclk_exists_quirkdc55c67e9c95 usb: dwc3: gadget: improve increment request->actual f99f53f24d87 usb: dwc3: gadget: remove condition that never happens 1f512119a08c usb: dwc3: gadget: add remaining sg entries to ring 2c78c0295fd8 usb: dwc3: gadget: interrupt on ring full too 0b3e4af3c740 usb: dwc3: gadget: add sg and num_pending_sgs to dwc3_request 31162af447d7 usb: dwc3: gadget: avoid while (1) loop on completion 08a36b543803 usb: dwc3: gadget: simplify __dwc3_gadget_ep_queue() 45438a0cd9c2 usb: dwc3: gadget: simplify dwc3_ep_prev_trb() 737f1ae2556a usb: dwc3: gadget: increment dequeue pointer on completion 4bc48c974708 usb: dwc3: gadget: retire LST bit completely a26a142275c6 usb: remove redundant dependency on USB_SUPPORT
--- drivers/usb/dwc3/core.c | 127 ++++++++++++++--- drivers/usb/dwc3/core.h | 35 ++++- drivers/usb/dwc3/gadget.c | 292 +++++++++++++++----------------------- 3 files changed, 258 insertions(+), 196 deletions(-)
drivers/usb/dwc3/core.c +110 -17
@@ -49,6 +49,57 @@#define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000/* ms */ +/** +* dwc3_get_dr_mode - Validates and sets dr_mode +* @dwc: pointer to our context structure +*/ +static int dwc3_get_dr_mode (struct dwc3 *dwc) +{ +enum usb_dr_mode mode; +struct device *dev = dwc->dev; +unsigned int hw_mode; + +if (dwc->dr_mode ==USB_DR_MODE_UNKNOWN ) + dwc->dr_mode =USB_DR_MODE_OTG ; + + mode = dwc->dr_mode; + hw_mode =DWC3_GHWPARAMS0_MODE (dwc->hwparams.hwparams0); + +switch (hw_mode) { +case DWC3_GHWPARAMS0_MODE_GADGET : +if (IS_ENABLED (CONFIG_USB_DWC3_HOST )) { +dev_err (dev, +"Controller does not support host mode.\n" ); +return -EINVAL ; + } + mode =USB_DR_MODE_PERIPHERAL ; +break ; +case DWC3_GHWPARAMS0_MODE_HOST : +if (IS_ENABLED (CONFIG_USB_DWC3_GADGET )) { +dev_err (dev, +"Controller does not support device mode.\n" ); +return -EINVAL ; + } + mode =USB_DR_MODE_HOST ; +break ; +default : +if (IS_ENABLED (CONFIG_USB_DWC3_HOST )) + mode =USB_DR_MODE_HOST ; +else if (IS_ENABLED (CONFIG_USB_DWC3_GADGET )) + mode =USB_DR_MODE_PERIPHERAL ; + } + +if (mode != dwc->dr_mode) { +dev_warn (dev, +"Configuration mismatch. dr_mode forced to %s\n" , + mode ==USB_DR_MODE_HOST ?"host" :"gadget" ); + + dwc->dr_mode = mode; + } + +return 0 ; +} +void dwc3_set_mode (struct dwc3 *dwc,u32 mode) {u32 reg;
@@ -448,6 +499,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_u3_susphy_quirk) reg &= ~DWC3_GUSB3PIPECTL_SUSPHY ; +if (dwc->dis_del_phy_power_chg_quirk) + reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE ; +dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 ));
@@ -485,6 +539,23 @@ static int dwc3_phy_setup(struct dwc3 *dwc)break ; } +switch (dwc->hsphy_mode) { +case USBPHY_INTERFACE_MODE_UTMI : + reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | +DWC3_GUSB2PHYCFG_USBTRDTIM_MASK ); + reg |=DWC3_GUSB2PHYCFG_PHYIF (UTMI_PHYIF_8_BIT ) | +DWC3_GUSB2PHYCFG_USBTRDTIM (USBTRDTIM_UTMI_8_BIT ); +break ; +case USBPHY_INTERFACE_MODE_UTMIW : + reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | +DWC3_GUSB2PHYCFG_USBTRDTIM_MASK ); + reg |=DWC3_GUSB2PHYCFG_PHYIF (UTMI_PHYIF_16_BIT ) | +DWC3_GUSB2PHYCFG_USBTRDTIM (USBTRDTIM_UTMI_16_BIT ); +break ; +default : +break ; + } +/* * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to * '0' during coreConsultant configuration. So default value will
@@ -500,6 +571,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_enblslpm_quirk) reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; +if (dwc->dis_u2_freeclk_exists_quirk) + reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg);return 0 ;
@@ -666,18 +740,43 @@ static int dwc3_core_init(struct dwc3 *dwc) goto err4; } +switch (dwc->dr_mode) { +case USB_DR_MODE_PERIPHERAL : +dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE ); +break ; +case USB_DR_MODE_HOST : +dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_HOST ); +break ; +case USB_DR_MODE_OTG : +dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_OTG ); +break ; +default : +dev_warn (dwc->dev,"Unsupported mode %d\n" , dwc->dr_mode); +break ; + } + +/* +* ENDXFER polling is available on version 3.10a and later of +* the DWC_usb3 controller. It is NOT available in the +* DWC_usb31 controller. +*/ +if (!dwc3_is_usb31 (dwc) && dwc->revision >=DWC3_REVISION_310A ) { + reg =dwc3_readl (dwc->regs,DWC3_GUCTL2 ); + reg |=DWC3_GUCTL2_RST_ACTBITLATER ; +dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); + } +return 0 ; err4: -phy_power_off (dwc->usb2_generic_phy); +phy_power_off (dwc->usb3_generic_phy); err3: -phy_power_off (dwc->usb3_generic_phy); +phy_power_off (dwc->usb2_generic_phy); err2:usb_phy_set_suspend (dwc->usb2_phy,1 );usb_phy_set_suspend (dwc->usb3_phy,1 ); -dwc3_core_exit (dwc); err1:usb_phy_shutdown (dwc->usb2_phy);
@@ -763,7 +862,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL : -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE ); ret =dwc3_gadget_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -772,7 +870,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) }break ;case USB_DR_MODE_HOST : -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_HOST ); ret =dwc3_host_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -781,7 +878,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) }break ;case USB_DR_MODE_OTG : -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_OTG ); ret =dwc3_host_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -888,6 +984,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc->maximum_speed =usb_get_maximum_speed (dev); dwc->dr_mode =usb_get_dr_mode (dev); + dwc->hsphy_mode =of_usb_get_phy_mode (dev->of_node); dwc->has_lpm_erratum =device_property_read_bool (dev,"snps,has-lpm-erratum" );
@@ -924,6 +1021,10 @@ static int dwc3_probe(struct platform_device *pdev) "snps,dis_enblslpm_quirk"); dwc->dis_rxdet_inp3_quirk =device_property_read_bool (dev,"snps,dis_rxdet_inp3_quirk" ); + dwc->dis_u2_freeclk_exists_quirk =device_property_read_bool (dev, +"snps,dis-u2-freeclk-exists-quirk" ); + dwc->dis_del_phy_power_chg_quirk =device_property_read_bool (dev, +"snps,dis-del-phy-power-chg-quirk" ); dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" );
@@ -972,17 +1073,9 @@ static int dwc3_probe(struct platform_device *pdev) goto err2; } -if (IS_ENABLED (CONFIG_USB_DWC3_HOST ) && - (dwc->dr_mode ==USB_DR_MODE_OTG || - dwc->dr_mode ==USB_DR_MODE_UNKNOWN )) - dwc->dr_mode =USB_DR_MODE_HOST ; -else if (IS_ENABLED (CONFIG_USB_DWC3_GADGET ) && - (dwc->dr_mode ==USB_DR_MODE_OTG || - dwc->dr_mode ==USB_DR_MODE_UNKNOWN )) - dwc->dr_mode =USB_DR_MODE_PERIPHERAL ; - -if (dwc->dr_mode ==USB_DR_MODE_UNKNOWN ) - dwc->dr_mode =USB_DR_MODE_OTG ; + ret =dwc3_get_dr_mode (dwc); +if (ret) + goto err3; ret =dwc3_alloc_scratch_buffers (dwc);if (ret)
drivers/usb/dwc3/core.h +34 -1
@@ -109,6 +109,7 @@#define DWC3_GPRTBIMAP_HS1 0xc184#define DWC3_GPRTBIMAP_FS0 0xc188#define DWC3_GPRTBIMAP_FS1 0xc18c +#define DWC3_GUCTL2 0xc19c#define DWC3_VER_NUMBER 0xc1a0#define DWC3_VER_TYPE 0xc1a4
@@ -199,9 +200,18 @@/* Global USB2 PHY Configuration Register */ #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31) +#define DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS (1 << 30)#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6)#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4)#define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8) +#define DWC3_GUSB2PHYCFG_PHYIF (n) (n << 3) +#define DWC3_GUSB2PHYCFG_PHYIF_MASK DWC3_GUSB2PHYCFG_PHYIF(1) +#define DWC3_GUSB2PHYCFG_USBTRDTIM (n) (n << 10) +#define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK DWC3_GUSB2PHYCFG_USBTRDTIM(0xf) +#define USBTRDTIM_UTMI_8_BIT 9 +#define USBTRDTIM_UTMI_16_BIT 5 +#define UTMI_PHYIF_16_BIT 1 +#define UTMI_PHYIF_8_BIT 0/* Global USB2 PHY Vendor Control Register */ #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
@@ -235,7 +245,10 @@#define DWC3_GEVNTSIZ_SIZE (n) ((n) & 0xffff)/* Global HWPARAMS0 Register */ -#define DWC3_GHWPARAMS0_USB3_MODE (n) ((n) & 0x3) +#define DWC3_GHWPARAMS0_MODE (n) ((n) & 0x3) +#define DWC3_GHWPARAMS0_MODE_GADGET 0 +#define DWC3_GHWPARAMS0_MODE_HOST 1 +#define DWC3_GHWPARAMS0_MODE_DRD 2#define DWC3_GHWPARAMS0_MBUS_TYPE (n) (((n) >> 3) & 0x7)#define DWC3_GHWPARAMS0_SBUS_TYPE (n) (((n) >> 6) & 0x3)#define DWC3_GHWPARAMS0_MDWIDTH (n) (((n) >> 8) & 0xff)
@@ -279,6 +292,9 @@#define DWC3_GFLADJ_30MHZ_SDBND_SEL (1 << 7)#define DWC3_GFLADJ_30MHZ_MASK 0x3f +/* Global User Control Register 2 */ +#define DWC3_GUCTL2_RST_ACTBITLATER (1 << 14) +/* Device Configuration Register */ #define DWC3_DCFG_DEVADDR (addr) ((addr) << 3)#define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
@@ -685,6 +701,8 @@ struct dwc3_hwparams {* @request: struct usb_request to be transferred * @list: a list_head used for request queueing * @dep: struct dwc3_ep owning this request +* @sg: pointer to first incomplete sg +* @num_pending_sgs: counter to pending sgs * @first_trb_index: index to first trb used by this request * @epnum: endpoint number to which this request refers * @trb: pointer to struct dwc3_trb
@@ -697,7 +715,9 @@ struct dwc3_request {struct usb_request request;struct list_head list;struct dwc3_ep *dep; +struct scatterlist *sg; +unsigned num_pending_sgs;u8 first_trb_index;u8 epnum;struct dwc3_trb *trb;
@@ -743,6 +763,9 @@ struct dwc3_scratchpad_array {* @maximum_speed: maximum speed requested (mainly for testing purposes) * @revision: revision register contents * @dr_mode: requested mode of operation +* @hsphy_mode: UTMI phy mode, one of following: +* - USBPHY_INTERFACE_MODE_UTMI +* - USBPHY_INTERFACE_MODE_UTMIW * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY
@@ -799,6 +822,11 @@ struct dwc3_scratchpad_array {* @dis_u2_susphy_quirk: set if we disable usb2 suspend phy * @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG, * disabling the suspend signal to the PHY. +* @dis_u2_freeclk_exists_quirk : set if we clear u2_freeclk_exists +* in GUSB2PHYCFG, specify that USB2 PHY doesn't +* provide a free-running PHY clock. +* @dis_del_phy_power_chg_quirk: set if we disable delay phy power +* change quirk. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk * @tx_de_emphasis: Tx de-emphasis value * 0 - -6dB de-emphasis
@@ -845,6 +873,7 @@ struct dwc3 {size_t regs_size;enum usb_dr_mode dr_mode; +enum usb_phy_interface hsphy_mode;u32 fladj;u32 irq_gadget;
@@ -880,6 +909,8 @@ struct dwc3 {#define DWC3_REVISION_260A 0x5533260a#define DWC3_REVISION_270A 0x5533270a#define DWC3_REVISION_280A 0x5533280a +#define DWC3_REVISION_300A 0x5533300a +#define DWC3_REVISION_310A 0x5533310a/* * NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really
@@ -942,6 +973,8 @@ struct dwc3 { unsigned dis_u2_susphy_quirk:1; unsigned dis_enblslpm_quirk:1; unsigned dis_rxdet_inp3_quirk:1; + unsigned dis_u2_freeclk_exists_quirk:1; + unsigned dis_del_phy_power_chg_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;
drivers/usb/dwc3/gadget.c +114 -178
496 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 12/75] usb: dwc3: import from kernel v4.9
Hi Anders,
Thank you for the patch.
Quoted 54 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.8 to v4.9.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.8..v4.9
Commits imported:4accb8a1ee7dusb: dwc3: st: add missing <linux/pinctrl/consumer.h> include9b9d7cdd0a20usb: dwc3: Fix error handling for core init51fbc7c06c89usb: dwc3: Fix size used indma_free_coherent()d889c23ce4e3usb: dwc3: gadget: never pre-start Isochronous endpointsa9c3ca5fae6busb: dwc3: gadget: properly account queued requestsb281dc630b41usb: dwc3: of-simple: add compatible for Cavium26c9cac402c4usb: dwc3: of-simple: allow glues without clocks8d53e6267594usb: dwc3: of-simple: Fix warning during unbind5e6c88d28ccbusb: dwc3: fix Clear Stall EP command failured6e10bf2ba47usb: dwc3: avoid -Wmaybe-uninitialized warning9d6173e125d9usb: dwc3: Fixdr_modevalidation073c47aca7b7usb: dwc3: ulpi: makedwc3_ulpi_opsconstante6f74849784cusb: ulpi: rename operations {read|write}_dev to simply {read|write}b7cf1dc3414dusb: dwc3: ulpi: use new api594e121f2568usb: dwc3: gadget: stop kicking if we run out of space7ae7df4982afusb: dwc3: gadget: abolishtrbs_left06281d460fc5usb: dwc3: Add ENDXFER command polling512e47572f7dusb: dwc3: Add revision numbers for the USB 3.0 IP00af62330c39usb: dwc3: core: Move the mode setting to the right placef652191be3f6usb: dwc3: of-simple: add compatible for rockchip rk339900fe081dc3a3usb: dwc3: adddis_del_phy_power_chg_quirk32f2ed864dd5usb: dwc3: make usb2 phy utmi interface configurable16199f338939usb: dwc3: adddis_u2_freeclk_exists_quirkdc55c67e9c95usb: dwc3: gadget: improve incrementrequest->actualf99f53f24d87usb: dwc3: gadget: remove condition that never happens1f512119a08cusb: dwc3: gadget: add remaining sg entries to ring2c78c0295fd8usb: dwc3: gadget: interrupt on ring full too0b3e4af3c740usb: dwc3: gadget: add sg andnum_pending_sgstodwc3_request31162af447d7usb: dwc3: gadget: avoid while (1) loop on completion08a36b543803usb: dwc3: gadget: simplify__dwc3_gadget_ep_queue()45438a0cd9c2usb: dwc3: gadget: simplifydwc3_ep_prev_trb()737f1ae2556ausb: dwc3: gadget: increment dequeue pointer on completion4bc48c974708usb: dwc3: gadget: retire LST bit completelya26a142275c6usb: remove redundant dependency onUSB_SUPPORT
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 13/75 usb: dwc3: import from kernel v4.10
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.9 to v4.10.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.9..v4.10
Commits imported:8ae584d1951f usb: dwc3: exynos fix axius clock error path to do cleanup 9418ee15f718 usb: dwc3: gadget: Fix full speed mode8f8983a56836 usb: dwc3: pci: add Intel Gemini Lake PCI ID 0eae2fde164c usb: dwc3: pci: Add "linux,sysdev_is_parent" property 12a7f17fac5b usb: dwc3: omap: fix race of pm runtime with irq handler in probe d7fd41c6dbcc usb: dwc3: skip interrupt when ep disabled 51c1685d9562 usb: dwc3: pci: Fix dr_mode misspellinge71d363d9c61 usb: dwc3: core: avoid Overflow eventsd62145929992 usb: dwc3: gadget: always unmap EP0 requests 19ec31230eb3 usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb() 7931ec86c1b7 usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb() 9165dabb2500 treewide: Fix printk() message errors8c9f2de459c7 usb: dwc3: Do not set dma coherent maskd64ff406e51e usb: dwc3: use bus->sysdev for DMA configuration 1c404b51a05d usb: dwc3: ep0: avoid empty-body warning36daf3aa399c usb: dwc3: pci: avoid build warning28632b44d129 usb: dwc3: Workaround for irq mask issuecf40b86b6ef6 usb: dwc3: Implement interrupt moderation 65aca3205046 usb: dwc3: gadget: clear events in top-half handler ebbb2d59398f usb: dwc3: gadget: use evt->cache for processing events caefe6c7be47 usb: dwc3: gadget: use evt->length as we should d9fa4c63f766 usb: dwc3: core: add a event buffer cache a22f884b2665 usb: dwc3: core: remove dwc3_soft_reset() 7ac51a12ea11 usb: dwc3: Add a function to check properties a987a906e95c usb: dwc3: Add a check for the DWC_usb3 core 5fb6fdaf38f7 usb: dwc3: gadget: Fix dead code writing GCTL.RAMCLKSEL 39ebb05ca83d usb: dwc3: gadget: Remove descriptor arguments to ep_enable f2694a93e0df usb: dwc3: warn on once when no trbs87aba10639b0 usb: dwc3: isoc clean DWC3_EP_PENDING_REQUEST flag e3aee48692ac usb: dwc3: fix post-incrementce3fc8b32994 usb: dwc3: clean TRB if STARTTRANSFER fail 8ab89da4c281 usb: dwc3: decrement queued_requests5eb30cedced6 usb: dwc3: trace: purge dwc3_trace()2870e5013e19 usb: dwc3: trace: add a tracepoint for ep enable/disable 9cecca75b5a0 usb: dwc3: pci: call _DSM for suspend/resume 0f817ae696b0 usb: dwc3: pci: add a private driver structure ff377ae47de5 usb: dwc3: gadget: always kick if num_pending_sgs > 0 7282c4ef0b66 usb: dwc3: gadget: stop touching HWO TRBs d86c5a676e5b usb: dwc3: gadget: always try to prepare on started_list first e62c5bc57367 usb: dwc3: gadget: tracking per-TRB remaining bytes 6cb2e4e3de10 usb: dwc3: gadget: cope with XferNotReady before usb_ep_queue() 76a638f8ac0d usb: dwc3: gadget: wait for End Transfer to complete 785c91f8ae4d usb: dwc3: cleanup with list_first_entry_or_null() bb0147364850 usb: dwc3: gadget: don't clear RUN/STOP when it's invalid to do so cf68923055cb usb: dwc3: gadget: purge dwc3_stop_active_transfers() c5ac6116db35 usb: dwc3: core: add dwc3_get_properties() 3b2733227f40 usb: dwc3: core: remove unnecessary alignment 941f918ecfa7 usb: dwc3: core: introduce dwc3_core_setup_global_control() 0759956f8ae7 usb: dwc3: core: introduce dwc3_core_is_valid() 0bb39ca1ad87 usb: dwc3: Add support for device L1 exit f9d2f9228cde usb: dwc3: remove unused struct member dwc3->mem 0a695d4c75ff usb: dwc3: gadget: never ever kill the machine c9508c8c50f9 usb: dwc3: gadget: only interrupt on short if short_not_ok is set 58f29034b4c4 usb: dwc3: gadget: CSP is only valid for OUT endpoints b9bd138e06b9 usb: dwc3: gadget: remove unused 'first_trb_index' 39e07ffb1c3d usb: dwc3: ep0: simplify dwc3_ep0_handle_feature() 6d729a55cc0f usb: dwc3: host: extract dwc3_host_get_irq() 6db3812e09db usb: dwc3: gadget: extract dwc3_gadget_get_irq() 4dd5a69e495b usb: dwc3: trace: add a proper tracepoint for reg accessors ba1773fb7de9 usb: dwc3: Kconfig: allow all glues to build if COMPILE_TEST 57b14da56227 usb: dwc3: don't compile dwc3_trace() unless CONFIG_FTRACE=y a97ea994605e usb: dwc3: gadget: offset Start Transfer latency for bulk EPs fa8d965d736b usb: dwc3: trace: pretty print high-bandwidth transfers too 43c96be1c46e usb: dwc3: trace: print out ep0state also from XferComplete cdd72ac20b4a usb: dwc3: debug: move dwc3_ep0_state_string() to debug.h 8566cd1adf29 usb: dwc3: gadget: remove redundant trace prints 45a2af2f2b5a usb: dwc3: debug: decode control endpoint phase too 799e9dc82968 usb: dwc3: gadget: conditionally disable Link State change events 15b8d9332b92 usb: dwc3: gadget: giveback request if we can't kick it 8897a761c371 usb: dwc3: gadget: make use of No Response Update Transfer 5999914f227b usb: dwc3: gadget: properly check ep cmd6b9018d4c1e5 usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs
--- drivers/usb/dwc3/core.c | 358 ++++++++++++----------- drivers/usb/dwc3/core.h | 63 +++- drivers/usb/dwc3/debug.c | 32 -- drivers/usb/dwc3/debug.h | 41 ++- drivers/usb/dwc3/ep0.c | 391 +++++++++++++------------ drivers/usb/dwc3/gadget.c | 594 ++++++++++++++++++++++---------------- drivers/usb/dwc3/gadget.h | 5 +- drivers/usb/dwc3/io.h | 6 +- 8 files changed, 830 insertions(+), 660 deletions(-) delete mode 100644 drivers/usb/dwc3/debug.c
drivers/usb/dwc3/core.c +190 -168
@@ -169,33 +169,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)return -ETIMEDOUT ; } -/** -* dwc3_soft_reset - Issue soft reset -* @dwc: Pointer to our controller context structure -*/ -static int dwc3_soft_reset (struct dwc3 *dwc) -{ -unsigned long timeout; -u32 reg; - - timeout = jiffies +msecs_to_jiffies (500 ); -dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); -do { - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); -if (!(reg &DWC3_DCTL_CSFTRST )) -break ; - -if (time_after (jiffies, timeout)) { -dev_err (dwc->dev,"Reset Timed Out\n" ); -return -ETIMEDOUT ; - } - -cpu_relax (); - }while (true); - -return 0 ; -} -/* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure
@@ -229,7 +202,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)static void dwc3_free_one_event_buffer (struct dwc3 *dwc,struct dwc3_event_buffer *evt) { -dma_free_coherent (dwc->dev, evt->length, evt->buf, evt->dma); +dma_free_coherent (dwc->sysdev, evt->length, evt->buf, evt->dma); }/**
@@ -251,7 +224,11 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, evt->dwc = dwc; evt->length = length; - evt->buf =dma_alloc_coherent (dwc->dev, length, + evt->cache =devm_kzalloc (dwc->dev, length,GFP_KERNEL ); +if (!evt->cache) +return ERR_PTR (-ENOMEM ); + + evt->buf =dma_alloc_coherent (dwc->sysdev, length, &evt->dma,GFP_KERNEL );if (!evt->buf)return ERR_PTR (-ENOMEM );
@@ -305,13 +282,7 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc)struct dwc3_event_buffer *evt; evt = dwc->ev_buf; -dwc3_trace (trace_dwc3_core, -"Event buf %p dma %08llx length %d\n" , - evt->buf, (unsigned long long ) evt->dma, - evt->length); - evt->lpos =0 ; -dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (0 ),lower_32_bits (evt->dma)); dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
@@ -370,11 +341,11 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)if (!WARN_ON (dwc->scratchbuf))return 0 ; - scratch_addr =dma_map_single (dwc->dev, dwc->scratchbuf, + scratch_addr =dma_map_single (dwc->sysdev, dwc->scratchbuf, dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); -if (dma_mapping_error (dwc->dev, scratch_addr)) { -dev_err (dwc->dev,"failed to map scratch buffer\n" ); +if (dma_mapping_error (dwc->sysdev, scratch_addr)) { +dev_err (dwc->sysdev,"failed to map scratch buffer\n" ); ret = -EFAULT ; goto err0; }
@@ -398,7 +369,7 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)return 0 ; err1: -dma_unmap_single (dwc->dev, dwc->scratch_addr, dwc->nr_scratch * +dma_unmap_single (dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); err0:
@@ -417,7 +388,7 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)if (!WARN_ON (dwc->scratchbuf))return ; -dma_unmap_single (dwc->dev, dwc->scratch_addr, dwc->nr_scratch * +dma_unmap_single (dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL );kfree (dwc->scratchbuf); }
@@ -428,9 +399,6 @@ static void dwc3_core_num_eps(struct dwc3 *dwc) dwc->num_in_eps =DWC3_NUM_IN_EPS (parms); dwc->num_out_eps =DWC3_NUM_EPS (parms) - dwc->num_in_eps; - -dwc3_trace (trace_dwc3_core,"found %d IN and %d OUT endpoints" , - dwc->num_in_eps, dwc->num_out_eps); }static void dwc3_cache_hwparams (struct dwc3 *dwc)
@@ -524,13 +492,6 @@ static int dwc3_phy_setup(struct dwc3 *dwc) }/* FALLTHROUGH */ case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : -/* Making sure the interface and PHY are operational */ - ret =dwc3_soft_reset (dwc); -if (ret) -return ret; - -udelay (1 ); - ret =dwc3_ulpi_init (dwc);if (ret)return ret;
@@ -594,19 +555,12 @@ static void dwc3_core_exit(struct dwc3 *dwc)phy_power_off (dwc->usb3_generic_phy); } -/** -* dwc3_core_init - Low-level initialization of DWC3 Core -* @dwc: Pointer to our controller context structure -* -* Returns 0 on success otherwise negative errno. -*/ -static int dwc3_core_init (struct dwc3 *dwc) +static bool dwc3_core_is_valid (struct dwc3 *dwc) { -u32 hwparams4 = dwc->hwparams.hwparams4; -u32 reg; -int ret; +u32 reg; reg =dwc3_readl (dwc->regs,DWC3_GSNPSID ); +/* This should read as U3 followed by revision number */ if ((reg &DWC3_GSNPSID_MASK ) ==0x55330000 ) {/* Detected DWC_usb3 IP */
@@ -616,36 +570,16 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); dwc->revision |=DWC3_REVISION_IS_DWC31 ; }else { -dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); - ret = -ENODEV ; - goto err0; +return false; } -/* -* Write Linux Version Code to our GUID register so it's easy to figure -* out which kernel version a bug was found. -*/ -dwc3_writel (dwc->regs,DWC3_GUID ,LINUX_VERSION_CODE ); - -/* Handle USB2.0-only core configuration */ -if (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == -DWC3_GHWPARAMS3_SSPHY_IFC_DIS ) { -if (dwc->maximum_speed ==USB_SPEED_SUPER ) - dwc->maximum_speed =USB_SPEED_HIGH ; - } - -/* issue device SoftReset too */ - ret =dwc3_soft_reset (dwc); -if (ret) - goto err0; - - ret =dwc3_core_soft_reset (dwc); -if (ret) - goto err0; +return true; +} - ret =dwc3_phy_setup (dwc); -if (ret) - goto err0; +static void dwc3_core_setup_global_control (struct dwc3 *dwc) +{ +u32 hwparams4 = dwc->hwparams.hwparams4; +u32 reg; reg =dwc3_readl (dwc->regs,DWC3_GCTL ); reg &= ~DWC3_GCTL_SCALEDOWN_MASK ;
@@ -683,13 +617,13 @@ static int dwc3_core_init(struct dwc3 *dwc) reg |=DWC3_GCTL_GBLHIBERNATIONEN ;break ;default : -dwc3_trace (trace_dwc3_core,"No power optimization available\n" ); +/* nothing */ +break ; }/* check if current dwc3 is on simulation board */ if (dwc->hwparams.hwparams6 &DWC3_GHWPARAMS6_EN_FPGA ) { -dwc3_trace (trace_dwc3_core, -"running on FPGA platform\n" ); +dev_info (dwc->dev,"Running with FPGA optmizations\n" ); dwc->is_fpga = true; }
@@ -714,7 +648,47 @@ static int dwc3_core_init(struct dwc3 *dwc) reg |=DWC3_GCTL_U2RSTECN ;dwc3_writel (dwc->regs,DWC3_GCTL , reg); +} + +/** +* dwc3_core_init - Low-level initialization of DWC3 Core +* @dwc: Pointer to our controller context structure +* +* Returns 0 on success otherwise negative errno. +*/ +static int dwc3_core_init (struct dwc3 *dwc) +{ +u32 reg; +int ret; + +if (!dwc3_core_is_valid (dwc)) { +dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); + ret = -ENODEV ; + goto err0; + } + +/* +* Write Linux Version Code to our GUID register so it's easy to figure +* out which kernel version a bug was found. +*/ +dwc3_writel (dwc->regs,DWC3_GUID ,LINUX_VERSION_CODE ); + +/* Handle USB2.0-only core configuration */ +if (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == +DWC3_GHWPARAMS3_SSPHY_IFC_DIS ) { +if (dwc->maximum_speed ==USB_SPEED_SUPER ) + dwc->maximum_speed =USB_SPEED_HIGH ; + } + + ret =dwc3_core_soft_reset (dwc); +if (ret) + goto err0; + ret =dwc3_phy_setup (dwc); +if (ret) + goto err0; + +dwc3_core_setup_global_control (dwc);dwc3_core_num_eps (dwc); ret =dwc3_setup_scratch_buffers (dwc);
@@ -766,6 +740,16 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); } +/* +* Enable hardware control of sending remote wakeup in HS when +* the device is in the L1 state. +*/ +if (dwc->revision >=DWC3_REVISION_290A ) { + reg =dwc3_readl (dwc->regs,DWC3_GUCTL1 ); + reg |=DWC3_GUCTL1_DEV_L1_EXIT_BY_HW ; +dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); + } +return 0 ; err4:
@@ -919,57 +903,13 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc) } } -#define DWC3_ALIGN_MASK (16 - 1) - -static int dwc3_probe (struct platform_device *pdev) +static void dwc3_get_properties (struct dwc3 *dwc) { -struct device *dev = &pdev->dev; -struct resource *res; -struct dwc3 *dwc; +struct device *dev = dwc->dev;u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold; -int ret; - -void __iomem *regs; -void *mem; - - mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL ); -if (!mem) -return -ENOMEM ; - - dwc =PTR_ALIGN (mem,DWC3_ALIGN_MASK +1 ); - dwc->mem = mem; - dwc->dev = dev; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (dev,"missing memory resource\n" ); -return -ENODEV ; - } - - dwc->xhci_resources[0 ].start = res->start; - dwc->xhci_resources[0 ].end = dwc->xhci_resources[0 ].start + -DWC3_XHCI_REGS_END ; - dwc->xhci_resources[0 ].flags = res->flags; - dwc->xhci_resources[0 ].name = res->name; - - res->start +=DWC3_GLOBALS_REGS_START ; - -/* -* Request memory region but exclude xHCI regs, -* since it will be requested by the xhci-plat driver. -*/ - regs =devm_ioremap_resource (dev, res); -if (IS_ERR (regs)) { - ret =PTR_ERR (regs); - goto err0; - } - - dwc->regs = regs; - dwc->regs_size =resource_size (res); -/* default to highest possible threshold */ lpm_nyet_threshold =0xff ;
@@ -986,6 +926,13 @@ static int dwc3_probe(struct platform_device *pdev) dwc->dr_mode =usb_get_dr_mode (dev); dwc->hsphy_mode =of_usb_get_phy_mode (dev->of_node); + dwc->sysdev_is_parent =device_property_read_bool (dev, +"linux,sysdev_is_parent" ); +if (dwc->sysdev_is_parent) + dwc->sysdev = dwc->dev->parent; +else + dwc->sysdev = dwc->dev; + dwc->has_lpm_erratum =device_property_read_bool (dev,"snps,has-lpm-erratum" ); device_property_read_u8(dev, "snps,lpm-nyet-threshold",
@@ -1041,6 +988,112 @@ static int dwc3_probe(struct platform_device *pdev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); + dwc->imod_interval =0 ; +} + +/* check whether the core supports IMOD */ +bool dwc3_has_imod (struct dwc3 *dwc) +{ +return ((dwc3_is_usb3 (dwc) && + dwc->revision >=DWC3_REVISION_300A ) || + (dwc3_is_usb31 (dwc) && + dwc->revision >=DWC3_USB31_REVISION_120A )); +} + +static void dwc3_check_params (struct dwc3 *dwc) +{ +struct device *dev = dwc->dev; + +/* Check for proper value of imod_interval */ +if (dwc->imod_interval && !dwc3_has_imod (dwc)) { +dev_warn (dwc->dev,"Interrupt moderation not supported\n" ); + dwc->imod_interval =0 ; + } + +/* +* Workaround for STAR 9000961433 which affects only version +* 3.00a of the DWC_usb3 core. This prevents the controller +* interrupt from being masked while handling events. IMOD +* allows us to work around this issue. Enable it for the +* affected version. +*/ +if (!dwc->imod_interval && + (dwc->revision ==DWC3_REVISION_300A )) + dwc->imod_interval =1 ; + +/* Check the maximum_speed parameter */ +switch (dwc->maximum_speed) { +case USB_SPEED_LOW : +case USB_SPEED_FULL : +case USB_SPEED_HIGH : +case USB_SPEED_SUPER : +case USB_SPEED_SUPER_PLUS : +break ; +default : +dev_err (dev,"invalid maximum_speed parameter %d\n" , + dwc->maximum_speed); +/* fall through */ +case USB_SPEED_UNKNOWN : +/* default to superspeed */ + dwc->maximum_speed =USB_SPEED_SUPER ; + +/* +* default to superspeed plus if we are capable. +*/ +if (dwc3_is_usb31 (dwc) && + (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == +DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 )) + dwc->maximum_speed =USB_SPEED_SUPER_PLUS ; + +break ; + } +} + +static int dwc3_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct resource *res; +struct dwc3 *dwc; + +int ret; + +void __iomem *regs; + + dwc =devm_kzalloc (dev,sizeof (*dwc),GFP_KERNEL ); +if (!dwc) +return -ENOMEM ; + + dwc->dev = dev; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (dev,"missing memory resource\n" ); +return -ENODEV ; + } + + dwc->xhci_resources[0 ].start = res->start; + dwc->xhci_resources[0 ].end = dwc->xhci_resources[0 ].start + +DWC3_XHCI_REGS_END ; + dwc->xhci_resources[0 ].flags = res->flags; + dwc->xhci_resources[0 ].name = res->name; + + res->start +=DWC3_GLOBALS_REGS_START ; + +/* +* Request memory region but exclude xHCI regs, +* since it will be requested by the xhci-plat driver. +*/ + regs =devm_ioremap_resource (dev, res); +if (IS_ERR (regs)) { + ret =PTR_ERR (regs); + goto err0; + } + + dwc->regs = regs; + dwc->regs_size =resource_size (res); + +dwc3_get_properties (dwc); +platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc);
@@ -1050,12 +1103,6 @@ static int dwc3_probe(struct platform_device *pdev)spin_lock_init (&dwc->lock); -if (!dev->dma_mask) { - dev->dma_mask = dev->parent->dma_mask; - dev->dma_parms = dev->parent->dma_parms; -dma_set_coherent_mask (dev, dev->parent->coherent_dma_mask); - } -pm_runtime_set_active (dev);pm_runtime_use_autosuspend (dev);pm_runtime_set_autosuspend_delay (dev,DWC3_DEFAULT_AUTOSUSPEND_DELAY );
@@ -1087,32 +1134,7 @@ static int dwc3_probe(struct platform_device *pdev) goto err4; } -/* Check the maximum_speed parameter */ -switch (dwc->maximum_speed) { -case USB_SPEED_LOW : -case USB_SPEED_FULL : -case USB_SPEED_HIGH : -case USB_SPEED_SUPER : -case USB_SPEED_SUPER_PLUS : -break ; -default : -dev_err (dev,"invalid maximum_speed parameter %d\n" , - dwc->maximum_speed); -/* fall through */ -case USB_SPEED_UNKNOWN : -/* default to superspeed */ - dwc->maximum_speed =USB_SPEED_SUPER ; - -/* -* default to superspeed plus if we are capable. -*/ -if (dwc3_is_usb31 (dwc) && - (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == -DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 )) - dwc->maximum_speed =USB_SPEED_SUPER_PLUS ; - -break ; - } +dwc3_check_params (dwc); ret =dwc3_core_init_mode (dwc);if (ret)
drivers/usb/dwc3/core.h +50 -13
261 lines not on this page · raw message
drivers/usb/dwc3/debug.c deleted +0 -32
@@ -1,32 +0,0 @@ -/** -* debug.c - DesignWare USB3 DRD Controller Debug/Trace Support -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com -* -* Author: Felipe Balbi <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ - -#include "debug.h" - -void dwc3_trace (void (*trace)(struct va_format *),const char *fmt, ...) -{ -struct va_format vaf; -va_list args; - -va_start (args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - -trace (&vaf); - -va_end (args); -}
drivers/usb/dwc3/debug.h +37 -4
86 lines not on this page · raw message
drivers/usb/dwc3/ep0.c +206 -185
620 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +344 -250
1,189 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +1 -4
@@ -62,10 +62,7 @@ struct dwc3;static inline struct dwc3_request *next_request (struct list_head *list) { -if (list_empty (list)) -return NULL ; - - return list_first_entry(list, struct dwc3_request, list); + return list_first_entry_or_null(list, struct dwc3_request, list); }static inline void dwc3_gadget_move_started_request (struct dwc3_request *req)
drivers/usb/dwc3/io.h +2 -4
@@ -40,8 +40,7 @@ static inline u32 dwc3_readl(void __iomem *base, u32 offset)* documentation, so we revert it back to the proper addresses, the * same way they are described on SNPS documentation */ -dwc3_trace (trace_dwc3_readl,"addr %p value %08x" , - base -DWC3_GLOBALS_REGS_START + offset, value); +trace_dwc3_readl (base -DWC3_GLOBALS_REGS_START , offset, value);return value; }
@@ -60,8 +59,7 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)* documentation, so we revert it back to the proper addresses, the * same way they are described on SNPS documentation */ -dwc3_trace (trace_dwc3_writel,"addr %p value %08x" , - base - DWC3_GLOBALS_REGS_START + offset, value); + trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value); }#endif /* __DRIVERS_USB_DWC3_IO_H */
Signature · 1 line
2.53.0
Re: [PATCH v5 13/75] usb: dwc3: import from kernel v4.10
Hi Anders,
Thank you for the patch.
Quoted 92 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.9 to v4.10.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.9..v4.10
Commits imported:8ae584d1951fusb: dwc3: exynos fix axius clock error path to do cleanup9418ee15f718usb: dwc3: gadget: Fix full speed mode8f8983a56836usb: dwc3: pci: add Intel Gemini Lake PCI ID0eae2fde164cusb: dwc3: pci: Add "linux,sysdev_is_parent" property12a7f17fac5busb: dwc3: omap: fix race of pm runtime with irq handler in probed7fd41c6dbccusb: dwc3: skip interrupt when ep disabled51c1685d9562usb: dwc3: pci: Fixdr_modemisspellinge71d363d9c61usb: dwc3: core: avoid Overflow eventsd62145929992usb: dwc3: gadget: always unmap EP0 requests19ec31230eb3usb: dwc3: ep0: explicitly calldwc3_ep0_prepare_one_trb()7931ec86c1b7usb: dwc3: ep0: adddwc3_ep0_prepare_one_trb()9165dabb2500treewide: Fixprintk()message errors8c9f2de459c7usb: dwc3: Do not set dma coherent maskd64ff406e51eusb: dwc3: usebus->sysdevfor DMA configuration1c404b51a05dusb: dwc3: ep0: avoid empty-body warning36daf3aa399cusb: dwc3: pci: avoid build warning28632b44d129usb: dwc3: Workaround for irq mask issuecf40b86b6ef6usb: dwc3: Implement interrupt moderation65aca3205046usb: dwc3: gadget: clear events in top-half handlerebbb2d59398fusb: dwc3: gadget: useevt->cachefor processing eventscaefe6c7be47usb: dwc3: gadget: useevt->lengthas we shouldd9fa4c63f766usb: dwc3: core: add a event buffer cachea22f884b2665usb: dwc3: core: removedwc3_soft_reset()7ac51a12ea11usb: dwc3: Add a function to check propertiesa987a906e95cusb: dwc3: Add a check for theDWC_usb3core5fb6fdaf38f7usb: dwc3: gadget: Fix dead code writing GCTL.RAMCLKSEL39ebb05ca83dusb: dwc3: gadget: Remove descriptor arguments toep_enablef2694a93e0dfusb: dwc3: warn on once when no trbs87aba10639b0usb: dwc3: isoc cleanDWC3_EP_PENDING_REQUESTflage3aee48692acusb: dwc3: fix post-incrementce3fc8b32994usb: dwc3: clean TRB if STARTTRANSFER fail8ab89da4c281usb: dwc3: decrementqueued_requests5eb30cedced6usb: dwc3: trace: purgedwc3_trace()2870e5013e19usb: dwc3: trace: add a tracepoint for ep enable/disable9cecca75b5a0usb: dwc3: pci: call_DSMfor suspend/resume0f817ae696b0usb: dwc3: pci: add a private driver structureff377ae47de5usb: dwc3: gadget: always kick ifnum_pending_sgs> 07282c4ef0b66usb: dwc3: gadget: stop touching HWO TRBsd86c5a676e5busb: dwc3: gadget: always try to prepare onstarted_listfirste62c5bc57367usb: dwc3: gadget: tracking per-TRB remaining bytes6cb2e4e3de10usb: dwc3: gadget: cope with XferNotReady beforeusb_ep_queue()76a638f8ac0dusb: dwc3: gadget: wait for End Transfer to complete785c91f8ae4dusb: dwc3: cleanup withlist_first_entry_or_null()bb0147364850usb: dwc3: gadget: don't clear RUN/STOP when it's invalid to do socf68923055cbusb: dwc3: gadget: purgedwc3_stop_active_transfers()c5ac6116db35usb: dwc3: core: adddwc3_get_properties()3b2733227f40usb: dwc3: core: remove unnecessary alignment941f918ecfa7usb: dwc3: core: introducedwc3_core_setup_global_control()0759956f8ae7usb: dwc3: core: introducedwc3_core_is_valid()0bb39ca1ad87usb: dwc3: Add support for device L1 exitf9d2f9228cdeusb: dwc3: remove unused struct memberdwc3->mem0a695d4c75ffusb: dwc3: gadget: never ever kill the machinec9508c8c50f9usb: dwc3: gadget: only interrupt on short ifshort_not_okis set58f29034b4c4usb: dwc3: gadget: CSP is only valid for OUT endpointsb9bd138e06b9usb: dwc3: gadget: remove unused 'first_trb_index'39e07ffb1c3dusb: dwc3: ep0: simplifydwc3_ep0_handle_feature()6d729a55cc0fusb: dwc3: host: extractdwc3_host_get_irq()6db3812e09dbusb: dwc3: gadget: extractdwc3_gadget_get_irq()4dd5a69e495busb: dwc3: trace: add a proper tracepoint for reg accessorsba1773fb7de9usb: dwc3:Kconfig: allow all glues to build ifCOMPILE_TEST57b14da56227usb: dwc3: don't compiledwc3_trace()unlessCONFIG_FTRACE=ya97ea994605eusb: dwc3: gadget: offset Start Transfer latency for bulk EPsfa8d965d736busb: dwc3: trace: pretty print high-bandwidth transfers too43c96be1c46eusb: dwc3: trace: print out ep0state also from XferCompletecdd72ac20b4ausb: dwc3: debug: movedwc3_ep0_state_string()todebug.h8566cd1adf29usb: dwc3: gadget: remove redundant trace prints45a2af2f2b5ausb: dwc3: debug: decode control endpoint phase too799e9dc82968usb: dwc3: gadget: conditionally disable Link State change events15b8d9332b92usb: dwc3: gadget: giveback request if we can't kick it8897a761c371usb: dwc3: gadget: make use of No Response Update Transfer5999914f227busb: dwc3: gadget: properly check ep cmd6b9018d4c1e5usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 14/75 usb: dwc3: import from kernel v4.11
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.10 to v4.11.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.10..v4.11
Commits imported:de288e36fe33 usb: dwc3: gadget: delay unmap of bounced requests35b2719e72d3 usb: dwc3: gadget: make to increment req->remaining in all cases 0913750f9fb6 usb: dwc3-omap: Fix missing break in dwc3_omap_set_mailbox() 1551e35ea418 usb: dwc3: gadget: Fix system suspend/resume on TI platforms 73561128eb72 usb: dwc3: Fix incorrect type for utmi modecf3113d893d4 usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue 7369090a9fb5 usb: dwc3: gadget: make Set Endpoint Configuration macros safe e42a5dbb8a3d usb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions 28781789051e usb: dwc3: gadget: read IN ep FIFO size from HWffb80fc672c3 usb: dwc3: gadget: skip Set/Clear Halt when invalid538967983b88 usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase c773bb0b9264 usb: dwc3: omap: Replace the extcon APIc6267a51639b usb: dwc3: gadget: align transfers to wMaxPacketSize 905dc04ea796 usb: dwc3: gadget: allocate bounce buffer for unaligned xfers e49d3cf4926a usb: dwc3: gadget: extract __dwc3_prepare_one_trb()843053093f47 usb: dwc3: gadget: simplify dwc3_prepare_one_trb()0e4018ff5d12 usb: dwc3: exynos: Remove MODULE_ALIAS()3e27b3f66a56 usb: dwc3: exynos remove suspend clock unspecified debug message
--- drivers/usb/dwc3/core.h | 5 + drivers/usb/dwc3/ep0.c | 14 ++ drivers/usb/dwc3/gadget.c | 287 +++++++++++++++++++++++++++++++------- drivers/usb/dwc3/gadget.h | 14 +- 4 files changed, 260 insertions(+), 60 deletions(-)
drivers/usb/dwc3/core.h +5 -0
@@ -40,6 +40,7 @@/* Global constants */ #define DWC3_PULL_UP_TIMEOUT 500/* ms */ #define DWC3_ZLP_BUF_SIZE 1024/* size of a superspeed bulk */ +#define DWC3_BOUNCE_SIZE 1024/* size of a superspeed bulk */ #define DWC3_EP0_BOUNCE_SIZE 512#define DWC3_ENDPOINTS_NUM 32#define DWC3_XHCI_RESOURCES_NUM 2
@@ -724,6 +725,7 @@ struct dwc3_hwparams {* @epnum: endpoint number to which this request refers * @trb: pointer to struct dwc3_trb * @trb_dma: DMA address of @trb +* @unaligned: true for OUT endpoints with length not divisible by maxp * @direction: IN or OUT direction flag * @mapped: true when request has been dma-mapped * @queued: true when request has been queued to HW
@@ -740,6 +742,7 @@ struct dwc3_request {struct dwc3_trb *trb;dma_addr_t trb_dma; + unsigned unaligned:1; unsigned direction:1; unsigned mapped:1; unsigned started:1;
@@ -857,12 +860,14 @@ struct dwc3_scratchpad_array {struct dwc3 {struct usb_ctrlrequest *ctrl_req;struct dwc3_trb *ep0_trb; +void *bounce;void *ep0_bounce;void *zlp_buf;void *scratchbuf;u8 *setup_buf;dma_addr_t ctrl_req_addr;dma_addr_t ep0_trb_addr; +dma_addr_t bounce_addr;dma_addr_t ep0_bounce_addr;dma_addr_t scratch_addr;struct dwc3_request ep0_usb_req;
drivers/usb/dwc3/ep0.c +14 -0
@@ -1123,7 +1123,21 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc, dwc->ep0state =EP0_STATUS_PHASE ;if (dwc->delayed_status) { +struct dwc3_ep *dep = dwc->eps[0 ]; +WARN_ON_ONCE (event->endpoint_number !=1 ); +/* +* We should handle the delay STATUS phase here if the +* request for handling delay STATUS has been queued +* into the list. +*/ +if (!list_empty (&dep->pending_list)) { + dwc->delayed_status = false; +usb_gadget_set_state (&dwc->gadget, +USB_STATE_CONFIGURED ); +dwc3_ep0_do_control_status (dwc, event); + } +return ; }
drivers/usb/dwc3/gadget.c +234 -53
447 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +7 -7
@@ -28,23 +28,23 @@ struct dwc3;#define gadget_to_dwc (g) (container_of(g, struct dwc3, gadget))/* DEPCFG parameter 1 */ -#define DWC3_DEPCFG_INT_NUM (n) ((n) << 0) +#define DWC3_DEPCFG_INT_NUM (n) (((n) & 0x1f) << 0)#define DWC3_DEPCFG_XFER_COMPLETE_EN (1 << 8)#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN (1 << 9)#define DWC3_DEPCFG_XFER_NOT_READY_EN (1 << 10)#define DWC3_DEPCFG_FIFO_ERROR_EN (1 << 11)#define DWC3_DEPCFG_STREAM_EVENT_EN (1 << 13) -#define DWC3_DEPCFG_BINTERVAL_M1 (n) ((n) << 16) +#define DWC3_DEPCFG_BINTERVAL_M1 (n) (((n) & 0xff) << 16)#define DWC3_DEPCFG_STREAM_CAPABLE (1 << 24) -#define DWC3_DEPCFG_EP_NUMBER (n) ((n) << 25) +#define DWC3_DEPCFG_EP_NUMBER (n) (((n) & 0x1f) << 25)#define DWC3_DEPCFG_BULK_BASED (1 << 30)#define DWC3_DEPCFG_FIFO_BASED (1 << 31)/* DEPCFG parameter 0 */ -#define DWC3_DEPCFG_EP_TYPE (n) ((n) << 1) -#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) ((n) << 3) -#define DWC3_DEPCFG_FIFO_NUMBER (n) ((n) << 17) -#define DWC3_DEPCFG_BURST_SIZE (n) ((n) << 22) +#define DWC3_DEPCFG_EP_TYPE (n) (((n) & 0x3) << 1) +#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) (((n) & 0x7ff) << 3) +#define DWC3_DEPCFG_FIFO_NUMBER (n) (((n) & 0x1f) << 17) +#define DWC3_DEPCFG_BURST_SIZE (n) (((n) & 0xf) << 22)#define DWC3_DEPCFG_DATA_SEQ_NUM (n) ((n) << 26)/* This applies for core versions earlier than 1.94a */ #define DWC3_DEPCFG_IGN_SEQ_NUM (1 << 31)
Signature · 1 line
2.53.0
Re: [PATCH v5 14/75] usb: dwc3: import from kernel v4.11
Hi Anders,
Thank you for the patch.
Quoted 38 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.10 to v4.11.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.10..v4.11
Commits imported:de288e36fe33usb: dwc3: gadget: delay unmap of bounced requests35b2719e72d3usb: dwc3: gadget: make to incrementreq->remainingin all cases0913750f9fb6usb: dwc3-omap: Fix missing break indwc3_omap_set_mailbox()1551e35ea418usb: dwc3: gadget: Fix system suspend/resume on TI platforms73561128eb72usb: dwc3: Fix incorrect type for utmi modecf3113d893d4usb: dwc3: gadget: properly increment dequeue pointer onep_dequeue7369090a9fb5usb: dwc3: gadget: make Set Endpoint Configuration macros safee42a5dbb8a3dusb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions28781789051eusb: dwc3: gadget: read IN ep FIFO size from HWffb80fc672c3usb: dwc3: gadget: skip Set/Clear Halt when invalid538967983b88usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phasec773bb0b9264usb: dwc3: omap: Replace the extcon APIc6267a51639busb: dwc3: gadget: align transfers to wMaxPacketSize905dc04ea796usb: dwc3: gadget: allocate bounce buffer for unaligned xferse49d3cf4926ausb: dwc3: gadget: extract__dwc3_prepare_one_trb()843053093f47usb: dwc3: gadget: simplifydwc3_prepare_one_trb()0e4018ff5d12usb: dwc3: exynos: RemoveMODULE_ALIAS()3e27b3f66a56usb: dwc3: exynos remove suspend clock unspecified debug message
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 15/75 usb: dwc3: import from kernel v4.12
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.11 to v4.12.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.11..v4.12
Commits imported:018047a1dba7 usb: dwc3: keystone: check return valued325a1de49d6 usb: dwc3: gadget: Prevent losing events in event cache f1d6826cae30 usb: dwc3: gadget: Fix ISO transfer performance682179592e48 usb: dwc3: pci: add Intel Cannonlake PCI IDs9840354ff429 usb: dwc3: Add dual-role support41ce1456e1db usb: dwc3: core: make dwc3_set_mode() work properly b202c42cbf81 usb: dwc3: debugfs: remove unnecessary | operator6b3261a27428 usb: dwc3: core: add current_dr_role memberd6e5a549cc4d usb: dwc3: simplify ZLP handling4199c5f8bccd usb: dwc3: ep0: improve handling of unaligned OUT requests d686a5ff6a2d usb: dwc3: ep0: pass dep as argument to internal functions 7d5e650a5fdb usb: dwc3: ep0: use immediate SETUP on TRBb5c7ed5cca82 usb: dwc3: expose dwc3_trb_type_string()90abb425d949 usb: dwc3: debugfs: return strings that match tracepoints 26c9f3e391d1 usb: dwc3: debugfs: make use of dwc3_gadget_link_string() 2df301cd3d71 usb: dwc3: debugfs: downcase OTG on 'mode' fileff3f0789b3dc usb: dwc3: use BIT() macro where possibleaad7c2596495 usb: dwc3: trace: change format for string to cmd trace af771d731b8e usb: dwc3: gadget: Fix starting microframe for ISOC 3a932b0f50f4 usb: dwc3: exynos: change goto labels to meaningful names f3bcfc7e68f0 usb: dwc3: remove dwc3_gadget_init_hw_endpoints47d3946ea220 usb: dwc3: refactor gadget endpoint count calculation 8261bd4e91e2 usb: dwc3: make macros safe to expression arguments 05428ba983e6 usb: dwc3: remove dwc3_log_msg trace class1966b8657d05 usb: dwc3: make sure UX_EXIT_PX is cleared4a56e413b50c usb: dwc3: pci: Switch to devm_acpi_dev_add_driver_gpios() 2c93e790e825 usb: add CONFIG_USB_PCI for system have both PCI HW and non-PCI based USB HW
--- drivers/usb/dwc3/core.c | 109 +++++++++++----- drivers/usb/dwc3/core.h | 261 ++++++++++++++++++++------------------ drivers/usb/dwc3/debug.h | 28 ++++ drivers/usb/dwc3/ep0.c | 151 ++++++++++------------ drivers/usb/dwc3/gadget.c | 218 +++++++++++-------------------- drivers/usb/dwc3/gadget.h | 20 +-- 6 files changed, 392 insertions(+), 395 deletions(-)
drivers/usb/dwc3/core.c +80 -29
@@ -100,7 +100,10 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)return 0 ; } -void dwc3_set_mode (struct dwc3 *dwc,u32 mode) +static void dwc3_event_buffers_cleanup (struct dwc3 *dwc); +static int dwc3_event_buffers_setup (struct dwc3 *dwc); + +static void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode) {u32 reg;
@@ -110,6 +113,69 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)dwc3_writel (dwc->regs,DWC3_GCTL , reg); } +static void __dwc3_set_mode (struct work_struct *work) +{ +struct dwc3 *dwc =work_to_dwc (work); +unsigned long flags; +int ret; + +if (!dwc->desired_dr_role) +return ; + +if (dwc->desired_dr_role == dwc->current_dr_role) +return ; + +if (dwc->dr_mode !=USB_DR_MODE_OTG ) +return ; + +switch (dwc->current_dr_role) { +case DWC3_GCTL_PRTCAP_HOST : +dwc3_host_exit (dwc); +break ; +case DWC3_GCTL_PRTCAP_DEVICE : +dwc3_gadget_exit (dwc); +dwc3_event_buffers_cleanup (dwc); +break ; +default : +break ; + } + +spin_lock_irqsave (&dwc->lock, flags); + +dwc3_set_prtcap (dwc, dwc->desired_dr_role); + + dwc->current_dr_role = dwc->desired_dr_role; + +spin_unlock_irqrestore (&dwc->lock, flags); + +switch (dwc->desired_dr_role) { +case DWC3_GCTL_PRTCAP_HOST : + ret =dwc3_host_init (dwc); +if (ret) +dev_err (dwc->dev,"failed to initialize host\n" ); +break ; +case DWC3_GCTL_PRTCAP_DEVICE : +dwc3_event_buffers_setup (dwc); + ret =dwc3_gadget_init (dwc); +if (ret) +dev_err (dwc->dev,"failed to initialize peripheral\n" ); +break ; +default : +break ; + } +} + +void dwc3_set_mode (struct dwc3 *dwc,u32 mode) +{ +unsigned long flags; + +spin_lock_irqsave (&dwc->lock, flags); + dwc->desired_dr_role = mode; +spin_unlock_irqrestore (&dwc->lock, flags); + +queue_work (system_power_efficient_wq, &dwc->drd_work); +} +u32 dwc3_core_fifo_space (struct dwc3_ep *dep,u8 type) {struct dwc3 *dwc = dep->dwc;
@@ -397,8 +463,7 @@ static void dwc3_core_num_eps(struct dwc3 *dwc) {struct dwc3_hwparams *parms = &dwc->hwparams; - dwc->num_in_eps =DWC3_NUM_IN_EPS (parms); - dwc->num_out_eps =DWC3_NUM_EPS (parms) - dwc->num_in_eps; + dwc->num_eps =DWC3_NUM_EPS (parms); }static void dwc3_cache_hwparams (struct dwc3 *dwc)
@@ -431,6 +496,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); +/* +* Make sure UX_EXIT_PX is cleared as that causes issues with some +* PHYs. Also, this bit is not supposed to be used in normal operation. +*/ + reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX ; +/* * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY * to '0' during coreConsultant configuration. So default value
@@ -714,21 +785,6 @@ static int dwc3_core_init(struct dwc3 *dwc) goto err4; } -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_DEVICE ); -break ; -case USB_DR_MODE_HOST : -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_HOST ); -break ; -case USB_DR_MODE_OTG : -dwc3_set_mode (dwc,DWC3_GCTL_PRTCAP_OTG ); -break ; -default : -dev_warn (dwc->dev,"Unsupported mode %d\n" , dwc->dr_mode); -break ; - } -/* * ENDXFER polling is available on version 3.10a and later of * the DWC_usb3 controller. It is NOT available in the
@@ -846,6 +902,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL : +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE ); ret =dwc3_gadget_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -854,6 +911,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) }break ;case USB_DR_MODE_HOST : +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST ); ret =dwc3_host_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -862,17 +920,11 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) }break ;case USB_DR_MODE_OTG : - ret =dwc3_host_init (dwc); -if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - - ret =dwc3_gadget_init (dwc); +INIT_WORK (&dwc->drd_work, __dwc3_set_mode); + ret =dwc3_drd_init (dwc);if (ret) {if (ret != -EPROBE_DEFER ) -dev_err (dev,"failed to initialize gadget\n" ); +dev_err (dev,"failed to initialize dual-role\n" );return ret; }break ;
@@ -894,8 +946,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)dwc3_host_exit (dwc);break ;case USB_DR_MODE_OTG : -dwc3_host_exit (dwc); -dwc3_gadget_exit (dwc); +dwc3_drd_exit (dwc);break ;default :/* do nothing */
drivers/usb/dwc3/core.h +136 -125
524 lines not on this page · raw message
drivers/usb/dwc3/debug.h +28 -0
@@ -124,6 +124,34 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state) } } +/** +* dwc3_trb_type_string - returns TRB type as a string +* @type: the type of the TRB +*/ +static inline const char *dwc3_trb_type_string (unsigned int type) +{ +switch (type) { +case DWC3_TRBCTL_NORMAL : +return "normal" ; +case DWC3_TRBCTL_CONTROL_SETUP : +return "setup" ; +case DWC3_TRBCTL_CONTROL_STATUS2 : +return "status2" ; +case DWC3_TRBCTL_CONTROL_STATUS3 : +return "status3" ; +case DWC3_TRBCTL_CONTROL_DATA : +return "data" ; +case DWC3_TRBCTL_ISOCHRONOUS_FIRST : +return "isoc-first" ; +case DWC3_TRBCTL_ISOCHRONOUS : +return "isoc" ; +case DWC3_TRBCTL_LINK_TRB : +return "link" ; +default : +return "UNKNOWN" ; + } +} +static inline const char *dwc3_ep0_state_string (enum dwc3_ep0_state state) {switch (state) {
drivers/usb/dwc3/ep0.c +66 -85
249 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +72 -146
399 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +10 -10
@@ -29,16 +29,16 @@ struct dwc3;/* DEPCFG parameter 1 */ #define DWC3_DEPCFG_INT_NUM (n) (((n) & 0x1f) << 0) -#define DWC3_DEPCFG_XFER_COMPLETE_EN (1 << 8) -#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN (1 << 9) -#define DWC3_DEPCFG_XFER_NOT_READY_EN (1 << 10) -#define DWC3_DEPCFG_FIFO_ERROR_EN (1 << 11) -#define DWC3_DEPCFG_STREAM_EVENT_EN (1 << 13) +#define DWC3_DEPCFG_XFER_COMPLETE_EN BIT(8) +#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN BIT(9) +#define DWC3_DEPCFG_XFER_NOT_READY_EN BIT(10) +#define DWC3_DEPCFG_FIFO_ERROR_EN BIT(11) +#define DWC3_DEPCFG_STREAM_EVENT_EN BIT(12)#define DWC3_DEPCFG_BINTERVAL_M1 (n) (((n) & 0xff) << 16) -#define DWC3_DEPCFG_STREAM_CAPABLE (1 << 24) +#define DWC3_DEPCFG_STREAM_CAPABLE BIT(24)#define DWC3_DEPCFG_EP_NUMBER (n) (((n) & 0x1f) << 25) -#define DWC3_DEPCFG_BULK_BASED (1 << 30) -#define DWC3_DEPCFG_FIFO_BASED (1 << 31) +#define DWC3_DEPCFG_BULK_BASED BIT(30) +#define DWC3_DEPCFG_FIFO_BASED BIT(31)/* DEPCFG parameter 0 */ #define DWC3_DEPCFG_EP_TYPE (n) (((n) & 0x3) << 1)
@@ -47,10 +47,10 @@ struct dwc3;#define DWC3_DEPCFG_BURST_SIZE (n) (((n) & 0xf) << 22)#define DWC3_DEPCFG_DATA_SEQ_NUM (n) ((n) << 26)/* This applies for core versions earlier than 1.94a */ -#define DWC3_DEPCFG_IGN_SEQ_NUM (1 << 31) +#define DWC3_DEPCFG_IGN_SEQ_NUM BIT(31)/* These apply for core versions 1.94a and later */ #define DWC3_DEPCFG_ACTION_INIT (0 << 30) -#define DWC3_DEPCFG_ACTION_RESTORE (1 << 30) +#define DWC3_DEPCFG_ACTION_RESTORE BIT(30)#define DWC3_DEPCFG_ACTION_MODIFY (2 << 30)/* DEPXFERCFG parameter 0 */
Signature · 1 line
2.53.0
Re: [PATCH v5 15/75] usb: dwc3: import from kernel v4.12
Hi Anders,
Thank you for the patch.
Quoted 47 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.11 to v4.12.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.11..v4.12
Commits imported:018047a1dba7usb: dwc3: keystone: check return valued325a1de49d6usb: dwc3: gadget: Prevent losing events in event cachef1d6826cae30usb: dwc3: gadget: Fix ISO transfer performance682179592e48usb: dwc3: pci: add Intel Cannonlake PCI IDs9840354ff429usb: dwc3: Add dual-role support41ce1456e1dbusb: dwc3: core: makedwc3_set_mode()work properlyb202c42cbf81usb: dwc3: debugfs: remove unnecessary | operator6b3261a27428usb: dwc3: core: addcurrent_dr_rolememberd6e5a549cc4dusb: dwc3: simplify ZLP handling4199c5f8bccdusb: dwc3: ep0: improve handling of unaligned OUT requestsd686a5ff6a2dusb: dwc3: ep0: pass dep as argument to internal functions7d5e650a5fdbusb: dwc3: ep0: use immediate SETUP on TRBb5c7ed5cca82usb: dwc3: exposedwc3_trb_type_string()90abb425d949usb: dwc3: debugfs: return strings that match tracepoints26c9f3e391d1usb: dwc3: debugfs: make use ofdwc3_gadget_link_string()2df301cd3d71usb: dwc3: debugfs: downcase OTG on 'mode' fileff3f0789b3dcusb: dwc3: useBIT()macro where possibleaad7c2596495usb: dwc3: trace: change format for string to cmd traceaf771d731b8eusb: dwc3: gadget: Fix starting microframe for ISOC3a932b0f50f4usb: dwc3: exynos: change goto labels to meaningful namesf3bcfc7e68f0usb: dwc3: removedwc3_gadget_init_hw_endpoints47d3946ea220usb: dwc3: refactor gadget endpoint count calculation8261bd4e91e2usb: dwc3: make macros safe to expression arguments05428ba983e6usb: dwc3: removedwc3_log_msgtrace class1966b8657d05usb: dwc3: make sureUX_EXIT_PXis cleared4a56e413b50cusb: dwc3: pci: Switch todevm_acpi_dev_add_driver_gpios()2c93e790e825usb: addCONFIG_USB_PCIfor system have both PCI HW and non-PCI based USB HW
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 16/75 usb: dwc3: import from kernel v4.13
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.12 to v4.13.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.12..v4.13
Commits imported:40d829fb2ec6 usb: dwc3: gadget: Correct ISOC DATA PIDs for short packets 4a71fcb8ac5f usb: dwc3: gadget: only unmap requests from DMA if mapped ee249b455494 usb: dwc3: omap: remove IRQ_NOAUTOEN used with shared irq 541768b08a40 usb: dwc3: core: Call dwc3_core_get_phy() before initializing phys de3ef1eb1cd0 PM / core: Drop run_wake flag from struct dev_pm_info ece7af5f787e usb: dwc3: exynos: Handle return value of clk_prepare_enable 46b780d46bcc usb: dwc3: gadget: increase readability of dwc3_gadget_init_endpoints() 958d1a4c40dd usb: dwc3: core: program PHY for proper DRD modes f54edb539c11 usb: dwc3: core: initialize ULPI before trying to get the PHY e0082698b689 usb: dwc3: ulpi: conditionally resume ULPI PHY 9b0a1f95c4b4 usb: dwc3: ep0: make sure wValue is 0 on GetStatus() 7d8d0639565f usb: dwc3: gadget: implement ->udc_set_speed() 94116f8126de ACPI: Switch to use generic guid_t in acpi_evaluate_dsm() af32423a2d86 usb: dwc3: trace: decode ctrl request3587f36a125f usb: dwc3: debug: remove static char buffer from dwc3_decode_event() e42f09b85f20 usb: dwc3: trace: rely on __string() and __assign_str() dfc5e80578f2 usb: dwc3: gadget: slight cleanup to dwc3_process_event_entry() 436841d53dd7 usb: dwc3: debugfs: slightly improve output of trb_ring bfad65ee9be2 usb: dwc3: update documentation04fb365c453e usb: dwc3: replace %p with %pK65db7a0c9816 usb: dwc3: add disable u2mac linestate check quirk cdb55b39fab8 usb: dwc3: gadget: lazily map requests for DMA 202adafe5a6e usb: dwc3: gadget: don't WARN about lack of TRBs
--- drivers/usb/dwc3/core.c | 57 +++++-- drivers/usb/dwc3/core.h | 48 +++--- drivers/usb/dwc3/debug.h | 247 ++++++++++++++++++++++++++- drivers/usb/dwc3/ep0.c | 8 +- drivers/usb/dwc3/gadget.c | 340 +++++++++++++++++++++++--------------- drivers/usb/dwc3/gadget.h | 22 ++- 6 files changed, 549 insertions(+), 173 deletions(-)
drivers/usb/dwc3/core.c +46 -11
@@ -151,11 +151,24 @@ static void __dwc3_set_mode(struct work_struct *work)switch (dwc->desired_dr_role) {case DWC3_GCTL_PRTCAP_HOST : ret =dwc3_host_init (dwc); -if (ret) +if (ret) {dev_err (dwc->dev,"failed to initialize host\n" ); + }else { +if (dwc->usb2_phy) +otg_set_vbus (dwc->usb2_phy->otg, true); +if (dwc->usb2_generic_phy) +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST ); + + }break ;case DWC3_GCTL_PRTCAP_DEVICE :dwc3_event_buffers_setup (dwc); + +if (dwc->usb2_phy) +otg_set_vbus (dwc->usb2_phy->otg, false); +if (dwc->usb2_generic_phy) +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_DEVICE ); + ret =dwc3_gadget_init (dwc);if (ret)dev_err (dwc->dev,"failed to initialize peripheral\n" );
@@ -721,6 +734,8 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GCTL , reg); } +static int dwc3_core_get_phy (struct dwc3 *dwc); +/** * dwc3_core_init - Low-level initialization of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -751,6 +766,10 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc->maximum_speed =USB_SPEED_HIGH ; } + ret =dwc3_core_get_phy (dwc); +if (ret) + goto err0; + ret =dwc3_core_soft_reset (dwc);if (ret) goto err0;
@@ -796,13 +815,19 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); } -/* -* Enable hardware control of sending remote wakeup in HS when -* the device is in the L1 state. -*/ -if (dwc->revision >=DWC3_REVISION_290A ) { +if (dwc->revision >=DWC3_REVISION_250A ) { reg =dwc3_readl (dwc->regs,DWC3_GUCTL1 ); - reg |=DWC3_GUCTL1_DEV_L1_EXIT_BY_HW ; + +/* +* Enable hardware control of sending remote wakeup +* in HS when the device is in the L1 state. +*/ +if (dwc->revision >=DWC3_REVISION_290A ) + reg |=DWC3_GUCTL1_DEV_L1_EXIT_BY_HW ; + +if (dwc->dis_tx_ipgap_linecheck_quirk) + reg |=DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS ; +dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); }
@@ -903,6 +928,12 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL :dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE ); + +if (dwc->usb2_phy) +otg_set_vbus (dwc->usb2_phy->otg, false); +if (dwc->usb2_generic_phy) +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_DEVICE ); + ret =dwc3_gadget_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -912,6 +943,12 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)break ;case USB_DR_MODE_HOST :dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST ); + +if (dwc->usb2_phy) +otg_set_vbus (dwc->usb2_phy->otg, true); +if (dwc->usb2_generic_phy) +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST ); + ret =dwc3_host_init (dwc);if (ret) {if (ret != -EPROBE_DEFER )
@@ -1023,6 +1060,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,dis-u2-freeclk-exists-quirk"); dwc->dis_del_phy_power_chg_quirk =device_property_read_bool (dev,"snps,dis-del-phy-power-chg-quirk" ); + dwc->dis_tx_ipgap_linecheck_quirk =device_property_read_bool (dev, +"snps,dis-tx-ipgap-linecheck-quirk" ); dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" );
@@ -1148,10 +1187,6 @@ static int dwc3_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc); - ret =dwc3_core_get_phy (dwc); -if (ret) - goto err0; -spin_lock_init (&dwc->lock);pm_runtime_set_active (dev);
drivers/usb/dwc3/core.h +28 -20
124 lines not on this page · raw message
drivers/usb/dwc3/debug.h +240 -7
278 lines not on this page · raw message
drivers/usb/dwc3/ep0.c +7 -1
@@ -1,4 +1,4 @@ -/** +/* * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling * * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
@@ -319,10 +319,16 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc, {struct dwc3_ep *dep;u32 recip; +u32 value;u32 reg;u16 usb_status =0 ;__le16 *response_pkt; +/* We don't support PTM_STATUS */ + value =le16_to_cpu (ctrl->wValue); +if (value !=0 ) +return -EINVAL ; + recip = ctrl->bRequestType &USB_RECIP_MASK ;switch (recip) {case USB_RECIP_DEVICE :
drivers/usb/dwc3/gadget.c +210 -130
595 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +18 -4
@@ -1,4 +1,4 @@ -/** +/* * gadget.h - DesignWare USB3 DRD Gadget Header * * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
@@ -60,11 +60,25 @@ struct dwc3;#define to_dwc3_request (r) (container_of(r, struct dwc3_request, request)) +/** +* next_request - gets the next request on the given list +* @list: the request list to operate on +* +* Caller should take care of locking. This function return %NULL or the first +* request available on @list. +*/ static inline struct dwc3_request *next_request (struct list_head *list) { return list_first_entry_or_null(list, struct dwc3_request, list); } +/** +* dwc3_gadget_move_started_request - move @req to the started_list +* @req: the request to be moved +* +* Caller should take care of locking. This function will move @req from its +* current list to the endpoint's started_list. +*/ static inline void dwc3_gadget_move_started_request (struct dwc3_request *req) {struct dwc3_ep *dep = req->dep;
@@ -87,10 +101,10 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol);/** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW -* @dwc: DesignWare USB3 Pointer -* @number: DWC endpoint number +* @dep: dwc3 endpoint * -* Caller should take care of locking +* Caller should take care of locking. Returns the transfer resource +* index for a given endpoint. */ static inline u32 dwc3_gadget_ep_get_transfer_index (struct dwc3_ep *dep) {
Signature · 1 line
2.53.0
Re: [PATCH v5 16/75] usb: dwc3: import from kernel v4.13
Hi Anders,
Thank you for the patch.
Quoted 43 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.12 to v4.13.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.12..v4.13
Commits imported:40d829fb2ec6usb: dwc3: gadget: Correct ISOC DATA PIDs for short packets4a71fcb8ac5fusb: dwc3: gadget: only unmap requests from DMA if mappedee249b455494usb: dwc3: omap: removeIRQ_NOAUTOENused with shared irq541768b08a40usb: dwc3: core: Calldwc3_core_get_phy()before initializing physde3ef1eb1cd0PM / core: Droprun_wakeflag from structdev_pm_infoece7af5f787eusb: dwc3: exynos: Handle return value ofclk_prepare_enable46b780d46bccusb: dwc3: gadget: increase readability ofdwc3_gadget_init_endpoints()958d1a4c40ddusb: dwc3: core: program PHY for proper DRD modesf54edb539c11usb: dwc3: core: initialize ULPI before trying to get the PHYe0082698b689usb: dwc3: ulpi: conditionally resume ULPI PHY9b0a1f95c4b4usb: dwc3: ep0: make sure wValue is 0 onGetStatus()7d8d0639565fusb: dwc3: gadget: implement ->udc_set_speed()94116f8126deACPI: Switch to use genericguid_tinacpi_evaluate_dsm()af32423a2d86usb: dwc3: trace: decode ctrl request3587f36a125fusb: dwc3: debug: remove static char buffer fromdwc3_decode_event()e42f09b85f20usb: dwc3: trace: rely on__string()and__assign_str()dfc5e80578f2usb: dwc3: gadget: slight cleanup todwc3_process_event_entry()436841d53dd7usb: dwc3: debugfs: slightly improve output oftrb_ringbfad65ee9be2usb: dwc3: update documentation04fb365c453eusb: dwc3: replace %p with %pK65db7a0c9816usb: dwc3: add disable u2mac linestate check quirkcdb55b39fab8usb: dwc3: gadget: lazily map requests for DMA202adafe5a6eusb: dwc3: gadget: don't WARN about lack of TRBs
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 17/75 usb: dwc3: import from kernel v4.14
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.13 to v4.14.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.13..v4.14
Commits imported:b24413180f56 License cleanup: add SPDX GPL-2.0 license identifier to files with no license c3cdce45f8d3 usb: dwc3: of-simple: Add compatible for Spreadtrum SC9860 platform 551684708356 usb: dwc3: ep0: fix DMA starvation by assigning req->trb on ep0 e7059ef82a22 usb: dwc3: of-simple: remove include of clk-provider.h 95aa932c93d2 usb/dwc3:constify dev_pm_opsc14af973ed86 usb: dwc3: keystone: Add PM_RUNTIME Support to DWC3 Keystone USB driver 0ae99ecba792 usb: dwc3: omap: fix error return code in dwc3_omap_probe() 8bcd9889721f usb: dwc3: pci: constify dev_pm_ops
--- drivers/usb/dwc3/ep0.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/dwc3/ep0.c +7 -0
@@ -990,6 +990,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,DWC3_TRBCTL_CONTROL_DATA , true); + req->trb = &dwc->ep0_trb[dep->trb_enqueue -1 ]; +/* Now prepare one extra TRB to align transfer size */ dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr, maxpacket - rem,
@@ -1015,6 +1017,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,DWC3_TRBCTL_CONTROL_DATA , true); + req->trb = &dwc->ep0_trb[dep->trb_enqueue -1 ]; +/* Now prepare one extra TRB to align transfer size */ dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr, 0, DWC3_TRBCTL_CONTROL_DATA,
@@ -1029,6 +1033,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,dwc3_ep0_prepare_one_trb (dep, req->request.dma, req->request.length,DWC3_TRBCTL_CONTROL_DATA , false); + + req->trb = &dwc->ep0_trb[dep->trb_enqueue]; + ret =dwc3_ep0_start_trans (dep); }
Signature · 1 line
2.53.0
Re: [PATCH v5 17/75] usb: dwc3: import from kernel v4.14
Hi Anders,
Thank you for the patch.
Quoted 28 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.13 to v4.14.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.13..v4.14
Commits imported:b24413180f56License cleanup: add SPDX GPL-2.0 license identifier to files with no licensec3cdce45f8d3usb: dwc3: of-simple: Add compatible for Spreadtrum SC9860 platform 551684708356 usb: dwc3: ep0: fix DMA starvation by assigningreq->trbon ep0e7059ef82a22usb: dwc3: of-simple: remove include ofclk-provider.h95aa932c93d2usb/dwc3:constifydev_pm_opsc14af973ed86usb: dwc3: keystone: AddPM_RUNTIMESupport to DWC3 Keystone USB driver0ae99ecba792usb: dwc3: omap: fix error return code indwc3_omap_probe()8bcd9889721fusb: dwc3: pci: constifydev_pm_ops
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Fixes b1a3ed068869 ("spl: make args file optional in falcon mode")
Why is this fixes tag here? How is a usb DWC3 update fixing falcon mode for SPL?
Quoted 1 line
Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and the result looks good to me.
Quoted 38 lines
--- drivers/usb/dwc3/ep0.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/usb/dwc3/ep0.c +7
-0@@ -990,6 +990,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,DWC3_TRBCTL_CONTROL_DATA , true); + req->trb = &dwc->ep0_trb[dep->trb_enqueue -1 ]; +/* Now prepare one extra TRB to align transfer size */ dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr, maxpacket - rem,@@ -1015,6 +1017,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,DWC3_TRBCTL_CONTROL_DATA , true); + req->trb = &dwc->ep0_trb[dep->trb_enqueue -1 ]; +/* Now prepare one extra TRB to align transfer size */ dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr, 0, DWC3_TRBCTL_CONTROL_DATA,@@ -1029,6 +1033,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,dwc3_ep0_prepare_one_trb (dep, req->request.dma, req->request.length,DWC3_TRBCTL_CONTROL_DATA , false); + + req->trb = &dwc->ep0_trb[dep->trb_enqueue]; + ret =dwc3_ep0_start_trans (dep); }Signature · 1 line
2.53.0
PATCH v5 18/75 usb: dwc3: import from kernel v4.15
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.14 to v4.15.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.14..v4.15
Commits imported:ec5bb87e4e2a usb: dwc3: gadget: Fix PCM1 for ISOC EP with ep->mult less than 3 a0d8c4cfdf31 usb: dwc3: of-simple: set dev_pm_opsded600ea9fb5 usb: dwc3: of-simple: fix missing clk_disable_unprepare 8722e095f5a4 usb: dwc3: gadget: Wait longer for controller to end command processing b5ea47570b5e USB: dwc3: Remove redundant license text5fd54ace4721 USB: add SPDX identifiers to all remaining files in drivers/usb/ 644cbbc3ab4d usb: dwc3: core: Notify current USB mode to USB3 PHY as well 8eed00b237a2 usb: dwc3: pci: Runtime resume child device from wq 689bf72c6e0d usb: dwc3: Don't reinitialize core during host bus-suspend/resume 06c47e6286d5 usb: dwc3: of-simple: Add support to get resets for the device d6d9c2a3eac2 usb: dwc3: of-simple: Re-order resource handling in remove 86763723eee8 usb: dwc3: ep0: Clean up unused variables7fdca766499b usb: dwc3: gadget: simplify __dwc3_gadget_kick_transfer() prototype 502a37b98a7b usb: dwc3: gadget: cache frame number in struct dwc3_ep 64e010802997 usb: dwc3: gadget: simplify __dwc3_gadget_ep_queue() ccb94ebf9e65 usb: dwc3: gadget: check for lack of TRBs a bit earlier
--- drivers/usb/dwc3/core.c | 74 +++++++++++++++----------------------- drivers/usb/dwc3/core.h | 12 ++----- drivers/usb/dwc3/debug.h | 10 +----- drivers/usb/dwc3/ep0.c | 30 +--------------- drivers/usb/dwc3/gadget.c | 76 ++++++++++++--------------------------- drivers/usb/dwc3/gadget.h | 10 +----- drivers/usb/dwc3/io.h | 10 +----- 7 files changed, 59 insertions(+), 163 deletions(-)
drivers/usb/dwc3/core.c +29 -45
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /** * core.c - DesignWare USB3 DRD Controller Core file *
@@ -5,18 +6,6 @@* * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <linux/version.h>
@@ -156,9 +145,8 @@ static void __dwc3_set_mode(struct work_struct *work) }else {if (dwc->usb2_phy)otg_set_vbus (dwc->usb2_phy->otg, true); -if (dwc->usb2_generic_phy) -phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST ); - +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST ); +phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_HOST ); }break ;case DWC3_GCTL_PRTCAP_DEVICE :
@@ -166,8 +154,8 @@ static void __dwc3_set_mode(struct work_struct *work)if (dwc->usb2_phy)otg_set_vbus (dwc->usb2_phy->otg, false); -if (dwc->usb2_generic_phy) -phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_DEVICE ); +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_DEVICE ); +phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_DEVICE ); ret =dwc3_gadget_init (dwc);if (ret)
@@ -927,12 +915,13 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL : + dwc->current_dr_role =DWC3_GCTL_PRTCAP_DEVICE ;dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE );if (dwc->usb2_phy)otg_set_vbus (dwc->usb2_phy->otg, false); -if (dwc->usb2_generic_phy) -phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_DEVICE ); +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_DEVICE ); +phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_DEVICE ); ret =dwc3_gadget_init (dwc);if (ret) {
@@ -942,12 +931,13 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) }break ;case USB_DR_MODE_HOST : + dwc->current_dr_role =DWC3_GCTL_PRTCAP_HOST ;dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST );if (dwc->usb2_phy)otg_set_vbus (dwc->usb2_phy->otg, true); -if (dwc->usb2_generic_phy) -phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST ); +phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST ); +phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_HOST ); ret =dwc3_host_init (dwc);if (ret) {
@@ -1293,21 +1283,19 @@ static int dwc3_suspend_common(struct dwc3 *dwc) {unsigned long flags; -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : +switch (dwc->current_dr_role) { +case DWC3_GCTL_PRTCAP_DEVICE :spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_suspend (dwc);spin_unlock_irqrestore (&dwc->lock, flags); +dwc3_core_exit (dwc);break ; -case USB_DR_MODE_HOST : +case DWC3_GCTL_PRTCAP_HOST :default :/* do nothing */ break ; } -dwc3_core_exit (dwc); -return 0 ; }
@@ -1316,18 +1304,17 @@ static int dwc3_resume_common(struct dwc3 *dwc)unsigned long flags;int ret; - ret =dwc3_core_init (dwc); -if (ret) -return ret; +switch (dwc->current_dr_role) { +case DWC3_GCTL_PRTCAP_DEVICE : + ret =dwc3_core_init (dwc); +if (ret) +return ret; -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG :spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_resume (dwc);spin_unlock_irqrestore (&dwc->lock, flags); -/* FALLTHROUGH */ -case USB_DR_MODE_HOST : +break ; +case DWC3_GCTL_PRTCAP_HOST :default :/* do nothing */ break ;
@@ -1338,7 +1325,7 @@ static int dwc3_resume_common(struct dwc3 *dwc)static int dwc3_runtime_checks (struct dwc3 *dwc) { -switch (dwc->dr_mode) { +switch (dwc->current_dr_role) {case USB_DR_MODE_PERIPHERAL :case USB_DR_MODE_OTG :if (dwc->connected)
@@ -1381,19 +1368,17 @@ static int dwc3_runtime_resume(struct device *dev)if (ret)return ret; -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : +switch (dwc->current_dr_role) { +case DWC3_GCTL_PRTCAP_DEVICE :dwc3_gadget_process_pending_events (dwc);break ; -case USB_DR_MODE_HOST : +case DWC3_GCTL_PRTCAP_HOST :default :/* do nothing */ break ; }pm_runtime_mark_last_busy (dev); -pm_runtime_put (dev);return 0 ; }
@@ -1402,13 +1387,12 @@ static int dwc3_runtime_idle(struct device *dev) {struct dwc3 *dwc =dev_get_drvdata (dev); -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : +switch (dwc->current_dr_role) { +case DWC3_GCTL_PRTCAP_DEVICE :if (dwc3_runtime_checks (dwc))return -EBUSY ;break ; -case USB_DR_MODE_HOST : +case DWC3_GCTL_PRTCAP_HOST :default :/* do nothing */ break ;
drivers/usb/dwc3/core.h +3 -9
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * core.h - DesignWare USB3 DRD Core Header *
@@ -5,15 +6,6 @@* * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #ifndef __DRIVERS_USB_DWC3_CORE_H
@@ -529,6 +521,7 @@ struct dwc3_event_buffer {* @number: endpoint number (1 - 15) * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK * @resource_index: Resource transfer index +* @frame_number: set to the frame number we want this transfer to start (ISOC) * @interval: the interval on which the ISOC transfer is started * @allocated_requests: number of requests allocated * @queued_requests: number of requests queued for transfer
@@ -581,6 +574,7 @@ struct dwc3_ep {u8 resource_index;u32 allocated_requests;u32 queued_requests; +u32 frame_number;u32 interval;char name[20 ];
drivers/usb/dwc3/debug.h +1 -9
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /** * debug.h - DesignWare USB3 DRD Controller Debug Header *
@@ -5,15 +6,6 @@* * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #ifndef __DWC3_DEBUG_H
drivers/usb/dwc3/ep0.c +1 -29
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling *
@@ -5,15 +6,6 @@* * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #include <linux/kernel.h>
@@ -487,14 +479,10 @@ static int dwc3_ep0_handle_device(struct dwc3 *dwc,static int dwc3_ep0_handle_intf (struct dwc3 *dwc,struct usb_ctrlrequest *ctrl,int set) { -enum usb_device_state state;u32 wValue; -u32 wIndex;int ret =0 ; wValue =le16_to_cpu (ctrl->wValue); - wIndex =le16_to_cpu (ctrl->wIndex); - state = dwc->gadget.state;switch (wValue) {case USB_INTRF_FUNC_SUSPEND :
@@ -517,14 +505,10 @@ static int dwc3_ep0_handle_endpoint(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl, int set) {struct dwc3_ep *dep; -enum usb_device_state state;u32 wValue; -u32 wIndex;int ret; wValue =le16_to_cpu (ctrl->wValue); - wIndex =le16_to_cpu (ctrl->wIndex); - state = dwc->gadget.state;switch (wValue) {case USB_ENDPOINT_HALT :
@@ -551,10 +535,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc, {u32 recip;int ret; -enum usb_device_state state; recip = ctrl->bRequestType &USB_RECIP_MASK ; - state = dwc->gadget.state;switch (recip) {case USB_RECIP_DEVICE :
@@ -712,12 +694,10 @@ static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)struct dwc3_ep *dep;enum usb_device_state state = dwc->gadget.state;u16 wLength; -u16 wValue;if (state ==USB_STATE_DEFAULT )return -EINVAL ; - wValue =le16_to_cpu (ctrl->wValue); wLength =le16_to_cpu (ctrl->wLength);if (wLength !=6 ) {
@@ -842,9 +822,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,struct usb_request *ur;struct dwc3_trb *trb;struct dwc3_ep *ep0; -unsigned maxp; -unsigned remaining_ur_length; -void *buf;u32 transferred =0 ;u32 status;u32 length;
@@ -871,11 +848,8 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, } ur = &r->request; - buf = ur->buf; - remaining_ur_length = ur->length; length = trb->size &DWC3_TRB_SIZE_MASK ; - maxp = ep0->endpoint.maxpacket; transferred = ur->length - length; ur->actual += transferred;
@@ -1001,7 +975,6 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, }else if (IS_ALIGNED (req->request.length, dep->endpoint.maxpacket) && req->request.length && req->request.zero) {u32 maxpacket; -u32 rem; ret =usb_gadget_map_request_by_dev (dwc->sysdev, &req->request, dep->number);
@@ -1009,7 +982,6 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,return ; maxpacket = dep->endpoint.maxpacket; - rem = req->request.length % maxpacket;/* prepare normal TRB */ dwc3_ep0_prepare_one_trb(dep, req->request.dma,
drivers/usb/dwc3/gadget.c +23 -53
168 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +1 -9
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * gadget.h - DesignWare USB3 DRD Gadget Header *
@@ -5,15 +6,6 @@* * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #ifndef __DRIVERS_USB_DWC3_GADGET_H
drivers/usb/dwc3/io.h +1 -9
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /** * io.h - DesignWare USB3 DRD IO Header *
@@ -5,15 +6,6 @@* * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #ifndef __DRIVERS_USB_DWC3_IO_H
Signature · 1 line
2.53.0
Re: [PATCH v5 18/75] usb: dwc3: import from kernel v4.15
Hi Anders,
Thank you for the patch.
Quoted 36 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.14 to v4.15.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.14..v4.15
Commits imported:ec5bb87e4e2ausb: dwc3: gadget: Fix PCM1 for ISOC EP withep->multless than 3a0d8c4cfdf31usb: dwc3: of-simple: setdev_pm_opsded600ea9fb5usb: dwc3: of-simple: fix missingclk_disable_unprepare8722e095f5a4usb: dwc3: gadget: Wait longer for controller to end command processingb5ea47570b5eUSB: dwc3: Remove redundant license text5fd54ace4721USB: add SPDX identifiers to all remaining files indrivers/usb/644cbbc3ab4dusb: dwc3: core: Notify current USB mode to USB3 PHY as well8eed00b237a2usb: dwc3: pci: Runtime resume child device from wq689bf72c6e0dusb: dwc3: Don't reinitialize core during host bus-suspend/resume06c47e6286d5usb: dwc3: of-simple: Add support to get resets for the deviced6d9c2a3eac2usb: dwc3: of-simple: Re-order resource handling in remove86763723eee8usb: dwc3: ep0: Clean up unused variables7fdca766499busb: dwc3: gadget: simplify__dwc3_gadget_kick_transfer()prototype502a37b98a7busb: dwc3: gadget: cache frame number in structdwc3_ep64e010802997usb: dwc3: gadget: simplify__dwc3_gadget_ep_queue()ccb94ebf9e65usb: dwc3: gadget: check for lack of TRBs a bit earlier
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 19/75 usb: dwc3: import from kernel v4.16
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.15 to v4.16.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.15..v4.16
Commits imported:084a804e0120 usb: dwc3: Fix lock-up on ID change during system suspend/resume 98112041bcca usb: dwc3: core: Fix ULPI PHYs and prevent phy_get/ulpi_init during suspend/resume b16ea8b9492e usb: dwc3: Fix GDBGFIFOSPACE_TYPE valuesc49f63055e25 usb: dwc3: omap: don't miss events during suspend/resume c4a5153e87fd usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode 00b42170c86f usb: dwc3: Undo PHY init if soft reset failsf035d139ffec usb: dwc3: ep0: Reset TRB counter for ep0 IN6180026341e8 usb: dwc3: gadget: Set maxpacket size for ep0 INbff52352e0cc usb: dwc3: of-simple: fix oops by unbalanced clk disable call d8c80bb3b55b phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800 42bf02ec6e42 usb: dwc3: Allow disabling of metastability workaround204ec1af6257 usb: dwc3: Make sparse a bit happier19e0b203bfbd usb: dwc3: ep0: use gadget->isoch_delay for isoch_delay value 0c5d2954f690 usb: dwc3: debug: decode a few more features
--- drivers/usb/dwc3/core.c | 93 ++++++++++++++++++++++++++++----------- drivers/usb/dwc3/core.h | 26 +++++++---- drivers/usb/dwc3/debug.h | 9 ++++ drivers/usb/dwc3/ep0.c | 13 +++--- drivers/usb/dwc3/gadget.c | 8 +++- 5 files changed, 106 insertions(+), 43 deletions(-)
drivers/usb/dwc3/core.c +67 -26
@@ -100,6 +100,8 @@ static void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) reg &= ~(DWC3_GCTL_PRTCAPDIR (DWC3_GCTL_PRTCAP_OTG )); reg |=DWC3_GCTL_PRTCAPDIR (mode);dwc3_writel (dwc->regs,DWC3_GCTL , reg); + + dwc->current_dr_role = mode; }static void __dwc3_set_mode (struct work_struct *work)
@@ -133,8 +135,6 @@ static void __dwc3_set_mode(struct work_struct *work)dwc3_set_prtcap (dwc, dwc->desired_dr_role); - dwc->current_dr_role = dwc->desired_dr_role; -spin_unlock_irqrestore (&dwc->lock, flags);switch (dwc->desired_dr_role) {
@@ -147,6 +147,7 @@ static void __dwc3_set_mode(struct work_struct *work)otg_set_vbus (dwc->usb2_phy->otg, true);phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST );phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_HOST ); +phy_calibrate (dwc->usb2_generic_phy); }break ;case DWC3_GCTL_PRTCAP_DEVICE :
@@ -174,7 +175,7 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) dwc->desired_dr_role = mode;spin_unlock_irqrestore (&dwc->lock, flags); -queue_work (system_power_efficient_wq, &dwc->drd_work); +queue_work (system_freezable_wq, &dwc->drd_work); }u32 dwc3_core_fifo_space (struct dwc3_ep *dep,u8 type)
@@ -218,7 +219,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)* XHCI driver will reset the host block. If dwc3 was configured for * host-only mode, then we can return early. */ -if (dwc->dr_mode ==USB_DR_MODE_HOST ) +if (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_HOST )return 0 ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );
@@ -233,6 +234,9 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)udelay (1 ); }while (--retries); +phy_exit (dwc->usb3_generic_phy); +phy_exit (dwc->usb2_generic_phy); +return -ETIMEDOUT ; }
@@ -482,6 +486,22 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc) parms->hwparams8 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS8 ); } +static int dwc3_core_ulpi_init (struct dwc3 *dwc) +{ +int intf; +int ret =0 ; + + intf =DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3); + +if (intf ==DWC3_GHWPARAMS3_HSPHY_IFC_ULPI || + (intf ==DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI && + dwc->hsphy_interface && + !strncmp (dwc->hsphy_interface,"ulpi" ,4 ))) + ret =dwc3_ulpi_init (dwc); + +return ret; +} +/** * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -493,7 +513,6 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; -int ret; reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 ));
@@ -564,9 +583,6 @@ static int dwc3_phy_setup(struct dwc3 *dwc) }/* FALLTHROUGH */ case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : - ret =dwc3_ulpi_init (dwc); -if (ret) -return ret;/* FALLTHROUGH */ default :break ;
@@ -723,6 +739,7 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc) }static int dwc3_core_get_phy (struct dwc3 *dwc); +static int dwc3_core_ulpi_init (struct dwc3 *dwc);/** * dwc3_core_init - Low-level initialization of DWC3 Core
@@ -754,17 +771,27 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc->maximum_speed =USB_SPEED_HIGH ; } - ret =dwc3_core_get_phy (dwc); + ret =dwc3_phy_setup (dwc);if (ret) goto err0; - ret =dwc3_core_soft_reset (dwc); -if (ret) - goto err0; +if (!dwc->ulpi_ready) { + ret =dwc3_core_ulpi_init (dwc); +if (ret) + goto err0; + dwc->ulpi_ready = true; + } - ret =dwc3_phy_setup (dwc); +if (!dwc->phys_ready) { + ret =dwc3_core_get_phy (dwc); +if (ret) + goto err0a; + dwc->phys_ready = true; + } + + ret =dwc3_core_soft_reset (dwc);if (ret) - goto err0; + goto err0a;dwc3_core_setup_global_control (dwc);dwc3_core_num_eps (dwc);
@@ -837,6 +864,9 @@ err1:phy_exit (dwc->usb2_generic_phy);phy_exit (dwc->usb3_generic_phy); +err0a: +dwc3_ulpi_exit (dwc); + err0:return ret; }
@@ -915,7 +945,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)switch (dwc->dr_mode) {case USB_DR_MODE_PERIPHERAL : - dwc->current_dr_role =DWC3_GCTL_PRTCAP_DEVICE ;dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE );if (dwc->usb2_phy)
@@ -931,7 +960,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) }break ;case USB_DR_MODE_HOST : - dwc->current_dr_role =DWC3_GCTL_PRTCAP_HOST ;dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST );if (dwc->usb2_phy)
@@ -945,6 +973,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dev_err (dev,"failed to initialize host\n" );return ret; } +phy_calibrate (dwc->usb2_generic_phy);break ;case USB_DR_MODE_OTG :INIT_WORK (&dwc->drd_work, __dwc3_set_mode);
@@ -1062,6 +1091,9 @@ static void dwc3_get_properties(struct dwc3 *dwc)device_property_read_u32 (dev,"snps,quirk-frame-length-adjustment" , &dwc->fladj); + dwc->dis_metastability_quirk =device_property_read_bool (dev, +"snps,dis_metastability_quirk" ); + dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis;
@@ -1229,7 +1261,6 @@ err4: err3:dwc3_free_event_buffers (dwc); -dwc3_ulpi_exit (dwc); err2:pm_runtime_allow (&pdev->dev);
@@ -1279,7 +1310,7 @@ static int dwc3_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int dwc3_suspend_common (struct dwc3 *dwc) +static int dwc3_suspend_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags;
@@ -1291,6 +1322,10 @@ static int dwc3_suspend_common(struct dwc3 *dwc)dwc3_core_exit (dwc);break ;case DWC3_GCTL_PRTCAP_HOST : +/* do nothing during host runtime_suspend */ +if (!PMSG_IS_AUTO (msg)) +dwc3_core_exit (dwc); +break ;default :/* do nothing */ break ;
@@ -1299,7 +1334,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc)return 0 ; } -static int dwc3_resume_common (struct dwc3 *dwc) +static int dwc3_resume_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags;int ret;
@@ -1315,6 +1350,13 @@ static int dwc3_resume_common(struct dwc3 *dwc)spin_unlock_irqrestore (&dwc->lock, flags);break ;case DWC3_GCTL_PRTCAP_HOST : +/* nothing to do on host runtime_resume */ +if (!PMSG_IS_AUTO (msg)) { + ret =dwc3_core_init (dwc); +if (ret) +return ret; + } +break ;default :/* do nothing */ break ;
@@ -1326,12 +1368,11 @@ static int dwc3_resume_common(struct dwc3 *dwc)static int dwc3_runtime_checks (struct dwc3 *dwc) {switch (dwc->current_dr_role) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : +case DWC3_GCTL_PRTCAP_DEVICE :if (dwc->connected)return -EBUSY ;break ; -case USB_DR_MODE_HOST : +case DWC3_GCTL_PRTCAP_HOST :default :/* do nothing */ break ;
@@ -1348,7 +1389,7 @@ static int dwc3_runtime_suspend(struct device *dev)if (dwc3_runtime_checks (dwc))return -EBUSY ; - ret =dwc3_suspend_common (dwc); + ret =dwc3_suspend_common (dwc,PMSG_AUTO_SUSPEND );if (ret)return ret;
@@ -1364,7 +1405,7 @@ static int dwc3_runtime_resume(struct device *dev)device_init_wakeup (dev, false); - ret =dwc3_resume_common (dwc); + ret =dwc3_resume_common (dwc,PMSG_AUTO_RESUME );if (ret)return ret;
@@ -1411,7 +1452,7 @@ static int dwc3_suspend(struct device *dev)struct dwc3 *dwc =dev_get_drvdata (dev);int ret; - ret =dwc3_suspend_common (dwc); + ret =dwc3_suspend_common (dwc,PMSG_SUSPEND );if (ret)return ret;
@@ -1427,7 +1468,7 @@ static int dwc3_resume(struct device *dev)pinctrl_pm_select_default_state (dev); - ret =dwc3_resume_common (dwc); + ret =dwc3_resume_common (dwc,PMSG_RESUME );if (ret)return ret;
drivers/usb/dwc3/core.h +17 -9
@@ -158,13 +158,15 @@#define DWC3_GDBGFIFOSPACE_TYPE (n) (((n) << 5) & 0x1e0)#define DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE (n) (((n) >> 16) & 0xffff) -#define DWC3_TXFIFOQ 1 -#define DWC3_RXFIFOQ 3 -#define DWC3_TXREQQ 5 -#define DWC3_RXREQQ 7 -#define DWC3_RXINFOQ 9 -#define DWC3_DESCFETCHQ 13 -#define DWC3_EVENTQ 15 +#define DWC3_TXFIFOQ 0 +#define DWC3_RXFIFOQ 1 +#define DWC3_TXREQQ 2 +#define DWC3_RXREQQ 3 +#define DWC3_RXINFOQ 4 +#define DWC3_PSTATQ 5 +#define DWC3_DESCFETCHQ 6 +#define DWC3_EVENTQ 7 +#define DWC3_AUXEVENTQ 8/* Global RX Threshold Configuration Register */ #define DWC3_GRXTHRCFG_MAXRXBURSTSIZE (n) (((n) & 0x1f) << 19)
@@ -795,8 +797,9 @@ struct dwc3_scratchpad_array {* @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY * @usb3_generic_phy: pointer to USB3 PHY +* @phys_ready: flag to indicate that PHYs are ready * @ulpi: pointer to ulpi interface -* @isoch_delay: wValue from Set Isochronous Delay request; +* @ulpi_ready: flag to indicate that ULPI is initialized * @u2sel: parameter from Set SEL request. * @u2pel: parameter from Set SEL request. * @u1sel: parameter from Set SEL request.
@@ -857,6 +860,7 @@ struct dwc3_scratchpad_array {* 1 - -3.5dB de-emphasis * 2 - No de-emphasis * 3 - Reserved +* @dis_metastability_quirk: set to disable metastability quirk. * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. */
@@ -893,7 +897,10 @@ struct dwc3 {struct phy *usb2_generic_phy;struct phy *usb3_generic_phy; +bool phys_ready; +struct ulpi *ulpi; +bool ulpi_ready;void __iomem *regs;size_t regs_size;
@@ -955,7 +962,6 @@ struct dwc3 {enum dwc3_ep0_state ep0state;enum dwc3_link_state link_state; -u16 isoch_delay;u16 u2sel;u16 u2pel;u8 u1sel;
@@ -1010,6 +1016,8 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + unsigned dis_metastability_quirk:1; +u16 imod_interval; };
drivers/usb/dwc3/debug.h +9 -0
@@ -247,6 +247,15 @@ static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v,case USB_DEVICE_TEST_MODE : s ="Test Mode" ;break ; +case USB_DEVICE_U1_ENABLE : + s ="U1 Enable" ; +break ; +case USB_DEVICE_U2_ENABLE : + s ="U2 Enable" ; +break ; +case USB_DEVICE_LTM_ENABLE : + s ="LTM Enable" ; +break ;default : s ="UNKNOWN" ; } s; }),
drivers/usb/dwc3/ep0.c +7 -6
@@ -736,11 +736,7 @@ static int dwc3_ep0_set_isoch_delay(struct dwc3 *dwc, struct usb_ctrlrequest *ctif (wIndex || wLength)return -EINVAL ; -/* -* REVISIT It's unclear from Databook what to do with this -* value. For now, just cache it. -*/ - dwc->isoch_delay = wValue; + dwc->gadget.isoch_delay = wValue;return 0 ; }
@@ -858,7 +854,12 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, trb++; trb->ctrl &= ~DWC3_TRB_CTRL_HWO ;trace_dwc3_complete_trb (ep0, trb); - ep0->trb_enqueue =0 ; + +if (r->direction) + dwc->eps[1 ]->trb_enqueue =0 ; +else + dwc->eps[0 ]->trb_enqueue =0 ; + dwc->ep0_bounced = false; }
drivers/usb/dwc3/gadget.c +6 -2
@@ -2005,7 +2005,8 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g,* STAR#9000525659: Clock Domain Crossing on DCTL in * USB 2.0 Mode */ -if (dwc->revision <DWC3_REVISION_220A ) { +if (dwc->revision <DWC3_REVISION_220A && + !dwc->dis_metastability_quirk) { reg |=DWC3_DCFG_SUPERSPEED ; }else {switch (speed) {
@@ -2744,6 +2745,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)break ; } + dwc->eps[1 ]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket; +/* Enable USB2 LPM Capability */ if ((dwc->revision > DWC3_REVISION_194A) &&
@@ -3224,7 +3227,8 @@ int dwc3_gadget_init(struct dwc3 *dwc)* is less than super speed because we don't have means, yet, to tell * composite.c that we are USB 2.0 + LPM ECN. */ -if (dwc->revision <DWC3_REVISION_220A ) +if (dwc->revision <DWC3_REVISION_220A && + !dwc->dis_metastability_quirk)dev_info (dwc->dev,"changing max_speed on rev %08x\n" , dwc->revision);
Signature · 1 line
2.53.0
Re: [PATCH v5 19/75] usb: dwc3: import from kernel v4.16
Hi Anders,
Thank you for the patch.
Quoted 34 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.15 to v4.16.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.15..v4.16
Commits imported:084a804e0120usb: dwc3: Fix lock-up on ID change during system suspend/resume98112041bccausb: dwc3: core: Fix ULPI PHYs and prevent phy_get/ulpi_init during suspend/resumeb16ea8b9492eusb: dwc3: FixGDBGFIFOSPACE_TYPEvaluesc49f63055e25usb: dwc3: omap: don't miss events during suspend/resumec4a5153e87fdusb: dwc3: core: Power-off core/PHYs onsystem_suspendin host mode00b42170c86fusb: dwc3: Undo PHY init if soft reset failsf035d139ffecusb: dwc3: ep0: Reset TRB counter for ep0 IN6180026341e8usb: dwc3: gadget: Set maxpacket size for ep0 INbff52352e0ccusb: dwc3: of-simple: fix oops by unbalanced clk disable calld8c80bb3b55bphy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/580042bf02ec6e42usb: dwc3: Allow disabling of metastability workaround204ec1af6257usb: dwc3: Make sparse a bit happier19e0b203bfbdusb: dwc3: ep0: usegadget->isoch_delayforisoch_delayvalue0c5d2954f690usb: dwc3: debug: decode a few more features
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 20/75 usb: dwc3: import from kernel v4.17
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.16 to v4.17.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.16..v4.17
Commits imported:96bd39df29c2 usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue 9cffd15de0c3 usb: dwc3: gadget: dwc3_gadget_del_and_unmap_request() can be static c91815b59624 usb: dwc3: gadget: never call ->complete() from ->ep_queue() 7d11c3ac6669 usb: dwc3: core: Fix broken system suspend/resume on AM437x 2f3090c6a8f2 usb: dwc3: Check controller type before setting speed 80b776340c78 usb: dwc3: Dump LSP and BMU debug info938a5ad1d305 usb: dwc3: Check for ESS TX/RX threshold config6743e817a4de usb: dwc3: Add DWC_usb31 GTXTHRCFG reg fields01b0e2cc7d89 usb: dwc3: gadget: Check IP revision for GRXTHRCFG 2fbc5bdc8fd1 usb: dwc3: Add DWC_usb31 GRXTHRCFG bit fieldsd548a61767fa usb: dwc3: Check IP revision for GTXFIFOSIZ0cab8d26d6e5 usb: dwc3: Update DWC_usb31 GTXFIFOSIZ reg fields fab383333877 usb: dwc3: Add SoftReset PHY synchonization delay cabdf83dadfb usb: dwc3: pci: Properly cleanup resourcede948a74ad6f usb: dwc3: Makefile: fix link error on randconfig 7642d8386ac7 usb: dwc3: ep0: remove redundant assignment498f0478aba4 usb: dwc3: Prevent indefinite sleep in _dwc3_set_mode during suspend/resume f09cc79b4b33 usb: dwc3: add dual role support using OTG blockdaaecc6541d0 usb: dwc3: prevent setting PRTCAP to OTG from debugfs 4cff75c7fe3d usb: dwc3: core.h: add some register definitionse8284db48f1f usb: dwc3: of-simple: add support for the Amlogic Meson GXL and AXG SoCs ff0a632f0875 usb: dwc3: of-simple: add support for shared and pulsed reset lines 6d5b53c1fd5c usb: dwc3: debugfs: Re-use DEFINE_SHOW_ATTRIBUTE() macro
--- drivers/usb/dwc3/core.c | 134 +++++++++++++++++++++++++++++++--- drivers/usb/dwc3/core.h | 146 ++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/dwc3/gadget.c | 84 +++++++++++++++------- 4 files changed, 332 insertions(+), 34 deletions(-)
drivers/usb/dwc3/core.c +126 -8
@@ -89,10 +89,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)return 0 ; } -static void dwc3_event_buffers_cleanup (struct dwc3 *dwc); -static int dwc3_event_buffers_setup (struct dwc3 *dwc); - -static void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode) +void dwc3_set_prtcap (struct dwc3 *dwc,u32 mode) {u32 reg;
@@ -110,13 +107,19 @@ static void __dwc3_set_mode(struct work_struct *work)unsigned long flags;int ret; +if (dwc->dr_mode !=USB_DR_MODE_OTG ) +return ; + +if (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_OTG ) +dwc3_otg_update (dwc,0 ); +if (!dwc->desired_dr_role)return ;if (dwc->desired_dr_role == dwc->current_dr_role)return ; -if (dwc->dr_mode !=USB_DR_MODE_OTG ) +if (dwc->desired_dr_role ==DWC3_GCTL_PRTCAP_OTG && dwc->edev)return ;switch (dwc->current_dr_role) {
@@ -127,6 +130,13 @@ static void __dwc3_set_mode(struct work_struct *work)dwc3_gadget_exit (dwc);dwc3_event_buffers_cleanup (dwc);break ; +case DWC3_GCTL_PRTCAP_OTG : +dwc3_otg_exit (dwc); +spin_lock_irqsave (&dwc->lock, flags); + dwc->desired_otg_role =DWC3_OTG_ROLE_IDLE ; +spin_unlock_irqrestore (&dwc->lock, flags); +dwc3_otg_update (dwc,1 ); +break ;default :break ; }
@@ -162,9 +172,14 @@ static void __dwc3_set_mode(struct work_struct *work)if (ret)dev_err (dwc->dev,"failed to initialize peripheral\n" );break ; +case DWC3_GCTL_PRTCAP_OTG : +dwc3_otg_init (dwc); +dwc3_otg_update (dwc,0 ); +break ;default :break ; } + }void dwc3_set_mode (struct dwc3 *dwc,u32 mode)
@@ -229,7 +244,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)do { reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (!(reg &DWC3_DCTL_CSFTRST )) -return 0 ; + goto done;udelay (1 ); }while (--retries);
@@ -238,6 +253,17 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)phy_exit (dwc->usb2_generic_phy);return -ETIMEDOUT ; + +done: +/* +* For DWC_usb31 controller, once DWC3_DCTL_CSFTRST bit is cleared, +* we must wait at least 50ms before accessing the PHY domain +* (synchronization delay). DWC_usb31 programming guide section 1.3.2. +*/ +if (dwc3_is_usb31 (dwc)) +msleep (50 ); + +return 0 ; }/*
@@ -348,7 +374,7 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)* * Returns 0 on success otherwise negative errno. */ -static int dwc3_event_buffers_setup (struct dwc3 *dwc) +int dwc3_event_buffers_setup (struct dwc3 *dwc) {struct dwc3_event_buffer *evt;
@@ -365,7 +391,7 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc)return 0 ; } -static void dwc3_event_buffers_cleanup (struct dwc3 *dwc) +void dwc3_event_buffers_cleanup (struct dwc3 *dwc) {struct dwc3_event_buffer *evt;
@@ -846,6 +872,43 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); } +/* +* Must config both number of packets and max burst settings to enable +* RX and/or TX threshold. +*/ +if (dwc3_is_usb31 (dwc) && dwc->dr_mode ==USB_DR_MODE_HOST ) { +u8 rx_thr_num = dwc->rx_thr_num_pkt_prd; +u8 rx_maxburst = dwc->rx_max_burst_prd; +u8 tx_thr_num = dwc->tx_thr_num_pkt_prd; +u8 tx_maxburst = dwc->tx_max_burst_prd; + +if (rx_thr_num && rx_maxburst) { + reg =dwc3_readl (dwc->regs,DWC3_GRXTHRCFG ); + reg |=DWC31_RXTHRNUMPKTSEL_PRD ; + + reg &= ~DWC31_RXTHRNUMPKT_PRD (~0 ); + reg |=DWC31_RXTHRNUMPKT_PRD (rx_thr_num); + + reg &= ~DWC31_MAXRXBURSTSIZE_PRD (~0 ); + reg |=DWC31_MAXRXBURSTSIZE_PRD (rx_maxburst); + +dwc3_writel (dwc->regs,DWC3_GRXTHRCFG , reg); + } + +if (tx_thr_num && tx_maxburst) { + reg =dwc3_readl (dwc->regs,DWC3_GTXTHRCFG ); + reg |=DWC31_TXTHRNUMPKTSEL_PRD ; + + reg &= ~DWC31_TXTHRNUMPKT_PRD (~0 ); + reg |=DWC31_TXTHRNUMPKT_PRD (tx_thr_num); + + reg &= ~DWC31_MAXTXBURSTSIZE_PRD (~0 ); + reg |=DWC31_MAXTXBURSTSIZE_PRD (tx_maxburst); + +dwc3_writel (dwc->regs,DWC3_GTXTHRCFG , reg); + } + } +return 0 ; err4:
@@ -1016,6 +1079,10 @@ static void dwc3_get_properties(struct dwc3 *dwc)u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold; +u8 rx_thr_num_pkt_prd; +u8 rx_max_burst_prd; +u8 tx_thr_num_pkt_prd; +u8 tx_max_burst_prd;/* default to highest possible threshold */ lpm_nyet_threshold =0xff ;
@@ -1050,6 +1117,14 @@ static void dwc3_get_properties(struct dwc3 *dwc) &hird_threshold); dwc->usb3_lpm_capable =device_property_read_bool (dev,"snps,usb3_lpm_capable" ); +device_property_read_u8 (dev,"snps,rx-thr-num-pkt-prd" , + &rx_thr_num_pkt_prd); +device_property_read_u8 (dev,"snps,rx-max-burst-prd" , + &rx_max_burst_prd); +device_property_read_u8 (dev,"snps,tx-thr-num-pkt-prd" , + &tx_thr_num_pkt_prd); +device_property_read_u8 (dev,"snps,tx-max-burst-prd" , + &tx_max_burst_prd); dwc->disable_scramble_quirk =device_property_read_bool (dev,"snps,disable_scramble_quirk" );
@@ -1100,6 +1175,12 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); + dwc->rx_thr_num_pkt_prd = rx_thr_num_pkt_prd; + dwc->rx_max_burst_prd = rx_max_burst_prd; + + dwc->tx_thr_num_pkt_prd = tx_thr_num_pkt_prd; + dwc->tx_max_burst_prd = tx_max_burst_prd; + dwc->imod_interval =0 ; }
@@ -1326,6 +1407,20 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)if (!PMSG_IS_AUTO (msg))dwc3_core_exit (dwc);break ; +case DWC3_GCTL_PRTCAP_OTG : +/* do nothing during runtime_suspend */ +if (PMSG_IS_AUTO (msg)) +break ; + +if (dwc->current_otg_role ==DWC3_OTG_ROLE_DEVICE ) { +spin_lock_irqsave (&dwc->lock, flags); +dwc3_gadget_suspend (dwc); +spin_unlock_irqrestore (&dwc->lock, flags); + } + +dwc3_otg_exit (dwc); +dwc3_core_exit (dwc); +break ;default :/* do nothing */ break ;
@@ -1345,6 +1440,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)if (ret)return ret; +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE );spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_resume (dwc);spin_unlock_irqrestore (&dwc->lock, flags);
@@ -1355,7 +1451,29 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) ret =dwc3_core_init (dwc);if (ret)return ret; +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST ); + } +break ; +case DWC3_GCTL_PRTCAP_OTG : +/* nothing to do on runtime_resume */ +if (PMSG_IS_AUTO (msg)) +break ; + + ret =dwc3_core_init (dwc); +if (ret) +return ret; + +dwc3_set_prtcap (dwc, dwc->current_dr_role); + +dwc3_otg_init (dwc); +if (dwc->current_otg_role ==DWC3_OTG_ROLE_HOST ) { +dwc3_otg_host_init (dwc); + }else if (dwc->current_otg_role ==DWC3_OTG_ROLE_DEVICE ) { +spin_lock_irqsave (&dwc->lock, flags); +dwc3_gadget_resume (dwc); +spin_unlock_irqrestore (&dwc->lock, flags); } +break ;default :/* do nothing */
drivers/usb/dwc3/core.h +146 -0
235 lines not on this page · raw message
drivers/usb/dwc3/ep0.c +1 -1
@@ -814,7 +814,7 @@ out:static void dwc3_ep0_complete_data (struct dwc3 *dwc,const struct dwc3_event_depevt *event) { -struct dwc3_request *r =NULL ; +struct dwc3_request *r;struct usb_request *ur;struct dwc3_trb *trb;struct dwc3_ep *ep0;
drivers/usb/dwc3/gadget.c +59 -25
151 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 20/75] usb: dwc3: import from kernel v4.17
Hi Anders,
Thank you for the patch.
Quoted 43 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.16 to v4.17.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.16..v4.17
Commits imported:96bd39df29c2usb: dwc3: gadget: Fixlist_delcorruption indwc3_ep_dequeue9cffd15de0c3usb: dwc3: gadget:dwc3_gadget_del_and_unmap_request()can be staticc91815b59624usb: dwc3: gadget: never call ->complete() from ->ep_queue()7d11c3ac6669usb: dwc3: core: Fix broken system suspend/resume on AM437x2f3090c6a8f2usb: dwc3: Check controller type before setting speed80b776340c78usb: dwc3: Dump LSP and BMU debug info938a5ad1d305usb: dwc3: Check for ESS TX/RX threshold config6743e817a4deusb: dwc3: AddDWC_usb31GTXTHRCFG reg fields01b0e2cc7d89usb: dwc3: gadget: Check IP revision for GRXTHRCFG2fbc5bdc8fd1usb: dwc3: AddDWC_usb31GRXTHRCFG bit fieldsd548a61767fausb: dwc3: Check IP revision for GTXFIFOSIZ0cab8d26d6e5usb: dwc3: UpdateDWC_usb31GTXFIFOSIZ reg fieldsfab383333877usb: dwc3: Add SoftReset PHY synchonization delaycabdf83dadfbusb: dwc3: pci: Properly cleanup resourcede948a74ad6fusb: dwc3:Makefile: fix link error on randconfig7642d8386ac7usb: dwc3: ep0: remove redundant assignment498f0478aba4usb: dwc3: Prevent indefinite sleep in_dwc3_set_modeduring suspend/resumef09cc79b4b33usb: dwc3: add dual role support using OTG blockdaaecc6541d0usb: dwc3: prevent setting PRTCAP to OTG from debugfs4cff75c7fe3dusb: dwc3:core.h: add some register definitionse8284db48f1fusb: dwc3: of-simple: add support for the Amlogic Meson GXL and AXG SoCsff0a632f0875usb: dwc3: of-simple: add support for shared and pulsed reset lines6d5b53c1fd5cusb: dwc3: debugfs: Re-useDEFINE_SHOW_ATTRIBUTE()macro
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 21/75 usb: dwc3: import from kernel v4.18
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.17 to v4.18.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.17..v4.18
Commits imported:9566a7c72f4f usb: dwc3: gadget: remove redundant variable maxpacket 9925e6ebe5c2 usb: dwc3: qcom: mark PM functions as __maybe_unused 93ef2dc0c4f7 usb: dwc3: Fix error return code in dwc3_qcom_probe() 615277779f41 usb: dwc3: Only call clk_bulk_get() on devicetree instantiated devices 896e518883f1 usb: dwc3: of-simple: fix use-after-free on remove 00908693c481 usb: dwc3: pci: add support for Intel IceLake 535c8dc5c480 USB: dwc3: no need to check return value of debugfs_create functions 3bea1cfcff11 usb: dwc3: Remove DEBUG define from Qualcomm DWC3 glue driver 05645366f389 usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue 691025107eb7 usb: dwc3: gadget: dwc3_gadget_del_and_unmap_request() can be static edbbfe19444e usb: dwc3: dwc3_get_extcon() can be static31a2f5a7e136 usb: dwc3: gadget: init req->{direction,epnum} from alloc_request() d7ca7e1896b2 usb: dwc3: gadget: initialize transfer index from send_gadget_ep_cmd() 4439661d64f5 usb: dwc3: gadget: assign resource_index inside get_transfer_index() f62afb4929a8 usb: dwc3: gadget: always start isochronous aligned to dep->interval d513320f1fd0 usb: dwc3: gadget: don't issue End Transfer if we have started reqs e1d542f712e1 usb: dwc3: debug: decode uFrame from event too 42626919efab usb: dwc3: gadget: move dwc3_calc_trbs_left() in place of prototype 20d1d43fa09a usb: dwc3: gadget: move set_xfer_resource() in place of prototype b07c2db83f92 usb: dwc3: gadget: remove a few more dwc arguments a2d23f08038e usb: dwc3: gadget: combine modify & restore into single argument 8f1c99cd24b0 usb: dwc3: gadget: refactor dwc3_gadget_init_endpoints() f38e35dd84e2 usb: dwc3: gadget: split dwc3_gadget_ep_cleanup_completed_requests() 6d9d22dac114 usb: dwc3: gadget: get rid of the length variable fee73e6144d8 usb: dwc3: gadget: reduce scope of ret variable 6afbdb57732b usb: dwc3: gadget: one declaration per linee0c42ce590fe usb: dwc3: gadget: simplify IOC handlingd80fe1b6e34d usb: dwc3: gadget: simplify short packet event b27972b508d1 usb: dwc3: trace: print out event status too8b3b7b66c0e6 usb: dwc3: gadget: simplify unaligned and zlp handling cf35fc336e66 usb: dwc3: gadget: remove unnecessary 'chain' variable 021595963a3c usb: dwc3: gadget: remove PENDING handling from cleanup_completed d36929538f8b usb: dwc3: gadget: split scatterlist and linear handlers d5044a04b529 usb: dwc3: gadget: simplify isoc case on cleanup_completed_requests fe990cea8ed5 usb: dwc3: gadget: simplify queueing of isoc transfers 4d588a145b3e usb: dwc3: gadget: remove duplicated missed isoc handling 6d8a019614f3 usb: dwc3: gadget: check for Missed Isoc from event status 58f0218a271d usb: dwc3: gadget: remove unnecessary 'ioc' variable 12a3a4ada816 usb: dwc3: gadget: make cleanup_completed_requests() return nothing 5f2e7975f0df usb: dwc3: gadget: remove DWC3_EP_BUSY flag1912cbc60f44 usb: dwc3: gadget: start removing BUSY flagee3638b897b9 usb: dwc3: gadget: update dep->frame_number from XferInprogress too 5828cada9908 usb: dwc3: gadget: always use frame number from XferNotReady 8f608e8ab628 usb: dwc3: gadget: remove unnecessary 'dwc' parameter 320338651d33 usb: dwc3: gadget: move handler closer to calling site ed27442e5093 usb: dwc3: gadget: rename dwc3_gadget_start_isoc() a24a6ab1493a usb: dwc3: gadget: remove some pointless checks 0bd0f6d201eb usb: dwc3: gadget: remove allocated/queued request tracking 66f5dd5a0379 usb: dwc3: gadget: rename done_trbs and done_reqs a861282f5037 usb: dwc3: gadget: don't kick transfer all the time fbea935accf4 usb: dwc3: gadget: rename dwc3_endpoint_transfer_complete() 742a4fff5f29 usb: dwc3: gadget: XferComplete only for EP038408464aa76 usb: dwc3: gadget: XferNotReady is Isoc-only52fcc0bead0f usb: dwc3: gadget: pre-issue Start Transfer for Interrupt EPs too c96e6725db9d usb: dwc3: gadget: Correct the logic for queuing sgs a31e63b608ff usb: dwc3: gadget: Correct handling of scattergather lists 5f0b74e54890 USB: dwc3: get extcon device by OF graph bindings fe8abf332b8f usb: dwc3: support clocks and resets for DWC3 core 44feb8e6ea2d usb: dwc3: use local copy of resource to fix-up register offset bcb128777af5 usb: dwc3: core: Suspend PHYs on runtime suspend in host mode a4333c3a6ba9 usb: dwc3: Add Qualcomm DWC3 glue drivere362098f0e12 usb: dwc3: of-simple: Add compatible for Allwinner H6 platform
--- drivers/usb/dwc3/core.c | 157 ++++++-- drivers/usb/dwc3/core.h | 25 +- drivers/usb/dwc3/debug.h | 26 +- drivers/usb/dwc3/ep0.c | 9 +- drivers/usb/dwc3/gadget.c | 773 ++++++++++++++++++-------------------- drivers/usb/dwc3/gadget.h | 5 +- 6 files changed, 531 insertions(+), 464 deletions(-)
drivers/usb/dwc3/core.c +129 -28
@@ -8,6 +8,7 @@* Sebastian Andrzej Siewior <[email protected]> */ +#include <linux/clk.h> #include <linux/version.h> #include <linux/module.h> #include <linux/kernel.h>
@@ -24,6 +25,7 @@#include <linux/of.h> #include <linux/acpi.h> #include <linux/pinctrl/consumer.h> +#include <linux/reset.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
@@ -266,6 +268,12 @@ done:return 0 ; } +static const struct clk_bulk_data dwc3_core_clks[] = { + { .id ="ref" }, + { .id ="bus_early" }, + { .id ="suspend" }, +}; +/* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure
@@ -667,6 +675,9 @@ static void dwc3_core_exit(struct dwc3 *dwc)usb_phy_set_suspend (dwc->usb3_phy,1 );phy_power_off (dwc->usb2_generic_phy);phy_power_off (dwc->usb3_generic_phy); +clk_bulk_disable (dwc->num_clks, dwc->clks); +clk_bulk_unprepare (dwc->num_clks, dwc->clks); +reset_control_assert (dwc->reset); }static bool dwc3_core_is_valid (struct dwc3 *dwc)
@@ -1245,7 +1256,7 @@ static void dwc3_check_params(struct dwc3 *dwc)static int dwc3_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct resource *res; +struct resource *res, dwc_res;struct dwc3 *dwc;int ret;
@@ -1256,6 +1267,11 @@ static int dwc3_probe(struct platform_device *pdev)if (!dwc)return -ENOMEM ; + dwc->clks =devm_kmemdup (dev, dwc3_core_clks,sizeof (dwc3_core_clks), +GFP_KERNEL ); +if (!dwc->clks) +return -ENOMEM ; + dwc->dev = dev; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -1270,23 +1286,52 @@ static int dwc3_probe(struct platform_device *pdev) dwc->xhci_resources[0 ].flags = res->flags; dwc->xhci_resources[0 ].name = res->name; - res->start +=DWC3_GLOBALS_REGS_START ; -/* * Request memory region but exclude xHCI regs, * since it will be requested by the xhci-plat driver. */ - regs =devm_ioremap_resource (dev, res); -if (IS_ERR (regs)) { - ret =PTR_ERR (regs); - goto err0; - } + dwc_res = *res; + dwc_res.start +=DWC3_GLOBALS_REGS_START ; + + regs =devm_ioremap_resource (dev, &dwc_res); +if (IS_ERR (regs)) +return PTR_ERR (regs); dwc->regs = regs; - dwc->regs_size =resource_size (res); + dwc->regs_size =resource_size (&dwc_res);dwc3_get_properties (dwc); + dwc->reset =devm_reset_control_get_optional_shared (dev,NULL ); +if (IS_ERR (dwc->reset)) +return PTR_ERR (dwc->reset); + +if (dev->of_node) { + dwc->num_clks =ARRAY_SIZE (dwc3_core_clks); + + ret =clk_bulk_get (dev, dwc->num_clks, dwc->clks); +if (ret == -EPROBE_DEFER ) +return ret; +/* +* Clocks are optional, but new DT platforms should support all +* clocks as required by the DT-binding. +*/ +if (ret) + dwc->num_clks =0 ; + } + + ret =reset_control_deassert (dwc->reset); +if (ret) + goto put_clks; + + ret =clk_bulk_prepare (dwc->num_clks, dwc->clks); +if (ret) + goto assert_reset; + + ret =clk_bulk_enable (dwc->num_clks, dwc->clks); +if (ret) + goto unprepare_clks; +platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc);
@@ -1350,13 +1395,13 @@ err1:pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); -err0: -/* -* restore res->start back to its original value so that, in case the -* probe is deferred, we don't end up getting error in request the -* memory region the next time probe is called. -*/ - res->start -=DWC3_GLOBALS_REGS_START ; +clk_bulk_disable (dwc->num_clks, dwc->clks); +unprepare_clks: +clk_bulk_unprepare (dwc->num_clks, dwc->clks); +assert_reset: +reset_control_assert (dwc->reset); +put_clks: +clk_bulk_put (dwc->num_clks, dwc->clks);return ret; }
@@ -1364,15 +1409,8 @@ err0:static int dwc3_remove (struct platform_device *pdev) {struct dwc3 *dwc =platform_get_drvdata (pdev); -struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );pm_runtime_get_sync (&pdev->dev); -/* -* restore res->start back to its original value so that, in case the -* probe is deferred, we don't end up getting error in request the -* memory region the next time probe is called. -*/ - res->start -=DWC3_GLOBALS_REGS_START ;dwc3_debugfs_exit (dwc);dwc3_core_exit_mode (dwc);
@@ -1386,14 +1424,48 @@ static int dwc3_remove(struct platform_device *pdev)dwc3_free_event_buffers (dwc);dwc3_free_scratch_buffers (dwc); +clk_bulk_put (dwc->num_clks, dwc->clks);return 0 ; }#ifdef CONFIG_PM +static int dwc3_core_init_for_resume (struct dwc3 *dwc) +{ +int ret; + + ret =reset_control_deassert (dwc->reset); +if (ret) +return ret; + + ret =clk_bulk_prepare (dwc->num_clks, dwc->clks); +if (ret) + goto assert_reset; + + ret =clk_bulk_enable (dwc->num_clks, dwc->clks); +if (ret) + goto unprepare_clks; + + ret =dwc3_core_init (dwc); +if (ret) + goto disable_clks; + +return 0 ; + +disable_clks: +clk_bulk_disable (dwc->num_clks, dwc->clks); +unprepare_clks: +clk_bulk_unprepare (dwc->num_clks, dwc->clks); +assert_reset: +reset_control_assert (dwc->reset); + +return ret; +} +static int dwc3_suspend_common (struct dwc3 *dwc,pm_message_t msg) {unsigned long flags; +u32 reg;switch (dwc->current_dr_role) {case DWC3_GCTL_PRTCAP_DEVICE :
@@ -1403,9 +1475,25 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)dwc3_core_exit (dwc);break ;case DWC3_GCTL_PRTCAP_HOST : -/* do nothing during host runtime_suspend */ -if (!PMSG_IS_AUTO (msg)) +if (!PMSG_IS_AUTO (msg)) {dwc3_core_exit (dwc); +break ; + } + +/* Let controller to suspend HSPHY before PHY driver suspends */ +if (dwc->dis_u2_susphy_quirk || + dwc->dis_enblslpm_quirk) { + reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); + reg |=DWC3_GUSB2PHYCFG_ENBLSLPM | +DWC3_GUSB2PHYCFG_SUSPHY ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); + +/* Give some time for USB2 PHY to suspend */ +usleep_range (5000 ,6000 ); + } + +phy_pm_runtime_put_sync (dwc->usb2_generic_phy); +phy_pm_runtime_put_sync (dwc->usb3_generic_phy);break ;case DWC3_GCTL_PRTCAP_OTG :/* do nothing during runtime_suspend */
@@ -1433,10 +1521,11 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) {unsigned long flags;int ret; +u32 reg;switch (dwc->current_dr_role) {case DWC3_GCTL_PRTCAP_DEVICE : - ret =dwc3_core_init (dwc); + ret =dwc3_core_init_for_resume (dwc);if (ret)return ret;
@@ -1446,13 +1535,25 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)spin_unlock_irqrestore (&dwc->lock, flags);break ;case DWC3_GCTL_PRTCAP_HOST : -/* nothing to do on host runtime_resume */ if (!PMSG_IS_AUTO (msg)) { - ret =dwc3_core_init (dwc); + ret =dwc3_core_init_for_resume (dwc);if (ret)return ret;dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST ); +break ; } +/* Restore GUSB2PHYCFG bits that were modified in suspend */ + reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); +if (dwc->dis_u2_susphy_quirk) + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ; + +if (dwc->dis_enblslpm_quirk) + reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; + +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); + +phy_pm_runtime_get_sync (dwc->usb2_generic_phy); +phy_pm_runtime_get_sync (dwc->usb3_generic_phy);break ;case DWC3_GCTL_PRTCAP_OTG :/* nothing to do on runtime_resume */
drivers/usb/dwc3/core.h +16 -9
@@ -639,8 +639,6 @@ struct dwc3_event_buffer {* @resource_index: Resource transfer index * @frame_number: set to the frame number we want this transfer to start (ISOC) * @interval: the interval on which the ISOC transfer is started -* @allocated_requests: number of requests allocated -* @queued_requests: number of requests queued for transfer * @name: a human readable name e.g. ep1out-bulk * @direction: true for TX, false for RX * @stream_capable: true when streams are enabled
@@ -664,11 +662,9 @@ struct dwc3_ep {#define DWC3_EP_ENABLED BIT(0)#define DWC3_EP_STALL BIT(1)#define DWC3_EP_WEDGE BIT(2) -#define DWC3_EP_BUSY BIT(4) +#define DWC3_EP_TRANSFER_STARTED BIT(3)#define DWC3_EP_PENDING_REQUEST BIT(5) -#define DWC3_EP_MISSED_ISOC BIT(6)#define DWC3_EP_END_TRANSFER_PENDING BIT(7) -#define DWC3_EP_TRANSFER_STARTED BIT(8)/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31)
@@ -688,8 +684,6 @@ struct dwc3_ep {u8 number;u8 type;u8 resource_index; -u32 allocated_requests; -u32 queued_requests;u32 frame_number;u32 interval;
@@ -832,7 +826,9 @@ struct dwc3_hwparams {* @list: a list_head used for request queueing * @dep: struct dwc3_ep owning this request * @sg: pointer to first incomplete sg +* @start_sg: pointer to the sg which should be queued next * @num_pending_sgs: counter to pending sgs +* @num_queued_sgs: counter to the number of sgs which already got queued * @remaining: amount of data remaining * @epnum: endpoint number to which this request refers * @trb: pointer to struct dwc3_trb
@@ -848,8 +844,10 @@ struct dwc3_request {struct list_head list;struct dwc3_ep *dep;struct scatterlist *sg; +struct scatterlist *start_sg;unsigned num_pending_sgs; +unsigned int num_queued_sgs;unsigned remaining;u8 epnum;struct dwc3_trb *trb;
@@ -891,6 +889,9 @@ struct dwc3_scratchpad_array {* @eps: endpoint array * @gadget: device side representation of the peripheral controller * @gadget_driver: pointer to the gadget driver +* @clks: array of clocks +* @num_clks: number of clocks +* @reset: reset control * @regs: base address for our registers * @regs_size: address space size * @fladj: frame length adjustment
@@ -1013,6 +1014,11 @@ struct dwc3 {struct usb_gadget gadget;struct usb_gadget_driver *gadget_driver; +struct clk_bulk_data *clks; +int num_clks; + +struct reset_control *reset; +struct usb_phy *usb2_phy;struct usb_phy *usb3_phy;
@@ -1197,11 +1203,12 @@ struct dwc3_event_depevt {/* Within XferNotReady */ #define DEPEVT_STATUS_TRANSFER_ACTIVE BIT(3) -/* Within XferComplete */ +/* Within XferComplete or XferInProgress */ #define DEPEVT_STATUS_BUSERR BIT(0)#define DEPEVT_STATUS_SHORT BIT(1)#define DEPEVT_STATUS_IOC BIT(2) -#define DEPEVT_STATUS_LST BIT(3) +#define DEPEVT_STATUS_LST BIT(3)/* XferComplete */ +#define DEPEVT_STATUS_MISSED_ISOC BIT(3)/* XferInProgress */ /* Stream event only */ #define DEPEVT_STREAMEVT_FOUND 1
drivers/usb/dwc3/debug.h +21 -5
@@ -475,21 +475,37 @@ dwc3_ep_event_string(char *str, const struct dwc3_event_depevt *event,if (ret <0 )return "UNKNOWN" ; + status = event->status; +switch (event->endpoint_event) {case DWC3_DEPEVT_XFERCOMPLETE : -strcat (str,"Transfer Complete" ); + len =strlen (str); +sprintf (str + len,"Transfer Complete (%c%c%c)" , + status &DEPEVT_STATUS_SHORT ?'S' :'s' , + status &DEPEVT_STATUS_IOC ?'I' :'i' , + status &DEPEVT_STATUS_LST ?'L' :'l' ); + len =strlen (str);if (epnum <=1 )sprintf (str + len," [%s]" ,dwc3_ep0_state_string (ep0state));break ;case DWC3_DEPEVT_XFERINPROGRESS : -strcat (str,"Transfer In-Progress" ); + len =strlen (str); + +sprintf (str + len,"Transfer In Progress [%d] (%c%c%c)" , + event->parameters, + status &DEPEVT_STATUS_SHORT ?'S' :'s' , + status &DEPEVT_STATUS_IOC ?'I' :'i' , + status &DEPEVT_STATUS_LST ?'M' :'m' );break ;case DWC3_DEPEVT_XFERNOTREADY : -strcat (str,"Transfer Not Ready" ); - status = event->status &DEPEVT_STATUS_TRANSFER_ACTIVE ; -strcat (str, status ?" (Active)" :" (Not Active)" ); + len =strlen (str); + +sprintf (str + len,"Transfer Not Ready [%d]%s" , + event->parameters, + status &DEPEVT_STATUS_TRANSFER_ACTIVE ? +" (Active)" :" (Not Active)" );/* Control Endpoints */ if (epnum <=1 ) {
drivers/usb/dwc3/ep0.c +2 -7
@@ -66,7 +66,7 @@ static int dwc3_ep0_start_trans(struct dwc3_ep *dep)struct dwc3 *dwc;int ret; -if (dep->flags &DWC3_EP_BUSY ) +if (dep->flags &DWC3_EP_TRANSFER_STARTED )return 0 ; dwc = dep->dwc;
@@ -79,8 +79,6 @@ static int dwc3_ep0_start_trans(struct dwc3_ep *dep)if (ret <0 )return ret; - dep->flags |=DWC3_EP_BUSY ; - dep->resource_index =dwc3_gadget_ep_get_transfer_index (dep); dwc->ep0_next_event =DWC3_EP0_COMPLETE ;return 0 ;
@@ -913,7 +911,7 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, {struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; - dep->flags &= ~DWC3_EP_BUSY ; + dep->flags &= ~DWC3_EP_TRANSFER_STARTED ; dep->resource_index =0 ; dwc->setup_packet_pending = false;
@@ -975,15 +973,12 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ret =dwc3_ep0_start_trans (dep); }else if (IS_ALIGNED (req->request.length, dep->endpoint.maxpacket) && req->request.length && req->request.zero) { -u32 maxpacket; ret =usb_gadget_map_request_by_dev (dwc->sysdev, &req->request, dep->number);if (ret)return ; - maxpacket = dep->endpoint.maxpacket; -/* prepare normal TRB */ dwc3_ep0_prepare_one_trb(dep, req->request.dma, req->request.length,
drivers/usb/dwc3/gadget.c +361 -412
1,144 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +2 -3
@@ -98,13 +98,12 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol);* Caller should take care of locking. Returns the transfer resource * index for a given endpoint. */ -static inline u32 dwc3_gadget_ep_get_transfer_index (struct dwc3_ep *dep) +static inline void dwc3_gadget_ep_get_transfer_index (struct dwc3_ep *dep) {u32 res_id; res_id =dwc3_readl (dep->regs,DWC3_DEPCMD ); - -return DWC3_DEPCMD_GET_RSC_IDX (res_id); + dep->resource_index =DWC3_DEPCMD_GET_RSC_IDX (res_id); }#endif /* __DRIVERS_USB_DWC3_GADGET_H */
Signature · 1 line
2.53.0
Re: [PATCH v5 21/75] usb: dwc3: import from kernel v4.18
Hi Anders,
Thank you for the patch.
Quoted 82 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.17 to v4.18.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.17..v4.18
Commits imported:9566a7c72f4fusb: dwc3: gadget: remove redundant variable maxpacket9925e6ebe5c2usb: dwc3: qcom: mark PM functions as__maybe_unused93ef2dc0c4f7usb: dwc3: Fix error return code indwc3_qcom_probe()615277779f41usb: dwc3: Only callclk_bulk_get()on devicetree instantiated devices896e518883f1usb: dwc3: of-simple: fix use-after-free on remove00908693c481usb: dwc3: pci: add support for Intel IceLake535c8dc5c480USB: dwc3: no need to check return value ofdebugfs_createfunctions3bea1cfcff11usb: dwc3: Remove DEBUG define from Qualcomm DWC3 glue driver05645366f389usb: dwc3: gadget: Fixlist_delcorruption indwc3_ep_dequeue691025107eb7usb: dwc3: gadget:dwc3_gadget_del_and_unmap_request()can be staticedbbfe19444eusb: dwc3:dwc3_get_extcon()can be static31a2f5a7e136usb: dwc3: gadget: init req->{direction,epnum} fromalloc_request()d7ca7e1896b2usb: dwc3: gadget: initialize transfer index fromsend_gadget_ep_cmd()4439661d64f5usb: dwc3: gadget: assignresource_indexinsideget_transfer_index()f62afb4929a8usb: dwc3: gadget: always start isochronous aligned todep->intervald513320f1fd0usb: dwc3: gadget: don't issue End Transfer if we have started reqse1d542f712e1usb: dwc3: debug: decode uFrame from event too42626919efabusb: dwc3: gadget: movedwc3_calc_trbs_left()in place of prototype20d1d43fa09ausb: dwc3: gadget: moveset_xfer_resource()in place of prototypeb07c2db83f92usb: dwc3: gadget: remove a few more dwc argumentsa2d23f08038eusb: dwc3: gadget: combine modify & restore into single argument8f1c99cd24b0usb: dwc3: gadget: refactordwc3_gadget_init_endpoints()f38e35dd84e2usb: dwc3: gadget: splitdwc3_gadget_ep_cleanup_completed_requests()6d9d22dac114usb: dwc3: gadget: get rid of the length variablefee73e6144d8usb: dwc3: gadget: reduce scope of ret variable6afbdb57732busb: dwc3: gadget: one declaration per linee0c42ce590feusb: dwc3: gadget: simplify IOC handlingd80fe1b6e34dusb: dwc3: gadget: simplify short packet eventb27972b508d1usb: dwc3: trace: print out event status too8b3b7b66c0e6usb: dwc3: gadget: simplify unaligned and zlp handlingcf35fc336e66usb: dwc3: gadget: remove unnecessary 'chain' variable021595963a3cusb: dwc3: gadget: remove PENDING handling fromcleanup_completedd36929538f8busb: dwc3: gadget: split scatterlist and linear handlersd5044a04b529usb: dwc3: gadget: simplify isoc case oncleanup_completed_requestsfe990cea8ed5usb: dwc3: gadget: simplify queueing of isoc transfers4d588a145b3eusb: dwc3: gadget: remove duplicated missed isoc handling6d8a019614f3usb: dwc3: gadget: check for Missed Isoc from event status58f0218a271dusb: dwc3: gadget: remove unnecessary 'ioc' variable12a3a4ada816usb: dwc3: gadget: makecleanup_completed_requests()return nothing5f2e7975f0dfusb: dwc3: gadget: removeDWC3_EP_BUSYflag1912cbc60f44usb: dwc3: gadget: start removing BUSY flagee3638b897b9usb: dwc3: gadget: updatedep->frame_numberfrom XferInprogress too5828cada9908usb: dwc3: gadget: always use frame number from XferNotReady8f608e8ab628usb: dwc3: gadget: remove unnecessary 'dwc' parameter320338651d33usb: dwc3: gadget: move handler closer to calling siteed27442e5093usb: dwc3: gadget: renamedwc3_gadget_start_isoc()a24a6ab1493ausb: dwc3: gadget: remove some pointless checks0bd0f6d201ebusb: dwc3: gadget: remove allocated/queued request tracking66f5dd5a0379usb: dwc3: gadget: renamedone_trbsanddone_reqsa861282f5037usb: dwc3: gadget: don't kick transfer all the timefbea935accf4usb: dwc3: gadget: renamedwc3_endpoint_transfer_complete()742a4fff5f29usb: dwc3: gadget: XferComplete only for EP038408464aa76usb: dwc3: gadget: XferNotReady is Isoc-only52fcc0bead0fusb: dwc3: gadget: pre-issue Start Transfer for Interrupt EPs tooc96e6725db9dusb: dwc3: gadget: Correct the logic for queuing sgsa31e63b608ffusb: dwc3: gadget: Correct handling of scattergather lists5f0b74e54890USB: dwc3: get extcon device by OF graph bindingsfe8abf332b8fusb: dwc3: support clocks and resets for DWC3 core44feb8e6ea2dusb: dwc3: use local copy of resource to fix-up register offsetbcb128777af5usb: dwc3: core: Suspend PHYs on runtime suspend in host modea4333c3a6ba9usb: dwc3: Add Qualcomm DWC3 glue drivere362098f0e12usb: dwc3: of-simple: Add compatible for Allwinner H6 platform
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 22/75 usb: dwc3: import from kernel v4.19
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.18 to v4.19.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.18..v4.19
Commits imported:4e3121abcf53 usb/dwc3/gadget: fix kernel-doc parameter warningb497fff6f59e usb: dwc3: pci: Fix return value check in dwc3_byt_enable_ulpi_refclock() 66174b6998a6 usb: dwc3: of-simple: avoid unused function warnings 4ea438da76f4 usb: dwc3: gadget: Check MaxPacketSize from descriptor b138e23d3dff usb: dwc3: core: Enable AutoRetry feature in the controller a77004681148 usb: dwc3: Set default mode for dwc_usb31c31d983beaf0 usb: dwc3: pci: Intel Merrifield can be host1a7b12f69a94 usb: dwc3: pci: Supply device properties via driver data d9612c2f0449 usb: dwc3: Enable undefined length INCR burst typed635db5508b0 usb: dwc3: add global soc bus configuration reg087d852de94d6 usb: dwc3: Describe 'wakeup_work' field of struct dwc3_pci 9a7faac36502 usb: dwc3: change stream event enable bit back to 13 76251db86561 usb: dwc3: of-simple: reset host controller at suspend/resume 211f658b7b40 usb: dwc3: pci: Use devm functions to get the phy GPIOs 7740d04d901d usb: dwc3: pci: Enable ULPI Refclk on platforms where the firmware does not 5741022cbdf3 usb: dwc3: pci: Add GPIO lookup table on platforms without ACPI GPIO resources 3fe314ca8c97 usb: dwc3: Add a glue driver for Synopsys HAPS platform db9fc500e85a usb: dwc3: gadget: remove redundant variable maxpacket
--- drivers/usb/dwc3/core.c | 118 ++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/core.h | 17 ++++++ drivers/usb/dwc3/gadget.c | 3 +- drivers/usb/dwc3/gadget.h | 2 +- 4 files changed, 137 insertions(+), 3 deletions(-)
drivers/usb/dwc3/core.c +118 -0
@@ -78,6 +78,14 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) mode =USB_DR_MODE_HOST ; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode =USB_DR_MODE_PERIPHERAL ; + +/* +* dwc_usb31 does not support OTG mode. If the controller +* supports DRD but the dr_mode is not specified or set to OTG, +* then set the mode to peripheral. +*/ +if (mode ==USB_DR_MODE_OTG &&dwc3_is_usb31 (dwc)) + mode =USB_DR_MODE_PERIPHERAL ; }if (mode != dwc->dr_mode) {
@@ -778,6 +786,98 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)static int dwc3_core_get_phy (struct dwc3 *dwc);static int dwc3_core_ulpi_init (struct dwc3 *dwc); +/* set global incr burst type configuration registers */ +static void dwc3_set_incr_burst_type (struct dwc3 *dwc) +{ +struct device *dev = dwc->dev; +/* incrx_mode : for INCR burst type. */ +bool incrx_mode; +/* incrx_size : for size of INCRX burst. */ +u32 incrx_size; +u32 *vals; +u32 cfg; +int ntype; +int ret; +int i; + + cfg =dwc3_readl (dwc->regs,DWC3_GSBUSCFG0 ); + +/* +* Handle property "snps,incr-burst-type-adjustment". +* Get the number of value from this property: +* result <= 0, means this property is not supported. +* result = 1, means INCRx burst mode supported. +* result > 1, means undefined length burst mode supported. +*/ + ntype =device_property_read_u32_array (dev, +"snps,incr-burst-type-adjustment" ,NULL ,0 ); +if (ntype <=0 ) +return ; + + vals =kcalloc (ntype,sizeof (u32),GFP_KERNEL ); +if (!vals) { +dev_err (dev,"Error to get memory\n" ); +return ; + } + +/* Get INCR burst type, and parse it */ + ret =device_property_read_u32_array (dev, +"snps,incr-burst-type-adjustment" , vals, ntype); +if (ret) { +dev_err (dev,"Error to get property\n" ); +return ; + } + + incrx_size = *vals; + +if (ntype >1 ) { +/* INCRX (undefined length) burst mode */ + incrx_mode =INCRX_UNDEF_LENGTH_BURST_MODE ; +for (i =1 ; i < ntype; i++) { +if (vals[i] > incrx_size) + incrx_size = vals[i]; + } + }else { +/* INCRX burst mode */ + incrx_mode =INCRX_BURST_MODE ; + } + +/* Enable Undefined Length INCR Burst and Enable INCRx Burst */ + cfg &= ~DWC3_GSBUSCFG0_INCRBRST_MASK ; +if (incrx_mode) + cfg |=DWC3_GSBUSCFG0_INCRBRSTENA ; +switch (incrx_size) { +case 256 : + cfg |=DWC3_GSBUSCFG0_INCR256BRSTENA ; +break ; +case 128 : + cfg |=DWC3_GSBUSCFG0_INCR128BRSTENA ; +break ; +case 64 : + cfg |=DWC3_GSBUSCFG0_INCR64BRSTENA ; +break ; +case 32 : + cfg |=DWC3_GSBUSCFG0_INCR32BRSTENA ; +break ; +case 16 : + cfg |=DWC3_GSBUSCFG0_INCR16BRSTENA ; +break ; +case 8 : + cfg |=DWC3_GSBUSCFG0_INCR8BRSTENA ; +break ; +case 4 : + cfg |=DWC3_GSBUSCFG0_INCR4BRSTENA ; +break ; +case 1 : +break ; +default : +dev_err (dev,"Invalid property\n" ); +break ; + } + +dwc3_writel (dwc->regs,DWC3_GSBUSCFG0 , cfg); +} +/** * dwc3_core_init - Low-level initialization of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -840,6 +940,8 @@ static int dwc3_core_init(struct dwc3 *dwc)/* Adjust Frame Length */ dwc3_frame_length_adjustment (dwc); +dwc3_set_incr_burst_type (dwc); +usb_phy_set_suspend (dwc->usb2_phy,0 );usb_phy_set_suspend (dwc->usb3_phy,0 ); ret =phy_power_on (dwc->usb2_generic_phy);
@@ -883,6 +985,22 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); } +if (dwc->dr_mode ==USB_DR_MODE_HOST || + dwc->dr_mode ==USB_DR_MODE_OTG ) { + reg =dwc3_readl (dwc->regs,DWC3_GUCTL ); + +/* +* Enable Auto retry Feature to make the controller operating in +* Host mode on seeing transaction errors(CRC errors or internal +* overrun scenerios) on IN transfers to reply to the device +* with a non-terminating retry ACK (i.e, an ACK transcation +* packet with Retry=1 & Nump != 0) +*/ + reg |=DWC3_GUCTL_HSTINAUTORETRY ; + +dwc3_writel (dwc->regs,DWC3_GUCTL , reg); + } +/* * Must config both number of packets and max burst settings to enable * RX and/or TX threshold.
drivers/usb/dwc3/core.h +17 -0
@@ -163,6 +163,17 @@/* Bit fields */ +/* Global SoC Bus Configuration INCRx Register 0 */ +#define DWC3_GSBUSCFG0_INCR256BRSTENA (1 << 7)/* INCR256 burst */ +#define DWC3_GSBUSCFG0_INCR128BRSTENA (1 << 6)/* INCR128 burst */ +#define DWC3_GSBUSCFG0_INCR64BRSTENA (1 << 5)/* INCR64 burst */ +#define DWC3_GSBUSCFG0_INCR32BRSTENA (1 << 4)/* INCR32 burst */ +#define DWC3_GSBUSCFG0_INCR16BRSTENA (1 << 3)/* INCR16 burst */ +#define DWC3_GSBUSCFG0_INCR8BRSTENA (1 << 2)/* INCR8 burst */ +#define DWC3_GSBUSCFG0_INCR4BRSTENA (1 << 1)/* INCR4 burst */ +#define DWC3_GSBUSCFG0_INCRBRSTENA (1 << 0)/* undefined length enable */ +#define DWC3_GSBUSCFG0_INCRBRST_MASK 0xff +/* Global Debug Queue/FIFO Space Available Register */ #define DWC3_GDBGFIFOSPACE_NUM (n) ((n) & 0x1f)#define DWC3_GDBGFIFOSPACE_TYPE (n) (((n) << 5) & 0x1e0)
@@ -227,6 +238,9 @@#define DWC3_GCTL_GBLHIBERNATIONEN BIT(1)#define DWC3_GCTL_DSBLCLKGTNG BIT(0) +/* Global User Control Register */ +#define DWC3_GUCTL_HSTINAUTORETRY BIT(14) +/* Global User Control 1 Register */ #define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28)#define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24)
@@ -1157,6 +1171,9 @@ struct dwc3 {u16 imod_interval; }; +#define INCRX_BURST_MODE 0 +#define INCRX_UNDEF_LENGTH_BURST_MODE 1 +#define work_to_dwc (w) (container_of((w), struct dwc3, drd_work))/* -------------------------------------------------------------------------- */
drivers/usb/dwc3/gadget.c +1 -2
@@ -473,7 +473,6 @@ static int dwc3_gadget_set_xfer_resource(struct dwc3_ep *dep)/** * dwc3_gadget_start_config - configure ep resources -* @dwc: pointer to our controller context structure * @dep: endpoint that is being enabled * * Issue a %DWC3_DEPCMD_DEPSTARTCFG command to @dep. After the command's
@@ -1121,7 +1120,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, req->request.short_not_ok, req->request.no_interrupt); }else if (req->request.zero && req->request.length && - (IS_ALIGNED (req->request.length,dep->endpoint.maxpacket))) { + (IS_ALIGNED (req->request.length, maxp))) {struct dwc3 *dwc = dep->dwc;struct dwc3_trb *trb;
drivers/usb/dwc3/gadget.h +1 -1
@@ -25,7 +25,7 @@ struct dwc3;#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN BIT(9)#define DWC3_DEPCFG_XFER_NOT_READY_EN BIT(10)#define DWC3_DEPCFG_FIFO_ERROR_EN BIT(11) -#define DWC3_DEPCFG_STREAM_EVENT_EN BIT(12) +#define DWC3_DEPCFG_STREAM_EVENT_EN BIT(13)#define DWC3_DEPCFG_BINTERVAL_M1 (n) (((n) & 0xff) << 16)#define DWC3_DEPCFG_STREAM_CAPABLE BIT(24)#define DWC3_DEPCFG_EP_NUMBER (n) (((n) & 0x1f) << 25)
Signature · 1 line
2.53.0
Re: [PATCH v5 22/75] usb: dwc3: import from kernel v4.19
Hi Anders,
Thank you for the patch.
Quoted 38 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.18 to v4.19.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.18..v4.19
Commits imported:4e3121abcf53usb/dwc3/gadget: fix kernel-doc parameter warningb497fff6f59eusb: dwc3: pci: Fix return value check indwc3_byt_enable_ulpi_refclock()66174b6998a6usb: dwc3: of-simple: avoid unused function warnings4ea438da76f4usb: dwc3: gadget: Check MaxPacketSize from descriptorb138e23d3dffusb: dwc3: core: Enable AutoRetry feature in the controllera77004681148usb: dwc3: Set default mode fordwc_usb31c31d983beaf0usb: dwc3: pci: Intel Merrifield can be host1a7b12f69a94usb: dwc3: pci: Supply device properties via driver datad9612c2f0449usb: dwc3: Enable undefined length INCR burst typed635db5508b0usb: dwc3: add global soc bus configuration reg087d852de94d6usb: dwc3: Describe 'wakeup_work' field of structdwc3_pci9a7faac36502usb: dwc3: change stream event enable bit back to 1376251db86561usb: dwc3: of-simple: reset host controller at suspend/resume211f658b7b40usb: dwc3: pci: Use devm functions to get the phy GPIOs7740d04d901dusb: dwc3: pci: Enable ULPI Refclk on platforms where the firmware does not5741022cbdf3usb: dwc3: pci: Add GPIO lookup table on platforms without ACPI GPIO resources3fe314ca8c97usb: dwc3: Add a glue driver for Synopsys HAPS platformdb9fc500e85ausb: dwc3: gadget: remove redundant variable maxpacket
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 23/75 usb: dwc3: import from kernel v4.20
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.19 to v4.20.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.19..v4.20
Commits imported:38317f5c0f2f Revert "usb: dwc3: gadget: skip Set/Clear Halt when invalid" 2fc6d4be35fb usb: dwc3: gadget: fix ISOC TRB type on unaligned transfers 7b412b04a0c7 usb: dwc3: Fix NULL pointer exception in dwc3_pci_remove() ba3a51ac32eb usb: dwc3: gadget: Properly check last unaligned/zero chain TRB 08fd9a82fda8 usb: dwc3: core: Clean up ULPI device6af19fd10595 usb: dwc3: Fix spelling of 'optimizations'87dd96111b0b usb: dwc3: gadget: Check ENBLSLPM before sending ep command 3def4031b3e3 usb: dwc3: add EXTCON dependency for qcom4c19cc14064d usb: dwc3: exynos: Add support for Exynos5433 variant with all clocks 9f2168367a0a usb: dwc3: exynos: Rework clock handling and prepare for new variants 1e041b6f313a usb: dwc3: exynos: Remove dead code
--- drivers/usb/dwc3/core.c | 3 ++- drivers/usb/dwc3/gadget.c | 42 +++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 20 deletions(-)
drivers/usb/dwc3/core.c +2 -1
@@ -756,7 +756,7 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)/* check if current dwc3 is on simulation board */ if (dwc->hwparams.hwparams6 &DWC3_GHWPARAMS6_EN_FPGA ) { -dev_info (dwc->dev,"Running with FPGA optmizations\n" ); +dev_info (dwc->dev,"Running with FPGA optimizations\n" ); dwc->is_fpga = true; }
@@ -1499,6 +1499,7 @@ static int dwc3_probe(struct platform_device *pdev) err5:dwc3_event_buffers_cleanup (dwc); +dwc3_ulpi_exit (dwc); err4:dwc3_free_scratch_buffers (dwc);
drivers/usb/dwc3/gadget.c +23 -19
104 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 23/75] usb: dwc3: import from kernel v4.20
Hi Anders,
Thank you for the patch.
Quoted 31 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.19 to v4.20.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.19..v4.20
Commits imported:38317f5c0f2fRevert "usb: dwc3: gadget: skip Set/Clear Halt when invalid"2fc6d4be35fbusb: dwc3: gadget: fix ISOC TRB type on unaligned transfers7b412b04a0c7usb: dwc3: Fix NULL pointer exception indwc3_pci_remove()ba3a51ac32ebusb: dwc3: gadget: Properly check last unaligned/zero chain TRB08fd9a82fda8usb: dwc3: core: Clean up ULPI device6af19fd10595usb: dwc3: Fix spelling of 'optimizations'87dd96111b0busb: dwc3: gadget: Check ENBLSLPM before sending ep command3def4031b3e3usb: dwc3: add EXTCON dependency for qcom4c19cc14064dusb: dwc3: exynos: Add support for Exynos5433 variant with all clocks9f2168367a0ausb: dwc3: exynos: Rework clock handling and prepare for new variants1e041b6f313ausb: dwc3: exynos: Remove dead code
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 24/75 usb: dwc3: import from kernel v5.0
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.20 to v5.0.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.20..v5.0
Commits imported:512e6fb589bc usb: dwc3: exynos: Fix error handling of clk_prepare_enable 1e19cdc80602 usb: dwc3: gadget: Handle 0 xfer length for OUT EP88b1bb1f3b88 usb: dwc3: gadget: Fix the uninitialized link_state when udc starts bd6742249b9c usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup 01c10880d242 usb: dwc3: gadget: synchronize_irq dwc irq in suspend b6061b1e566d PCI: Move Synopsys HAPS platform device IDs244add8ebfb2 usb: dwc3: gadget: Disable CSP for stream OUT ep3004cfd62049 Revert "usb: dwc3: pci: Use devm functions to get the phy GPIOs" 54d48183d21e usb: dwc3: trace: add missing break statement to make compiler happy 6abfa0f5bb7c usb: dwc3: gadget: Report isoc transfer frame number b7a4fbe2300a usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb() 26d62b4d10ad usb: dwc3: don't issue no-op trb for stream capable endpoints a7351807bd8b usb: dwc3: update stream id in depcmdd53701067f04 usb: dwc3: gadget: check if dep->frame_number is still valid 3451f6affaef usb: dwc3: gadget: remove unnecessary dev_info()1517265228b4 usb: dwc3: trace: log ep commands in hex25abad6a0584 usb: dwc3: gadget: return errors from __dwc3_gadget_start_isoc() fec9095bdef4 usb: dwc3: gadget: remove wait_end_transferd4f1afe5e896 usb: dwc3: gadget: move requests to cancelled_listd5443bbf5fc8 usb: dwc3: gadget: introduce cancelled_list7746a8dfb3f9 usb: dwc3: gadget: extract dwc3_gadget_ep_skip_trbs() c3acd5901414 usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue() 09fe1f8d7e2f usb: dwc3: gadget: track number of TRBs per request 1a22ec643580 usb: dwc3: gadget: combine unaligned and zero flags d92021f66063 usb: dwc3: Add workaround for isoc start transfer failure 475d8e0197f1 usb: dwc3: Track DWC_usb31 VERSIONTYPE89a9cc47513e usb: dwc3: Set default mode for DWC_usb3 v3.30a and higher 268784ba14a7 usb: dwc3: drd: Add support for DR detection through extcon 85383756ae34 usb: dwc3: drd: Switch to device property for 'extcon' handling 408d3ba006af usb: dwc3: don't log probe deferrals; but do log other error codes 022a0208c0ff usb: dwc3: Support option to disable USB2 LPMeafeacf11964 usb: dwc3: Set GUSB2PHYCFG.ENBLSLPMd102444cac15 usb: dwc3: debugfs: Print/set link state for peripheral mode 0d36dede4578 usb: dwc3: debugfs: Properly print/set link state for HS 62ba09d6bb63 usb: dwc3: debugfs: Dump internal LSP and ep registers 0f874f79dc81 usb: dwc3: debugfs: Print eps Tx/RxFIFO in bytes2c85a1817e4b usb: dwc3: debugfs: Properly name Tx/RxFIFO
--- drivers/usb/dwc3/core.c | 19 ++- drivers/usb/dwc3/core.h | 60 ++++++- drivers/usb/dwc3/debug.h | 29 ++++ drivers/usb/dwc3/gadget.c | 348 +++++++++++++++++++++++++------------- drivers/usb/dwc3/gadget.h | 15 ++ 5 files changed, 336 insertions(+), 135 deletions(-)
drivers/usb/dwc3/core.c +14 -5
@@ -80,11 +80,12 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) mode =USB_DR_MODE_PERIPHERAL ;/* -* dwc_usb31 does not support OTG mode. If the controller -* supports DRD but the dr_mode is not specified or set to OTG, -* then set the mode to peripheral. +* DWC_usb31 and DWC_usb3 v3.30a and higher do not support OTG +* mode. If the controller supports DRD but the dr_mode is not +* specified or set to OTG, then set the mode to peripheral. */ -if (mode ==USB_DR_MODE_OTG &&dwc3_is_usb31 (dwc)) +if (mode ==USB_DR_MODE_OTG && + dwc->revision >=DWC3_REVISION_330A ) mode =USB_DR_MODE_PERIPHERAL ; }
@@ -661,6 +662,8 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (dwc->dis_enblslpm_quirk) reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; +else + reg |=DWC3_GUSB2PHYCFG_ENBLSLPM ;if (dwc->dis_u2_freeclk_exists_quirk) reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS ;
@@ -702,6 +705,7 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc)/* Detected DWC_usb31 IP */ dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); dwc->revision |=DWC3_REVISION_IS_DWC31 ; + dwc->version_type =dwc3_readl (dwc->regs,DWC3_VER_TYPE ); }else {return false; }
@@ -1244,8 +1248,12 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,is-utmi-l1-suspend");device_property_read_u8 (dev,"snps,hird-threshold" , &hird_threshold); + dwc->dis_start_transfer_quirk =device_property_read_bool (dev, +"snps,dis-start-transfer-quirk" ); dwc->usb3_lpm_capable =device_property_read_bool (dev,"snps,usb3_lpm_capable" ); + dwc->usb2_lpm_disable =device_property_read_bool (dev, +"snps,usb2-lpm-disable" );device_property_read_u8 (dev,"snps,rx-thr-num-pkt-prd" , &rx_thr_num_pkt_prd); device_property_read_u8(dev, "snps,rx-max-burst-prd",
@@ -1482,7 +1490,8 @@ static int dwc3_probe(struct platform_device *pdev) ret =dwc3_core_init (dwc);if (ret) { -dev_err (dev,"failed to initialize core\n" ); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"failed to initialize core: %d\n" , ret); goto err4; }
drivers/usb/dwc3/core.h +51 -9
183 lines not on this page · raw message
drivers/usb/dwc3/debug.h +29 -0
@@ -116,6 +116,35 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state) } } +/** +* dwc3_gadget_hs_link_string - returns highspeed and below link name +* @link_state: link state code +*/ +static inline const char * +dwc3_gadget_hs_link_string (enum dwc3_link_state link_state) +{ +switch (link_state) { +case DWC3_LINK_STATE_U0 : +return "On" ; +case DWC3_LINK_STATE_U2 : +return "Sleep" ; +case DWC3_LINK_STATE_U3 : +return "Suspend" ; +case DWC3_LINK_STATE_SS_DIS : +return "Disconnected" ; +case DWC3_LINK_STATE_RX_DET : +return "Early Suspend" ; +case DWC3_LINK_STATE_RECOV : +return "Recovery" ; +case DWC3_LINK_STATE_RESET : +return "Reset" ; +case DWC3_LINK_STATE_RESUME : +return "Resume" ; +default : +return "UNKNOWN link state\n" ; + } +} +/** * dwc3_trb_type_string - returns TRB type as a string * @type: the type of the TRB
drivers/usb/dwc3/gadget.c +227 -121
559 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +15 -0
@@ -79,6 +79,21 @@ static inline void dwc3_gadget_move_started_request(struct dwc3_request *req)list_move_tail (&req->list, &dep->started_list); } +/** +* dwc3_gadget_move_cancelled_request - move @req to the cancelled_list +* @req: the request to be moved +* +* Caller should take care of locking. This function will move @req from its +* current list to the endpoint's cancelled_list. +*/ +static inline void dwc3_gadget_move_cancelled_request (struct dwc3_request *req) +{ +struct dwc3_ep *dep = req->dep; + + req->started = false; +list_move_tail (&req->list, &dep->cancelled_list); +} +void dwc3_gadget_giveback (struct dwc3_ep *dep,struct dwc3_request *req,int status);
Signature · 1 line
2.53.0
Re: [PATCH v5 24/75] usb: dwc3: import from kernel v5.0
Hi Anders,
Thank you for the patch.
Quoted 57 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v4.20 to v5.0.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v4.20..v5.0
Commits imported:512e6fb589bcusb: dwc3: exynos: Fix error handling ofclk_prepare_enable1e19cdc80602usb: dwc3: gadget: Handle 0 xfer length for OUT EP88b1bb1f3b88usb: dwc3: gadget: Fix the uninitializedlink_statewhen udc startsbd6742249b9cusb: dwc3: gadget: Clearreq->needs_extra_trbflag on cleanup01c10880d242usb: dwc3: gadget:synchronize_irqdwc irq in suspendb6061b1e566dPCI: Move Synopsys HAPS platform device IDs244add8ebfb2usb: dwc3: gadget: Disable CSP for stream OUT ep3004cfd62049Revert "usb: dwc3: pci: Use devm functions to get the phy GPIOs"54d48183d21eusb: dwc3: trace: add missing break statement to make compiler happy6abfa0f5bb7cusb: dwc3: gadget: Report isoc transfer frame numberb7a4fbe2300ausb: dwc3: Correct the logic for checking TRB full in__dwc3_prepare_one_trb()26d62b4d10adusb: dwc3: don't issue no-op trb for stream capable endpointsa7351807bd8busb: dwc3: update stream id in depcmdd53701067f04usb: dwc3: gadget: check ifdep->frame_numberis still valid3451f6affaefusb: dwc3: gadget: remove unnecessarydev_info()1517265228b4usb: dwc3: trace: log ep commands in hex25abad6a0584usb: dwc3: gadget: return errors from__dwc3_gadget_start_isoc()fec9095bdef4usb: dwc3: gadget: removewait_end_transferd4f1afe5e896usb: dwc3: gadget: move requests tocancelled_listd5443bbf5fc8usb: dwc3: gadget: introducecancelled_list7746a8dfb3f9usb: dwc3: gadget: extractdwc3_gadget_ep_skip_trbs()c3acd5901414usb: dwc3: gadget: usenum_trbswhen skipping TRBs on ->dequeue()09fe1f8d7e2fusb: dwc3: gadget: track number of TRBs per request1a22ec643580usb: dwc3: gadget: combine unaligned and zero flagsd92021f66063usb: dwc3: Add workaround for isoc start transfer failure475d8e0197f1usb: dwc3: TrackDWC_usb31VERSIONTYPE89a9cc47513eusb: dwc3: Set default mode forDWC_usb3v3.30a and higher268784ba14a7usb: dwc3: drd: Add support for DR detection through extcon85383756ae34usb: dwc3: drd: Switch to device property for 'extcon' handling408d3ba006afusb: dwc3: don't log probe deferrals; but do log other error codes022a0208c0ffusb: dwc3: Support option to disable USB2 LPMeafeacf11964usb: dwc3: Set GUSB2PHYCFG.ENBLSLPMd102444cac15usb: dwc3: debugfs: Print/set link state for peripheral mode0d36dede4578usb: dwc3: debugfs: Properly print/set link state for HS62ba09d6bb63usb: dwc3: debugfs: Dump internal LSP and ep registers0f874f79dc81usb: dwc3: debugfs: Print eps Tx/RxFIFO in bytes2c85a1817e4busb: dwc3: debugfs: Properly name Tx/RxFIFO
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 25/75 usb: dwc3: import from kernel v5.1
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.0 to v5.1.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.0..v5.1
Commits imported:7ae622c978db usb: dwc3: pci: add support for Comet Lake PCH ID 98bba546e82d usb: dwc3: drd: Defer probe if extcon device is not found c7152763f02e usb: dwc3: Reset num_trbs after skippingc5353b225df9 usb: dwc3: gadget: don't enable interrupt when disabling endpoint 9c7ebc99b382 usb: dwc3: haps: Workaround matching VID PID 1381a5113caf usb: dwc3: debug: purge usage of strcat7790b3556fcc usb: dwc3: trace: pass trace buffer size to decoding functions 3aec99154db3 usb: dwc3: gadget: remove DWC3_EP_END_TRANSFER_PENDING 9f45581f5eec usb: dwc3: gadget: early giveback if End Transfer already completed 974a1368c33e usb: dwc3: gadget: don't use resource_index as a flag acbfa6c26f21 usb: dwc3: gadget: clear DWC3_EP_TRANSFER_STARTED on cmd complete 7c3d7dc89e57 usb: dwc3: gadget: remove req->started flag b2b6d601365a usb: dwc3: gadget: prevent dwc3_request from being queued twice a3af5e3ad3f1 usb: dwc3: gadget: add dwc3_request status tracking eca6b49430c6 usb: dwc3: keystone: Add support for ti,am654-dwc3 169e3b68cadb usb: dwc3: gadget: Fix OTG events when gadget driver isn't loaded 54c9da1bcec4 usb: dwc3: qcom: Add support for MSM8998cae8dc3b685f USB: add missing SPDX lines to Kconfig and Makefiles
--- drivers/usb/dwc3/core.h | 12 ++- drivers/usb/dwc3/debug.h | 156 +++++++++++++++++++++----------------- drivers/usb/dwc3/gadget.c | 65 ++++++++-------- drivers/usb/dwc3/gadget.h | 4 +- 4 files changed, 130 insertions(+), 107 deletions(-)
drivers/usb/dwc3/core.h +9 -3
@@ -692,7 +692,6 @@ struct dwc3_ep {#define DWC3_EP_WEDGE BIT(2)#define DWC3_EP_TRANSFER_STARTED BIT(3)#define DWC3_EP_PENDING_REQUEST BIT(5) -#define DWC3_EP_END_TRANSFER_PENDING BIT(7)/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31)
@@ -863,6 +862,7 @@ struct dwc3_hwparams {* @num_pending_sgs: counter to pending sgs * @num_queued_sgs: counter to the number of sgs which already got queued * @remaining: amount of data remaining +* @status: internal dwc3 request status tracking * @epnum: endpoint number to which this request refers * @trb: pointer to struct dwc3_trb * @trb_dma: DMA address of @trb
@@ -871,7 +871,6 @@ struct dwc3_hwparams {* or unaligned OUT) * @direction: IN or OUT direction flag * @mapped: true when request has been dma-mapped -* @started: request is started */ struct dwc3_request {struct usb_request request;
@@ -883,6 +882,14 @@ struct dwc3_request {unsigned num_pending_sgs;unsigned int num_queued_sgs;unsigned remaining; + +unsigned int status; +#define DWC3_REQUEST_STATUS_QUEUED 0 +#define DWC3_REQUEST_STATUS_STARTED 1 +#define DWC3_REQUEST_STATUS_CANCELLED 2 +#define DWC3_REQUEST_STATUS_COMPLETED 3 +#define DWC3_REQUEST_STATUS_UNKNOWN -1 +u8 epnum;struct dwc3_trb *trb;dma_addr_t trb_dma;
@@ -892,7 +899,6 @@ struct dwc3_request { unsigned needs_extra_trb:1; unsigned direction:1; unsigned mapped:1; - unsigned started:1; };/*
drivers/usb/dwc3/debug.h +85 -71
372 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +34 -31
201 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +2 -2
@@ -75,7 +75,7 @@ static inline void dwc3_gadget_move_started_request(struct dwc3_request *req) {struct dwc3_ep *dep = req->dep; - req->started = true; + req->status =DWC3_REQUEST_STATUS_STARTED ;list_move_tail (&req->list, &dep->started_list); }
@@ -90,7 +90,7 @@ static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req) {struct dwc3_ep *dep = req->dep; - req->started = false; + req->status =DWC3_REQUEST_STATUS_CANCELLED ;list_move_tail (&req->list, &dep->cancelled_list); }
Signature · 1 line
2.53.0
Re: [PATCH v5 25/75] usb: dwc3: import from kernel v5.1
Hi Anders,
Thank you for the patch.
Quoted 38 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.0 to v5.1.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.0..v5.1
Commits imported:7ae622c978dbusb: dwc3: pci: add support for Comet Lake PCH ID98bba546e82dusb: dwc3: drd: Defer probe if extcon device is not foundc7152763f02eusb: dwc3: Resetnum_trbsafter skippingc5353b225df9usb: dwc3: gadget: don't enable interrupt when disabling endpoint9c7ebc99b382usb: dwc3: haps: Workaround matching VID PID1381a5113cafusb: dwc3: debug: purge usage of strcat7790b3556fccusb: dwc3: trace: pass trace buffer size to decoding functions3aec99154db3usb: dwc3: gadget: removeDWC3_EP_END_TRANSFER_PENDING9f45581f5eecusb: dwc3: gadget: early giveback if End Transfer already completed974a1368c33eusb: dwc3: gadget: don't useresource_indexas a flagacbfa6c26f21usb: dwc3: gadget: clearDWC3_EP_TRANSFER_STARTEDon cmd complete7c3d7dc89e57usb: dwc3: gadget: removereq->startedflagb2b6d601365ausb: dwc3: gadget: preventdwc3_requestfrom being queued twicea3af5e3ad3f1usb: dwc3: gadget: adddwc3_requeststatus trackingeca6b49430c6usb: dwc3: keystone: Add support for ti,am654-dwc3169e3b68cadbusb: dwc3: gadget: Fix OTG events when gadget driver isn't loaded54c9da1bcec4usb: dwc3: qcom: Add support for MSM8998cae8dc3b685fUSB: add missing SPDX lines toKconfigand Makefiles
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 26/75 usb: dwc3: import from kernel v5.2
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.1 to v5.2.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.1..v5.2
Commits imported:2e487d280525 usb: dwc3: Rename DWC3_DCTL_LPM_ERRATA8d791929b2fb usb: dwc3: Fix default lpm_nyet_threshold value dd24f9b604d3 usb: dwc3: debug: Print GET_STATUS(device) tracepoint b873e2d0ea1e usb: dwc3: Do core validation early on probe c729969b2b69 usb: dwc3: gadget: Set lpm_capable41a91c606e7d usb: dwc3: move synchronize_irq() out of the spinlock protected block 75ecb9dd56a7 usb: dwc3: Free resource immediately after use c0c61471ef86 usb: dwc3: of-simple: Convert to bulk clk API c99993376f72 usb: dwc3: Add Amlogic G12A DWC3 glue67130830ce42 usb: dwc3: Allow building USB_DWC3_QCOM without EXTCON f06ddb53096b BackMerge v5.1-rc5 into drm-nextf31d5c24fb2e reset: Add acquired flag to of_reset_control_array_get()
--- drivers/usb/dwc3/core.c | 18 +++++++++++------- drivers/usb/dwc3/core.h | 3 +-- drivers/usb/dwc3/debug.h | 3 +++ drivers/usb/dwc3/gadget.c | 5 ++--- 4 files changed, 17 insertions(+), 12 deletions(-)
drivers/usb/dwc3/core.c +11 -7
@@ -828,6 +828,7 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc) ret =device_property_read_u32_array (dev,"snps,incr-burst-type-adjustment" , vals, ntype);if (ret) { +kfree (vals);dev_err (dev,"Error to get property\n" );return ; }
@@ -846,6 +847,8 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc) incrx_mode =INCRX_BURST_MODE ; } +kfree (vals); +/* Enable Undefined Length INCR Burst and Enable INCRx Burst */ cfg &= ~DWC3_GSBUSCFG0_INCRBRST_MASK ;if (incrx_mode)
@@ -893,12 +896,6 @@ static int dwc3_core_init(struct dwc3 *dwc)u32 reg;int ret; -if (!dwc3_core_is_valid (dwc)) { -dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); - ret = -ENODEV ; - goto err0; - } -/* * Write Linux Version Code to our GUID register so it's easy to figure * out which kernel version a bug was found.
@@ -1218,7 +1215,7 @@ static void dwc3_get_properties(struct dwc3 *dwc)u8 tx_max_burst_prd;/* default to highest possible threshold */ - lpm_nyet_threshold =0xff ; + lpm_nyet_threshold =0xf ;/* default to -3.5dB de-emphasis */ tx_de_emphasis =1 ;
@@ -1426,6 +1423,11 @@ static int dwc3_probe(struct platform_device *pdev) dwc->regs = regs; dwc->regs_size =resource_size (&dwc_res); +if (!dwc3_core_is_valid (dwc)) { +dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); +return -ENODEV ; + } +dwc3_get_properties (dwc); dwc->reset =devm_reset_control_get_optional_shared (dev,NULL );
@@ -1600,6 +1602,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_suspend (dwc);spin_unlock_irqrestore (&dwc->lock, flags); +synchronize_irq (dwc->irq_gadget);dwc3_core_exit (dwc);break ;case DWC3_GCTL_PRTCAP_HOST :
@@ -1632,6 +1635,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_suspend (dwc);spin_unlock_irqrestore (&dwc->lock, flags); +synchronize_irq (dwc->irq_gadget); }dwc3_otg_exit (dwc);
drivers/usb/dwc3/core.h +1 -2
@@ -406,8 +406,7 @@#define DWC3_DCTL_TRGTULST_SS_INACT (DWC3_DCTL_TRGTULST(6))/* These apply for core versions 1.94a and later */ -#define DWC3_DCTL_LPM_ERRATA_MASK DWC3_DCTL_LPM_ERRATA(0xf) -#define DWC3_DCTL_LPM_ERRATA (n) ((n) << 20) +#define DWC3_DCTL_NYET_THRES (n) (((n) & 0xf) << 20)#define DWC3_DCTL_KEEP_CONNECT BIT(19)#define DWC3_DCTL_L1_HIBER_EN BIT(18)
drivers/usb/dwc3/debug.h +3 -0
@@ -250,6 +250,9 @@ static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str, size_t size) {switch (t &USB_RECIP_MASK ) { +case USB_RECIP_DEVICE : +snprintf (str, size,"Get Device Status(Length = %d)" , l); +break ;case USB_RECIP_INTERFACE :snprintf (str, size,"Get Interface Status(Intf = %d, Length = %d)" , i, l);
drivers/usb/dwc3/gadget.c +2 -3
@@ -2863,7 +2863,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) "LPM Erratum not available on dwc3 revisions < 2.40a\n");if (dwc->has_lpm_erratum && dwc->revision >=DWC3_REVISION_240A ) - reg |=DWC3_DCTL_LPM_ERRATA (dwc->lpm_nyet_threshold); + reg |=DWC3_DCTL_NYET_THRES (dwc->lpm_nyet_threshold);dwc3_writel (dwc->regs,DWC3_DCTL , reg); }else {
@@ -3301,6 +3301,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc->gadget.sg_supported = true; dwc->gadget.name ="dwc3-gadget" ; dwc->gadget.is_otg = dwc->dr_mode ==USB_DR_MODE_OTG ; + dwc->gadget.lpm_capable = true;/* * FIXME We might be setting max_speed to <SUPER, however versions
@@ -3384,8 +3385,6 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)dwc3_disconnect_gadget (dwc);__dwc3_gadget_stop (dwc); -synchronize_irq (dwc->irq_gadget); -return 0 ; }
Signature · 1 line
2.53.0
Re: [PATCH v5 26/75] usb: dwc3: import from kernel v5.2
Hi Anders,
Thank you for the patch.
Quoted 30 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.1 to v5.2.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.1..v5.2
Commits imported:2e487d280525usb: dwc3: RenameDWC3_DCTL_LPM_ERRATA8d791929b2fbusb: dwc3: Fix defaultlpm_nyet_thresholdvaluedd24f9b604d3usb: dwc3: debug: PrintGET_STATUS(device)tracepointb873e2d0ea1eusb: dwc3: Do core validation early on probec729969b2b69usb: dwc3: gadget: Setlpm_capable41a91c606e7dusb: dwc3: movesynchronize_irq()out of the spinlock protected block75ecb9dd56a7usb: dwc3: Free resource immediately after usec0c61471ef86usb: dwc3: of-simple: Convert to bulk clk APIc99993376f72usb: dwc3: Add Amlogic G12A DWC3 glue67130830ce42usb: dwc3: Allow buildingUSB_DWC3_QCOMwithout EXTCON
Quoted 1 line
f06ddb53096bBackMerge v5.1-rc5 into drm-next
I don't think this commit belongs in the list. Looking at the diff in linux, it only seems to touch dwc3-pci.c which we have skipped according to the commit message.
Quoted 1 line
f31d5c24fb2ereset: Add acquired flag toof_reset_control_array_get()
Same for this one, since it touches drivers/usb/dwc3/dwc3-of-simple.c which we have skipped (as it's unused).
Can we update the commit message please?
Thanks,
Mattijs
PATCH v5 27/75 usb: dwc3: import from kernel v5.3
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.2 to v5.3.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.2..v5.3
Commits imported:332694f8a4f7 Revert "usb:gadget Separated decoding functions from dwc3 driver." 3db1b636c07e usb:gadget Separated decoding functions from dwc3 driver. b3649dee5fbb usb: dwc3: pci: add support for TigerLake Devices aa23ce847dda usb: dwc3: remove unused @lock member of dwc3_ep struct dbb0569de852 usb: dwc3: pci: Add Support for Intel Elkhart Lake Devices 729dcffd1ed3 usb: dwc3: gadget: Add support for disabling U1 and U2 entries 4d20a6107050 usb: dwc3: qcom: Use of_clk_get_parent_count() dc1b5d9aed17 usb: dwc3: Fix core validation in probe, move after clocks are enabled 7f5d6a469617 usb: dwc3: qcom: Improve error handlinga6e456209d08 usb: dwc3: qcom: Start USB in 'host mode' on the SDM845 2bc02355f8ba usb: dwc3: qcom: Add support for booting with ACPI f90db10779ad usb: dwc3: meson-g12a: Add support for IRQ based OTG switching
--- drivers/usb/dwc3/core.c | 16 +++++++++++----- drivers/usb/dwc3/core.h | 6 ++++-- drivers/usb/dwc3/ep0.c | 9 ++++++++- drivers/usb/dwc3/gadget.c | 22 ++++++++++++++++++++-- drivers/usb/dwc3/gadget.h | 6 ++++++ 5 files changed, 49 insertions(+), 10 deletions(-)
drivers/usb/dwc3/core.c +11 -5
@@ -1282,6 +1282,10 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,dis_u2_susphy_quirk"); dwc->dis_enblslpm_quirk =device_property_read_bool (dev,"snps,dis_enblslpm_quirk" ); + dwc->dis_u1_entry_quirk =device_property_read_bool (dev, +"snps,dis-u1-entry-quirk" ); + dwc->dis_u2_entry_quirk =device_property_read_bool (dev, +"snps,dis-u2-entry-quirk" ); dwc->dis_rxdet_inp3_quirk =device_property_read_bool (dev,"snps,dis_rxdet_inp3_quirk" ); dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev,
@@ -1423,11 +1427,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->regs = regs; dwc->regs_size =resource_size (&dwc_res); -if (!dwc3_core_is_valid (dwc)) { -dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); -return -ENODEV ; - } -dwc3_get_properties (dwc); dwc->reset =devm_reset_control_get_optional_shared (dev,NULL );
@@ -1460,6 +1459,12 @@ static int dwc3_probe(struct platform_device *pdev)if (ret) goto unprepare_clks; +if (!dwc3_core_is_valid (dwc)) { +dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); + ret = -ENODEV ; + goto disable_clks; + } +platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc);
@@ -1525,6 +1530,7 @@ err1:pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); +disable_clks:clk_bulk_disable (dwc->num_clks, dwc->clks); unprepare_clks:clk_bulk_unprepare (dwc->num_clks, dwc->clks);
drivers/usb/dwc3/core.h +4 -2
@@ -649,7 +649,6 @@ struct dwc3_event_buffer {* @cancelled_list: list of cancelled requests for this endpoint * @pending_list: list of pending requests for this endpoint * @started_list: list of started requests on this endpoint -* @lock: spinlock for endpoint request queue traversal * @regs: pointer to first endpoint register * @trb_pool: array of transaction buffers * @trb_pool_dma: dma address of @trb_pool
@@ -677,7 +676,6 @@ struct dwc3_ep {struct list_head pending_list;struct list_head started_list; -spinlock_t lock;void __iomem *regs;struct dwc3_trb *trb_pool;
@@ -1014,6 +1012,8 @@ struct dwc3_scratchpad_array {* @dis_u2_susphy_quirk: set if we disable usb2 suspend phy * @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG, * disabling the suspend signal to the PHY. +* @dis_u1_entry_quirk: set if link entering into U1 state needs to be disabled. +* @dis_u2_entry_quirk: set if link entering into U2 state needs to be disabled. * @dis_rxdet_inp3_quirk: set if we disable Rx.Detect in P3 * @dis_u2_freeclk_exists_quirk : set if we clear u2_freeclk_exists * in GUSB2PHYCFG, specify that USB2 PHY doesn't
@@ -1205,6 +1205,8 @@ struct dwc3 { unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; unsigned dis_enblslpm_quirk:1; + unsigned dis_u1_entry_quirk:1; + unsigned dis_u2_entry_quirk:1; unsigned dis_rxdet_inp3_quirk:1; unsigned dis_u2_freeclk_exists_quirk:1; unsigned dis_del_phy_power_chg_quirk:1;
drivers/usb/dwc3/ep0.c +8 -1
@@ -379,6 +379,8 @@ static int dwc3_ep0_handle_u1(struct dwc3 *dwc, enum usb_device_state state,if ((dwc->speed !=DWC3_DSTS_SUPERSPEED ) && (dwc->speed !=DWC3_DSTS_SUPERSPEED_PLUS ))return -EINVAL ; +if (set && dwc->dis_u1_entry_quirk) +return -EINVAL ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (set)
@@ -401,6 +403,8 @@ static int dwc3_ep0_handle_u2(struct dwc3 *dwc, enum usb_device_state state,if ((dwc->speed !=DWC3_DSTS_SUPERSPEED ) && (dwc->speed !=DWC3_DSTS_SUPERSPEED_PLUS ))return -EINVAL ; +if (set && dwc->dis_u2_entry_quirk) +return -EINVAL ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (set)
@@ -626,7 +630,10 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)* nothing is pending from application. */ reg =dwc3_readl (dwc->regs,DWC3_DCTL ); - reg |= (DWC3_DCTL_ACCEPTU1ENA |DWC3_DCTL_ACCEPTU2ENA ); +if (!dwc->dis_u1_entry_quirk) + reg |=DWC3_DCTL_ACCEPTU1ENA ; +if (!dwc->dis_u2_entry_quirk) + reg |=DWC3_DCTL_ACCEPTU2ENA ;dwc3_writel (dwc->regs,DWC3_DCTL , reg); }break ;
drivers/usb/dwc3/gadget.c +20 -2
@@ -2073,6 +2073,25 @@ out:return 0 ; } +static void dwc3_gadget_config_params (struct usb_gadget *g, +struct usb_dcd_config_params *params) +{ +struct dwc3 *dwc =gadget_to_dwc (g); + +/* U1 Device exit Latency */ +if (dwc->dis_u1_entry_quirk) + params->bU1devExitLat =0 ; +else + params->bU1devExitLat =DWC3_DEFAULT_U1_DEV_EXIT_LAT ; + +/* U2 Device exit Latency */ +if (dwc->dis_u2_entry_quirk) + params->bU2DevExitLat =0 ; +else + params->bU2DevExitLat = +cpu_to_le16 (DWC3_DEFAULT_U2_DEV_EXIT_LAT ); +} +static void dwc3_gadget_set_speed (struct usb_gadget *g,enum usb_device_speed speed) {
@@ -2142,6 +2161,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { .udc_start = dwc3_gadget_start, .udc_stop = dwc3_gadget_stop, .udc_set_speed = dwc3_gadget_set_speed, + .get_config_params = dwc3_gadget_config_params, };/* -------------------------------------------------------------------------- */
@@ -2251,8 +2271,6 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum) dep->endpoint.comp_desc =NULL ; } -spin_lock_init (&dep->lock); -if (num ==0 ) ret =dwc3_gadget_init_control_endpoint (dep);else if (direction)
drivers/usb/dwc3/gadget.h +6 -0
@@ -48,6 +48,12 @@ struct dwc3;/* DEPXFERCFG parameter 0 */ #define DWC3_DEPXFERCFG_NUM_XFER_RES (n) ((n) & 0xffff) +/* U1 Device exit Latency */ +#define DWC3_DEFAULT_U1_DEV_EXIT_LAT 0x0A/* Less then 10 microsec */ + +/* U2 Device exit Latency */ +#define DWC3_DEFAULT_U2_DEV_EXIT_LAT 0x1FF/* Less then 511 microsec */ +/* -------------------------------------------------------------------------- */ #define to_dwc3_request (r) (container_of(r, struct dwc3_request, request))
Signature · 1 line
2.53.0
Re: [PATCH v5 27/75] usb: dwc3: import from kernel v5.3
Hi Anders,
Thank you for the patch.
Quoted 32 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.2 to v5.3.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.2..v5.3
Commits imported:332694f8a4f7Revert "usb:gadget Separated decoding functions from dwc3 driver."3db1b636c07eusb:gadget Separated decoding functions from dwc3 driver.b3649dee5fbbusb: dwc3: pci: add support for TigerLake Devicesaa23ce847ddausb: dwc3: remove unused @lock member ofdwc3_epstructdbb0569de852usb: dwc3: pci: Add Support for Intel Elkhart Lake Devices729dcffd1ed3usb: dwc3: gadget: Add support for disabling U1 and U2 entries4d20a6107050usb: dwc3: qcom: Useof_clk_get_parent_count()dc1b5d9aed17usb: dwc3: Fix core validation in probe, move after clocks are enabled7f5d6a469617usb: dwc3: qcom: Improve error handlinga6e456209d08usb: dwc3: qcom: Start USB in 'host mode' on the SDM8452bc02355f8bausb: dwc3: qcom: Add support for booting with ACPIf90db10779adusb: dwc3: meson-g12a: Add support for IRQ based OTG switching
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 28/75 usb: dwc3: import from kernel v5.4
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.3 to v5.4.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.3..v5.4
Commits imported:d8eca64eec71 usb: dwc3: gadget: fix race when disabling ep with cancelled xfers a7d9874c6f3f usb: dwc3: remove the call trace of USBx_GFLADJ9bbfceea12a8 usb: dwc3: pci: prevent memory leak in dwc3_pci_probe a51bab592fbb usb: dwc3: select CONFIG_REGMAP_MMIOd819f6584c20 usb: dwc3: Remove dev_err() on platform_get_irq() failure f146b40ba1f0 usb: dwc3: Switch to platform_get_irq_byname_optional() a0a465569b45 usb: dwc3: remove generic PHY calibrate() calls17b63704ec7c usb: dwc3: gadget: Workaround Mirosoft's BESL check 91f255a26bce usb: common: Separated decoding functions from dwc3 driver. 54fb5ba647f8 usb: dwc3: gadget: Set BESL config parameter16fe4f304015 usb: dwc3: Separate field holding multiple properties 1cf084d161f4 usb: dwc3: meson-g12a: fix suspend resume regulator unbalanced disables bceb418b65b9 usb: dwc3: st: Add of_dev_put() in probe functione36721b90144 usb: dwc3: st: Add of_node_put() before return in probe function c09b73cfac2a usb: dwc3: don't set gadget->is_otg flag240b65dc1e89 usb: dwc3: Use clk_bulk_prepare_enable()03bf32bbb607 usb: dwc3: Use devres to get clocks3cd703f483d1 usb: dwc3: remove generic PHYs forwarding for XHCI device 4749e0e61241 usb: dwc3: Update soft-reset wait polling rateb2a3974253d3 usb: dwc3: omap: squash include/linux/platform_data/dwc3-omap.h a6e5e6794a53 usb: dwc3: Switch to use device_property_count_u32() 5b76f6a0b0f8 usb: dwc3: keystone: use devm_platform_ioremap_resource() to simplify code 58dd0bad2554 usb: dwc3: omap: use devm_platform_ioremap_resource() to simplify code c6e4999cd930 usb: dwc3: meson-g12a: use devm_platform_ioremap_resource() to simplify code d3523b631403 usb: dwc3: meson-g12a: use devm_platform_ioremap_resource() to simplify code b33f37064b74 usb: Remove dev_err() usage after platform_get_irq() 41b57327b270 usb: dwc3: Switch to use device_property_count_u32()
--- drivers/usb/dwc3/core.c | 64 +++++----- drivers/usb/dwc3/core.h | 2 + drivers/usb/dwc3/debug.h | 252 -------------------------------------- drivers/usb/dwc3/gadget.c | 37 ++++-- 4 files changed, 60 insertions(+), 295 deletions(-)
drivers/usb/dwc3/core.c +28 -36
@@ -168,7 +168,6 @@ static void __dwc3_set_mode(struct work_struct *work)otg_set_vbus (dwc->usb2_phy->otg, true);phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST );phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_HOST ); -phy_calibrate (dwc->usb2_generic_phy); }break ;case DWC3_GCTL_PRTCAP_DEVICE :
@@ -252,12 +251,25 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) reg |=DWC3_DCTL_CSFTRST ;dwc3_writel (dwc->regs,DWC3_DCTL , reg); +/* +* For DWC_usb31 controller 1.90a and later, the DCTL.CSFRST bit +* is cleared only after all the clocks are synchronized. This can +* take a little more than 50ms. Set the polling rate at 20ms +* for 10 times instead. +*/ +if (dwc3_is_usb31 (dwc) && dwc->revision >=DWC3_USB31_REVISION_190A ) + retries =10 ; +do { reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (!(reg &DWC3_DCTL_CSFTRST )) goto done; -udelay (1 ); +if (dwc3_is_usb31 (dwc) && + dwc->revision >=DWC3_USB31_REVISION_190A ) +msleep (20 ); +else +udelay (1 ); }while (--retries);phy_exit (dwc->usb3_generic_phy);
@@ -267,11 +279,11 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) done:/* -* For DWC_usb31 controller, once DWC3_DCTL_CSFTRST bit is cleared, -* we must wait at least 50ms before accessing the PHY domain -* (synchronization delay). DWC_usb31 programming guide section 1.3.2. +* For DWC_usb31 controller 1.80a and prior, once DCTL.CSFRST bit +* is cleared, we must wait at least 50ms before accessing the PHY +* domain (synchronization delay). */ -if (dwc3_is_usb31 (dwc)) +if (dwc3_is_usb31 (dwc) && dwc->revision <=DWC3_USB31_REVISION_180A )msleep (50 );return 0 ;
@@ -300,8 +312,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc) 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);
@@ -686,8 +697,7 @@ static void dwc3_core_exit(struct dwc3 *dwc)usb_phy_set_suspend (dwc->usb3_phy,1 );phy_power_off (dwc->usb2_generic_phy);phy_power_off (dwc->usb3_generic_phy); -clk_bulk_disable (dwc->num_clks, dwc->clks); -clk_bulk_unprepare (dwc->num_clks, dwc->clks); +clk_bulk_disable_unprepare (dwc->num_clks, dwc->clks);reset_control_assert (dwc->reset); }
@@ -813,8 +823,7 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)* result = 1, means INCRx burst mode supported. * result > 1, means undefined length burst mode supported. */ - ntype =device_property_read_u32_array (dev, -"snps,incr-burst-type-adjustment" ,NULL ,0 ); + ntype =device_property_count_u32 (dev,"snps,incr-burst-type-adjustment" );if (ntype <=0 )return ;
@@ -1166,7 +1175,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)dev_err (dev,"failed to initialize host\n" );return ret; } -phy_calibrate (dwc->usb2_generic_phy);break ;case USB_DR_MODE_OTG :INIT_WORK (&dwc->drd_work, __dwc3_set_mode);
@@ -1310,8 +1318,7 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; - dwc->hird_threshold = hird_threshold - | (dwc->is_utmi_l1_suspend <<4 ); + dwc->hird_threshold = hird_threshold; dwc->rx_thr_num_pkt_prd = rx_thr_num_pkt_prd; dwc->rx_max_burst_prd = rx_max_burst_prd;
@@ -1436,7 +1443,7 @@ static int dwc3_probe(struct platform_device *pdev)if (dev->of_node) { dwc->num_clks =ARRAY_SIZE (dwc3_core_clks); - ret =clk_bulk_get (dev, dwc->num_clks, dwc->clks); + ret =devm_clk_bulk_get (dev, dwc->num_clks, dwc->clks);if (ret == -EPROBE_DEFER )return ret;/*
@@ -1449,16 +1456,12 @@ static int dwc3_probe(struct platform_device *pdev) ret =reset_control_deassert (dwc->reset);if (ret) - goto put_clks; +return ret; - ret =clk_bulk_prepare (dwc->num_clks, dwc->clks); + ret =clk_bulk_prepare_enable (dwc->num_clks, dwc->clks);if (ret) goto assert_reset; - ret =clk_bulk_enable (dwc->num_clks, dwc->clks); -if (ret) - goto unprepare_clks; -if (!dwc3_core_is_valid (dwc)) {dev_err (dwc->dev,"this is not a DesignWare USB3 DRD Core\n" ); ret = -ENODEV ;
@@ -1531,13 +1534,9 @@ err1:pm_runtime_disable (&pdev->dev); disable_clks: -clk_bulk_disable (dwc->num_clks, dwc->clks); -unprepare_clks: -clk_bulk_unprepare (dwc->num_clks, dwc->clks); +clk_bulk_disable_unprepare (dwc->num_clks, dwc->clks); assert_reset:reset_control_assert (dwc->reset); -put_clks: -clk_bulk_put (dwc->num_clks, dwc->clks);return ret; }
@@ -1560,7 +1559,6 @@ static int dwc3_remove(struct platform_device *pdev)dwc3_free_event_buffers (dwc);dwc3_free_scratch_buffers (dwc); -clk_bulk_put (dwc->num_clks, dwc->clks);return 0 ; }
@@ -1574,14 +1572,10 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc)if (ret)return ret; - ret =clk_bulk_prepare (dwc->num_clks, dwc->clks); + ret =clk_bulk_prepare_enable (dwc->num_clks, dwc->clks);if (ret) goto assert_reset; - ret =clk_bulk_enable (dwc->num_clks, dwc->clks); -if (ret) - goto unprepare_clks; - ret =dwc3_core_init (dwc);if (ret) goto disable_clks;
@@ -1589,9 +1583,7 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc)return 0 ; disable_clks: -clk_bulk_disable (dwc->num_clks, dwc->clks); -unprepare_clks: -clk_bulk_unprepare (dwc->num_clks, dwc->clks); +clk_bulk_disable_unprepare (dwc->num_clks, dwc->clks); assert_reset:reset_control_assert (dwc->reset);
drivers/usb/dwc3/core.h +2 -0
@@ -1137,6 +1137,8 @@ struct dwc3 {#define DWC3_USB31_REVISION_120A (0x3132302a | DWC3_REVISION_IS_DWC31)#define DWC3_USB31_REVISION_160A (0x3136302a | DWC3_REVISION_IS_DWC31)#define DWC3_USB31_REVISION_170A (0x3137302a | DWC3_REVISION_IS_DWC31) +#define DWC3_USB31_REVISION_180A (0x3138302a | DWC3_REVISION_IS_DWC31) +#define DWC3_USB31_REVISION_190A (0x3139302a | DWC3_REVISION_IS_DWC31)u32 version_type;
drivers/usb/dwc3/debug.h +0 -252
258 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +30 -7
@@ -707,6 +707,12 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)dwc3_gadget_giveback (dep, req, -ESHUTDOWN ); } + +while (!list_empty (&dep->cancelled_list)) { + req =next_request (&dep->cancelled_list); + +dwc3_gadget_giveback (dep, req, -ESHUTDOWN ); + } }/**
@@ -2078,6 +2084,26 @@ static void dwc3_gadget_config_params(struct usb_gadget *g, {struct dwc3 *dwc =gadget_to_dwc (g); + params->besl_baseline =USB_DEFAULT_BESL_UNSPECIFIED ; + params->besl_deep =USB_DEFAULT_BESL_UNSPECIFIED ; + +/* Recommended BESL */ +if (!dwc->dis_enblslpm_quirk) { +/* +* If the recommended BESL baseline is 0 or if the BESL deep is +* less than 2, Microsoft's Windows 10 host usb stack will issue +* a usb reset immediately after it receives the extended BOS +* descriptor and the enumeration will fail. To maintain +* compatibility with the Windows' usb stack, let's set the +* recommended BESL baseline to 1 and clamp the BESL deep to be +* within 2 to 15. +*/ + params->besl_baseline =1 ; +if (dwc->is_utmi_l1_suspend) + params->besl_deep = +clamp_t (u8, dwc->hird_threshold,2 ,15 ); + } +/* U1 Device exit Latency */ if (dwc->dis_u1_entry_quirk) params->bU1devExitLat =0 ;
@@ -2868,7 +2894,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_DCTL ); reg &= ~(DWC3_DCTL_HIRD_THRES_MASK |DWC3_DCTL_L1_HIBER_EN ); - reg |=DWC3_DCTL_HIRD_THRES (dwc->hird_threshold); + reg |=DWC3_DCTL_HIRD_THRES (dwc->hird_threshold | + (dwc->is_utmi_l1_suspend <<4 ));/* * When dwc3 revisions >= 2.40a, LPM Erratum is enabled and
@@ -3243,14 +3270,14 @@ static int dwc3_gadget_get_irq(struct dwc3 *dwc)struct platform_device *dwc3_pdev =to_platform_device (dwc->dev);int irq; - irq =platform_get_irq_byname (dwc3_pdev,"peripheral" ); + irq =platform_get_irq_byname_optional (dwc3_pdev,"peripheral" );if (irq >0 ) goto out;if (irq == -EPROBE_DEFER ) goto out; - irq =platform_get_irq_byname (dwc3_pdev,"dwc_usb3" ); + irq =platform_get_irq_byname_optional (dwc3_pdev,"dwc_usb3" );if (irq >0 ) goto out;
@@ -3261,9 +3288,6 @@ static int dwc3_gadget_get_irq(struct dwc3 *dwc)if (irq >0 ) goto out; -if (irq != -EPROBE_DEFER ) -dev_err (dwc->dev,"missing peripheral IRQ\n" ); -if (!irq) irq = -EINVAL ;
@@ -3318,7 +3342,6 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc->gadget.speed =USB_SPEED_UNKNOWN ; dwc->gadget.sg_supported = true; dwc->gadget.name ="dwc3-gadget" ; - dwc->gadget.is_otg = dwc->dr_mode ==USB_DR_MODE_OTG ; dwc->gadget.lpm_capable = true;/*
Signature · 1 line
2.53.0
Re: [PATCH v5 28/75] usb: dwc3: import from kernel v5.4
Hi Anders,
Thank you for the patch.
Quoted 47 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.3 to v5.4.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.3..v5.4
Commits imported:d8eca64eec71usb: dwc3: gadget: fix race when disabling ep with cancelled xfersa7d9874c6f3fusb: dwc3: remove the call trace ofUSBx_GFLADJ9bbfceea12a8usb: dwc3: pci: prevent memory leak indwc3_pci_probea51bab592fbbusb: dwc3: selectCONFIG_REGMAP_MMIOd819f6584c20usb: dwc3: Removedev_err()onplatform_get_irq()failuref146b40ba1f0usb: dwc3: Switch toplatform_get_irq_byname_optional()a0a465569b45usb: dwc3: remove generic PHYcalibrate()calls17b63704ec7cusb: dwc3: gadget: Workaround Mirosoft's BESL check91f255a26bceusb: common: Separated decoding functions from dwc3 driver.54fb5ba647f8usb: dwc3: gadget: Set BESL config parameter16fe4f304015usb: dwc3: Separate field holding multiple properties1cf084d161f4usb: dwc3: meson-g12a: fix suspend resume regulator unbalanced disablesbceb418b65b9usb: dwc3: st: Addof_dev_put()in probe functione36721b90144usb: dwc3: st: Addof_node_put()before return in probe functionc09b73cfac2ausb: dwc3: don't setgadget->is_otgflag240b65dc1e89usb: dwc3: Useclk_bulk_prepare_enable()03bf32bbb607usb: dwc3: Use devres to get clocks3cd703f483d1usb: dwc3: remove generic PHYs forwarding for XHCI device4749e0e61241usb: dwc3: Update soft-reset wait polling rateb2a3974253d3usb: dwc3: omap: squashinclude/linux/platform_data/dwc3-omap.ha6e5e6794a53usb: dwc3: Switch to usedevice_property_count_u32()5b76f6a0b0f8usb: dwc3: keystone: usedevm_platform_ioremap_resource()to simplify code58dd0bad2554usb: dwc3: omap: usedevm_platform_ioremap_resource()to simplify codec6e4999cd930usb: dwc3: meson-g12a: usedevm_platform_ioremap_resource()to simplify coded3523b631403usb: dwc3: meson-g12a: usedevm_platform_ioremap_resource()to simplify codeb33f37064b74usb: Removedev_err()usage afterplatform_get_irq()41b57327b270usb: dwc3: Switch to usedevice_property_count_u32()
Quoted 3 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
Quoted 1 line
---
PATCH v5 29/75 usb: dwc3: import from kernel v5.5
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.4 to v5.5.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.4..v5.5
Commits imported:ea0d762775e2 usb: dwc3: gadget: Fix request complete check 3c3caae4cd6e usb: dwc3: pci: add ID for the Intel Comet Lake -H variant 2d7b78f59e02 usb: dwc3: ep0: Clear started flag on completion d3abda5a98a1 usb: dwc3: gadget: Clear started flag for non-IOC 8c7d4b7b3d43 usb: dwc3: gadget: Fix logical condition c3afa2224345 usb: dwc3: Fix Kconfig indentationdcf5a2c390a3 usb: dwc3: create debugfs directory under usb root 726b4fba94be usb: dwc3: of-simple: add a shutdown 038761ce68c2 usb: dwc3: debug: Remove newline printout 9ba3aca8fe82 usb: dwc3: Disable phy suspend after power-on reset c2c1c66b5d43 usb: Fix Kconfig indentation
--- drivers/usb/dwc3/core.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/debug.h | 4 ++-- drivers/usb/dwc3/ep0.c | 8 ++++++++ drivers/usb/dwc3/gadget.c | 12 +++++++++++- 4 files changed, 58 insertions(+), 3 deletions(-)
drivers/usb/dwc3/core.c +37 -0
@@ -566,8 +566,11 @@ static int dwc3_core_ulpi_init(struct dwc3 *dwc)*/ 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 ));/*
@@ -585,6 +588,14 @@ static int dwc3_phy_setup(struct dwc3 *dwc)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 ;
@@ -668,6 +679,14 @@ static int dwc3_phy_setup(struct dwc3 *dwc)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 +921,12 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)*/ 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.
@@ -940,6 +962,21 @@ static int dwc3_core_init(struct dwc3 *dwc)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);
drivers/usb/dwc3/debug.h +2 -2
@@ -112,7 +112,7 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state)case DWC3_LINK_STATE_RESUME :return "Resume" ;default : -return "UNKNOWN link state\n" ; +return "UNKNOWN link state" ; } }
@@ -141,7 +141,7 @@ dwc3_gadget_hs_link_string(enum dwc3_link_state link_state)case DWC3_LINK_STATE_RESUME :return "Resume" ;default : -return "UNKNOWN link state\n" ; +return "UNKNOWN link state" ; } }
drivers/usb/dwc3/ep0.c +8 -0
@@ -1117,6 +1117,9 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,void dwc3_ep0_interrupt (struct dwc3 *dwc,const struct dwc3_event_depevt *event) { +struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; +u8 cmd; +switch (event->endpoint_event) {case DWC3_DEPEVT_XFERCOMPLETE :dwc3_ep0_xfer_complete (dwc, event);
@@ -1129,7 +1132,12 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,case DWC3_DEPEVT_XFERINPROGRESS :case DWC3_DEPEVT_RXTXFIFOEVT :case DWC3_DEPEVT_STREAMEVT : +break ;case DWC3_DEPEVT_EPCMDCMPLT : + cmd =DEPEVT_PARAMETER_CMD (event->parameters); + +if (cmd ==DWC3_DEPCMD_ENDTRANSFER ) + dep->flags &= ~DWC3_EP_TRANSFER_STARTED ;break ; } }
drivers/usb/dwc3/gadget.c +11 -1
@@ -2467,6 +2467,13 @@ static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep,static bool dwc3_gadget_ep_request_completed (struct dwc3_request *req) { +/* +* For OUT direction, host may send less than the setup +* length. Return true for all OUT requests. +*/ +if (!req->direction) +return true; +return req->request.actual == req->request.length; }
@@ -2491,7 +2498,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, req->request.actual = req->request.length - req->remaining; -if (!dwc3_gadget_ep_request_completed (req) && +if (!dwc3_gadget_ep_request_completed (req) || req->num_pending_sgs) {__dwc3_gadget_kick_transfer (dep); goto out;
@@ -2719,6 +2726,9 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,WARN_ON_ONCE (ret); dep->resource_index =0 ; +if (!interrupt) + dep->flags &= ~DWC3_EP_TRANSFER_STARTED ; +if (dwc3_is_usb31 (dwc) || dwc->revision <DWC3_REVISION_310A )udelay (100 ); }
Signature · 1 line
2.53.0
Re: [PATCH v5 29/75] usb: dwc3: import from kernel v5.5
Hi Anders,
Thank you for the patch.
Quoted 30 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.4 to v5.5.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.4..v5.5
Commits imported:ea0d762775e2usb: dwc3: gadget: Fix request complete check3c3caae4cd6eusb: dwc3: pci: add ID for the Intel Comet Lake -H variant2d7b78f59e02usb: dwc3: ep0: Clear started flag on completiond3abda5a98a1usb: dwc3: gadget: Clear started flag for non-IOC8c7d4b7b3d43usb: dwc3: gadget: Fix logical conditionc3afa2224345usb: dwc3: FixKconfigindentationdcf5a2c390a3usb: dwc3: create debugfs directory under usb root726b4fba94beusb: dwc3: of-simple: add a shutdown038761ce68c2usb: dwc3: debug: Remove newline printout9ba3aca8fe82usb: dwc3: Disable phy suspend after power-on reset
Quoted 1 line
c2c1c66b5d43usb: FixKconfigindentation
We don't touch the Kconfig (as mentioned in the commit message). Therefore we should drop this commit from the list of imported commits.
Also, I've file-compared with the mentioned Linux kernel release, and that part looks good to me.
After removing the "c2c1c66b5d43 usb: Fix Kconfig indentation" line, please add:
Quoted 4 lines
Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Anders Roxell <[email protected]>
PATCH v5 30/75 usb: dwc3: import from kernel v5.6
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.5 to v5.6.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.5..v5.6
Commits imported:dad2aff3e827 usb: dwc3: gadget: Update chain bit correctly when using sg list 42cd5ffe46c1 usb: dwc3: debug: fix string position formatting mixup with ret and len 5ee858975b13 usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields f5ae88690955 usb: dwc3: pci: add ID for the Intel Comet Lake -V variant cf2f8b63f7f1 usb: dwc3: gadget: Remove END_TRANSFER delayda10bcdd6f70 usb: dwc3: gadget: Delay starting transferc58d8bfc77a2 usb: dwc3: gadget: Check END_TRANSFER completion 09ed259fac62 usb: dwc3: turn off VBUS when leaving host mode 2e708fa3b898 usb: dwc3: gadget: Clear DCTL.ULSTCHNGREQ before set 1b6009ea88ec usb: dwc3: gadget: Set link state to RX_Detect on disconnect 5b738211fb59 usb: dwc3: gadget: Don't send unintended link state change dea7b202bd9c usb: exynos: Rename Samsung and Exynos to lowercase 5eb5afb07853 usb: dwc3: use proper initializers for property entries
--- drivers/usb/dwc3/core.c | 3 ++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/debug.h | 39 +++++++++------------- drivers/usb/dwc3/ep0.c | 4 ++- drivers/usb/dwc3/gadget.c | 68 +++++++++++++++++++++++++-------------- drivers/usb/dwc3/gadget.h | 14 ++++++++ 6 files changed, 80 insertions(+), 50 deletions(-)
drivers/usb/dwc3/core.c +3 -0
@@ -1246,6 +1246,9 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)/* do nothing */ break ; } + +/* de-assert DRVVBUS for HOST and OTG mode */ +dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_DEVICE ); }static void dwc3_get_properties (struct dwc3 *dwc)
drivers/usb/dwc3/core.h +2 -0
@@ -688,7 +688,9 @@ struct dwc3_ep {#define DWC3_EP_STALL BIT(1)#define DWC3_EP_WEDGE BIT(2)#define DWC3_EP_TRANSFER_STARTED BIT(3) +#define DWC3_EP_END_TRANSFER_PENDING BIT(4)#define DWC3_EP_PENDING_REQUEST BIT(5) +#define DWC3_EP_DELAY_START BIT(6)/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31)
drivers/usb/dwc3/debug.h +15 -24
@@ -256,86 +256,77 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,u8 epnum = event->endpoint_number;size_t len;int status; -int ret; - ret =snprintf (str, size,"ep%d%s: " , epnum >>1 , + len =scnprintf (str, size,"ep%d%s: " , epnum >>1 , (epnum &1 ) ?"in" :"out" ); -if (ret <0 ) -return "UNKNOWN" ; status = event->status;switch (event->endpoint_event) {case DWC3_DEPEVT_XFERCOMPLETE : - len =strlen (str); -snprintf (str + len, size - len,"Transfer Complete (%c%c%c)" , + len +=scnprintf (str + len, size - len, +"Transfer Complete (%c%c%c)" , status &DEPEVT_STATUS_SHORT ?'S' :'s' , status &DEPEVT_STATUS_IOC ?'I' :'i' , status &DEPEVT_STATUS_LST ?'L' :'l' ); - len =strlen (str); -if (epnum <=1 ) -snprintf (str + len, size - len," [%s]" , +scnprintf (str + len, size - len," [%s]" ,dwc3_ep0_state_string (ep0state));break ;case DWC3_DEPEVT_XFERINPROGRESS : - len =strlen (str); - -snprintf (str + len, size - len,"Transfer In Progress [%d] (%c%c%c)" , +scnprintf (str + len, size - len, +"Transfer In Progress [%d] (%c%c%c)" , event->parameters, status &DEPEVT_STATUS_SHORT ?'S' :'s' , status &DEPEVT_STATUS_IOC ?'I' :'i' , status &DEPEVT_STATUS_LST ?'M' :'m' );break ;case DWC3_DEPEVT_XFERNOTREADY : - len =strlen (str); - -snprintf (str + len, size - len,"Transfer Not Ready [%d]%s" , + len +=scnprintf (str + len, size - len, +"Transfer Not Ready [%d]%s" , event->parameters, status &DEPEVT_STATUS_TRANSFER_ACTIVE ?" (Active)" :" (Not Active)" ); - len =strlen (str); -/* Control Endpoints */ if (epnum <=1 ) {int phase =DEPEVT_STATUS_CONTROL_PHASE (event->status);switch (phase) {case DEPEVT_STATUS_CONTROL_DATA : -snprintf (str + ret, size - ret, +scnprintf (str + len, size - len," [Data Phase]" );break ;case DEPEVT_STATUS_CONTROL_STATUS : -snprintf (str + ret, size - ret, +scnprintf (str + len, size - len," [Status Phase]" ); } }break ;case DWC3_DEPEVT_RXTXFIFOEVT : -snprintf (str + ret, size - ret,"FIFO" ); +scnprintf (str + len, size - len,"FIFO" );break ;case DWC3_DEPEVT_STREAMEVT : status = event->status;switch (status) {case DEPEVT_STREAMEVT_FOUND : -snprintf (str + ret, size - ret," Stream %d Found" , +scnprintf (str + len, size - len," Stream %d Found" , event->parameters);break ;case DEPEVT_STREAMEVT_NOTFOUND :default : -snprintf (str + ret, size - ret," Stream Not Found" ); +scnprintf (str + len, size - len," Stream Not Found" );break ; }break ;case DWC3_DEPEVT_EPCMDCMPLT : -snprintf (str + ret, size - ret,"Endpoint Command Complete" ); +scnprintf (str + len, size - len,"Endpoint Command Complete" );break ;default : -snprintf (str, size,"UNKNOWN" ); +scnprintf (str + len, size - len,"UNKNOWN" ); }return str;
drivers/usb/dwc3/ep0.c +3 -1
@@ -1136,8 +1136,10 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,case DWC3_DEPEVT_EPCMDCMPLT : cmd =DEPEVT_PARAMETER_CMD (event->parameters); -if (cmd ==DWC3_DEPCMD_ENDTRANSFER ) +if (cmd ==DWC3_DEPCMD_ENDTRANSFER ) { + dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING ; dep->flags &= ~DWC3_EP_TRANSFER_STARTED ; + }break ; } }
drivers/usb/dwc3/gadget.c +43 -25
173 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +14 -0
@@ -127,4 +127,18 @@ static inline void dwc3_gadget_ep_get_transfer_index(struct dwc3_ep *dep) dep->resource_index = DWC3_DEPCMD_GET_RSC_IDX(res_id); } +/** +* dwc3_gadget_dctl_write_safe - write to DCTL safe from link state change +* @dwc: pointer to our context structure +* @value: value to write to DCTL +* +* Use this function when doing read-modify-write to DCTL. It will not +* send link state change request. +*/ +static inline void dwc3_gadget_dctl_write_safe (struct dwc3 *dwc,u32 value) +{ + value &= ~DWC3_DCTL_ULSTCHNGREQ_MASK ; +dwc3_writel (dwc->regs,DWC3_DCTL , value); +} +#endif /* __DRIVERS_USB_DWC3_GADGET_H */
Signature · 1 line
2.53.0
Re: [PATCH v5 30/75] usb: dwc3: import from kernel v5.6
Hi Anders,
Thank you for the patch.
Quoted 33 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.5 to v5.6.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.5..v5.6
Commits imported:dad2aff3e827usb: dwc3: gadget: Update chain bit correctly when using sg list42cd5ffe46c1usb: dwc3: debug: fix string position formatting mixup with ret and len5ee858975b13usb: dwc3: gadget: Check for IOC/LST bit inTRB->ctrlfieldsf5ae88690955usb: dwc3: pci: add ID for the Intel Comet Lake -V variantcf2f8b63f7f1usb: dwc3: gadget: RemoveEND_TRANSFERdelayda10bcdd6f70usb: dwc3: gadget: Delay starting transferc58d8bfc77a2usb: dwc3: gadget: CheckEND_TRANSFERcompletion09ed259fac62usb: dwc3: turn off VBUS when leaving host mode2e708fa3b898usb: dwc3: gadget: Clear DCTL.ULSTCHNGREQ before set1b6009ea88ecusb: dwc3: gadget: Set link state toRX_Detecton disconnect5b738211fb59usb: dwc3: gadget: Don't send unintended link state changedea7b202bd9cusb: exynos: Rename Samsung and Exynos to lowercase5eb5afb07853usb: dwc3: use proper initializers for property entries
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 31/75 usb: dwc3: import from kernel v5.7
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.6 to v5.7.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.6..v5.7
Commits imported:4748d396399a usb: dwc3: select USB_ROLE_SWITCH066c09593454 usb: dwc3: pci: Enable extcon driver for Intel Merrifield 00e21763f2c8 dwc3: Remove check for HWO flag in dwc3_gadget_ep_reclaim_trb_sg() 49e0590e3a60 usb: dwc3: gadget: Fix request completion checkd0550cd20e52 usb: dwc3: gadget: Do link recovery for SS and SSPd94ea5319813 usb: dwc3: gadget: Properly set maxpacket limit586f4335700f usb: dwc3: Fix GTXFIFOSIZ.TXFDEP macro name0339f7fbc82e usb: dwc3: fix up for role switch API change201c26c08db4 usb: dwc3: qcom: Replace <linux/clk-provider.h> by <linux/of_clk.h> 0227cc84c444 usb: dwc3: core: don't do suspend for device mode if already suspended 4a1d042af420 usb: dwc3: Rework resets initialization to be more flexible 0d3a97083e0c usb: dwc3: Rework clock initialization to be more flexible 98ed256a4dba usb: dwc3: Add support for role-switch-default-mode binding 8a0a13799744 usb: dwc3: Registering a role switch in the DRD code. 7ba6b09fda5e usb: dwc3: core: add support for disabling SS instances in park mode 2dedea035ae8 usb: dwc3: gadget: Wrap around when skip TRBsa114c4ca64bd usb: dwc3: gadget: Don't clear flags before transfer ended a33e5d639c9b usb: dwc3: Remove kernel doc annotation where it's not needed 11c39809070f usb: dwc3: Add ACPI support for xHCI ports07f6842341ab usb: dwc3: exynos: Add support for Exynos5422 suspend clk 238d76021654 usb: dwc3: meson-g12a: Don't use ret uninitialized in dwc3_meson_g12a_otg_init 1e355f21d3fb usb: dwc3: Add Amlogic A1 DWC3 glue30ad6273adad usb: dwc3: trace: print enqueue/dequeue pointers too bce3052f0c16 usb: roles: Provide the switch drivers handle to the switch in the API 882f7a4dae1d usb: dwc3: qcom: Replace <linux/clk-provider.h> by <linux/of_clk.h>
--- drivers/usb/dwc3/core.c | 29 ++++++------- drivers/usb/dwc3/core.h | 18 ++++++++- drivers/usb/dwc3/gadget.c | 85 ++++++++++++++++++++++----------------- 3 files changed, 78 insertions(+), 54 deletions(-)
drivers/usb/dwc3/core.c +13 -16
@@ -289,12 +289,6 @@ done:return 0 ; } -static const struct clk_bulk_data dwc3_core_clks[] = { - { .id ="ref" }, - { .id ="bus_early" }, - { .id ="suspend" }, -}; -/* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure
@@ -1029,6 +1023,9 @@ static int dwc3_core_init(struct dwc3 *dwc)if (dwc->dis_tx_ipgap_linecheck_quirk) reg |=DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS ; +if (dwc->parkmode_disable_ss_quirk) + reg |=DWC3_GUCTL1_PARKMODE_DISABLE_SS ; +dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); }
@@ -1342,6 +1339,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,dis-del-phy-power-chg-quirk"); dwc->dis_tx_ipgap_linecheck_quirk =device_property_read_bool (dev,"snps,dis-tx-ipgap-linecheck-quirk" ); + dwc->parkmode_disable_ss_quirk =device_property_read_bool (dev, +"snps,parkmode-disable-ss-quirk" ); dwc->tx_de_emphasis_quirk =device_property_read_bool (dev,"snps,tx_de_emphasis_quirk" );
@@ -1441,11 +1440,6 @@ static int dwc3_probe(struct platform_device *pdev)if (!dwc)return -ENOMEM ; - dwc->clks =devm_kmemdup (dev, dwc3_core_clks,sizeof (dwc3_core_clks), -GFP_KERNEL ); -if (!dwc->clks) -return -ENOMEM ; - dwc->dev = dev; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -1476,22 +1470,23 @@ static int dwc3_probe(struct platform_device *pdev)dwc3_get_properties (dwc); - dwc->reset =devm_reset_control_get_optional_shared (dev,NULL ); + dwc->reset =devm_reset_control_array_get (dev, true, true);if (IS_ERR (dwc->reset))return PTR_ERR (dwc->reset);if (dev->of_node) { - dwc->num_clks =ARRAY_SIZE (dwc3_core_clks); - - ret =devm_clk_bulk_get (dev, dwc->num_clks, dwc->clks); + ret =devm_clk_bulk_get_all (dev, &dwc->clks);if (ret == -EPROBE_DEFER )return ret;/* * Clocks are optional, but new DT platforms should support all * clocks as required by the DT-binding. */ -if (ret) +if (ret <0 ) dwc->num_clks =0 ; +else + dwc->num_clks = ret; + } ret =reset_control_deassert (dwc->reset);
@@ -1637,6 +1632,8 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)switch (dwc->current_dr_role) {case DWC3_GCTL_PRTCAP_DEVICE : +if (pm_runtime_suspended (dwc->dev)) +break ;spin_lock_irqsave (&dwc->lock, flags);dwc3_gadget_suspend (dwc);spin_unlock_irqrestore (&dwc->lock, flags);
drivers/usb/dwc3/core.h +16 -2
@@ -25,6 +25,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> +#include <linux/usb/role.h> #include <linux/ulpi/interface.h> #include <linux/phy/phy.h>
@@ -249,6 +250,7 @@#define DWC3_GUCTL_HSTINAUTORETRY BIT(14)/* Global User Control 1 Register */ +#define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17)#define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28)#define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24)
@@ -305,10 +307,14 @@/* Global TX Fifo Size Register */ #define DWC31_GTXFIFOSIZ_TXFRAMNUM BIT(15)/* DWC_usb31 only */ -#define DWC31_GTXFIFOSIZ_TXFDEF (n) ((n) & 0x7fff)/* DWC_usb31 only */ -#define DWC3_GTXFIFOSIZ_TXFDEF (n) ((n) & 0xffff) +#define DWC31_GTXFIFOSIZ_TXFDEP (n) ((n) & 0x7fff)/* DWC_usb31 only */ +#define DWC3_GTXFIFOSIZ_TXFDEP (n) ((n) & 0xffff)#define DWC3_GTXFIFOSIZ_TXFSTADDR (n) ((n) & 0xffff0000) +/* Global RX Fifo Size Register */ +#define DWC31_GRXFIFOSIZ_RXFDEP (n) ((n) & 0x7fff)/* DWC_usb31 only */ +#define DWC3_GRXFIFOSIZ_RXFDEP (n) ((n) & 0xffff) +/* Global Event Size Registers */ #define DWC3_GEVNTSIZ_INTMASK BIT(31)#define DWC3_GEVNTSIZ_SIZE (n) ((n) & 0xffff)
@@ -953,6 +959,9 @@ struct dwc3_scratchpad_array {* @hsphy_mode: UTMI phy mode, one of following: * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW +* @role_sw: usb_role_switch handle +* @role_switch_default_mode: default operation mode of controller while +* usb role is USB_ROLE_NONE. * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY
@@ -1024,6 +1033,8 @@ struct dwc3_scratchpad_array {* change quirk. * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate * check during HS transmit. +* @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed +* instances in park mode. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk * @tx_de_emphasis: Tx de-emphasis value * 0 - -6dB de-emphasis
@@ -1086,6 +1097,8 @@ struct dwc3 {struct extcon_dev *edev;struct notifier_block edev_nb;enum usb_phy_interface hsphy_mode; +struct usb_role_switch *role_sw; +enum usb_dr_mode role_switch_default_mode;u32 fladj;u32 irq_gadget;
@@ -1215,6 +1228,7 @@ struct dwc3 { unsigned dis_u2_freeclk_exists_quirk:1; unsigned dis_del_phy_power_chg_quirk:1; unsigned dis_tx_ipgap_linecheck_quirk:1; + unsigned parkmode_disable_ss_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2;
drivers/usb/dwc3/gadget.c +49 -36
159 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 31/75] usb: dwc3: import from kernel v5.7
Hi Anders,
Thank you for the patch.
Quoted 45 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.6 to v5.7.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.6..v5.7
Commits imported:4748d396399ausb: dwc3: selectUSB_ROLE_SWITCH066c09593454usb: dwc3: pci: Enable extcon driver for Intel Merrifield00e21763f2c8dwc3: Remove check for HWO flag indwc3_gadget_ep_reclaim_trb_sg()49e0590e3a60usb: dwc3: gadget: Fix request completion checkd0550cd20e52usb: dwc3: gadget: Do link recovery for SS and SSPd94ea5319813usb: dwc3: gadget: Properly set maxpacket limit586f4335700fusb: dwc3: Fix GTXFIFOSIZ.TXFDEP macro name0339f7fbc82eusb: dwc3: fix up for role switch API change201c26c08db4usb: dwc3: qcom: Replace <linux/clk-provider.h> by <linux/of_clk.h>0227cc84c444usb: dwc3: core: don't do suspend for device mode if already suspended4a1d042af420usb: dwc3: Rework resets initialization to be more flexible0d3a97083e0cusb: dwc3: Rework clock initialization to be more flexible98ed256a4dbausb: dwc3: Add support for role-switch-default-mode binding8a0a13799744usb: dwc3: Registering a role switch in the DRD code.7ba6b09fda5eusb: dwc3: core: add support for disabling SS instances in park mode2dedea035ae8usb: dwc3: gadget: Wrap around when skip TRBsa114c4ca64bdusb: dwc3: gadget: Don't clear flags before transfer endeda33e5d639c9busb: dwc3: Remove kernel doc annotation where it's not needed11c39809070fusb: dwc3: Add ACPI support for xHCI ports07f6842341abusb: dwc3: exynos: Add support for Exynos5422 suspend clk238d76021654usb: dwc3: meson-g12a: Don't use ret uninitialized indwc3_meson_g12a_otg_init1e355f21d3fbusb: dwc3: Add Amlogic A1 DWC3 glue30ad6273adadusb: dwc3: trace: print enqueue/dequeue pointers toobce3052f0c16usb: roles: Provide the switch drivers handle to the switch in the API882f7a4dae1dusb: dwc3: qcom: Replace <linux/clk-provider.h> by <linux/of_clk.h>
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 32/75 usb: dwc3: import from kernel v5.8
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.7 to v5.8.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.7..v5.8
Commits imported:e25d1e8532c3 usb: dwc3: pci: add support for the Intel Jasper Lake c3f595a81192 usb: dwc3: pci: add support for the Intel Tiger Lake PCH -H variant cd37c6976f6a Revert "usb: dwc3: exynos: Add support for Exynos5422 suspend clk" 2655971ad4b3 usb: dwc3: pci: Fix reference count leak in dwc3_pci_resume_work 347052e3bf1b usb: dwc3: meson-g12a: fix USB2 PHY initialization on G12A and A1 SoCs be8c1001a7e6 usb: dwc3: meson-g12a: fix error path when fetching the reset line fails 1c11e74e9079 usb: dwc3: keystone: Turn on USB3 PHY before controller 63c7bb299fc9 usb: dwc3: gadget: Check for prepared TRBs1c0e69ae1b9f usb: dwc3: Increase timeout for CmdAct cleared by device controller b10e1c253577 usb: dwc3: gadget: Use SET_EP_PRIME for NoStream 140ca4cfea8a usb: dwc3: gadget: Handle stream transfersaefe3d232b66 usb: dwc3: gadget: Don't prepare beyond a transfer e0d19563eb6c usb: dwc3: gadget: Wait for transfer completion 3eaecd0c2333 usb: dwc3: gadget: Handle XferComplete for streams 548f8b316563 usb: dwc3: gadget: Enable XferComplete event2e6e9e4b2ed7 usb: dwc3: gadget: Refactor TRB completion handler b6842d4938c3 usb: dwc3: gadget: Check for in-progress END_TRANSFER 4244ba02edb8 usb: dwc3: Get MDWIDTH for DWC_usb329af21dd6faeb usb: dwc3: Add support for DWC_usb32 IPc685114f63b1 usb: dwc3: use true,false for dwc->otg_restart_host f4cc91ddd856 usb: dwc3: of-simple: remove Amlogic GXL and AXG compatibles a9fc15e0fd78 usb: dwc3: meson-g12a: add support for GXL and GXM SoCs df7e37458151 usb: dwc3: meson-g12a: support the GXL/GXM DWC3 host phy disconnect 5b0ba0caaf3a usb: dwc3: meson-g12a: refactor usb initd9feef974e0d usb: dwc3: gadget: Continue to process pending requests f7ac582effc6 usb: dwc3: gadget: WARN on no-resource status36f05d36b035 usb: dwc3: gadget: Issue END_TRANSFER to retry isoc transfer 9bc3395c2496 usb: dwc3: gadget: Store resource index of start cmd 8d99087c2db8 usb: dwc3: gadget: Properly handle failed kick_transfer 8bb14308a869 usb: dwc3: core: Use role-switch default dr_mode 8cc6d55bc200 usb: dwc3: drd: Don't free non-existing irq31306821d877 usb: dwc3: meson-g12a: refactor usb2 phy init8f5bc1ec770c usb: dwc3: meson-g12a: check return of dwc3_meson_g12a_usb_init 6d9fa35a347a usb: dwc3: meson-g12a: get the reset as shared 013af227f58a usb: dwc3: meson-g12a: handle the phy and glue registers separately 5174564cb915 usb: dwc3: meson-g12a: specify phy names in soc data fcd2def66392 usb: dwc3: gadget: Refactor dwc3_gadget_ep_dequeue 8411993e79df usb: dwc3: gadget: Remove unnecessary checksa7027ca69d82 usb: dwc3: gadget: Give back staled requestscb11ea56f37a usb: dwc3: gadget: Properly handle ClearFeature(halt) c2cd3452d5f8 usb: dwc3: support continuous runtime PM with dual role b33f69f56352 USB: dwc3: Use the correct style for SPDX License Identifier
--- drivers/usb/dwc3/core.c | 62 ++--- drivers/usb/dwc3/core.h | 83 ++++--- drivers/usb/dwc3/debug.h | 4 +- drivers/usb/dwc3/gadget.c | 469 +++++++++++++++++++++++++++++--------- drivers/usb/dwc3/gadget.h | 2 +- drivers/usb/dwc3/io.h | 2 +- 6 files changed, 452 insertions(+), 170 deletions(-)
drivers/usb/dwc3/core.c +32 -30
@@ -85,7 +85,9 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)* specified or set to OTG, then set the mode to peripheral. */ if (mode ==USB_DR_MODE_OTG && - dwc->revision >=DWC3_REVISION_330A ) + (!IS_ENABLED (CONFIG_USB_ROLE_SWITCH ) || + !device_property_read_bool (dwc->dev,"usb-role-switch" )) && + !DWC3_VER_IS_PRIOR(DWC3, 330A)) mode =USB_DR_MODE_PERIPHERAL ; }
@@ -121,17 +123,19 @@ static void __dwc3_set_mode(struct work_struct *work)if (dwc->dr_mode !=USB_DR_MODE_OTG )return ; +pm_runtime_get_sync (dwc->dev); +if (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_OTG )dwc3_otg_update (dwc,0 );if (!dwc->desired_dr_role) -return ; + goto out;if (dwc->desired_dr_role == dwc->current_dr_role) -return ; + goto out;if (dwc->desired_dr_role ==DWC3_GCTL_PRTCAP_OTG && dwc->edev) -return ; + goto out;switch (dwc->current_dr_role) {case DWC3_GCTL_PRTCAP_HOST :
@@ -190,6 +194,9 @@ static void __dwc3_set_mode(struct work_struct *work)break ; } +out: +pm_runtime_mark_last_busy (dwc->dev); +pm_runtime_put_autosuspend (dwc->dev); }void dwc3_set_mode (struct dwc3 *dwc,u32 mode)
@@ -257,7 +264,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)* take a little more than 50ms. Set the polling rate at 20ms * for 10 times instead. */ -if (dwc3_is_usb31 (dwc) && dwc->revision >=DWC3_USB31_REVISION_190A ) + if (DWC3_VER_IS_WITHIN(DWC31, 190A, ANY) || DWC3_IP_IS(DWC32)) retries =10 ; do {
@@ -265,8 +272,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)if (!(reg &DWC3_DCTL_CSFTRST )) goto done; -if (dwc3_is_usb31 (dwc) && - dwc->revision >=DWC3_USB31_REVISION_190A ) + if (DWC3_VER_IS_WITHIN(DWC31, 190A, ANY) || DWC3_IP_IS(DWC32))msleep (20 );else udelay (1 );
@@ -283,7 +289,7 @@ done:* is cleared, we must wait at least 50ms before accessing the PHY * domain (synchronization delay). */ -if (dwc3_is_usb31 (dwc) && dwc->revision <=DWC3_USB31_REVISION_180A ) + if (DWC3_VER_IS_WITHIN(DWC31, ANY, 180A))msleep (50 );return 0 ;
@@ -298,7 +304,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)u32 reg;u32 dft; -if (dwc->revision <DWC3_REVISION_250A ) + if (DWC3_VER_IS_PRIOR(DWC3, 250A))return ;if (dwc->fladj ==0 )
@@ -579,7 +585,7 @@ static int dwc3_phy_setup(struct dwc3 *dwc)* will be '0' when the core is reset. Application needs to set it * to '1' after the core initialization is completed. */ -if (dwc->revision >DWC3_REVISION_194A ) + if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) reg |=DWC3_GUSB3PIPECTL_SUSPHY ;/*
@@ -670,7 +676,7 @@ static int dwc3_phy_setup(struct dwc3 *dwc)* be '0' when the core is reset. Application needs to set it to * '1' after the core initialization is completed. */ -if (dwc->revision >DWC3_REVISION_194A ) + if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) reg |=DWC3_GUSB2PHYCFG_SUSPHY ;/*
@@ -719,15 +725,13 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc)u32 reg; reg =dwc3_readl (dwc->regs,DWC3_GSNPSID ); + dwc->ip =DWC3_GSNPS_ID (reg);/* This should read as U3 followed by revision number */ -if ((reg &DWC3_GSNPSID_MASK ) ==0x55330000 ) { -/* Detected DWC_usb3 IP */ +if (DWC3_IP_IS (DWC3 )) { dwc->revision = reg; - }else if ((reg &DWC3_GSNPSID_MASK ) ==0x33310000 ) { -/* Detected DWC_usb31 IP */ + }else if (DWC3_IP_IS (DWC31 ) ||DWC3_IP_IS (DWC32 )) { dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); - dwc->revision |=DWC3_REVISION_IS_DWC31 ; dwc->version_type =dwc3_readl (dwc->regs,DWC3_VER_TYPE ); }else {return false;
@@ -760,8 +764,7 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)*/ if ((dwc->dr_mode ==USB_DR_MODE_HOST || dwc->dr_mode ==USB_DR_MODE_OTG ) && - (dwc->revision >=DWC3_REVISION_210A && - dwc->revision <=DWC3_REVISION_250A )) + DWC3_VER_IS_WITHIN(DWC3, 210A, 250A)) reg |=DWC3_GCTL_DSBLCLKGTNG |DWC3_GCTL_SOFITPSYNC ;else reg &= ~DWC3_GCTL_DSBLCLKGTNG ;
@@ -804,7 +807,7 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)* and falls back to high-speed mode which causes * the device to enter a Connect/Disconnect loop */ -if (dwc->revision <DWC3_REVISION_190A ) + if (DWC3_VER_IS_PRIOR(DWC3, 190A)) reg |=DWC3_GCTL_U2RSTECN ;dwc3_writel (dwc->regs,DWC3_GCTL , reg);
@@ -957,7 +960,7 @@ static int dwc3_core_init(struct dwc3 *dwc) goto err0a;if (hw_mode ==DWC3_GHWPARAMS0_MODE_DRD && - dwc->revision >DWC3_REVISION_194A ) { + !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) {if (!dwc->dis_u3_susphy_quirk) { reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); reg |=DWC3_GUSB3PIPECTL_SUSPHY ;
@@ -1004,20 +1007,20 @@ static int dwc3_core_init(struct dwc3 *dwc)* the DWC_usb3 controller. It is NOT available in the * DWC_usb31 controller. */ -if (!dwc3_is_usb31 (dwc) && dwc->revision >=DWC3_REVISION_310A ) { + if (DWC3_VER_IS_WITHIN(DWC3, 310A, ANY)) { reg =dwc3_readl (dwc->regs,DWC3_GUCTL2 ); reg |=DWC3_GUCTL2_RST_ACTBITLATER ;dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); } -if (dwc->revision >=DWC3_REVISION_250A ) { + if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) { reg =dwc3_readl (dwc->regs,DWC3_GUCTL1 );/* * Enable hardware control of sending remote wakeup * in HS when the device is in the L1 state. */ -if (dwc->revision >=DWC3_REVISION_290A ) + if (!DWC3_VER_IS_PRIOR(DWC3, 290A)) reg |=DWC3_GUCTL1_DEV_L1_EXIT_BY_HW ;if (dwc->dis_tx_ipgap_linecheck_quirk)
@@ -1049,7 +1052,7 @@ static int dwc3_core_init(struct dwc3 *dwc)* Must config both number of packets and max burst settings to enable * RX and/or TX threshold. */ -if (dwc3_is_usb31 (dwc) && dwc->dr_mode ==USB_DR_MODE_HOST ) { +if (!DWC3_IP_IS (DWC3 ) && dwc->dr_mode ==USB_DR_MODE_HOST ) {u8 rx_thr_num = dwc->rx_thr_num_pkt_prd;u8 rx_maxburst = dwc->rx_max_burst_prd;u8 tx_thr_num = dwc->tx_thr_num_pkt_prd;
@@ -1371,10 +1374,9 @@ static void dwc3_get_properties(struct dwc3 *dwc)/* check whether the core supports IMOD */ bool dwc3_has_imod (struct dwc3 *dwc) { -return ((dwc3_is_usb3 (dwc) && - dwc->revision >=DWC3_REVISION_300A ) || - (dwc3_is_usb31 (dwc) && - dwc->revision >=DWC3_USB31_REVISION_120A )); + return DWC3_VER_IS_WITHIN(DWC3, 300A, ANY) || + DWC3_VER_IS_WITHIN(DWC31, 120A, ANY) || +DWC3_IP_IS (DWC32 ); }static void dwc3_check_params (struct dwc3 *dwc)
@@ -1395,7 +1397,7 @@ static void dwc3_check_params(struct dwc3 *dwc)* affected version. */ if (!dwc->imod_interval && - (dwc->revision ==DWC3_REVISION_300A )) + DWC3_VER_IS(DWC3, 300A)) dwc->imod_interval =1 ;/* Check the maximum_speed parameter */
@@ -1417,7 +1419,7 @@ static void dwc3_check_params(struct dwc3 *dwc)/* * default to superspeed plus if we are capable. */ -if (dwc3_is_usb31 (dwc) && +if ((DWC3_IP_IS (DWC31 ) ||DWC3_IP_IS (DWC32 )) && (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) ==DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 )) dwc->maximum_speed =USB_SPEED_SUPER_PLUS ;
drivers/usb/dwc3/core.h +53 -30
146 lines not on this page · raw message
drivers/usb/dwc3/debug.h +3 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /** * debug.h - DesignWare USB3 DRD Controller Debug Header *
@@ -68,6 +68,8 @@ dwc3_gadget_generic_cmd_string(u8 cmd)return "All FIFO Flush" ;case DWC3_DGCMD_SET_ENDPOINT_NRDY :return "Set Endpoint NRDY" ; +case DWC3_DGCMD_SET_ENDPOINT_PRIME : +return "Set Endpoint Prime" ;case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK :return "Run SoC Bus Loopback Test" ;default :
drivers/usb/dwc3/gadget.c +362 -107
854 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * gadget.h - DesignWare USB3 DRD Gadget Header *
drivers/usb/dwc3/io.h +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /** * io.h - DesignWare USB3 DRD IO Header *
Signature · 1 line
2.53.0
Re: [PATCH v5 32/75] usb: dwc3: import from kernel v5.8
Hi Anders,
Thank you for the patch.
Quoted 17 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.7 to v5.8.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
Quoted 9 lines
List of commits: git log --oneline v5.7..v5.8
Commits imported:e25d1e8532c3usb: dwc3: pci: add support for the Intel Jasper Lakec3f595a81192usb: dwc3: pci: add support for the Intel Tiger Lake PCH -H variantcd37c6976f6aRevert "usb: dwc3: exynos: Add support for Exynos5422 suspend clk"2655971ad4b3usb: dwc3: pci: Fix reference count leak indwc3_pci_resume_work347052e3bf1busb: dwc3: meson-g12a: fix USB2 PHY initialization on G12A and A1 SoCsbe8c1001a7e6usb: dwc3: meson-g12a: fix error path when fetching the reset line fails1c11e74e9079usb: dwc3: keystone: Turn on USB3 PHY before controller
Is this patch really imported? It seems to only touch drivers/usb/dwc3/dwc3-keystone.c which is not part of the diffstat below.
Quoted 47 lines
63c7bb299fc9usb: dwc3: gadget: Check for prepared TRBs1c0e69ae1b9fusb: dwc3: Increase timeout for CmdAct cleared by device controllerb10e1c253577usb: dwc3: gadget: UseSET_EP_PRIMEfor NoStream140ca4cfea8ausb: dwc3: gadget: Handle stream transfersaefe3d232b66usb: dwc3: gadget: Don't prepare beyond a transfere0d19563eb6cusb: dwc3: gadget: Wait for transfer completion3eaecd0c2333usb: dwc3: gadget: Handle XferComplete for streams548f8b316563usb: dwc3: gadget: Enable XferComplete event2e6e9e4b2ed7usb: dwc3: gadget: Refactor TRB completion handlerb6842d4938c3usb: dwc3: gadget: Check for in-progressEND_TRANSFER4244ba02edb8usb: dwc3: Get MDWIDTH forDWC_usb329af21dd6faebusb: dwc3: Add support forDWC_usb32IPc685114f63b1usb: dwc3: use true,false fordwc->otg_restart_hostf4cc91ddd856usb: dwc3: of-simple: remove Amlogic GXL and AXG compatiblesa9fc15e0fd78usb: dwc3: meson-g12a: add support for GXL and GXM SoCsdf7e37458151usb: dwc3: meson-g12a: support the GXL/GXM DWC3 host phy disconnect5b0ba0caaf3ausb: dwc3: meson-g12a: refactor usb initd9feef974e0dusb: dwc3: gadget: Continue to process pending requestsf7ac582effc6usb: dwc3: gadget: WARN on no-resource status36f05d36b035usb: dwc3: gadget: IssueEND_TRANSFERto retry isoc transfer9bc3395c2496usb: dwc3: gadget: Store resource index of start cmd8d99087c2db8usb: dwc3: gadget: Properly handle failedkick_transfer8bb14308a869usb: dwc3: core: Use role-switch defaultdr_mode8cc6d55bc200usb: dwc3: drd: Don't free non-existing irq31306821d877usb: dwc3: meson-g12a: refactor usb2 phy init8f5bc1ec770cusb: dwc3: meson-g12a: check return ofdwc3_meson_g12a_usb_init6d9fa35a347ausb: dwc3: meson-g12a: get the reset as shared013af227f58ausb: dwc3: meson-g12a: handle the phy and glue registers separately5174564cb915usb: dwc3: meson-g12a: specify phy names in soc datafcd2def66392usb: dwc3: gadget: Refactordwc3_gadget_ep_dequeue8411993e79dfusb: dwc3: gadget: Remove unnecessary checksa7027ca69d82usb: dwc3: gadget: Give back staled requestscb11ea56f37ausb: dwc3: gadget: Properly handle ClearFeature(halt)c2cd3452d5f8usb: dwc3: support continuous runtime PM with dual roleb33f69f56352USB: dwc3: Use the correct style for SPDX License IdentifierSigned-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>--- drivers/usb/dwc3/core.c | 62 ++--- drivers/usb/dwc3/core.h | 83 ++++--- drivers/usb/dwc3/debug.h | 4 +- drivers/usb/dwc3/gadget.c | 469 +++++++++++++++++++++++++++++--------- drivers/usb/dwc3/gadget.h | 2 +- drivers/usb/dwc3/io.h | 2 +- 6 files changed, 452 insertions(+), 170 deletions(-)
PATCH v5 33/75 usb: dwc3: import from kernel v5.9
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.8 to v5.9.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.8..v5.9
Commits imported:a6498d51821e Revert "usb: dwc3: meson-g12a: fix shared reset control use" df561f6688fe treewide: Use fallthrough pseudo-keywordbc9a2e226ea9 usb: dwc3: gadget: Handle ZLP for sg requestsd2ee3ff79e6a usb: dwc3: gadget: Fix handling ZLP5d187c0454ef usb: dwc3: gadget: Don't setup more than requesteddb123bea9625 usb: dwc3: convert to devm_platform_ioremap_resource_byname f5e46aa4a124 usb: dwc3: gadget: when the started list is empty stop the active xfer c5a7092f4015 usb: dwc3: gadget: make starting isoc transfers more robust ca14378560db usb: dwc3: gadget: add frame number mask7a410953d1fb usb: dwc3: meson-g12a: fix shared reset control use10623b879da3 usb: dwc3: Replace HTTP links with HTTPS onesb789710de583 usb: dwc3: dwc3-qcom: Do not define 'struct acpi_device_id' when !CONFIG_ACPI 26ef796f9306 usb: dwc3: dwc3-of-simple: Function headers are not good candidates for kerneldoc 4d72cf0cb9e2 usb: dwc3: dwc3-haps: Function headers are not suitable for kerneldoc 3c373454a9f2 usb: dwc3: dwc3-omap: Do not read DMA statusfb678a5a76a4 usb: dwc3: ulpi: File headers are not doc headers7679defc3e29 usb: dwc3: drd: File headers are not doc headers62fb45d317c5 USB: ch9: add "USB_" prefix in front of TEST defines
--- drivers/usb/dwc3/core.c | 7 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/dwc3/debug.h | 2 +- drivers/usb/dwc3/ep0.c | 12 +-- drivers/usb/dwc3/gadget.c | 149 +++++++++++++++++++++++++++++++------- drivers/usb/dwc3/gadget.h | 4 +- drivers/usb/dwc3/io.h | 2 +- 7 files changed, 137 insertions(+), 41 deletions(-)
drivers/usb/dwc3/core.c +3 -4
@@ -2,7 +2,7 @@/** * core.c - DesignWare USB3 DRD Controller Core file * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]>
@@ -646,9 +646,8 @@ static int dwc3_phy_setup(struct dwc3 *dwc)if (!(reg &DWC3_GUSB2PHYCFG_ULPI_UTMI ))break ; } -/* FALLTHROUGH */ + fallthrough;case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : -/* FALLTHROUGH */ default :break ; }
@@ -1411,7 +1410,7 @@ static void dwc3_check_params(struct dwc3 *dwc)default :dev_err (dev,"invalid maximum_speed parameter %d\n" , dwc->maximum_speed); -/* fall through */ + fallthrough;case USB_SPEED_UNKNOWN :/* default to superspeed */ dwc->maximum_speed =USB_SPEED_SUPER ;
drivers/usb/dwc3/core.h +1 -1
@@ -2,7 +2,7 @@/* * core.h - DesignWare USB3 DRD Core Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]>
drivers/usb/dwc3/debug.h +1 -1
@@ -2,7 +2,7 @@/** * debug.h - DesignWare USB3 DRD Controller Debug Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]>
drivers/usb/dwc3/ep0.c +6 -6
@@ -2,7 +2,7 @@/* * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]>
@@ -425,11 +425,11 @@ static int dwc3_ep0_handle_test(struct dwc3 *dwc, enum usb_device_state state,return -EINVAL ;switch (wIndex >>8 ) { -case TEST_J : -case TEST_K : -case TEST_SE0_NAK : -case TEST_PACKET : -case TEST_FORCE_EN : +case USB_TEST_J : +case USB_TEST_K : +case USB_TEST_SE0_NAK : +case USB_TEST_PACKET : +case USB_TEST_FORCE_ENABLE : dwc->test_mode_nr = wIndex >>8 ; dwc->test_mode = true;break ;
drivers/usb/dwc3/gadget.c +122 -27
290 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +3 -1
@@ -2,7 +2,7 @@/* * gadget.h - DesignWare USB3 DRD Gadget Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]>
@@ -54,6 +54,8 @@ struct dwc3;/* U2 Device exit Latency */ #define DWC3_DEFAULT_U2_DEV_EXIT_LAT 0x1FF/* Less then 511 microsec */ +/* Frame/Microframe Number Mask */ +#define DWC3_FRNUMBER_MASK 0x3fff/* -------------------------------------------------------------------------- */ #define to_dwc3_request (r) (container_of(r, struct dwc3_request, request))
drivers/usb/dwc3/io.h +1 -1
@@ -2,7 +2,7 @@/** * io.h - DesignWare USB3 DRD IO Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]>
Signature · 1 line
2.53.0
Re: [PATCH v5 33/75] usb: dwc3: import from kernel v5.9
Quoted 17 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.8 to v5.9.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
Quoted 14 lines
List of commits: git log --oneline v5.8..v5.9
Commits imported:a6498d51821eRevert "usb: dwc3: meson-g12a: fix shared reset control use"df561f6688fetreewide: Use fallthrough pseudo-keywordbc9a2e226ea9usb: dwc3: gadget: Handle ZLP for sg requestsd2ee3ff79e6ausb: dwc3: gadget: Fix handling ZLP5d187c0454efusb: dwc3: gadget: Don't setup more than requesteddb123bea9625usb: dwc3: convert todevm_platform_ioremap_resource_bynamef5e46aa4a124usb: dwc3: gadget: when the started list is empty stop the active xferc5a7092f4015usb: dwc3: gadget: make starting isoc transfers more robustca14378560dbusb: dwc3: gadget: add frame number mask7a410953d1fbusb: dwc3: meson-g12a: fix shared reset control use10623b879da3usb: dwc3: Replace HTTP links with HTTPS onesb789710de583usb: dwc3: dwc3-qcom: Do not define 'structacpi_device_id' when !CONFIG_ACPI
Are we actually importing this? Since it's marked as "unused files" in the commit message I think we should drop this from the git log
Quoted 5 lines
26ef796f9306usb: dwc3: dwc3-of-simple: Function headers are not good candidates for kerneldoc4d72cf0cb9e2usb: dwc3: dwc3-haps: Function headers are not suitable for kerneldoc3c373454a9f2usb: dwc3: dwc3-omap: Do not read DMA statusfb678a5a76a4usb: dwc3: ulpi: File headers are not doc headers7679defc3e29usb: dwc3: drd: File headers are not doc headers
Same for ulpi and drd here.
Quoted 14 lines
62fb45d317c5USB: ch9: add "USB_" prefix in front of TEST definesSigned-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>--- drivers/usb/dwc3/core.c | 7 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/dwc3/debug.h | 2 +- drivers/usb/dwc3/ep0.c | 12 +-- drivers/usb/dwc3/gadget.c | 149 +++++++++++++++++++++++++++++++------- drivers/usb/dwc3/gadget.h | 4 +- drivers/usb/dwc3/io.h | 2 +- 7 files changed, 137 insertions(+), 41 deletions(-)
PATCH v5 34/75 usb: dwc3: import from kernel v5.10
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.9 to v5.10.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.9..v5.10
Commits imported:cbdc0f54560f usb: fix kernel-doc markupsfa27e2f6c5e6 usb: dwc3: ep0: Fix delay status handling1384ab4fee12 usb: dwc3: pci: add support for the Intel Alder Lake-S e2c53515b2a6 usb: dwc3: of-simple: Add compatible string for Intel Keem Bay platform e0a93d98f488 usb: dwc3: gadget: Support up to max stream id2338484d14f3 usb: dwc3: gadget: Return early if no TRB update346a15cdf652 usb: dwc3: gadget: Keep TRBs in request order8dbbe48c7a99 usb: dwc3: gadget: Revise setting IOC when no TRB left f9cc581badb1 usb: dwc3: gadget: Look ahead when setting IOCd72ecc08dee4 usb: dwc3: gadget: Allow restarting a transferae7e86108b12 usb: dwc3: Stop active transfers before halting the controller f580170f135a usb: dwc3: Add splitdisable quirk for Hisilicon Kirin Soc 7f2958d9ad58 usb: dwc3: gadget: Rename misleading function names cb1b3997b636 usb: dwc3: gadget: Refactor preparing last TRBs30892cba5596 usb: dwc3: gadget: Set IOC if not enough for extra TRBs 490410b2e73c usb: dwc3: gadget: Check for number of TRBs prepared 13111fcb0d64 usb: dwc3: gadget: Return the number of prepared TRBs 66706077dc89 usb: dwc3: ep0: Fix ZLP for OUT ep0 requestsa2841f41d07f usb: dwc3: gadget: Improve TRB ZLP setup2b80357b773c usb: dwc3: gadget: Refactor preparing extra TRB690e5c2dc29f usb: dwc3: gadget: Reclaim extra TRBs after request completion ca3df3468eec usb: dwc3: gadget: Check MPS of the request length 8266b08ed90c usb: dwc3: gadget: Refactor ep command completion5bde3f020a15 usb: dwc3: debugfs: do not queue work if try to change mode on non-drd 03c1fd622f72 usb: dwc3: core: add phy cleanup for probe error handling 266d0493900a usb: dwc3: core: don't trigger runtime pm when remove driver e81a7018d93a usb: dwc3: allocate gadget structure dynamicallya609ce2a1336 usb: dwc3: pci: Allow Elkhart Lake to utilize DSM method for PM functionality 65f3d449f438 usb: dwc-meson-g12a: Add support for USB on AXG SoCs dc336b19e82d usb: dwc3: core: do not queue work if dr_mode is not USB_DR_MODE_OTG e319bd62292c usb: dwc3: gadget: fix checkpatch warnings87b923a2e059 usb: dwc3: core: fix checkpatch warnings9ae0eb455b91 usb: dwc3: debugfs: fix checkpatch warnings993ffc5b32d2 usb: dwc3: qcom: fix checkpatch warningsc64b475b8488 usb: dwc3: ep0: fix checkpatch warnings035cbca1360a usb: dwc3: debug: fix checkpatch warning159fdf295c67 usb: dwc3: trace: fix checkpatch warnings2a499b452952 usb: dwc3: ulpi: fix checkpatch warninge5ee93d42b3f usb: dwc3: meson: fix checkpatch errors and warnings 27c7ab0fdd0b usb: dwc3: debug: fix sparse warninga793cf81ad0c usb: dwc3: meson: fix coccinelle WARNINGbea46b981515 usb: dwc3: qcom: Add interconnect support in dwc3 driver e518bdd9f02c usb: dwc3: core: Print warning on unsupported speed b574ce3ee459 usb: dwc3: core: Properly default unspecified speed b68d9251561f usb: dwc3: simple: add support for Hikey 970d97c78a1908e usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command c503672abe13 usb: dwc3: gadget: Resume pending requests after CLEAR_STALL
--- drivers/usb/dwc3/core.c | 92 ++++-- drivers/usb/dwc3/core.h | 49 ++-- drivers/usb/dwc3/debug.h | 8 +- drivers/usb/dwc3/ep0.c | 62 ++-- drivers/usb/dwc3/gadget.c | 593 ++++++++++++++++++++++---------------- drivers/usb/dwc3/gadget.h | 3 +- 6 files changed, 499 insertions(+), 308 deletions(-)
drivers/usb/dwc3/core.c +69 -23
@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -/** +/* * core.c - DesignWare USB3 DRD Controller Core file * * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com
@@ -119,9 +119,7 @@ static void __dwc3_set_mode(struct work_struct *work)struct dwc3 *dwc =work_to_dwc (work);unsigned long flags;int ret; - -if (dwc->dr_mode !=USB_DR_MODE_OTG ) -return ; +u32 reg;pm_runtime_get_sync (dwc->dev);
@@ -172,6 +170,11 @@ static void __dwc3_set_mode(struct work_struct *work)otg_set_vbus (dwc->usb2_phy->otg, true);phy_set_mode (dwc->usb2_generic_phy,PHY_MODE_USB_HOST );phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_HOST ); +if (dwc->dis_split_quirk) { + reg =dwc3_readl (dwc->regs,DWC3_GUCTL3 ); + reg |=DWC3_GUCTL3_SPLITDISABLE ; +dwc3_writel (dwc->regs,DWC3_GUCTL3 , reg); + } }break ;case DWC3_GCTL_PRTCAP_DEVICE :
@@ -203,6 +206,9 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) {unsigned long flags; +if (dwc->dr_mode !=USB_DR_MODE_OTG ) +return ; +spin_lock_irqsave (&dwc->lock, flags); dwc->desired_dr_role = mode;spin_unlock_irqrestore (&dwc->lock, flags);
@@ -929,13 +935,6 @@ static int dwc3_core_init(struct dwc3 *dwc)*/ dwc3_writel (dwc->regs,DWC3_GUID ,LINUX_VERSION_CODE ); -/* Handle USB2.0-only core configuration */ -if (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == -DWC3_GHWPARAMS3_SSPHY_IFC_DIS ) { -if (dwc->maximum_speed ==USB_SPEED_SUPER ) - dwc->maximum_speed =USB_SPEED_HIGH ; - } - ret =dwc3_phy_setup (dwc);if (ret) goto err0;
@@ -1356,6 +1355,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->dis_metastability_quirk =device_property_read_bool (dev,"snps,dis_metastability_quirk" ); + dwc->dis_split_quirk =device_property_read_bool (dev, +"snps,dis-split-quirk" ); + dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis;
@@ -1381,6 +1383,8 @@ bool dwc3_has_imod(struct dwc3 *dwc)static void dwc3_check_params (struct dwc3 *dwc) {struct device *dev = dwc->dev; +unsigned int hwparam_gen = +DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3);/* Check for proper value of imod_interval */ if (dwc->imod_interval && !dwc3_has_imod (dwc)) {
@@ -1404,25 +1408,40 @@ static void dwc3_check_params(struct dwc3 *dwc)case USB_SPEED_LOW :case USB_SPEED_FULL :case USB_SPEED_HIGH : +break ;case USB_SPEED_SUPER : +if (hwparam_gen ==DWC3_GHWPARAMS3_SSPHY_IFC_DIS ) +dev_warn (dev,"UDC doesn't support Gen 1\n" ); +break ;case USB_SPEED_SUPER_PLUS : +if ((DWC3_IP_IS (DWC32 ) && + hwparam_gen ==DWC3_GHWPARAMS3_SSPHY_IFC_DIS ) || + (!DWC3_IP_IS (DWC32 ) && + hwparam_gen !=DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 )) +dev_warn (dev,"UDC doesn't support SSP\n" );break ;default :dev_err (dev,"invalid maximum_speed parameter %d\n" , dwc->maximum_speed); fallthrough;case USB_SPEED_UNKNOWN : -/* default to superspeed */ - dwc->maximum_speed =USB_SPEED_SUPER ; - -/* -* default to superspeed plus if we are capable. -*/ -if ((DWC3_IP_IS (DWC31 ) ||DWC3_IP_IS (DWC32 )) && - (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) == -DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 )) +switch (hwparam_gen) { +case DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 : dwc->maximum_speed =USB_SPEED_SUPER_PLUS ; - +break ; +case DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 : +if (DWC3_IP_IS (DWC32 )) + dwc->maximum_speed =USB_SPEED_SUPER_PLUS ; +else + dwc->maximum_speed =USB_SPEED_SUPER ; +break ; +case DWC3_GHWPARAMS3_SSPHY_IFC_DIS : + dwc->maximum_speed =USB_SPEED_HIGH ; +break ; +default : + dwc->maximum_speed =USB_SPEED_SUPER ; +break ; + }break ; } }
@@ -1554,6 +1573,17 @@ static int dwc3_probe(struct platform_device *pdev) err5:dwc3_event_buffers_cleanup (dwc); + +usb_phy_shutdown (dwc->usb2_phy); +usb_phy_shutdown (dwc->usb3_phy); +phy_exit (dwc->usb2_generic_phy); +phy_exit (dwc->usb3_generic_phy); + +usb_phy_set_suspend (dwc->usb2_phy,1 ); +usb_phy_set_suspend (dwc->usb3_phy,1 ); +phy_power_off (dwc->usb2_generic_phy); +phy_power_off (dwc->usb3_generic_phy); +dwc3_ulpi_exit (dwc); err4:
@@ -1589,9 +1619,9 @@ static int dwc3_remove(struct platform_device *pdev)dwc3_core_exit (dwc);dwc3_ulpi_exit (dwc); -pm_runtime_put_sync (&pdev->dev); -pm_runtime_allow (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev);dwc3_free_event_buffers (dwc);dwc3_free_scratch_buffers (dwc);
@@ -1865,10 +1895,26 @@ static int dwc3_resume(struct device *dev) return 0; } + +static void dwc3_complete (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); +u32 reg; + +if (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_HOST && + dwc->dis_split_quirk) { + reg =dwc3_readl (dwc->regs,DWC3_GUCTL3 ); + reg |=DWC3_GUCTL3_SPLITDISABLE ; +dwc3_writel (dwc->regs,DWC3_GUCTL3 , reg); + } +} +#else +#define dwc3_complete NULL#endif /* CONFIG_PM_SLEEP */ static const struct dev_pm_ops dwc3_dev_pm_ops = {SET_SYSTEM_SLEEP_PM_OPS (dwc3_suspend, dwc3_resume) + .complete = dwc3_complete,SET_RUNTIME_PM_OPS (dwc3_runtime_suspend, dwc3_runtime_resume, dwc3_runtime_idle) };
drivers/usb/dwc3/core.h +29 -20
138 lines not on this page · raw message
drivers/usb/dwc3/debug.h +5 -3
@@ -371,7 +371,9 @@ static inline const char *dwc3_gadget_event_type_string(u8 event)static inline const char *dwc3_decode_event (char *str,size_t size,u32 event,u32 ep0state) { -const union dwc3_event evt = (union dwc3_event ) event; +union dwc3_event evt; + +memcpy (&evt, &event,sizeof (event));if (evt.type.is_devspec)return dwc3_gadget_event_string (str, size, &evt.devt);
@@ -411,8 +413,8 @@ static inline const char *dwc3_gadget_generic_cmd_status_string(int status)#ifdef CONFIG_DEBUG_FS -extern void dwc3_debugfs_init (struct dwc3 *); -extern void dwc3_debugfs_exit (struct dwc3 *); +extern void dwc3_debugfs_init (struct dwc3 *d); +extern void dwc3_debugfs_exit (struct dwc3 *d);#else static inline void dwc3_debugfs_init (struct dwc3 *d) { }
drivers/usb/dwc3/ep0.c +43 -19
187 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +351 -242
1,007 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +2 -1
@@ -17,7 +17,7 @@struct dwc3 ;#define to_dwc3_ep (ep) (container_of(ep, struct dwc3_ep, endpoint)) -#define gadget_to_dwc (g) (container_of(g, struct dwc3, gadget)) +#define gadget_to_dwc (g) (dev_get_platdata(&g->dev))/* DEPCFG parameter 1 */ #define DWC3_DEPCFG_INT_NUM (n) (((n) & 0x1f) << 0)
@@ -113,6 +113,7 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);int dwc3_gadget_ep0_queue (struct usb_ep *ep,struct usb_request *request,gfp_t gfp_flags);int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value,int protocol); +void dwc3_ep0_send_delayed_status (struct dwc3 *dwc);/** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
Signature · 1 line
2.53.0
Re: [PATCH v5 34/75] usb: dwc3: import from kernel v5.10
Hi Anders,
Thank you for the patch.
Quoted 67 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.9 to v5.10.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.9..v5.10
Commits imported:cbdc0f54560fusb: fix kernel-doc markupsfa27e2f6c5e6usb: dwc3: ep0: Fix delay status handling1384ab4fee12usb: dwc3: pci: add support for the Intel Alder Lake-Se2c53515b2a6usb: dwc3: of-simple: Add compatible string for Intel Keem Bay platforme0a93d98f488usb: dwc3: gadget: Support up to max stream id2338484d14f3usb: dwc3: gadget: Return early if no TRB update346a15cdf652usb: dwc3: gadget: Keep TRBs in request order8dbbe48c7a99usb: dwc3: gadget: Revise setting IOC when no TRB leftf9cc581badb1usb: dwc3: gadget: Look ahead when setting IOCd72ecc08dee4usb: dwc3: gadget: Allow restarting a transferae7e86108b12usb: dwc3: Stop active transfers before halting the controllerf580170f135ausb: dwc3: Add splitdisable quirk for Hisilicon Kirin Soc7f2958d9ad58usb: dwc3: gadget: Rename misleading function namescb1b3997b636usb: dwc3: gadget: Refactor preparing last TRBs30892cba5596usb: dwc3: gadget: Set IOC if not enough for extra TRBs490410b2e73cusb: dwc3: gadget: Check for number of TRBs prepared13111fcb0d64usb: dwc3: gadget: Return the number of prepared TRBs66706077dc89usb: dwc3: ep0: Fix ZLP for OUT ep0 requestsa2841f41d07fusb: dwc3: gadget: Improve TRB ZLP setup2b80357b773cusb: dwc3: gadget: Refactor preparing extra TRB690e5c2dc29fusb: dwc3: gadget: Reclaim extra TRBs after request completionca3df3468eecusb: dwc3: gadget: Check MPS of the request length8266b08ed90cusb: dwc3: gadget: Refactor ep command completion5bde3f020a15usb: dwc3: debugfs: do not queue work if try to change mode on non-drd03c1fd622f72usb: dwc3: core: add phy cleanup for probe error handling266d0493900ausb: dwc3: core: don't trigger runtime pm when remove drivere81a7018d93ausb: dwc3: allocate gadget structure dynamicallya609ce2a1336usb: dwc3: pci: Allow Elkhart Lake to utilize DSM method for PM functionality65f3d449f438usb: dwc-meson-g12a: Add support for USB on AXG SoCsdc336b19e82dusb: dwc3: core: do not queue work ifdr_modeis notUSB_DR_MODE_OTGe319bd62292cusb: dwc3: gadget: fix checkpatch warnings87b923a2e059usb: dwc3: core: fix checkpatch warnings9ae0eb455b91usb: dwc3: debugfs: fix checkpatch warnings993ffc5b32d2usb: dwc3: qcom: fix checkpatch warningsc64b475b8488usb: dwc3: ep0: fix checkpatch warnings035cbca1360ausb: dwc3: debug: fix checkpatch warning159fdf295c67usb: dwc3: trace: fix checkpatch warnings2a499b452952usb: dwc3: ulpi: fix checkpatch warninge5ee93d42b3fusb: dwc3: meson: fix checkpatch errors and warnings27c7ab0fdd0busb: dwc3: debug: fix sparse warninga793cf81ad0cusb: dwc3: meson: fix coccinelle WARNINGbea46b981515usb: dwc3: qcom: Add interconnect support in dwc3 drivere518bdd9f02cusb: dwc3: core: Print warning on unsupported speedb574ce3ee459usb: dwc3: core: Properly default unspecified speedb68d9251561fusb: dwc3: simple: add support for Hikey 970d97c78a1908eusb: dwc3: gadget:END_TRANSFERbeforeCLEAR_STALLcommandc503672abe13usb: dwc3: gadget: Resume pending requests afterCLEAR_STALL
Quoted 2 lines
Signed-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
I've file-compared with the mentioned Linux kernel release, and this looks good to me:
PATCH v5 35/75 usb: dwc3: import from kernel v5.11
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.10 to v5.11.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.10..v5.11
Commits imported:0e5a3c8284a3 usb: dwc3: fix clock issue during resume in OTG mode a5c7682aaaa1 usb: dwc3: gadget: Clear wait flag on dequeue a1383b3537a7 usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup e5f4ca3fce90 usb: dwc3: ulpi: Fix USB2.0 HS/FS/LS PHY suspend regression fca3f1381057 usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one ce722da66d3e usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion a5ada3dfe6a2 usb: dwc3: meson-g12a: disable clk on error handling path in probe
--- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/gadget.c | 16 +++++----------- 3 files changed, 7 insertions(+), 12 deletions(-)
drivers/usb/dwc3/core.c +1 -1
@@ -1758,7 +1758,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)if (PMSG_IS_AUTO (msg))break ; - ret =dwc3_core_init (dwc); + ret =dwc3_core_init_for_resume (dwc);if (ret)return ret;
drivers/usb/dwc3/core.h +1 -0
@@ -285,6 +285,7 @@/* Global USB2 PHY Vendor Control Register */ #define DWC3_GUSB2PHYACC_NEWREGREQ BIT(25) +#define DWC3_GUSB2PHYACC_DONE BIT(24)#define DWC3_GUSB2PHYACC_BUSY BIT(23)#define DWC3_GUSB2PHYACC_WRITE BIT(22)#define DWC3_GUSB2PHYACC_ADDR (n) (n << 16)
drivers/usb/dwc3/gadget.c +5 -11
@@ -1763,6 +1763,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,list_for_each_entry_safe (r, t, &dep->started_list, list)dwc3_gadget_move_cancelled_request (r); + dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE ; + goto out; } }
@@ -2083,6 +2085,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)static void dwc3_gadget_disable_irq (struct dwc3 *dwc);static void __dwc3_gadget_stop (struct dwc3 *dwc); +static int __dwc3_gadget_start (struct dwc3 *dwc);static int dwc3_gadget_pullup (struct usb_gadget *g,int is_on) {
@@ -2145,6 +2148,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % dwc->ev_buf->length; } + }else { +__dwc3_gadget_start (dwc); } ret =dwc3_gadget_run_stop (dwc, is_on, false);
@@ -2319,10 +2324,6 @@ static int dwc3_gadget_start(struct usb_gadget *g, } dwc->gadget_driver = driver; - -if (pm_runtime_active (dwc->dev)) -__dwc3_gadget_start (dwc); -spin_unlock_irqrestore (&dwc->lock, flags);return 0 ;
@@ -2348,13 +2349,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)unsigned long flags;spin_lock_irqsave (&dwc->lock, flags); - -if (pm_runtime_suspended (dwc->dev)) - goto out; - -__dwc3_gadget_stop (dwc); - -out: dwc->gadget_driver =NULL ;spin_unlock_irqrestore (&dwc->lock, flags);
Signature · 1 line
2.53.0
Re: [PATCH v5 35/75] usb: dwc3: import from kernel v5.11
Hi Anders,
Thank you for the patch.
Quoted 17 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.10 to v5.11.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
Quoted 8 lines
List of commits: git log --oneline v5.10..v5.11
Commits imported:0e5a3c8284a3usb: dwc3: fix clock issue during resume in OTG modea5c7682aaaa1usb: dwc3: gadget: Clear wait flag on dequeuea1383b3537a7usb: dwc3: gadget: Restart DWC3 gadget when enabling pullupe5f4ca3fce90usb: dwc3: ulpi: Fix USB2.0 HS/FS/LS PHY suspend regressionfca3f1381057usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based onece722da66d3eusb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion
ulpi.c is part of the unused files, so we should drop these 3 commits from the changelog.
With that fixed:
Quoted 4 lines
a5ada3dfe6a2usb: dwc3: meson-g12a: disable clk on error handling path in probeSigned-off-by Jens Wiklander <[email protected]>Signed-off-by Anders Roxell <[email protected]>
PATCH v5 36/75 usb: dwc3: import from kernel v5.12
In reply to Anders RoxellFrom: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.11 to v5.12.
The following files are preserved accross the import:Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c dwc3-layerscape.c ti_usb_phy.c
Skipping unused files:debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c
Note that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.11..v5.12
Commits imported:5aef629704ad usb: dwc3: gadget: Clear DEP flags after stop transfers in ep disable b522f830d351 usb: dwc3: pci: Enable dis_uX_susphy_quirk for Intel Merrifield 93f1d43c5767 usb: dwc3: gadget: Use max speed if unspecified cdb651b6021e usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate 5e4010e36a58 usb: dwc3: qcom: skip interconnect init for ACPI probe f09ddcfcb8c5 usb: dwc3: gadget: Prevent EP queuing while stopping transfers 1cffb1c66499 usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement 2664deb09306 usb: dwc3: qcom: Honor wakeup enabled/disabled state 1edbff9c80ed usb: dwc3: qcom: add ACPI device id for sc8180x 83c4a4eec06a of: Remove of_dev_{get,put}()4b049f55ed95 usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt a1679af85b2a usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 8cf9045b9138 usb: dwc3: gadget: Remove check for bounded driver 450b9e9fabd8 usb: dwc3: gadget: Set speed only up to the max supported f551037c0770 usb: dwc3: gadget: Track connected SSP rate and lane count 072cab8a0fe2 usb: dwc3: gadget: Implement setting of SSP rate 678481467d2e usb: dwc3: core: Check maximum_speed SSP genXxY b1638ee56c1a usb: dwc3: host: Use software node API with the properties 8dc6e6dd1bee usb: dwc3: qcom: Constify the software nodeefc9812edc61 usb: dwc3: haps: Constify the software nodec25c210f590e usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot f08fc2c30e78 usb: dwc3: pci: add support for the Intel Alder Lake-P 73203bde3a95 usb: dwc3: pci: ID for Tiger Lake CPUe492ce9bcaa1 usb: dwc3: pci: Register a software node for the dwc3 platform device 5dc71f1eb870 USB: dwc3: document gadget_max_speed132ee0da6e9f usb: dwc3: gadget: Disable Vendor Test LMP Received event 0c0a20f6da04 usb: dwc3: Simplify with dev_err_probe()370e3d5b711d usb: dwc3: keystone: Simplify with dev_err_probe() babbdfc9d229 usb: dwc3: core: Replace devm_reset_control_array_get() 7c9a2598463a usb: dwc3: gadget: Preserve UDC max speed setting 77adb8bdf422 usb: dwc3: gadget: Allow runtime suspend if UDC unbinded 82c46b8ed9dc usb: dwc3: gadget: Introduce a DWC3 VBUS draw callback 6dd2565989b4 usb: dwc3: add imx8mp dwc3 glue layer driver cb4d9b52ec06 usb: dwc3: drd: Improve dwc3_get_extcon() style c824c73a5e08 usb: dwc3: drd: Avoid error when extcon is missing
--- drivers/usb/dwc3/core.c | 83 +++++++----- drivers/usb/dwc3/core.h | 11 ++ drivers/usb/dwc3/gadget.c | 263 ++++++++++++++++++++++++++------------ 3 files changed, 243 insertions(+), 114 deletions(-)
drivers/usb/dwc3/core.c +49 -34
@@ -1126,11 +1126,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc) ret =PTR_ERR (dwc->usb2_phy);if (ret == -ENXIO || ret == -ENODEV ) { dwc->usb2_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; }else { -dev_err (dev,"no usb2 phy configured\n" ); -return ret; +return dev_err_probe (dev, ret,"no usb2 phy configured\n" ); } }
@@ -1138,11 +1135,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc) ret =PTR_ERR (dwc->usb3_phy);if (ret == -ENXIO || ret == -ENODEV ) { dwc->usb3_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; }else { -dev_err (dev,"no usb3 phy configured\n" ); -return ret; +return dev_err_probe (dev, ret,"no usb3 phy configured\n" ); } }
@@ -1151,11 +1145,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc) ret =PTR_ERR (dwc->usb2_generic_phy);if (ret == -ENOSYS || ret == -ENODEV ) { dwc->usb2_generic_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; }else { -dev_err (dev,"no usb2 phy configured\n" ); -return ret; +return dev_err_probe (dev, ret,"no usb2 phy configured\n" ); } }
@@ -1164,11 +1155,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc) ret =PTR_ERR (dwc->usb3_generic_phy);if (ret == -ENOSYS || ret == -ENODEV ) { dwc->usb3_generic_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; }else { -dev_err (dev,"no usb3 phy configured\n" ); -return ret; +return dev_err_probe (dev, ret,"no usb3 phy configured\n" ); } }
@@ -1190,11 +1178,8 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_DEVICE ); ret =dwc3_gadget_init (dwc); -if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (dev,"failed to initialize gadget\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to initialize gadget\n" );break ;case USB_DR_MODE_HOST :dwc3_set_prtcap (dwc,DWC3_GCTL_PRTCAP_HOST );
@@ -1205,20 +1190,14 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)phy_set_mode (dwc->usb3_generic_phy,PHY_MODE_USB_HOST ); ret =dwc3_host_init (dwc); -if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (dev,"failed to initialize host\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to initialize host\n" );break ;case USB_DR_MODE_OTG :INIT_WORK (&dwc->drd_work, __dwc3_set_mode); ret =dwc3_drd_init (dwc); -if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (dev,"failed to initialize dual-role\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to initialize dual-role\n" );break ;default :dev_err (dev,"Unsupported mode of operation %d\n" , dwc->dr_mode);
@@ -1273,6 +1252,7 @@ static void dwc3_get_properties(struct dwc3 *dwc) hird_threshold =12 ; dwc->maximum_speed =usb_get_maximum_speed (dev); + dwc->max_ssp_rate =usb_get_maximum_ssp_rate (dev); dwc->dr_mode =usb_get_dr_mode (dev); dwc->hsphy_mode =of_usb_get_phy_mode (dev->of_node);
@@ -1444,6 +1424,42 @@ static void dwc3_check_params(struct dwc3 *dwc) }break ; } + +/* +* Currently the controller does not have visibility into the HW +* parameter to determine the maximum number of lanes the HW supports. +* If the number of lanes is not specified in the device property, then +* set the default to support dual-lane for DWC_usb32 and single-lane +* for DWC_usb31 for super-speed-plus. +*/ +if (dwc->maximum_speed ==USB_SPEED_SUPER_PLUS ) { +switch (dwc->max_ssp_rate) { +case USB_SSP_GEN_2x1: +if (hwparam_gen ==DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 ) +dev_warn (dev,"UDC only supports Gen 1\n" ); +break ; +case USB_SSP_GEN_1x2: +case USB_SSP_GEN_2x2: +if (DWC3_IP_IS (DWC31 )) +dev_warn (dev,"UDC only supports single lane\n" ); +break ; +case USB_SSP_GEN_UNKNOWN : +default : +switch (hwparam_gen) { +case DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 : +if (DWC3_IP_IS (DWC32 )) + dwc->max_ssp_rate = USB_SSP_GEN_2x2; +else + dwc->max_ssp_rate = USB_SSP_GEN_2x1; +break ; +case DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 : +if (DWC3_IP_IS (DWC32 )) + dwc->max_ssp_rate = USB_SSP_GEN_1x2; +break ; + } +break ; + } + } }static int dwc3_probe (struct platform_device *pdev)
@@ -1490,7 +1506,7 @@ static int dwc3_probe(struct platform_device *pdev)dwc3_get_properties (dwc); - dwc->reset =devm_reset_control_array_get (dev, true, true); + dwc->reset =devm_reset_control_array_get_optional_shared (dev);if (IS_ERR (dwc->reset))return PTR_ERR (dwc->reset);
@@ -1555,8 +1571,7 @@ static int dwc3_probe(struct platform_device *pdev) ret =dwc3_core_init (dwc);if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (dev,"failed to initialize core: %d\n" , ret); +dev_err_probe (dev, ret,"failed to initialize core\n" ); goto err4; }
drivers/usb/dwc3/core.h +11 -0
@@ -386,6 +386,8 @@#define DWC3_GUCTL3_SPLITDISABLE BIT(14)/* Device Configuration Register */ +#define DWC3_DCFG_NUMLANES (n) (((n) & 0x3) << 30)/* DWC_usb32 only */ +#define DWC3_DCFG_DEVADDR (addr) ((addr) << 3)#define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
@@ -459,6 +461,8 @@#define DWC3_DEVTEN_USBRSTEN BIT(1)#define DWC3_DEVTEN_DISCONNEVTEN BIT(0) +#define DWC3_DSTS_CONNLANES (n) (((n) >> 30) & 0x3)/* DWC_usb32 only */ +/* Device Status Register */ #define DWC3_DSTS_DCNRD BIT(29)
@@ -964,6 +968,10 @@ struct dwc3_scratchpad_array {* @nr_scratch: number of scratch buffers * @u1u2: only used on revisions <1.83a for workaround * @maximum_speed: maximum speed requested (mainly for testing purposes) +* @max_ssp_rate: SuperSpeed Plus maximum signaling rate and lane count +* @gadget_max_speed: maximum gadget speed requested +* @gadget_ssp_rate: Gadget driver's maximum supported SuperSpeed Plus signaling +* rate and lane count. * @ip: controller's ID * @revision: controller's version of an IP * @version_type: VERSIONTYPE register contents, a sub release of a revision
@@ -1126,6 +1134,9 @@ struct dwc3 {u32 nr_scratch;u32 u1u2;u32 maximum_speed; +u32 gadget_max_speed; +enum usb_ssp_rate max_ssp_rate; +enum usb_ssp_rate gadget_ssp_rate;u32 ip;
drivers/usb/dwc3/gadget.c +183 -80
422 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v5 36/75] usb: dwc3: import from kernel v5.12
Hi Anders,
Thank you for the patch.
Quoted 46 lines · Anders Roxell
From: Jens Wiklander <[email protected]>
Sync Linux kernel dwc3 changes from v5.11 to v5.12.
The following files are preserved accross the import:
MakefileKconfigdwc3-meson-g12a.cdwc3-meson-gxl.cdwc3-omap.cdwc3-uniphier.cdwc3-generic.hdwc3-generic.cdwc3-generic-sti.cdwc3-layerscape.cti_usb_phy.cSkipping unused files:
debugfs.cdrd.cdwc3-exynos.cdwc3-haps.cdwc3-imx8mp.cdwc3-keystone.cdwc3-octeon.cdwc3-of-simple.cdwc3-pci.cdwc3-qcom.cdwc3-qcom-legacy.cdwc3-rtk.cdwc3-st.cdwc3-xilinx.chost.ctrace.ctrace.hulpi.cNote that this is a raw import and doesn't build. A fixup commit at the end of the series fixes that.
List of commits: git log --oneline v5.11..v5.12
Commits imported:5aef629704adusb: dwc3: gadget: Clear DEP flags after stop transfers in ep disableb522f830d351usb: dwc3: pci: Enabledis_uX_susphy_quirkfor Intel Merrifield93f1d43c5767usb: dwc3: gadget: Use max speed if unspecifiedcdb651b6021eusb: dwc3: gadget: Setgadget_max_speedwhen setssp_rate5e4010e36a58usb: dwc3: qcom: skip interconnect init for ACPI probef09ddcfcb8c5usb: dwc3: gadget: Prevent EP queuing while stopping transfers1cffb1c66499usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement2664deb09306usb: dwc3: qcom: Honor wakeup enabled/disabled state1edbff9c80edusb: dwc3: qcom: add ACPI device id for sc8180x83c4a4eec06aof: Remove of_dev_{get,put}()4b049f55ed95usb: dwc3: gadget: Fixdep->intervalfor fullspeed interrupta1679af85b2ausb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m18cf9045b9138usb: dwc3: gadget: Remove check for bounded driver450b9e9fabd8usb: dwc3: gadget: Set speed only up to the max supportedf551037c0770usb: dwc3: gadget: Track connected SSP rate and lane count072cab8a0fe2usb: dwc3: gadget: Implement setting of SSP rate678481467d2eusb: dwc3: core: Checkmaximum_speedSSP genXxYb1638ee56c1ausb: dwc3: host: Use software node API with the properties8dc6e6dd1beeusb: dwc3: qcom: Constify the software nodeefc9812edc61usb: dwc3: haps: Constify the software nodec25c210f590eusb: dwc3: qcom: add URS Host support for sdm845 ACPI bootf08fc2c30e78usb: dwc3: pci: add support for the Intel Alder Lake-P73203bde3a95usb: dwc3: pci: ID for Tiger Lake CPUe492ce9bcaa1usb: dwc3: pci: Register a software node for the dwc3 platform device5dc71f1eb870USB: dwc3: documentgadget_max_speed132ee0da6e9fusb: dwc3: gadget: Disable Vendor Test LMP Received event0c0a20f6da04usb: dwc3: Simplify withdev_err_probe()
Quoted 8 lines
370e3d5b711dusb: dwc3: keystone: Simplify withdev_err_probe()babbdfc9d229usb: dwc3: core: Replacedevm_reset_control_array_get()7c9a2598463ausb: dwc3: gadget: Preserve UDC max speed setting77adb8bdf422usb: dwc3: gadget: Allow runtime suspend if UDC unbinded82c46b8ed9dcusb: dwc3: gadget: Introduce a DWC3 VBUS draw callback6dd2565989b4usb: dwc3: add imx8mp dwc3 glue layer drivercb4d9b52ec06usb: dwc3: drd: Improvedwc3_get_extcon()stylec824c73a5e08usb: dwc3: drd: Avoid error when extcon is missing
Drop qcom, host, haps, pci, drd patches from the changelog since we chose to skip those files.
With that fixed: