usb: dwc2: Refactor and update USB DWC2 driver
v4 cover usb: dwc2: Refactor and update USB DWC2 driver
This series improves the USB DWC2 driver by extracting register definitions into a common file for better readability and updating the reset method to reflect changes in version 4.20a, including the new GRSTCTL_CSFTRST_DONE bit for reset completion indication.
This series has been tested on two platforms:
- MK808 with RK3066 SoC and dwc2 v2.91a, tested with USB flash drive and connected the board to the PC through the rockusb command. Test log [1].
- K230-CanMV with K230 SoC [2] and dwc2 v4.30a, tested with the onboard rtl8152 USB to net chip and an external rtl8152 adapter connected to the onboard USB-C interface via USB hub. Test log [3].
[1] https://gist.github.com/Judehahh/878ace2607d201dc49211f2c655f0fe0#file-mk808-md
[2] https://developer.canaan-creative.com/k230/en/dev/CanMV_K230_Tutorial.html
[3] https://gist.github.com/Judehahh/878ace2607d201dc49211f2c655f0fe0#file-k230-canmv-md
---
Changes in v4:
- Fixed typo from dwc2_core_reg to dwc2_core_regs in patch 1&5.
- Restored struct dwc2_usbotg_phy definition that was incorrectly
removed in patch 6.
- Updated copyright headers to include 2025 in patch 7.
- Expanded comments to clarify PHY clock delay in patch 7.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Handled warnings from checkpatch.pl (add spaces around '<<' and
replace 'x' with '(x)' for macro argument).
- Add return ret; when timeout happens.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Reorganized structures, renamed macros, and moved code for better
clarity and maintainability.
- Added a fix for the incorrect ULPI_UTMI_SEL bit setting.
- Added a fix for incorrectly calculating HBstLen for external DMA mode.
- Extend the changes that replace uint32 with u32 to also include u8 and u16.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Junhui Liu (1):
usb: dwc2: Fix incorrect ULPI_UTMI_SEL bit setting
Kongyang Liu (7):
usb: dwc2: Extract register definitions to common header file
usb: dwc2: Fix HBstLen setting for external DMA mode
usb: dwc2: Clean up with bitfield macros
usb: dwc2: Align macros with Linux kernel definitions
usb: dwc2: Extract macro definitions to common header
usb: dwc2: Unify flush and reset logic with v4.20a support
usb: dwc2: Replace uint<x>_t types with u<x>
drivers/usb/common/Makefile | 2 + drivers/usb/common/dwc2_core.c | 131 +++++ drivers/usb/common/dwc2_core.h | 560 +++++++++++++++++++++ drivers/usb/gadget/dwc2_udc_otg.c | 125 ++--- drivers/usb/gadget/dwc2_udc_otg_regs.h | 289 ++--------- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 306 ++++++------ drivers/usb/host/dwc2.c | 494 ++++++++----------- drivers/usb/host/dwc2.h | 750 +---------------------------- 8 files changed, 1154 insertions(+), 1503 deletions(-)
---
base-commit: 38a371110308ebeb277e20531a7b698b7981bbfa
change-id: 20241218-dwc2-dev-955c21a81118
Best regards,
Signature · 1 line
Junhui Liu <[email protected]>
PATCH v4 1/8 usb: dwc2: Extract register definitions to common header file
From: Kongyang Liu <[email protected]>
The same registers are accessed in both the otg and gatet drivers of dwc2, and these registers are repeatedly defined in these two parts. Extract register definitions into a common header file to reduce redundancy and make the code more maintainable.
--- drivers/usb/common/dwc2_core.h | 126 ++++++++++++++++++ drivers/usb/gadget/dwc2_udc_otg.c | 94 +++++++------- drivers/usb/gadget/dwc2_udc_otg_regs.h | 68 +--------- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 201 +++++++++++++++-------------- drivers/usb/host/dwc2.c | 102 ++++++++------- drivers/usb/host/dwc2.h | 58 --------- 6 files changed, 332 insertions(+), 317 deletions(-)
drivers/usb/common/dwc2_core.h new file +126 -0
@@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2024, Kongyang Liu <[email protected]> +* +*/ + +#ifndef __DWC2_CORE_H_ +#define __DWC2_CORE_H_ + +struct dwc2_global_regs { +u32 gotgctl;/* 0x000 */ +u32 gotgint; +u32 gahbcfg; +u32 gusbcfg; +u32 grstctl;/* 0x010 */ +u32 gintsts; +u32 gintmsk; +u32 grxstsr; +u32 grxstsp;/* 0x020 */ +u32 grxfsiz; +u32 gnptxfsiz; +u32 gnptxsts; +u32 gi2cctl;/* 0x030 */ +u32 gpvndctl; +u32 ggpio; +u32 guid; +u32 gsnpsid;/* 0x040 */ +u32 ghwcfg1; +u32 ghwcfg2; +u32 ghwcfg3; +u32 ghwcfg4;/* 0x050 */ +u32 glpmcfg; +u32 gpwrdn; +u32 gdfifocfg; +u32 gadpctl;/* 0x060 */ +u32 grefclk; +u32 gintmsk2; +u32 gintsts2; +u8 _pad_from_0x70_to_0x100[0x100 -0x70 ]; +u32 hptxfsiz;/* 0x100 */ +u32 dptxfsizn[15 ]; +u8 _pad_from_0x140_to_0x400[0x400 -0x140 ]; +}; + +struct dwc2_hc_regs { +u32 hcchar;/* 0x500 + 0x20 * ch */ +u32 hcsplt; +u32 hcint; +u32 hcintmsk; +u32 hctsiz; +u32 hcdma; +u32 reserved; +u32 hcdmab; +}; + +struct dwc2_host_regs { +u32 hcfg;/* 0x400 */ +u32 hfir; +u32 hfnum; +u32 _pad_0x40c; +u32 hptxsts;/* 0x410 */ +u32 haint; +u32 haintmsk; +u32 hflbaddr; +u8 _pad_from_0x420_to_0x440[0x440 -0x420 ]; +u32 hprt0;/* 0x440 */ +u8 _pad_from_0x444_to_0x500[0x500 -0x444 ]; +struct dwc2_hc_regs hc[16 ];/* 0x500 */ +u8 _pad_from_0x700_to_0x800[0x800 -0x700 ]; +}; + +/* Device Logical IN Endpoint-Specific Registers */ +struct dwc2_dev_in_endp { +u32 diepctl;/* 0x900 + 0x20 * ep */ +u32 reserved0; +u32 diepint; +u32 reserved1; +u32 dieptsiz; +u32 diepdma; +u32 reserved2; +u32 diepdmab; +}; + +/* Device Logical OUT Endpoint-Specific Registers */ +struct dwc2_dev_out_endp { +u32 doepctl;/* 0xB00 + 0x20 * ep */ +u32 reserved0; +u32 doepint; +u32 reserved1; +u32 doeptsiz; +u32 doepdma; +u32 reserved2; +u32 doepdmab; +}; + +struct dwc2_device_regs { +u32 dcfg;/* 0x800 */ +u32 dctl; +u32 dsts; +u32 _pad_0x80c; +u32 diepmsk;/* 0x810 */ +u32 doepmsk; +u32 daint; +u32 daintmsk; +u32 dtknqr1;/* 0x820 */ +u32 dtknqr2; +u32 dvbusdis; +u32 dvbuspulse; +u32 dtknqr3;/* 0x830 */ +u32 dtknqr4; +u8 _pad_from_0x838_to_0x900[0x900 -0x838 ]; +struct dwc2_dev_in_endp in_endp[16 ];/* 0x900 */ +struct dwc2_dev_out_endp out_endp[16 ];/* 0xB00 */ +}; + +struct dwc2_core_regs { +struct dwc2_global_regs global_regs;/* 0x000 */ +struct dwc2_host_regs host_regs;/* 0x400 */ +struct dwc2_device_regs device_regs;/* 0x800 */ +u8 _pad_from_0xd00_to_0xe00[0xe00 -0xd00 ]; +u32 pcgcctl;/* 0xe00 */ +u8 _pad_from_0xe04_to_0x1000[0x1000 -0xe04 ]; +u8 ep_fifo[16 ][0x1000 ];/* 0x1000 */ +}; + +#endif /* __DWC2_CORE_H_ */
drivers/usb/gadget/dwc2_udc_otg.c +49 -45
236 lines not on this page · raw message
drivers/usb/gadget/dwc2_udc_otg_regs.h +1 -67
81 lines not on this page · raw message
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +102 -99
498 lines not on this page · raw message
drivers/usb/host/dwc2.c +54 -48
318 lines not on this page · raw message
drivers/usb/host/dwc2.h +0 -58
64 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH v4 2/8 usb: dwc2: Fix incorrect ULPI_UTMI_SEL bit setting
In reply to Junhui LiuThe ULPI_UTMI_SEL bit in the DWC2 driver was set incorrectly. According to the datasheet [1], this bit should be set to 0 for UTMI interface and 1 for ULPI interface. The existing code had this logic reversed, causing the interface selection to be incorrect.
This commit corrects the ULPI_UTMI_SEL bit setting to match the datasheet's description. Referencing the kernel's code [2] also confirms this fix.
[1] https://rockchip.fr/RK312X%20TRM/chapter-26-usb-otg-2-0.pdf#page=30
[2] https://github.com/torvalds/linux/blob/v6.13-rc3/drivers/usb/dwc2/core.c#L1106
--- drivers/usb/host/dwc2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/usb/host/dwc2.c +13 -11
@@ -402,20 +402,22 @@ static void dwc_otg_core_init(struct udevice *dev)* soft reset so only program the first time. Do a soft reset * immediately after setting phyif. */ - usbcfg &= ~(DWC2_GUSBCFG_ULPI_UTMI_SEL |DWC2_GUSBCFG_PHYIF ); - usbcfg |=DWC2_PHY_TYPE <<DWC2_GUSBCFG_ULPI_UTMI_SEL_OFFSET ; - -if (usbcfg &DWC2_GUSBCFG_ULPI_UTMI_SEL ) {/* ULPI interface */ +#if (DWC2_PHY_TYPE ==DWC2_PHY_TYPE_ULPI ) + usbcfg |=DWC2_GUSBCFG_ULPI_UTMI_SEL ; + usbcfg &= ~DWC2_GUSBCFG_PHYIF ;#ifdef DWC2_PHY_ULPI_DDR - usbcfg |=DWC2_GUSBCFG_DDRSEL ; + usbcfg |=DWC2_GUSBCFG_DDRSEL ;#else - usbcfg &= ~DWC2_GUSBCFG_DDRSEL ; -#endif - }else {/* UTMI+ interface */ + usbcfg &= ~DWC2_GUSBCFG_DDRSEL ; +#endif /* DWC2_PHY_ULPI_DDR */ +#elif (DWC2_PHY_TYPE ==DWC2_PHY_TYPE_UTMI ) + usbcfg &= ~DWC2_GUSBCFG_ULPI_UTMI_SEL ;#if (DWC2_UTMI_WIDTH ==16 ) - usbcfg |=DWC2_GUSBCFG_PHYIF ; -#endif - } + usbcfg |=DWC2_GUSBCFG_PHYIF ; +#else + usbcfg &= ~DWC2_GUSBCFG_PHYIF ; +#endif /* DWC2_UTMI_WIDTH */ +#endif /* DWC2_PHY_TYPE */ writel (usbcfg, ®s->global_regs.gusbcfg);
Signature · 1 line
2.47.1
PATCH v4 3/8 usb: dwc2: Fix HBstLen setting for external DMA mode
In reply to Junhui LiuFrom: Kongyang Liu <[email protected]>
The loop used to calculate HBstLen for extern DMA mode does not produce the correct result according to the datasheet [1]. Replacing that loop with a direct calculation using LOG2 to correctly assign the burst length in the GAHBCFG register for external DMA mode.
[1] https://rockchip.fr/RK312X%20TRM/chapter-26-usb-otg-2-0.pdf#page=24
---
Additionally, the boards I have only use internal DMA mode, and it’s unclear which chips employ external DMA. The testing was performed by comparing against the datasheet, and the results are shown in [2].
[2] https://gist.github.com/Judehahh/34530da390b58728102778406e602cb1
--- drivers/usb/host/dwc2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/host/dwc2.c +2 -5
@@ -448,11 +448,8 @@ static void dwc_otg_core_init(struct udevice *dev)case DWC2_HWCFG2_ARCHITECTURE_SLAVE_ONLY :break ;case DWC2_HWCFG2_ARCHITECTURE_EXT_DMA : -while (brst_sz >1 ) { - ahbcfg |= ahbcfg + (1 <<DWC2_GAHBCFG_HBURSTLEN_OFFSET ); - ahbcfg &=DWC2_GAHBCFG_HBURSTLEN_MASK ; - brst_sz >>=1 ; - } + ahbcfg |= (LOG2 (brst_sz >>1 ) <<DWC2_GAHBCFG_HBURSTLEN_OFFSET ) & +DWC2_GAHBCFG_HBURSTLEN_MASK ;#ifdef DWC2_DMA_ENABLE ahbcfg |=DWC2_GAHBCFG_DMAENABLE ;
Signature · 1 line
2.47.1
PATCH v4 4/8 usb: dwc2: Clean up with bitfield macros
In reply to Junhui LiuFrom: Kongyang Liu <[email protected]>
Use FIELD_PREP, FIELD_GET, BIT, and GENMASK macros to standardize bit manipulation across the DWC2 code, improving readability and maintainability without altering functionality.
--- drivers/usb/gadget/dwc2_udc_otg.c | 5 +- drivers/usb/gadget/dwc2_udc_otg_regs.h | 250 ++++---- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 21 +- drivers/usb/host/dwc2.c | 101 ++- drivers/usb/host/dwc2.h | 993 ++++++++++------------------- 5 files changed, 517 insertions(+), 853 deletions(-)
drivers/usb/gadget/dwc2_udc_otg.c +3 -2
@@ -29,6 +29,7 @@#include <linux/delay.h> #include <linux/printk.h> +#include <linux/bitfield.h> #include <linux/errno.h> #include <linux/list.h>
@@ -526,8 +527,8 @@ static void reconfig_usbd(struct dwc2_udc *dev) }/* 8. Unmask EPO interrupts*/ -writel (((1 <<EP0_CON ) <<DAINT_OUT_BIT ) - | (1 <<EP0_CON ), ®->device_regs.daintmsk); +writel (FIELD_PREP (DAINT_OUTEP_MASK ,BIT (EP0_CON )) | +FIELD_PREP (DAINT_INEP_MASK ,BIT (EP0_CON )), ®->device_regs.daintmsk);/* 9. Unmask device OUT EP common interrupts*/ writel (DOEPMSK_INIT , ®->device_regs.doepmsk);
drivers/usb/gadget/dwc2_udc_otg_regs.h +123 -127
316 lines not on this page · raw message
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +11 -10
@@ -19,6 +19,7 @@#include <cpu_func.h> #include <log.h> +#include <linux/bitfield.h> #include <linux/bug.h> static u8 clear_feature_num;
@@ -174,11 +175,11 @@ static int setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req) ctrl =readl (®->device_regs.in_endp[ep_num].diepctl);/* Write the FIFO number to be used for this endpoint */ - ctrl &=DIEPCTL_TX_FIFO_NUM_MASK ; - ctrl |=DIEPCTL_TX_FIFO_NUM (ep->fifo_num); + ctrl &= ~DIEPCTL_TX_FIFO_NUM_MASK ; + ctrl |=FIELD_PREP (DIEPCTL_TX_FIFO_NUM_MASK , ep->fifo_num);/* Clear reserved (Next EP) bits */ - ctrl = (ctrl&~(EP_MASK <<DEPCTL_NEXT_EP_BIT )); + ctrl &= ~DEPCTL_NEXT_EP_MASK ;writel (DEPCTL_EPENA |DEPCTL_CNAK | ctrl, ®->device_regs.in_endp[ep_num].diepctl);
@@ -380,7 +381,7 @@ static void process_ep_in_intr(struct dwc2_udc *dev)debug_cond (DEBUG_IN_EP ,"*** %s: EP In interrupt : DAINT = 0x%x\n" , __func__, ep_intr); - ep_intr &=DAINT_MASK ; + ep_intr =FIELD_GET (DAINT_INEP_MASK , ep_intr);while (ep_intr) {if (ep_intr &DAINT_IN_EP_INT (1 )) {
@@ -431,10 +432,10 @@ static void process_ep_out_intr(struct dwc2_udc *dev)"*** %s: EP OUT interrupt : DAINT = 0x%x\n" , __func__, ep_intr); - ep_intr = (ep_intr >>DAINT_OUT_BIT ) &DAINT_MASK ; + ep_intr =FIELD_GET (DAINT_OUTEP_MASK , ep_intr);while (ep_intr) { -if (ep_intr &0x1 ) { +if (ep_intr &BIT (EP0_CON )) { ep_intr_status =readl (®->device_regs.out_endp[ep_num].doepint); debug_cond(DEBUG_OUT_EP != 0, "\tEP%d-OUT : DOEPINT = 0x%x\n",
@@ -1114,10 +1115,10 @@ static void dwc2_udc_ep_activate(struct dwc2_ep *ep)/* Read DEPCTLn register */ if (ep_is_in (ep)) { ep_ctrl =readl (®->device_regs.in_endp[ep_num].diepctl); - daintmsk =1 << ep_num; + daintmsk =FIELD_PREP (DAINT_INEP_MASK ,BIT (ep_num)); }else { ep_ctrl =readl (®->device_regs.out_endp[ep_num].doepctl); - daintmsk = (1 << ep_num) <<DAINT_OUT_BIT ; + daintmsk =FIELD_PREP (DAINT_OUTEP_MASK ,BIT (ep_num)); } debug("%s: EPCTRL%d = 0x%x, ep_is_in = %d\n",
@@ -1127,9 +1128,9 @@ static void dwc2_udc_ep_activate(struct dwc2_ep *ep)* register. */ if (!(ep_ctrl &DEPCTL_USBACTEP )) { ep_ctrl = (ep_ctrl & ~DEPCTL_TYPE_MASK ) | - (ep->bmAttributes <<DEPCTL_TYPE_BIT ); +FIELD_PREP (DEPCTL_TYPE_MASK , ep->bmAttributes); ep_ctrl = (ep_ctrl & ~DEPCTL_MPS_MASK ) | - (ep->ep.maxpacket <<DEPCTL_MPS_BIT ); +FIELD_PREP (DEPCTL_MPS_MASK , ep->ep.maxpacket); ep_ctrl |= (DEPCTL_SETD0PID |DEPCTL_USBACTEP |DEPCTL_SNAK );if (ep_is_in (ep)) {
drivers/usb/host/dwc2.c +46 -55
222 lines not on this page · raw message
drivers/usb/host/dwc2.h +334 -659
1,030 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH v4 5/8 usb: dwc2: Align macros with Linux kernel definitions
In reply to Junhui LiuFrom: Kongyang Liu <[email protected]>
Update the DWC2 macros to match those used in the Linux kernel, making it easier to synchronize updates with kernel. Also removed some unused macros to cleanup the code.
--- drivers/usb/gadget/dwc2_udc_otg.c | 62 +-- drivers/usb/gadget/dwc2_udc_otg_regs.h | 243 ++++++----- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 130 +++--- drivers/usb/host/dwc2.c | 260 ++++++------ drivers/usb/host/dwc2.h | 638 +++++++++++++---------------- 5 files changed, 632 insertions(+), 701 deletions(-)
drivers/usb/gadget/dwc2_udc_otg.c +33 -29
@@ -160,7 +160,7 @@ struct dwc2_core_regs *reg;bool dfu_usb_get_reset (void ) { -return !!(readl (®->global_regs.gintsts) &INT_RESET ); +return !!(readl (®->global_regs.gintsts) &GINTSTS_USBRST ); }__weak void otg_phy_init (struct dwc2_udc *dev) {}
@@ -240,8 +240,8 @@ static int udc_enable(struct dwc2_udc *dev)static int dwc2_gadget_pullup (struct usb_gadget *g,int is_on) { -clrsetbits_le32 (®->device_regs.dctl,SOFT_DISCONNECT , - is_on ?0 :SOFT_DISCONNECT ); +clrsetbits_le32 (®->device_regs.dctl,DCTL_SFTDISCON , + is_on ?0 :DCTL_SFTDISCON );return 0 ; }
@@ -471,7 +471,7 @@ static void reconfig_usbd(struct dwc2_udc *dev)u32 max_hw_ep;int pdata_hw_ep; -writel (CORE_SOFT_RESET , ®->global_regs.grstctl); +writel (GRSTCTL_CSFTRST , ®->global_regs.grstctl);debug ("Resetting OTG controller\n" );
@@ -498,19 +498,20 @@ static void reconfig_usbd(struct dwc2_udc *dev)/* 3. Put the OTG device core in the disconnected state.*/ uTemp =readl (®->device_regs.dctl); - uTemp |=SOFT_DISCONNECT ; + uTemp |=DCTL_SFTDISCON ;writel (uTemp, ®->device_regs.dctl);udelay (20 );/* 4. Make the OTG device core exit from the disconnected state.*/ uTemp =readl (®->device_regs.dctl); - uTemp = uTemp & ~SOFT_DISCONNECT ; + uTemp = uTemp & ~DCTL_SFTDISCON ;writel (uTemp, ®->device_regs.dctl);/* 5. Configure OTG Core to initial settings of device mode.*/ /* [][1: full speed(30Mhz) 0:high speed]*/ -writel (EP_MISS_CNT (1 ) |DEV_SPEED_HIGH_SPEED_20 , ®->device_regs.dcfg); +writel (FIELD_PREP (DCFG_EPMISCNT_MASK ,1 ) | +FIELD_PREP (DCFG_DEVSPD_MASK ,DCFG_DEVSPD_HS ), ®->device_regs.dcfg);mdelay (1 );
@@ -518,12 +519,12 @@ static void reconfig_usbd(struct dwc2_udc *dev)writel (GINTMSK_INIT , ®->global_regs.gintmsk);/* 7. Set NAK bit of EP0, EP1, EP2*/ -writel (DEPCTL_EPDIS |DEPCTL_SNAK , ®->device_regs.out_endp[EP0_CON ].doepctl); -writel (DEPCTL_EPDIS |DEPCTL_SNAK , ®->device_regs.in_endp[EP0_CON ].diepctl); +writel (DXEPCTL_EPDIS |DXEPCTL_SNAK , ®->device_regs.out_endp[EP0_CON ].doepctl); +writel (DXEPCTL_EPDIS |DXEPCTL_SNAK , ®->device_regs.in_endp[EP0_CON ].diepctl);for (i =1 ; i <DWC2_MAX_ENDPOINTS ; i++) { -writel (DEPCTL_EPDIS |DEPCTL_SNAK , ®->device_regs.out_endp[i].doepctl); -writel (DEPCTL_EPDIS |DEPCTL_SNAK , ®->device_regs.in_endp[i].diepctl); +writel (DXEPCTL_EPDIS |DXEPCTL_SNAK , ®->device_regs.out_endp[i].doepctl); +writel (DXEPCTL_EPDIS |DXEPCTL_SNAK , ®->device_regs.in_endp[i].diepctl); }/* 8. Unmask EPO interrupts*/
@@ -551,12 +552,12 @@ static void reconfig_usbd(struct dwc2_udc *dev)writel (rx_fifo_sz, ®->global_regs.grxfsiz);/* 12. Set Non Periodic Tx FIFO Size */ -writel ((np_tx_fifo_sz <<16 ) | rx_fifo_sz, +writel (FIELD_PREP (FIFOSIZE_DEPTH_MASK , np_tx_fifo_sz) | +FIELD_PREP (FIFOSIZE_STARTADDR_MASK , rx_fifo_sz), ®->global_regs.gnptxfsiz);/* retrieve the number of IN Endpoints (excluding ep0) */ - max_hw_ep = (readl (®->global_regs.ghwcfg4) &GHWCFG4_NUM_IN_EPS_MASK ) >> -GHWCFG4_NUM_IN_EPS_SHIFT ; + max_hw_ep =FIELD_GET (GHWCFG4_NUM_IN_EPS_MASK ,readl (®->global_regs.ghwcfg4)); pdata_hw_ep = dev->pdata->tx_fifo_sz_nb;/* tx_fifo_sz_nb should equal to number of IN Endpoint */
@@ -568,24 +569,27 @@ static void reconfig_usbd(struct dwc2_udc *dev)if (pdata_hw_ep) tx_fifo_sz = dev->pdata->tx_fifo_sz_array[i]; -writel ((rx_fifo_sz + np_tx_fifo_sz + (tx_fifo_sz * i)) | - tx_fifo_sz <<16 , ®->global_regs.dptxfsizn[i]); +writel (FIELD_PREP (FIFOSIZE_DEPTH_MASK , tx_fifo_sz) | +FIELD_PREP (FIFOSIZE_STARTADDR_MASK , + rx_fifo_sz + np_tx_fifo_sz + tx_fifo_sz * i), + ®->global_regs.dptxfsizn[i]); }/* Flush the RX FIFO */ -writel (RX_FIFO_FLUSH , ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &RX_FIFO_FLUSH ) +writel (GRSTCTL_RXFFLSH , ®->global_regs.grstctl); +while (readl (®->global_regs.grstctl) &GRSTCTL_RXFFLSH )debug ("%s: waiting for DWC2_UDC_OTG_GRSTCTL\n" , __func__);/* Flush all the Tx FIFO's */ -writel (TX_FIFO_FLUSH_ALL , ®->global_regs.grstctl); -writel (TX_FIFO_FLUSH_ALL |TX_FIFO_FLUSH , ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &TX_FIFO_FLUSH ) +writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK ,GRSTCTL_TXFNUM_ALL ), ®->global_regs.grstctl); +writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK ,GRSTCTL_TXFNUM_ALL ) |GRSTCTL_TXFFLSH , + ®->global_regs.grstctl); +while (readl (®->global_regs.grstctl) &GRSTCTL_TXFFLSH )debug ("%s: waiting for DWC2_UDC_OTG_GRSTCTL\n" , __func__);/* 13. Clear NAK bit of EP0, EP1, EP2*/ /* For Slave mode*/ /* EP0: Control OUT */ -writel (DEPCTL_EPDIS |DEPCTL_CNAK , +writel (DXEPCTL_EPDIS |DXEPCTL_CNAK , ®->device_regs.out_endp[EP0_CON ].doepctl);/* 14. Initialize OTG Link Core.*/
@@ -1127,8 +1131,8 @@ static int dwc2_udc_otg_probe(struct udevice *dev)if (plat->force_b_session_valid && !plat->force_vbus_detection) {/* Override VBUS detection: enable then value*/ -setbits_le32 (&usbotg_reg->global_regs.gotgctl,VB_VALOEN ); -setbits_le32 (&usbotg_reg->global_regs.gotgctl,VB_VALOVAL ); +setbits_le32 (&usbotg_reg->global_regs.gotgctl,GOTGCTL_VBVALOEN ); +setbits_le32 (&usbotg_reg->global_regs.gotgctl,GOTGCTL_VBVALOVAL ); }else {/* Enable VBUS sensing */ setbits_le32(&usbotg_reg->global_regs.ggpio,
@@ -1137,9 +1141,9 @@ static int dwc2_udc_otg_probe(struct udevice *dev)if (plat->force_b_session_valid) {/* Override B session bits: enable then value */ setbits_le32 (&usbotg_reg->global_regs.gotgctl, -A_VALOEN |B_VALOEN ); +GOTGCTL_AVALOEN |GOTGCTL_BVALOEN );setbits_le32 (&usbotg_reg->global_regs.gotgctl, -A_VALOVAL |B_VALOVAL ); +GOTGCTL_AVALOVAL |GOTGCTL_BVALOVAL ); }else {/* Enable ID detection */ setbits_le32(&usbotg_reg->global_regs.ggpio,
@@ -1205,10 +1209,10 @@ U_BOOT_DRIVER(dwc2_udc_otg) = {int dwc2_udc_B_session_valid (struct udevice *dev) {struct dwc2_plat_otg_data *plat =dev_get_plat (dev); -struct dwc2_usbotg_reg *usbotg_reg = - (struct dwc2_usbotg_reg *)plat->regs_otg; +struct dwc2_core_regs *usbotg_reg = + (struct dwc2_core_regs *)plat->regs_otg; -return readl (&usbotg_reg->gotgctl) &B_SESSION_VALID ; +return readl (&usbotg_reg->global_regs.gotgctl) &GOTGCTL_BSESVLD ; }#else int dm_usb_gadget_handle_interrupts (struct udevice *dev)
drivers/usb/gadget/dwc2_udc_otg_regs.h +119 -124
292 lines not on this page · raw message
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +66 -64
346 lines not on this page · raw message
drivers/usb/host/dwc2.c +126 -134
551 lines not on this page · raw message
drivers/usb/host/dwc2.h +288 -350
644 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH v4 6/8 usb: dwc2: Extract macro definitions to common header
In reply to Junhui LiuFrom: Kongyang Liu <[email protected]>
Some macros are shared between host and gadget code, causing duplicated definitions. Move DWC2 macro definitions from host and gadget code into a common header to reduce duplication.
--- drivers/usb/common/dwc2_core.h | 430 +++++++++++++++++++++++++++++++++ drivers/usb/gadget/dwc2_udc_otg_regs.h | 154 +----------- drivers/usb/host/dwc2.h | 291 ---------------------- 3 files changed, 431 insertions(+), 444 deletions(-)
drivers/usb/common/dwc2_core.h +430 -0
@@ -7,6 +7,8 @@ #ifndef __DWC2_CORE_H_ #define __DWC2_CORE_H_ +#include <linux/bitops.h> + struct dwc2_global_regs { u32 gotgctl; /* 0x000 */ u32 gotgint;
@@ -123,4 +125,432 @@ struct dwc2_core_regs {u8 ep_fifo[16 ][0x1000 ];/* 0x1000 */ }; +/* Core Global Register */ +#define GOTGCTL_CHIRPEN BIT(27) +#define GOTGCTL_MULT_VALID_BC_MASK GENMASK(26, 22) +#define GOTGCTL_CURMODE_HOST BIT(21) +#define GOTGCTL_OTGVER BIT(20) +#define GOTGCTL_BSESVLD BIT(19) +#define GOTGCTL_ASESVLD BIT(18) +#define GOTGCTL_DBNC_SHORT BIT(17) +#define GOTGCTL_CONID_B BIT(16) +#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) +#define GOTGCTL_DEVHNPEN BIT(11) +#define GOTGCTL_HSTSETHNPEN BIT(10) +#define GOTGCTL_HNPREQ BIT(9) +#define GOTGCTL_HSTNEGSCS BIT(8) +#define GOTGCTL_BVALOVAL BIT(7) +#define GOTGCTL_BVALOEN BIT(6) +#define GOTGCTL_AVALOVAL BIT(5) +#define GOTGCTL_AVALOEN BIT(4) +#define GOTGCTL_VBVALOVAL BIT(3) +#define GOTGCTL_VBVALOEN BIT(2) +#define GOTGCTL_SESREQ BIT(1) +#define GOTGCTL_SESREQSCS BIT(0) + +#define GOTGINT_DBNCE_DONE BIT(19) +#define GOTGINT_A_DEV_TOUT_CHG BIT(18) +#define GOTGINT_HST_NEG_DET BIT(17) +#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) +#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) +#define GOTGINT_SES_END_DET BIT(2) + +#define GAHBCFG_AHB_SINGLE BIT(23) +#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) +#define GAHBCFG_REM_MEM_SUPP BIT(21) +#define GAHBCFG_P_TXF_EMP_LVL BIT(8) +#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) +#define GAHBCFG_DMA_EN BIT(5) +#define GAHBCFG_HBSTLEN_MASK GENMASK(4, 1) +#define GAHBCFG_HBSTLEN_SINGLE 0 +#define GAHBCFG_HBSTLEN_INCR 1 +#define GAHBCFG_HBSTLEN_INCR4 3 +#define GAHBCFG_HBSTLEN_INCR8 5 +#define GAHBCFG_HBSTLEN_INCR16 7 +#define GAHBCFG_GLBL_INTR_EN BIT(0) +#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ + GAHBCFG_NP_TXF_EMP_LVL | \ + GAHBCFG_DMA_EN | \ + GAHBCFG_GLBL_INTR_EN) + +#define GUSBCFG_FORCEDEVMODE BIT(30) +#define GUSBCFG_FORCEHOSTMODE BIT(29) +#define GUSBCFG_TXENDDELAY BIT(28) +#define GUSBCFG_ICTRAFFICPULLREMOVE BIT(27) +#define GUSBCFG_ICUSBCAP BIT(26) +#define GUSBCFG_ULPI_INT_PROT_DIS BIT(25) +#define GUSBCFG_INDICATORPASSTHROUGH BIT(24) +#define GUSBCFG_INDICATORCOMPLEMENT BIT(23) +#define GUSBCFG_TERMSELDLPULSE BIT(22) +#define GUSBCFG_ULPI_INT_VBUS_IND BIT(21) +#define GUSBCFG_ULPI_EXT_VBUS_DRV BIT(20) +#define GUSBCFG_ULPI_CLK_SUSP_M BIT(19) +#define GUSBCFG_ULPI_AUTO_RES BIT(18) +#define GUSBCFG_ULPI_FS_LS BIT(17) +#define GUSBCFG_OTG_UTMI_FS_SEL BIT(16) +#define GUSBCFG_PHY_LP_CLK_SEL BIT(15) +#define GUSBCFG_USBTRDTIM_MASK GENMASK(14, 10) +#define GUSBCFG_HNPCAP BIT(9) +#define GUSBCFG_SRPCAP BIT(8) +#define GUSBCFG_DDRSEL BIT(7) +#define GUSBCFG_PHYSEL BIT(6) +#define GUSBCFG_FSINTF BIT(5) +#define GUSBCFG_ULPI_UTMI_SEL BIT(4) +#define GUSBCFG_PHYIF16 BIT(3) +#define GUSBCFG_TOUTCAL_MASK GENMASK(2, 0) + +#define GRSTCTL_AHBIDLE BIT(31) +#define GRSTCTL_DMAREQ BIT(30) +#define GRSTCTL_CSFTRST_DONE BIT(29) +#define GRSTCTL_TXFNUM_MASK GENMASK(10, 6) +#define GRSTCTL_TXFFLSH BIT(5) +#define GRSTCTL_RXFFLSH BIT(4) +#define GRSTCTL_IN_TKNQ_FLSH BIT(3) +#define GRSTCTL_FRMCNTRRST BIT(2) +#define GRSTCTL_HSFTRST BIT(1) +#define GRSTCTL_CSFTRST BIT(0) +#define GRSTCTL_TXFNUM_ALL 0x10 + +#define GINTSTS_WKUPINT BIT(31) +#define GINTSTS_SESSREQINT BIT(30) +#define GINTSTS_DISCONNINT BIT(29) +#define GINTSTS_CONIDSTSCHNG BIT(28) +#define GINTSTS_LPMTRANRCVD BIT(27) +#define GINTSTS_PTXFEMP BIT(26) +#define GINTSTS_HCHINT BIT(25) +#define GINTSTS_PRTINT BIT(24) +#define GINTSTS_RESETDET BIT(23) +#define GINTSTS_FET_SUSP BIT(22) +#define GINTSTS_INCOMPL_IP BIT(21) +#define GINTSTS_INCOMPL_SOOUT BIT(21) +#define GINTSTS_INCOMPL_SOIN BIT(20) +#define GINTSTS_OEPINT BIT(19) +#define GINTSTS_IEPINT BIT(18) +#define GINTSTS_EPMIS BIT(17) +#define GINTSTS_RESTOREDONE BIT(16) +#define GINTSTS_EOPF BIT(15) +#define GINTSTS_ISOUTDROP BIT(14) +#define GINTSTS_ENUMDONE BIT(13) +#define GINTSTS_USBRST BIT(12) +#define GINTSTS_USBSUSP BIT(11) +#define GINTSTS_ERLYSUSP BIT(10) +#define GINTSTS_I2CINT BIT(9) +#define GINTSTS_ULPI_CK_INT BIT(8) +#define GINTSTS_GOUTNAKEFF BIT(7) +#define GINTSTS_GINNAKEFF BIT(6) +#define GINTSTS_NPTXFEMP BIT(5) +#define GINTSTS_RXFLVL BIT(4) +#define GINTSTS_SOF BIT(3) +#define GINTSTS_OTGINT BIT(2) +#define GINTSTS_MODEMIS BIT(1) +#define GINTSTS_CURMODE_HOST BIT(0) + +#define GRXSTS_FN_MASK GENMASK(31, 25) +#define GRXSTS_PKTSTS_MASK GENMASK(20, 17) +#define GRXSTS_PKTSTS_GLOBALOUTNAK 1 +#define GRXSTS_PKTSTS_OUTRX 2 +#define GRXSTS_PKTSTS_HCHIN 2 +#define GRXSTS_PKTSTS_OUTDONE 3 +#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3 +#define GRXSTS_PKTSTS_SETUPDONE 4 +#define GRXSTS_PKTSTS_DATATOGGLEERR 5 +#define GRXSTS_PKTSTS_SETUPRX 6 +#define GRXSTS_PKTSTS_HCHHALTED 7 +#define GRXSTS_DPID_MASK GENMASK(16, 15) +#define GRXSTS_BYTECNT_MASK GENMASK(14, 4) +#define GRXSTS_HCHNUM_MASK GENMASK(3, 0) + +#define GRXFSIZ_DEPTH_MASK GENMASK(15, 0) + +#define GI2CCTL_BSYDNE BIT(31) +#define GI2CCTL_RW BIT(30) +#define GI2CCTL_I2CDATSE0 BIT(28) +#define GI2CCTL_I2CDEVADDR_MASK GENMASK(27, 26) +#define GI2CCTL_I2CSUSPCTL BIT(25) +#define GI2CCTL_ACK BIT(24) +#define GI2CCTL_I2CEN BIT(23) +#define GI2CCTL_ADDR_MASK GENMASK(22, 16) +#define GI2CCTL_REGADDR_MASK GENMASK(15, 8) +#define GI2CCTL_RWDATA_MASK GENMASK(7, 0) + +#define GGPIO_STM32_OTG_GCCFG_IDEN BIT(22) +#define GGPIO_STM32_OTG_GCCFG_VBDEN BIT(21) +#define GGPIO_STM32_OTG_GCCFG_PWRDWN BIT(16) + +#define GSNPSID_ID_MASK GENMASK(31, 16) +#define GSNPSID_OTG_ID 0x4f54 +#define GSNPSID_VER_MASK GENMASK(15, 0) + +#define GHWCFG2_OTG_ENABLE_IC_USB BIT(31) +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK GENMASK(30, 26) +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK GENMASK(25, 24) +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK GENMASK(23, 22) +#define GHWCFG2_MULTI_PROC_INT BIT(20) +#define GHWCFG2_DYNAMIC_FIFO BIT(19) +#define GHWCFG2_PERIO_EP_SUPPORTED BIT(18) +#define GHWCFG2_NUM_HOST_CHAN_MASK GENMASK(17, 14) +#define GHWCFG2_NUM_DEV_EP_MASK GENMASK(13, 10) +#define GHWCFG2_FS_PHY_TYPE_MASK GENMASK(9, 8) +#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 +#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 +#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 +#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 +#define GHWCFG2_HS_PHY_TYPE_MASK GENMASK(7, 6) +#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 +#define GHWCFG2_HS_PHY_TYPE_UTMI 1 +#define GHWCFG2_HS_PHY_TYPE_ULPI 2 +#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 +#define GHWCFG2_POINT2POINT BIT(5) +#define GHWCFG2_ARCHITECTURE_MASK GENMASK(4, 3) +#define GHWCFG2_SLAVE_ONLY_ARCH 0 +#define GHWCFG2_EXT_DMA_ARCH 1 +#define GHWCFG2_INT_DMA_ARCH 2 +#define GHWCFG2_OP_MODE_MASK GENMASK(2, 0) +#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 +#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 +#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 +#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 +#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 +#define GHWCFG2_OP_MODE_UNDEFINED 7 + +#define GHWCFG4_DESC_DMA_DYN BIT(31) +#define GHWCFG4_DESC_DMA BIT(30) +#define GHWCFG4_NUM_IN_EPS_MASK GENMASK(29, 26) +#define GHWCFG4_DED_FIFO_EN BIT(25) +#define GHWCFG4_SESSION_END_FILT_EN BIT(24) +#define GHWCFG4_B_VALID_FILT_EN BIT(23) +#define GHWCFG4_A_VALID_FILT_EN BIT(22) +#define GHWCFG4_VBUS_VALID_FILT_EN BIT(21) +#define GHWCFG4_IDDIG_FILT_EN BIT(20) +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK GENMASK(19, 16) +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK GENMASK(15, 14) +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 +#define GHWCFG4_ACG_SUPPORTED BIT(12) +#define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) +#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) +#define GHWCFG4_XHIBER BIT(7) +#define GHWCFG4_HIBER BIT(6) +#define GHWCFG4_MIN_AHB_FREQ BIT(5) +#define GHWCFG4_POWER_OPTIMIZ BIT(4) +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK GENMASK(3, 0) + +#define FIFOSIZE_DEPTH_MASK GENMASK(31, 16) +#define FIFOSIZE_STARTADDR_MASK GENMASK(15, 0) + +/* Host Register */ +#define HCFG_MODECHTIMEN BIT(31) +#define HCFG_PERSCHEDENA BIT(26) +#define HCFG_FRLISTEN_MASK GENMASK(25, 24) +#define HCFG_FRLISTEN_8 0 +#define HCFG_FRLISTEN_16 1 +#define HCFG_FRLISTEN_32 2 +#define HCFG_FRLISTEN_64 3 +#define HCFG_DESCDMA BIT(23) +#define HCFG_RESVALID_MASK GENMASK(15, 8) +#define HCFG_ENA32KHZ BIT(7) +#define HCFG_FSLSSUPP BIT(2) +#define HCFG_FSLSPCLKSEL_MASK GENMASK(2, 0) +#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 +#define HCFG_FSLSPCLKSEL_48_MHZ 1 +#define HCFG_FSLSPCLKSEL_6_MHZ 2 + +#define HFNUM_FRREM_MASK GENMASK(31, 16) +#define HFNUM_FRNUM_MASK GENMASK(15, 0) + +#define HPRT0_SPD_MASK GENMASK(18, 17) +#define HPRT0_SPD_HIGH_SPEED 0 +#define HPRT0_SPD_FULL_SPEED 1 +#define HPRT0_SPD_LOW_SPEED 2 +#define HPRT0_TSTCTL_MASK GENMASK(16, 13) +#define HPRT0_PWR BIT(12) +#define HPRT0_LNSTS_MASK GENMASK(11, 10) +#define HPRT0_RST BIT(8) +#define HPRT0_SUSP BIT(7) +#define HPRT0_RES BIT(6) +#define HPRT0_OVRCURRCHG BIT(5) +#define HPRT0_OVRCURRACT BIT(4) +#define HPRT0_ENACHG BIT(3) +#define HPRT0_ENA BIT(2) +#define HPRT0_CONNDET BIT(1) +#define HPRT0_CONNSTS BIT(0) +#define HPRT0_W1C_MASK (HPRT0_CONNDET | \ + HPRT0_ENA | \ + HPRT0_ENACHG | \ + HPRT0_OVRCURRCHG) + +#define HCCHAR_CHENA BIT(31) +#define HCCHAR_CHDIS BIT(30) +#define HCCHAR_ODDFRM BIT(29) +#define HCCHAR_DEVADDR_MASK GENMASK(28, 22) +#define HCCHAR_MULTICNT_MASK GENMASK(21, 20) +#define HCCHAR_EPTYPE_MASK GENMASK(19, 18) +#define HCCHAR_EPTYPE_CONTROL 0 +#define HCCHAR_EPTYPE_ISOC 1 +#define HCCHAR_EPTYPE_BULK 2 +#define HCCHAR_EPTYPE_INTR 3 +#define HCCHAR_LSPDDEV BIT(17) +#define HCCHAR_EPDIR BIT(15) +#define HCCHAR_EPNUM_MASK GENMASK(14, 11) +#define HCCHAR_MPS_MASK GENMASK(10, 0) + +#define HCSPLT_SPLTENA BIT(31) +#define HCSPLT_COMPSPLT BIT(16) +#define HCSPLT_XACTPOS_MASK GENMASK(15, 14) +#define HCSPLT_XACTPOS_MID 0 +#define HCSPLT_XACTPOS_END 1 +#define HCSPLT_XACTPOS_BEGIN 2 +#define HCSPLT_XACTPOS_ALL 3 +#define HCSPLT_HUBADDR_MASK GENMASK(13, 7) +#define HCSPLT_PRTADDR_MASK GENMASK(6, 0) + +#define HCINTMSK_FRM_LIST_ROLL BIT(13) +#define HCINTMSK_XCS_XACT BIT(12) +#define HCINTMSK_BNA BIT(11) +#define HCINTMSK_DATATGLERR BIT(10) +#define HCINTMSK_FRMOVRUN BIT(9) +#define HCINTMSK_BBLERR BIT(8) +#define HCINTMSK_XACTERR BIT(7) +#define HCINTMSK_NYET BIT(6) +#define HCINTMSK_ACK BIT(5) +#define HCINTMSK_NAK BIT(4) +#define HCINTMSK_STALL BIT(3) +#define HCINTMSK_AHBERR BIT(2) +#define HCINTMSK_CHHLTD BIT(1) +#define HCINTMSK_XFERCOMPL BIT(0) + +#define TSIZ_DOPNG BIT(31) +#define TSIZ_SC_MC_PID_MASK GENMASK(30, 29) +#define TSIZ_SC_MC_PID_DATA0 0 +#define TSIZ_SC_MC_PID_DATA2 1 +#define TSIZ_SC_MC_PID_DATA1 2 +#define TSIZ_SC_MC_PID_MDATA 3 +#define TSIZ_SC_MC_PID_SETUP 3 +#define TSIZ_PKTCNT_MASK GENMASK(28, 19) +#define TSIZ_NTD_MASK GENMASK(15, 8) +#define TSIZ_SCHINFO_MASK GENMASK(7, 0) +#define TSIZ_XFERSIZE_MASK GENMASK(18, 0) + +/* Device Mode Register */ +#define DCFG_DESCDMA_EN BIT(23) +#define DCFG_EPMISCNT_MASK GENMASK(22, 18) +#define DCFG_IPG_ISOC_SUPPORDED BIT(17) +#define DCFG_PERFRINT_MASK GENMASK(12, 11) +#define DCFG_DEVADDR_MASK GENMASK(10, 4) +#define DCFG_NZ_STS_OUT_HSHK BIT(2) +#define DCFG_DEVSPD_MASK GENMASK(1, 0) +#define DCFG_DEVSPD_HS 0 +#define DCFG_DEVSPD_FS 1 +#define DCFG_DEVSPD_LS 2 +#define DCFG_DEVSPD_FS48 3 + +#define DCTL_SERVICE_INTERVAL_SUPPORTED BIT(19) +#define DCTL_PWRONPRGDONE BIT(11) +#define DCTL_CGOUTNAK BIT(10) +#define DCTL_SGOUTNAK BIT(9) +#define DCTL_CGNPINNAK BIT(8) +#define DCTL_SGNPINNAK BIT(7) +#define DCTL_TSTCTL_MASK GENMASK(6, 4) +#define DCTL_GOUTNAKSTS BIT(3) +#define DCTL_GNPINNAKSTS BIT(2) +#define DCTL_SFTDISCON BIT(1) +#define DCTL_RMTWKUPSIG BIT(0) + +#define DSTS_SOFFN_MASK GENMASK(21, 8) +#define DSTS_ERRATICERR BIT(3) +#define DSTS_ENUMSPD_MASK GENMASK(2, 1) +#define DSTS_ENUMSPD_HS 0 +#define DSTS_ENUMSPD_FS 1 +#define DSTS_ENUMSPD_LS 2 +#define DSTS_ENUMSPD_FS48 3 +#define DSTS_SUSPSTS BIT(0) + +#define DIEPMSK_NAKMSK BIT(13) +#define DIEPMSK_BNAININTRMSK BIT(9) +#define DIEPMSK_TXFIFOUNDRNMSK BIT(8) +#define DIEPMSK_TXFIFOEMPTY BIT(7) +#define DIEPMSK_INEPNAKEFFMSK BIT(6) +#define DIEPMSK_INTKNEPMISMSK BIT(5) +#define DIEPMSK_INTKNTXFEMPMSK BIT(4) +#define DIEPMSK_TIMEOUTMSK BIT(3) +#define DIEPMSK_AHBERRMSK BIT(2) +#define DIEPMSK_EPDISBLDMSK BIT(1) +#define DIEPMSK_XFERCOMPLMSK BIT(0) + +#define DOEPMSK_BNAMSK BIT(9) +#define DOEPMSK_BACK2BACKSETUP BIT(6) +#define DOEPMSK_STSPHSERCVDMSK BIT(5) +#define DOEPMSK_OUTTKNEPDISMSK BIT(4) +#define DOEPMSK_SETUPMSK BIT(3) +#define DOEPMSK_AHBERRMSK BIT(2) +#define DOEPMSK_EPDISBLDMSK BIT(1) +#define DOEPMSK_XFERCOMPLMSK BIT(0) + +#define DAINT_OUTEP_MASK GENMASK(31, 16) +#define DAINT_INEP_MASK GENMASK(15, 0) + +#define D0EPCTL_MPS_MASK GENMASK(1, 0) +#define D0EPCTL_MPS_64 0 +#define D0EPCTL_MPS_32 1 +#define D0EPCTL_MPS_16 2 +#define D0EPCTL_MPS_8 3 + +#define DXEPCTL_EPENA BIT(31) +#define DXEPCTL_EPDIS BIT(30) +#define DXEPCTL_SETD1PID BIT(29) +#define DXEPCTL_SETODDFR BIT(29) +#define DXEPCTL_SETD0PID BIT(28) +#define DXEPCTL_SETEVENFR BIT(28) +#define DXEPCTL_SNAK BIT(27) +#define DXEPCTL_CNAK BIT(26) +#define DXEPCTL_TXFNUM_MASK GENMASK(25, 22) +#define DXEPCTL_STALL BIT(21) +#define DXEPCTL_SNP BIT(20) +#define DXEPCTL_EPTYPE_MASK GENMASK(19, 18) +#define DXEPCTL_EPTYPE_CONTROL 0 +#define DXEPCTL_EPTYPE_ISO 1 +#define DXEPCTL_EPTYPE_BULK 2 +#define DXEPCTL_EPTYPE_INTERRUPT 3 +#define DXEPCTL_NAKSTS BIT(17) +#define DXEPCTL_DPID BIT(16) +#define DXEPCTL_EOFRNUM BIT(16) +#define DXEPCTL_USBACTEP BIT(15) +#define DXEPCTL_NEXTEP_MASK GENMASK(14, 11) +#define DXEPCTL_MPS_MASK GENMASK(10, 0) + +#define DXEPINT_SETUP_RCVD BIT(15) +#define DXEPINT_NYETINTRPT BIT(14) +#define DXEPINT_NAKINTRPT BIT(13) +#define DXEPINT_BBLEERRINTRPT BIT(12) +#define DXEPINT_PKTDRPSTS BIT(11) +#define DXEPINT_BNAINTR BIT(9) +#define DXEPINT_TXFIFOUNDRN BIT(8) +#define DXEPINT_OUTPKTERR BIT(8) +#define DXEPINT_TXFEMP BIT(7) +#define DXEPINT_INEPNAKEFF BIT(6) +#define DXEPINT_BACK2BACKSETUP BIT(6) +#define DXEPINT_INTKNEPMIS BIT(5) +#define DXEPINT_STSPHSERCVD BIT(5) +#define DXEPINT_INTKNTXFEMP BIT(4) +#define DXEPINT_OUTTKNEPDIS BIT(4) +#define DXEPINT_TIMEOUT BIT(3) +#define DXEPINT_SETUP BIT(3) +#define DXEPINT_AHBERR BIT(2) +#define DXEPINT_EPDISBLD BIT(1) +#define DXEPINT_XFERCOMPL BIT(0) + +#define DIEPTSIZ0_PKTCNT_MASK GENMASK(20, 19) +#define DIEPTSIZ0_XFERSIZE_MASK GENMASK(6, 0) + +#define DOEPTSIZ0_SUPCNT_MASK GENMASK(30, 29) +#define DOEPTSIZ0_PKTCNT BIT(19) +#define DOEPTSIZ0_XFERSIZE_MASK GENMASK(6, 0) + +#define DXEPTSIZ_MC_MASK GENMASK(30, 29) +#define DXEPTSIZ_PKTCNT_MASK GENMASK(28, 19) +#define DXEPTSIZ_XFERSIZE_MASK GENMASK(18, 0) +#endif /* __DWC2_CORE_H_ */
drivers/usb/gadget/dwc2_udc_otg_regs.h +1 -153
182 lines not on this page · raw message
drivers/usb/host/dwc2.h +0 -291
297 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH v4 6/8] usb: dwc2: Extract macro definitions to common header
Hi Junhui,
Thank you for the patch.
Quoted 10 lines · Junhui Liu
From: Kongyang Liu <[email protected]>
Some macros are shared between host and gadget code, causing duplicated definitions. Move DWC2 macro definitions from host and gadget code into a common header to reduce duplication.
Signed-off-by Kongyang Liu <[email protected]>Reviewed-by Marek Vasut <[email protected]>Tested-by Peter Robinson <[email protected]>Signed-off-by Junhui Liu <[email protected]>
Quoted 948 lines
--- drivers/usb/common/dwc2_core.h | 430 +++++++++++++++++++++++++++++++++ drivers/usb/gadget/dwc2_udc_otg_regs.h | 154 +----------- drivers/usb/host/dwc2.h | 291 ---------------------- 3 files changed, 431 insertions(+), 444 deletions(-)drivers/usb/common/dwc2_core.h +430
-0@@ -7,6 +7,8 @@ #ifndef __DWC2_CORE_H_ #define __DWC2_CORE_H_ +#include <linux/bitops.h> + struct dwc2_global_regs { u32 gotgctl; /* 0x000 */ u32 gotgint;@@ -123,4 +125,432 @@ struct dwc2_core_regs {u8 ep_fifo[16 ][0x1000 ];/* 0x1000 */ }; +/* Core Global Register */ +#define GOTGCTL_CHIRPEN BIT(27) +#define GOTGCTL_MULT_VALID_BC_MASK GENMASK(26, 22) +#define GOTGCTL_CURMODE_HOST BIT(21) +#define GOTGCTL_OTGVER BIT(20) +#define GOTGCTL_BSESVLD BIT(19) +#define GOTGCTL_ASESVLD BIT(18) +#define GOTGCTL_DBNC_SHORT BIT(17) +#define GOTGCTL_CONID_B BIT(16) +#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) +#define GOTGCTL_DEVHNPEN BIT(11) +#define GOTGCTL_HSTSETHNPEN BIT(10) +#define GOTGCTL_HNPREQ BIT(9) +#define GOTGCTL_HSTNEGSCS BIT(8) +#define GOTGCTL_BVALOVAL BIT(7) +#define GOTGCTL_BVALOEN BIT(6) +#define GOTGCTL_AVALOVAL BIT(5) +#define GOTGCTL_AVALOEN BIT(4) +#define GOTGCTL_VBVALOVAL BIT(3) +#define GOTGCTL_VBVALOEN BIT(2) +#define GOTGCTL_SESREQ BIT(1) +#define GOTGCTL_SESREQSCS BIT(0) + +#define GOTGINT_DBNCE_DONE BIT(19) +#define GOTGINT_A_DEV_TOUT_CHG BIT(18) +#define GOTGINT_HST_NEG_DET BIT(17) +#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) +#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) +#define GOTGINT_SES_END_DET BIT(2) + +#define GAHBCFG_AHB_SINGLE BIT(23) +#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) +#define GAHBCFG_REM_MEM_SUPP BIT(21) +#define GAHBCFG_P_TXF_EMP_LVL BIT(8) +#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) +#define GAHBCFG_DMA_EN BIT(5) +#define GAHBCFG_HBSTLEN_MASK GENMASK(4, 1) +#define GAHBCFG_HBSTLEN_SINGLE 0 +#define GAHBCFG_HBSTLEN_INCR 1 +#define GAHBCFG_HBSTLEN_INCR4 3 +#define GAHBCFG_HBSTLEN_INCR8 5 +#define GAHBCFG_HBSTLEN_INCR16 7 +#define GAHBCFG_GLBL_INTR_EN BIT(0) +#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ + GAHBCFG_NP_TXF_EMP_LVL | \ + GAHBCFG_DMA_EN | \ + GAHBCFG_GLBL_INTR_EN) + +#define GUSBCFG_FORCEDEVMODE BIT(30) +#define GUSBCFG_FORCEHOSTMODE BIT(29) +#define GUSBCFG_TXENDDELAY BIT(28) +#define GUSBCFG_ICTRAFFICPULLREMOVE BIT(27) +#define GUSBCFG_ICUSBCAP BIT(26) +#define GUSBCFG_ULPI_INT_PROT_DIS BIT(25) +#define GUSBCFG_INDICATORPASSTHROUGH BIT(24) +#define GUSBCFG_INDICATORCOMPLEMENT BIT(23) +#define GUSBCFG_TERMSELDLPULSE BIT(22) +#define GUSBCFG_ULPI_INT_VBUS_IND BIT(21) +#define GUSBCFG_ULPI_EXT_VBUS_DRV BIT(20) +#define GUSBCFG_ULPI_CLK_SUSP_M BIT(19) +#define GUSBCFG_ULPI_AUTO_RES BIT(18) +#define GUSBCFG_ULPI_FS_LS BIT(17) +#define GUSBCFG_OTG_UTMI_FS_SEL BIT(16) +#define GUSBCFG_PHY_LP_CLK_SEL BIT(15) +#define GUSBCFG_USBTRDTIM_MASK GENMASK(14, 10) +#define GUSBCFG_HNPCAP BIT(9) +#define GUSBCFG_SRPCAP BIT(8) +#define GUSBCFG_DDRSEL BIT(7) +#define GUSBCFG_PHYSEL BIT(6) +#define GUSBCFG_FSINTF BIT(5) +#define GUSBCFG_ULPI_UTMI_SEL BIT(4) +#define GUSBCFG_PHYIF16 BIT(3) +#define GUSBCFG_TOUTCAL_MASK GENMASK(2, 0) + +#define GRSTCTL_AHBIDLE BIT(31) +#define GRSTCTL_DMAREQ BIT(30) +#define GRSTCTL_CSFTRST_DONE BIT(29) +#define GRSTCTL_TXFNUM_MASK GENMASK(10, 6) +#define GRSTCTL_TXFFLSH BIT(5) +#define GRSTCTL_RXFFLSH BIT(4) +#define GRSTCTL_IN_TKNQ_FLSH BIT(3) +#define GRSTCTL_FRMCNTRRST BIT(2) +#define GRSTCTL_HSFTRST BIT(1) +#define GRSTCTL_CSFTRST BIT(0) +#define GRSTCTL_TXFNUM_ALL 0x10 + +#define GINTSTS_WKUPINT BIT(31) +#define GINTSTS_SESSREQINT BIT(30) +#define GINTSTS_DISCONNINT BIT(29) +#define GINTSTS_CONIDSTSCHNG BIT(28) +#define GINTSTS_LPMTRANRCVD BIT(27) +#define GINTSTS_PTXFEMP BIT(26) +#define GINTSTS_HCHINT BIT(25) +#define GINTSTS_PRTINT BIT(24) +#define GINTSTS_RESETDET BIT(23) +#define GINTSTS_FET_SUSP BIT(22) +#define GINTSTS_INCOMPL_IP BIT(21) +#define GINTSTS_INCOMPL_SOOUT BIT(21) +#define GINTSTS_INCOMPL_SOIN BIT(20) +#define GINTSTS_OEPINT BIT(19) +#define GINTSTS_IEPINT BIT(18) +#define GINTSTS_EPMIS BIT(17) +#define GINTSTS_RESTOREDONE BIT(16) +#define GINTSTS_EOPF BIT(15) +#define GINTSTS_ISOUTDROP BIT(14) +#define GINTSTS_ENUMDONE BIT(13) +#define GINTSTS_USBRST BIT(12) +#define GINTSTS_USBSUSP BIT(11) +#define GINTSTS_ERLYSUSP BIT(10) +#define GINTSTS_I2CINT BIT(9) +#define GINTSTS_ULPI_CK_INT BIT(8) +#define GINTSTS_GOUTNAKEFF BIT(7) +#define GINTSTS_GINNAKEFF BIT(6) +#define GINTSTS_NPTXFEMP BIT(5) +#define GINTSTS_RXFLVL BIT(4) +#define GINTSTS_SOF BIT(3) +#define GINTSTS_OTGINT BIT(2) +#define GINTSTS_MODEMIS BIT(1) +#define GINTSTS_CURMODE_HOST BIT(0) + +#define GRXSTS_FN_MASK GENMASK(31, 25) +#define GRXSTS_PKTSTS_MASK GENMASK(20, 17) +#define GRXSTS_PKTSTS_GLOBALOUTNAK 1 +#define GRXSTS_PKTSTS_OUTRX 2 +#define GRXSTS_PKTSTS_HCHIN 2 +#define GRXSTS_PKTSTS_OUTDONE 3 +#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3 +#define GRXSTS_PKTSTS_SETUPDONE 4 +#define GRXSTS_PKTSTS_DATATOGGLEERR 5 +#define GRXSTS_PKTSTS_SETUPRX 6 +#define GRXSTS_PKTSTS_HCHHALTED 7 +#define GRXSTS_DPID_MASK GENMASK(16, 15) +#define GRXSTS_BYTECNT_MASK GENMASK(14, 4) +#define GRXSTS_HCHNUM_MASK GENMASK(3, 0) + +#define GRXFSIZ_DEPTH_MASK GENMASK(15, 0) + +#define GI2CCTL_BSYDNE BIT(31) +#define GI2CCTL_RW BIT(30) +#define GI2CCTL_I2CDATSE0 BIT(28) +#define GI2CCTL_I2CDEVADDR_MASK GENMASK(27, 26) +#define GI2CCTL_I2CSUSPCTL BIT(25) +#define GI2CCTL_ACK BIT(24) +#define GI2CCTL_I2CEN BIT(23) +#define GI2CCTL_ADDR_MASK GENMASK(22, 16) +#define GI2CCTL_REGADDR_MASK GENMASK(15, 8) +#define GI2CCTL_RWDATA_MASK GENMASK(7, 0) + +#define GGPIO_STM32_OTG_GCCFG_IDEN BIT(22) +#define GGPIO_STM32_OTG_GCCFG_VBDEN BIT(21) +#define GGPIO_STM32_OTG_GCCFG_PWRDWN BIT(16) + +#define GSNPSID_ID_MASK GENMASK(31, 16) +#define GSNPSID_OTG_ID 0x4f54 +#define GSNPSID_VER_MASK GENMASK(15, 0) + +#define GHWCFG2_OTG_ENABLE_IC_USB BIT(31) +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK GENMASK(30, 26) +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK GENMASK(25, 24) +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK GENMASK(23, 22) +#define GHWCFG2_MULTI_PROC_INT BIT(20) +#define GHWCFG2_DYNAMIC_FIFO BIT(19) +#define GHWCFG2_PERIO_EP_SUPPORTED BIT(18) +#define GHWCFG2_NUM_HOST_CHAN_MASK GENMASK(17, 14) +#define GHWCFG2_NUM_DEV_EP_MASK GENMASK(13, 10) +#define GHWCFG2_FS_PHY_TYPE_MASK GENMASK(9, 8) +#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 +#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 +#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 +#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 +#define GHWCFG2_HS_PHY_TYPE_MASK GENMASK(7, 6) +#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 +#define GHWCFG2_HS_PHY_TYPE_UTMI 1 +#define GHWCFG2_HS_PHY_TYPE_ULPI 2 +#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 +#define GHWCFG2_POINT2POINT BIT(5) +#define GHWCFG2_ARCHITECTURE_MASK GENMASK(4, 3) +#define GHWCFG2_SLAVE_ONLY_ARCH 0 +#define GHWCFG2_EXT_DMA_ARCH 1 +#define GHWCFG2_INT_DMA_ARCH 2 +#define GHWCFG2_OP_MODE_MASK GENMASK(2, 0) +#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 +#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 +#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 +#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 +#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 +#define GHWCFG2_OP_MODE_UNDEFINED 7 + +#define GHWCFG4_DESC_DMA_DYN BIT(31) +#define GHWCFG4_DESC_DMA BIT(30) +#define GHWCFG4_NUM_IN_EPS_MASK GENMASK(29, 26) +#define GHWCFG4_DED_FIFO_EN BIT(25) +#define GHWCFG4_SESSION_END_FILT_EN BIT(24) +#define GHWCFG4_B_VALID_FILT_EN BIT(23) +#define GHWCFG4_A_VALID_FILT_EN BIT(22) +#define GHWCFG4_VBUS_VALID_FILT_EN BIT(21) +#define GHWCFG4_IDDIG_FILT_EN BIT(20) +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK GENMASK(19, 16) +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK GENMASK(15, 14) +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 +#define GHWCFG4_ACG_SUPPORTED BIT(12) +#define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) +#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) +#define GHWCFG4_XHIBER BIT(7) +#define GHWCFG4_HIBER BIT(6) +#define GHWCFG4_MIN_AHB_FREQ BIT(5) +#define GHWCFG4_POWER_OPTIMIZ BIT(4) +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK GENMASK(3, 0) + +#define FIFOSIZE_DEPTH_MASK GENMASK(31, 16) +#define FIFOSIZE_STARTADDR_MASK GENMASK(15, 0) + +/* Host Register */ +#define HCFG_MODECHTIMEN BIT(31) +#define HCFG_PERSCHEDENA BIT(26) +#define HCFG_FRLISTEN_MASK GENMASK(25, 24) +#define HCFG_FRLISTEN_8 0 +#define HCFG_FRLISTEN_16 1 +#define HCFG_FRLISTEN_32 2 +#define HCFG_FRLISTEN_64 3 +#define HCFG_DESCDMA BIT(23) +#define HCFG_RESVALID_MASK GENMASK(15, 8) +#define HCFG_ENA32KHZ BIT(7) +#define HCFG_FSLSSUPP BIT(2) +#define HCFG_FSLSPCLKSEL_MASK GENMASK(2, 0) +#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 +#define HCFG_FSLSPCLKSEL_48_MHZ 1 +#define HCFG_FSLSPCLKSEL_6_MHZ 2 + +#define HFNUM_FRREM_MASK GENMASK(31, 16) +#define HFNUM_FRNUM_MASK GENMASK(15, 0) + +#define HPRT0_SPD_MASK GENMASK(18, 17) +#define HPRT0_SPD_HIGH_SPEED 0 +#define HPRT0_SPD_FULL_SPEED 1 +#define HPRT0_SPD_LOW_SPEED 2 +#define HPRT0_TSTCTL_MASK GENMASK(16, 13) +#define HPRT0_PWR BIT(12) +#define HPRT0_LNSTS_MASK GENMASK(11, 10) +#define HPRT0_RST BIT(8) +#define HPRT0_SUSP BIT(7) +#define HPRT0_RES BIT(6) +#define HPRT0_OVRCURRCHG BIT(5) +#define HPRT0_OVRCURRACT BIT(4) +#define HPRT0_ENACHG BIT(3) +#define HPRT0_ENA BIT(2) +#define HPRT0_CONNDET BIT(1) +#define HPRT0_CONNSTS BIT(0) +#define HPRT0_W1C_MASK (HPRT0_CONNDET | \ + HPRT0_ENA | \ + HPRT0_ENACHG | \ + HPRT0_OVRCURRCHG) + +#define HCCHAR_CHENA BIT(31) +#define HCCHAR_CHDIS BIT(30) +#define HCCHAR_ODDFRM BIT(29) +#define HCCHAR_DEVADDR_MASK GENMASK(28, 22) +#define HCCHAR_MULTICNT_MASK GENMASK(21, 20) +#define HCCHAR_EPTYPE_MASK GENMASK(19, 18) +#define HCCHAR_EPTYPE_CONTROL 0 +#define HCCHAR_EPTYPE_ISOC 1 +#define HCCHAR_EPTYPE_BULK 2 +#define HCCHAR_EPTYPE_INTR 3 +#define HCCHAR_LSPDDEV BIT(17) +#define HCCHAR_EPDIR BIT(15) +#define HCCHAR_EPNUM_MASK GENMASK(14, 11) +#define HCCHAR_MPS_MASK GENMASK(10, 0) + +#define HCSPLT_SPLTENA BIT(31) +#define HCSPLT_COMPSPLT BIT(16) +#define HCSPLT_XACTPOS_MASK GENMASK(15, 14) +#define HCSPLT_XACTPOS_MID 0 +#define HCSPLT_XACTPOS_END 1 +#define HCSPLT_XACTPOS_BEGIN 2 +#define HCSPLT_XACTPOS_ALL 3 +#define HCSPLT_HUBADDR_MASK GENMASK(13, 7) +#define HCSPLT_PRTADDR_MASK GENMASK(6, 0) + +#define HCINTMSK_FRM_LIST_ROLL BIT(13) +#define HCINTMSK_XCS_XACT BIT(12) +#define HCINTMSK_BNA BIT(11) +#define HCINTMSK_DATATGLERR BIT(10) +#define HCINTMSK_FRMOVRUN BIT(9) +#define HCINTMSK_BBLERR BIT(8) +#define HCINTMSK_XACTERR BIT(7) +#define HCINTMSK_NYET BIT(6) +#define HCINTMSK_ACK BIT(5) +#define HCINTMSK_NAK BIT(4) +#define HCINTMSK_STALL BIT(3) +#define HCINTMSK_AHBERR BIT(2) +#define HCINTMSK_CHHLTD BIT(1) +#define HCINTMSK_XFERCOMPL BIT(0) + +#define TSIZ_DOPNG BIT(31) +#define TSIZ_SC_MC_PID_MASK GENMASK(30, 29) +#define TSIZ_SC_MC_PID_DATA0 0 +#define TSIZ_SC_MC_PID_DATA2 1 +#define TSIZ_SC_MC_PID_DATA1 2 +#define TSIZ_SC_MC_PID_MDATA 3 +#define TSIZ_SC_MC_PID_SETUP 3 +#define TSIZ_PKTCNT_MASK GENMASK(28, 19) +#define TSIZ_NTD_MASK GENMASK(15, 8) +#define TSIZ_SCHINFO_MASK GENMASK(7, 0) +#define TSIZ_XFERSIZE_MASK GENMASK(18, 0) + +/* Device Mode Register */ +#define DCFG_DESCDMA_EN BIT(23) +#define DCFG_EPMISCNT_MASK GENMASK(22, 18) +#define DCFG_IPG_ISOC_SUPPORDED BIT(17) +#define DCFG_PERFRINT_MASK GENMASK(12, 11) +#define DCFG_DEVADDR_MASK GENMASK(10, 4) +#define DCFG_NZ_STS_OUT_HSHK BIT(2) +#define DCFG_DEVSPD_MASK GENMASK(1, 0) +#define DCFG_DEVSPD_HS 0 +#define DCFG_DEVSPD_FS 1 +#define DCFG_DEVSPD_LS 2 +#define DCFG_DEVSPD_FS48 3 + +#define DCTL_SERVICE_INTERVAL_SUPPORTED BIT(19) +#define DCTL_PWRONPRGDONE BIT(11) +#define DCTL_CGOUTNAK BIT(10) +#define DCTL_SGOUTNAK BIT(9) +#define DCTL_CGNPINNAK BIT(8) +#define DCTL_SGNPINNAK BIT(7) +#define DCTL_TSTCTL_MASK GENMASK(6, 4) +#define DCTL_GOUTNAKSTS BIT(3) +#define DCTL_GNPINNAKSTS BIT(2) +#define DCTL_SFTDISCON BIT(1) +#define DCTL_RMTWKUPSIG BIT(0) + +#define DSTS_SOFFN_MASK GENMASK(21, 8) +#define DSTS_ERRATICERR BIT(3) +#define DSTS_ENUMSPD_MASK GENMASK(2, 1) +#define DSTS_ENUMSPD_HS 0 +#define DSTS_ENUMSPD_FS 1 +#define DSTS_ENUMSPD_LS 2 +#define DSTS_ENUMSPD_FS48 3 +#define DSTS_SUSPSTS BIT(0) + +#define DIEPMSK_NAKMSK BIT(13) +#define DIEPMSK_BNAININTRMSK BIT(9) +#define DIEPMSK_TXFIFOUNDRNMSK BIT(8) +#define DIEPMSK_TXFIFOEMPTY BIT(7) +#define DIEPMSK_INEPNAKEFFMSK BIT(6) +#define DIEPMSK_INTKNEPMISMSK BIT(5) +#define DIEPMSK_INTKNTXFEMPMSK BIT(4) +#define DIEPMSK_TIMEOUTMSK BIT(3) +#define DIEPMSK_AHBERRMSK BIT(2) +#define DIEPMSK_EPDISBLDMSK BIT(1) +#define DIEPMSK_XFERCOMPLMSK BIT(0) + +#define DOEPMSK_BNAMSK BIT(9) +#define DOEPMSK_BACK2BACKSETUP BIT(6) +#define DOEPMSK_STSPHSERCVDMSK BIT(5) +#define DOEPMSK_OUTTKNEPDISMSK BIT(4) +#define DOEPMSK_SETUPMSK BIT(3) +#define DOEPMSK_AHBERRMSK BIT(2) +#define DOEPMSK_EPDISBLDMSK BIT(1) +#define DOEPMSK_XFERCOMPLMSK BIT(0) + +#define DAINT_OUTEP_MASK GENMASK(31, 16) +#define DAINT_INEP_MASK GENMASK(15, 0) + +#define D0EPCTL_MPS_MASK GENMASK(1, 0) +#define D0EPCTL_MPS_64 0 +#define D0EPCTL_MPS_32 1 +#define D0EPCTL_MPS_16 2 +#define D0EPCTL_MPS_8 3 + +#define DXEPCTL_EPENA BIT(31) +#define DXEPCTL_EPDIS BIT(30) +#define DXEPCTL_SETD1PID BIT(29) +#define DXEPCTL_SETODDFR BIT(29) +#define DXEPCTL_SETD0PID BIT(28) +#define DXEPCTL_SETEVENFR BIT(28) +#define DXEPCTL_SNAK BIT(27) +#define DXEPCTL_CNAK BIT(26) +#define DXEPCTL_TXFNUM_MASK GENMASK(25, 22) +#define DXEPCTL_STALL BIT(21) +#define DXEPCTL_SNP BIT(20) +#define DXEPCTL_EPTYPE_MASK GENMASK(19, 18) +#define DXEPCTL_EPTYPE_CONTROL 0 +#define DXEPCTL_EPTYPE_ISO 1 +#define DXEPCTL_EPTYPE_BULK 2 +#define DXEPCTL_EPTYPE_INTERRUPT 3 +#define DXEPCTL_NAKSTS BIT(17) +#define DXEPCTL_DPID BIT(16) +#define DXEPCTL_EOFRNUM BIT(16) +#define DXEPCTL_USBACTEP BIT(15) +#define DXEPCTL_NEXTEP_MASK GENMASK(14, 11) +#define DXEPCTL_MPS_MASK GENMASK(10, 0) + +#define DXEPINT_SETUP_RCVD BIT(15) +#define DXEPINT_NYETINTRPT BIT(14) +#define DXEPINT_NAKINTRPT BIT(13) +#define DXEPINT_BBLEERRINTRPT BIT(12) +#define DXEPINT_PKTDRPSTS BIT(11) +#define DXEPINT_BNAINTR BIT(9) +#define DXEPINT_TXFIFOUNDRN BIT(8) +#define DXEPINT_OUTPKTERR BIT(8) +#define DXEPINT_TXFEMP BIT(7) +#define DXEPINT_INEPNAKEFF BIT(6) +#define DXEPINT_BACK2BACKSETUP BIT(6) +#define DXEPINT_INTKNEPMIS BIT(5) +#define DXEPINT_STSPHSERCVD BIT(5) +#define DXEPINT_INTKNTXFEMP BIT(4) +#define DXEPINT_OUTTKNEPDIS BIT(4) +#define DXEPINT_TIMEOUT BIT(3) +#define DXEPINT_SETUP BIT(3) +#define DXEPINT_AHBERR BIT(2) +#define DXEPINT_EPDISBLD BIT(1) +#define DXEPINT_XFERCOMPL BIT(0) + +#define DIEPTSIZ0_PKTCNT_MASK GENMASK(20, 19) +#define DIEPTSIZ0_XFERSIZE_MASK GENMASK(6, 0) + +#define DOEPTSIZ0_SUPCNT_MASK GENMASK(30, 29) +#define DOEPTSIZ0_PKTCNT BIT(19) +#define DOEPTSIZ0_XFERSIZE_MASK GENMASK(6, 0) + +#define DXEPTSIZ_MC_MASK GENMASK(30, 29) +#define DXEPTSIZ_PKTCNT_MASK GENMASK(28, 19) +#define DXEPTSIZ_XFERSIZE_MASK GENMASK(18, 0) +#endif /* __DWC2_CORE_H_ */ drivers/usb/gadget/dwc2_udc_otg_regs.h +1
-153@@ -10,7 +10,7 @@ #ifndef __ASM_ARCH_REGS_USB_OTG_HS_H #define __ASM_ARCH_REGS_USB_OTG_HS_H -#include <linux/bitops.h> +#include "../common/dwc2_core.h" struct dwc2_usbotg_phy { u32 phypwr;@@ -18,58 +18,6 @@ struct dwc2_usbotg_phy {u32 rstcon; }; -/*===================================================================== */ -/*definitions related to CSR setting */ - -/* DWC2_UDC_OTG_GOTGCTL */ -#define GOTGCTL_BSESVLD BIT(19) -#define GOTGCTL_ASESVLD BIT(18) -#define GOTGCTL_BVALOVAL BIT(7) -#define GOTGCTL_BVALOEN BIT(6) -#define GOTGCTL_AVALOVAL BIT(5) -#define GOTGCTL_AVALOEN BIT(4) -#define GOTGCTL_VBVALOVAL BIT(3) -#define GOTGCTL_VBVALOEN BIT(2) - -/* DWC2_UDC_OTG_GOTINT */ -#define GOTGINT_SES_END_DET BIT(2) - -/* DWC2_UDC_OTG_GAHBCFG */ -#define GAHBCFG_AHB_SINGLE BIT(23) -#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) -#define GAHBCFG_REM_MEM_SUPP BIT(21) -#define GAHBCFG_P_TXF_EMP_LVL BIT(8) -#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) -#define GAHBCFG_DMA_EN BIT(5) -#define GAHBCFG_HBSTLEN_MASK GENMASK(4, 1) -#define GAHBCFG_HBSTLEN_SINGLE 0 -#define GAHBCFG_HBSTLEN_INCR 1 -#define GAHBCFG_HBSTLEN_INCR4 3 -#define GAHBCFG_HBSTLEN_INCR8 5 -#define GAHBCFG_HBSTLEN_INCR16 7 -#define GAHBCFG_GLBL_INTR_EN BIT(0) - -/* DWC2_UDC_OTG_GRSTCTL */ -#define GRSTCTL_AHBIDLE BIT(31) -#define GRSTCTL_CSFTRST BIT(0) - -/* DWC2_UDC_OTG_GINTSTS/DWC2_UDC_OTG_GINTMSK core interrupt register */ -#define GINTSTS_WKUPINT BIT(31) -#define GINTSTS_DISCONNINT BIT(29) -#define GINTSTS_CONIDSTSCHNG BIT(28) -#define GINTSTS_OEPINT BIT(19) -#define GINTSTS_IEPINT BIT(18) -#define GINTSTS_ENUMDONE BIT(13) -#define GINTSTS_USBRST BIT(12) -#define GINTSTS_USBSUSP BIT(11) -#define GINTSTS_ERLYSUSP BIT(10) -#define GINTSTS_NPTXFEMP BIT(5) -#define GINTSTS_RXFLVL BIT(4) -#define GINTSTS_SOF BIT(3) -#define GINTSTS_OTGINT BIT(2) -#define GINTSTS_MODEMIS BIT(1) -#define GINTSTS_CURMODE_HOST BIT(0) -#define FULL_SPEED_CONTROL_PKT_SIZE 8#define FULL_SPEED_BULK_PKT_SIZE 64@@ -80,69 +28,6 @@ struct dwc2_usbotg_phy {#define NPTX_FIFO_SIZE 1024#define PTX_FIFO_SIZE 384 -#define FIFOSIZE_DEPTH_MASK GENMASK(31, 16) -#define FIFOSIZE_STARTADDR_MASK GENMASK(15, 0) - -/* Enumeration speed */ -#define DSTS_ENUMSPD_MASK GENMASK(2, 1) -#define DSTS_ENUMSPD_HS 0 -#define DSTS_ENUMSPD_FS 1 -#define DSTS_ENUMSPD_LS 2 - -/* DWC2_UDC_OTG_DCTL device control register */ -#define DCTL_SFTDISCON BIT(1) -#define DCTL_RMTWKUPSIG BIT(0) - -/* DWC2_UDC_OTG_DAINT device all endpoint interrupt register */ -#define DAINT_OUTEP_MASK GENMASK(31, 16) -#define DAINT_INEP_MASK GENMASK(15, 0) - -/* DWC2_UDC_OTG_DIEPCTL0/DOEPCTL0 device -control IN/OUT endpoint 0 control register */ -#define DXEPCTL_EPENA BIT(31) -#define DXEPCTL_EPDIS BIT(30) -#define DXEPCTL_SETD1PID BIT(29) -#define DXEPCTL_SETODDFR BIT(29) -#define DXEPCTL_SETD0PID BIT(28) -#define DXEPCTL_SETEVENFR BIT(28) -#define DXEPCTL_SNAK BIT(27) -#define DXEPCTL_CNAK BIT(26) -#define DXEPCTL_STALL BIT(21) -#define DXEPCTL_EPTYPE_MASK GENMASK(19, 18) -#define DXEPCTL_EPTYPE_CONTROL 0 -#define DXEPCTL_EPTYPE_ISO 1 -#define DXEPCTL_EPTYPE_BULK 2 -#define DXEPCTL_EPTYPE_INTERRUPT 3 -#define DXEPCTL_EOFRNUM BIT(16) -#define DXEPCTL_USBACTEP BIT(15) -#define DXEPCTL_NEXTEP_MASK GENMASK(14, 11) -#define DXEPCTL_MPS_MASK GENMASK(10, 0) - - -/* DWC2_UDC_OTG_DIEPMSK/DOEPMSK device IN/OUT endpoint -common interrupt mask register */ -/* DWC2_UDC_OTG_DIEPINTn/DOEPINTn device IN/OUT endpoint interrupt register */ -#define DIEPMSK_NAKMSK BIT(13) -#define DIEPMSK_BNAININTRMSK BIT(9) -#define DIEPMSK_TXFIFOUNDRNMSK BIT(8) -#define DIEPMSK_TXFIFOEMPTY BIT(7) -#define DIEPMSK_INEPNAKEFFMSK BIT(6) -#define DIEPMSK_INTKNEPMISMSK BIT(5) -#define DIEPMSK_INTKNTXFEMPMSK BIT(4) -#define DIEPMSK_TIMEOUTMSK BIT(3) -#define DIEPMSK_AHBERRMSK BIT(2) -#define DIEPMSK_EPDISBLDMSK BIT(1) -#define DIEPMSK_XFERCOMPLMSK BIT(0) - -#define DOEPMSK_BNAMSK BIT(9) -#define DOEPMSK_BACK2BACKSETUP BIT(6) -#define DOEPMSK_STSPHSERCVDMSK BIT(5) -#define DOEPMSK_OUTTKNEPDISMSK BIT(4) -#define DOEPMSK_SETUPMSK BIT(3) -#define DOEPMSK_AHBERRMSK BIT(2) -#define DOEPMSK_EPDISBLDMSK BIT(1) -#define DOEPMSK_XFERCOMPLMSK BIT(0) -#define USB_PHY_CTRL_EN0 BIT(0)/* OPHYPWR */ @@ -171,21 +56,6 @@ struct dwc2_usbotg_phy {#define EXYNOS4X12_CLK_SEL_12MHZ (0x02 << 0)#define EXYNOS4X12_CLK_SEL_24MHZ (0x05 << 0) -/* Device Configuration Register DCFG */ -#define DCFG_EPMISCNT_MASK GENMASK(22, 18) -#define DCFG_DEVADDR_MASK GENMASK(10, 4) -#define DCFG_DEVSPD_MASK GENMASK(1, 0) -#define DCFG_DEVSPD_HS 0 -#define DCFG_DEVSPD_FS 1 -#define DCFG_DEVSPD_LS 2 -#define DCFG_DEVSPD_FS48 3 - -/* Core Reset Register (GRSTCTL) */ -#define GRSTCTL_TXFNUM_MASK GENMASK(10, 6) -#define GRSTCTL_TXFFLSH BIT(5) -#define GRSTCTL_RXFFLSH BIT(4) -#define GRSTCTL_TXFNUM_ALL 0x10 -/* Masks definitions */ #define GINTMSK_INIT (GINTSTS_WKUPINT | GINTSTS_OEPINT | GINTSTS_IEPINT | GINTSTS_ENUMDONE | \ GINTSTS_USBRST | GINTSTS_USBSUSP | GINTSTS_OTGINT)@@ -195,26 +65,4 @@ struct dwc2_usbotg_phy { FIELD_PREP(GAHBCFG_HBSTLEN_MASK, GAHBCFG_HBSTLEN_INCR4) | \ GAHBCFG_GLBL_INTR_EN) -/* Device Endpoint X Transfer Size Register (DIEPTSIZX/DOEPTSIZX) */ -#define DIEPTSIZ0_PKTCNT_MASK GENMASK(20, 19) -#define DIEPTSIZ0_XFERSIZE_MASK GENMASK(6, 0) - -#define DOEPTSIZ0_SUPCNT_MASK GENMASK(30, 29) -#define DOEPTSIZ0_PKTCNT BIT(19) -#define DOEPTSIZ0_XFERSIZE_MASK GENMASK(6, 0) - -#define DXEPTSIZ_MC_MASK GENMASK(30, 29) -#define DXEPTSIZ_PKTCNT_MASK GENMASK(28, 19) -#define DXEPTSIZ_XFERSIZE_MASK GENMASK(18, 0) - -/* Device Endpoint-N Control Register (DIEPCTLn/DOEPCTLn) */ -#define DXEPCTL_TXFNUM_MASK GENMASK(25, 22) - -/* User HW Config4 */ -#define GHWCFG4_NUM_IN_EPS_MASK GENMASK(29, 26) - -/* OTG general core configuration register (OTG_GCCFG:0x38) for STM32MP1 */ -#define GGPIO_STM32_OTG_GCCFG_VBDEN BIT(21) -#define GGPIO_STM32_OTG_GCCFG_IDEN BIT(22) -#endif drivers/usb/host/dwc2.h +0
-291@@ -6,297 +6,6 @@#ifndef __DWC2_H__#define __DWC2_H__ -#include <linux/bitops.h> - -#define GOTGCTL_CHIRPEN BIT(27) -#define GOTGCTL_MULT_VALID_BC_MASK GENMASK(26, 22) -#define GOTGCTL_CURMODE_HOST BIT(21) -#define GOTGCTL_OTGVER BIT(20) -#define GOTGCTL_BSESVLD BIT(19) -#define GOTGCTL_ASESVLD BIT(18) -#define GOTGCTL_DBNC_SHORT BIT(17) -#define GOTGCTL_CONID_B BIT(16) -#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) -#define GOTGCTL_DEVHNPEN BIT(11) -#define GOTGCTL_HSTSETHNPEN BIT(10) -#define GOTGCTL_HNPREQ BIT(9) -#define GOTGCTL_HSTNEGSCS BIT(8) -#define GOTGCTL_BVALOVAL BIT(7) -#define GOTGCTL_BVALOEN BIT(6) -#define GOTGCTL_AVALOVAL BIT(5) -#define GOTGCTL_AVALOEN BIT(4) -#define GOTGCTL_VBVALOVAL BIT(3) -#define GOTGCTL_VBVALOEN BIT(2) -#define GOTGCTL_SESREQ BIT(1) -#define GOTGCTL_SESREQSCS BIT(0) - -#define GOTGINT_DBNCE_DONE BIT(19) -#define GOTGINT_A_DEV_TOUT_CHG BIT(18) -#define GOTGINT_HST_NEG_DET BIT(17) -#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) -#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) -#define GOTGINT_SES_END_DET BIT(2) - -#define GAHBCFG_AHB_SINGLE BIT(23) -#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) -#define GAHBCFG_REM_MEM_SUPP BIT(21) -#define GAHBCFG_P_TXF_EMP_LVL BIT(8) -#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) -#define GAHBCFG_DMA_EN BIT(5) -#define GAHBCFG_HBSTLEN_MASK GENMASK(4, 1) -#define GAHBCFG_HBSTLEN_SINGLE 0 -#define GAHBCFG_HBSTLEN_INCR 1 -#define GAHBCFG_HBSTLEN_INCR4 3 -#define GAHBCFG_HBSTLEN_INCR8 5 -#define GAHBCFG_HBSTLEN_INCR16 7 -#define GAHBCFG_GLBL_INTR_EN BIT(0) -#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ - GAHBCFG_NP_TXF_EMP_LVL | \ - GAHBCFG_DMA_EN | \ - GAHBCFG_GLBL_INTR_EN) - -#define GUSBCFG_FORCEDEVMODE BIT(30) -#define GUSBCFG_FORCEHOSTMODE BIT(29) -#define GUSBCFG_TXENDDELAY BIT(28) -#define GUSBCFG_ICTRAFFICPULLREMOVE BIT(27) -#define GUSBCFG_ICUSBCAP BIT(26) -#define GUSBCFG_ULPI_INT_PROT_DIS BIT(25) -#define GUSBCFG_INDICATORPASSTHROUGH BIT(24) -#define GUSBCFG_INDICATORCOMPLEMENT BIT(23) -#define GUSBCFG_TERMSELDLPULSE BIT(22) -#define GUSBCFG_ULPI_INT_VBUS_IND BIT(21) -#define GUSBCFG_ULPI_EXT_VBUS_DRV BIT(20) -#define GUSBCFG_ULPI_CLK_SUSP_M BIT(19) -#define GUSBCFG_ULPI_AUTO_RES BIT(18) -#define GUSBCFG_ULPI_FS_LS BIT(17) -#define GUSBCFG_OTG_UTMI_FS_SEL BIT(16) -#define GUSBCFG_PHY_LP_CLK_SEL BIT(15) -#define GUSBCFG_USBTRDTIM_MASK GENMASK(14, 10) -#define GUSBCFG_HNPCAP BIT(9) -#define GUSBCFG_SRPCAP BIT(8) -#define GUSBCFG_DDRSEL BIT(7) -#define GUSBCFG_PHYSEL BIT(6) -#define GUSBCFG_FSINTF BIT(5) -#define GUSBCFG_ULPI_UTMI_SEL BIT(4) -#define GUSBCFG_PHYIF16 BIT(3) -#define GUSBCFG_TOUTCAL_MASK GENMASK(2, 0) - -#define GRSTCTL_AHBIDLE BIT(31) -#define GRSTCTL_DMAREQ BIT(30) -#define GRSTCTL_CSFTRST_DONE BIT(29) -#define GRSTCTL_TXFNUM_MASK GENMASK(10, 6) -#define GRSTCTL_TXFFLSH BIT(5) -#define GRSTCTL_RXFFLSH BIT(4) -#define GRSTCTL_IN_TKNQ_FLSH BIT(3) -#define GRSTCTL_FRMCNTRRST BIT(2) -#define GRSTCTL_HSFTRST BIT(1) -#define GRSTCTL_CSFTRST BIT(0) -#define GRSTCTL_TXFNUM_ALL 0x10 - -#define GINTSTS_WKUPINT BIT(31) -#define GINTSTS_SESSREQINT BIT(30) -#define GINTSTS_DISCONNINT BIT(29) -#define GINTSTS_CONIDSTSCHNG BIT(28) -#define GINTSTS_LPMTRANRCVD BIT(27) -#define GINTSTS_PTXFEMP BIT(26) -#define GINTSTS_HCHINT BIT(25) -#define GINTSTS_PRTINT BIT(24) -#define GINTSTS_RESETDET BIT(23) -#define GINTSTS_FET_SUSP BIT(22) -#define GINTSTS_INCOMPL_IP BIT(21) -#define GINTSTS_INCOMPL_SOOUT BIT(21) -#define GINTSTS_INCOMPL_SOIN BIT(20) -#define GINTSTS_OEPINT BIT(19) -#define GINTSTS_IEPINT BIT(18) -#define GINTSTS_EPMIS BIT(17) -#define GINTSTS_RESTOREDONE BIT(16) -#define GINTSTS_EOPF BIT(15) -#define GINTSTS_ISOUTDROP BIT(14) -#define GINTSTS_ENUMDONE BIT(13) -#define GINTSTS_USBRST BIT(12) -#define GINTSTS_USBSUSP BIT(11) -#define GINTSTS_ERLYSUSP BIT(10) -#define GINTSTS_I2CINT BIT(9) -#define GINTSTS_ULPI_CK_INT BIT(8) -#define GINTSTS_GOUTNAKEFF BIT(7) -#define GINTSTS_GINNAKEFF BIT(6) -#define GINTSTS_NPTXFEMP BIT(5) -#define GINTSTS_RXFLVL BIT(4) -#define GINTSTS_SOF BIT(3) -#define GINTSTS_OTGINT BIT(2) -#define GINTSTS_MODEMIS BIT(1) -#define GINTSTS_CURMODE_HOST BIT(0) - -#define FIFOSIZE_DEPTH_MASK GENMASK(31, 16) -#define FIFOSIZE_STARTADDR_MASK GENMASK(15, 0) - -#define GI2CCTL_BSYDNE BIT(31) -#define GI2CCTL_RW BIT(30) -#define GI2CCTL_I2CDATSE0 BIT(28) -#define GI2CCTL_I2CDEVADDR_MASK GENMASK(27, 26) -#define GI2CCTL_I2CSUSPCTL BIT(25) -#define GI2CCTL_ACK BIT(24) -#define GI2CCTL_I2CEN BIT(23) -#define GI2CCTL_ADDR_MASK GENMASK(22, 16) -#define GI2CCTL_REGADDR_MASK GENMASK(15, 8) -#define GI2CCTL_RWDATA_MASK GENMASK(7, 0) - -#define GHWCFG2_OTG_ENABLE_IC_USB BIT(31) -#define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK GENMASK(30, 26) -#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK GENMASK(25, 24) -#define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK GENMASK(23, 22) -#define GHWCFG2_MULTI_PROC_INT BIT(20) -#define GHWCFG2_DYNAMIC_FIFO BIT(19) -#define GHWCFG2_PERIO_EP_SUPPORTED BIT(18) -#define GHWCFG2_NUM_HOST_CHAN_MASK GENMASK(17, 14) -#define GHWCFG2_NUM_DEV_EP_MASK GENMASK(13, 10) -#define GHWCFG2_FS_PHY_TYPE_MASK GENMASK(9, 8) -#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 -#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 -#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 -#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 -#define GHWCFG2_HS_PHY_TYPE_MASK GENMASK(7, 6) -#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 -#define GHWCFG2_HS_PHY_TYPE_UTMI 1 -#define GHWCFG2_HS_PHY_TYPE_ULPI 2 -#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 -#define GHWCFG2_POINT2POINT BIT(5) -#define GHWCFG2_ARCHITECTURE_MASK GENMASK(4, 3) -#define GHWCFG2_SLAVE_ONLY_ARCH 0 -#define GHWCFG2_EXT_DMA_ARCH 1 -#define GHWCFG2_INT_DMA_ARCH 2 -#define GHWCFG2_OP_MODE_MASK GENMASK(2, 0) -#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 -#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 -#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 -#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 -#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 -#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 -#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 -#define GHWCFG2_OP_MODE_UNDEFINED 7 - -#define GHWCFG4_DESC_DMA_DYN BIT(31) -#define GHWCFG4_DESC_DMA BIT(30) -#define GHWCFG4_NUM_IN_EPS_MASK GENMASK(29, 26) -#define GHWCFG4_DED_FIFO_EN BIT(25) -#define GHWCFG4_SESSION_END_FILT_EN BIT(24) -#define GHWCFG4_B_VALID_FILT_EN BIT(23) -#define GHWCFG4_A_VALID_FILT_EN BIT(22) -#define GHWCFG4_VBUS_VALID_FILT_EN BIT(21) -#define GHWCFG4_IDDIG_FILT_EN BIT(20) -#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK GENMASK(19, 16) -#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK GENMASK(15, 14) -#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 -#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 -#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 -#define GHWCFG4_ACG_SUPPORTED BIT(12) -#define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) -#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) -#define GHWCFG4_XHIBER BIT(7) -#define GHWCFG4_HIBER BIT(6) -#define GHWCFG4_MIN_AHB_FREQ BIT(5) -#define GHWCFG4_POWER_OPTIMIZ BIT(4) -#define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK GENMASK(3, 0) - -#define HCFG_MODECHTIMEN BIT(31) -#define HCFG_PERSCHEDENA BIT(26) -#define HCFG_FRLISTEN_MASK GENMASK(25, 24) -#define HCFG_FRLISTEN_8 0 -#define HCFG_FRLISTEN_16 1 -#define HCFG_FRLISTEN_32 2 -#define HCFG_FRLISTEN_64 3 -#define HCFG_DESCDMA BIT(23) -#define HCFG_RESVALID_MASK GENMASK(15, 8) -#define HCFG_ENA32KHZ BIT(7) -#define HCFG_FSLSSUPP BIT(2) -#define HCFG_FSLSPCLKSEL_MASK GENMASK(2, 0) -#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 -#define HCFG_FSLSPCLKSEL_48_MHZ 1 -#define HCFG_FSLSPCLKSEL_6_MHZ 2 - -#define HFIR_FRINT_MASK GENMASK(15, 0) -#define HFIR_RLDCTRL BIT(16) - -#define HFNUM_FRREM_MASK GENMASK(31, 16) -#define HFNUM_FRNUM_MASK GENMASK(15, 0) - -#define HPRT0_SPD_MASK GENMASK(18, 17) -#define HPRT0_SPD_HIGH_SPEED 0 -#define HPRT0_SPD_FULL_SPEED 1 -#define HPRT0_SPD_LOW_SPEED 2 -#define HPRT0_TSTCTL_MASK GENMASK(16, 13) -#define HPRT0_PWR BIT(12) -#define HPRT0_LNSTS_MASK GENMASK(11, 10) -#define HPRT0_RST BIT(8) -#define HPRT0_SUSP BIT(7) -#define HPRT0_RES BIT(6) -#define HPRT0_OVRCURRCHG BIT(5) -#define HPRT0_OVRCURRACT BIT(4) -#define HPRT0_ENACHG BIT(3) -#define HPRT0_ENA BIT(2) -#define HPRT0_CONNDET BIT(1) -#define HPRT0_CONNSTS BIT(0) -#define HPRT0_W1C_MASK (HPRT0_CONNDET | \ - HPRT0_ENA | \ - HPRT0_ENACHG | \ - HPRT0_OVRCURRCHG) - -#define HCCHAR_CHENA BIT(31) -#define HCCHAR_CHDIS BIT(30) -#define HCCHAR_ODDFRM BIT(29) -#define HCCHAR_DEVADDR_MASK GENMASK(28, 22) -#define HCCHAR_MULTICNT_MASK GENMASK(21, 20) -#define HCCHAR_EPTYPE_MASK GENMASK(19, 18) -#define HCCHAR_EPTYPE_CONTROL 0 -#define HCCHAR_EPTYPE_ISOC 1 -#define HCCHAR_EPTYPE_BULK 2 -#define HCCHAR_EPTYPE_INTR 3 -#define HCCHAR_LSPDDEV BIT(17) -#define HCCHAR_EPDIR BIT(15) -#define HCCHAR_EPNUM_MASK GENMASK(14, 11) -#define HCCHAR_MPS_MASK GENMASK(10, 0) - -#define HCSPLT_SPLTENA BIT(31) -#define HCSPLT_COMPSPLT BIT(16) -#define HCSPLT_XACTPOS_MASK GENMASK(15, 14) -#define HCSPLT_XACTPOS_MID 0 -#define HCSPLT_XACTPOS_END 1 -#define HCSPLT_XACTPOS_BEGIN 2 -#define HCSPLT_XACTPOS_ALL 3 -#define HCSPLT_HUBADDR_MASK GENMASK(13, 7) -#define HCSPLT_PRTADDR_MASK GENMASK(6, 0) - -#define HCINTMSK_FRM_LIST_ROLL BIT(13) -#define HCINTMSK_XCS_XACT BIT(12) -#define HCINTMSK_BNA BIT(11) -#define HCINTMSK_DATATGLERR BIT(10) -#define HCINTMSK_FRMOVRUN BIT(9) -#define HCINTMSK_BBLERR BIT(8) -#define HCINTMSK_XACTERR BIT(7) -#define HCINTMSK_NYET BIT(6) -#define HCINTMSK_ACK BIT(5) -#define HCINTMSK_NAK BIT(4) -#define HCINTMSK_STALL BIT(3) -#define HCINTMSK_AHBERR BIT(2) -#define HCINTMSK_CHHLTD BIT(1) -#define HCINTMSK_XFERCOMPL BIT(0) - -#define TSIZ_DOPNG BIT(31) -#define TSIZ_SC_MC_PID_MASK GENMASK(30, 29) -#define TSIZ_SC_MC_PID_DATA0 0 -#define TSIZ_SC_MC_PID_DATA2 1 -#define TSIZ_SC_MC_PID_DATA1 2 -#define TSIZ_SC_MC_PID_MDATA 3 -#define TSIZ_SC_MC_PID_SETUP 3 -#define TSIZ_PKTCNT_MASK GENMASK(28, 19) -#define TSIZ_NTD_MASK GENMASK(15, 8) -#define TSIZ_SCHINFO_MASK GENMASK(7, 0) -#define TSIZ_XFERSIZE_MASK GENMASK(18, 0) - -#define GSNPSID_ID_MASK GENMASK(31, 16) -#define GSNPSID_OTG_ID 0x4f54 -#define GSNPSID_VER_MASK GENMASK(15, 0) -/* Host controller specific */ #define DWC2_HC_PID_DATA0 0#define DWC2_HC_PID_DATA2 1Signature · 2 lines
-- 2.47.1
PATCH v4 7/8 usb: dwc2: Unify flush and reset logic with v4.20a support
In reply to Junhui LiuFrom: Kongyang Liu <[email protected]>
This patch merges flush and reset logic for both host and gadget code into a common set of functions, reducing duplication. It also adds support for the updated reset logic to compatible with core version since v4.20a.
This patch mainly refers to the patch in the kernel.
---
This commit does not add the handling of ret returned from the dwc2_core_reset, dwc2_flush_tx_fifo and dwc2_flush_rx_fifo, because this may involve changes to the code logic, I think this should be a separate patch to handle with it.
--- drivers/usb/common/Makefile | 2 + drivers/usb/common/dwc2_core.c | 131 +++++++++++++++++++++++++++++ drivers/usb/common/dwc2_core.h | 4 + drivers/usb/gadget/dwc2_udc_otg.c | 12 +-- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 6 +- drivers/usb/host/dwc2.c | 80 +----------------- 6 files changed, 145 insertions(+), 90 deletions(-)
drivers/usb/common/Makefile +2 -0
@@ -4,6 +4,8 @@ # obj-$(CONFIG_$(XPL_)DM_USB) += common.o +obj-$(CONFIG_USB_DWC2) += dwc2_core.o +obj-$(CONFIG_USB_GADGET_DWC2_OTG) += dwc2_core.o obj-$(CONFIG_USB_ISP1760) += usb_urb.o obj-$(CONFIG_USB_MUSB_HOST) += usb_urb.o obj-$(CONFIG_USB_MUSB_GADGET) += usb_urb.o
drivers/usb/common/dwc2_core.c new file +131 -0
131 lines not on this page · raw message
drivers/usb/common/dwc2_core.h +4 -0
@@ -125,6 +125,10 @@ struct dwc2_core_regs {u8 ep_fifo[16 ][0x1000 ];/* 0x1000 */ }; +int dwc2_core_reset (struct dwc2_core_regs *regs); +int dwc2_flush_tx_fifo (struct dwc2_core_regs *regs,const int num); +int dwc2_flush_rx_fifo (struct dwc2_core_regs *regs); +/* Core Global Register */ #define GOTGCTL_CHIRPEN BIT(27)#define GOTGCTL_MULT_VALID_BC_MASK GENMASK(26, 22)
drivers/usb/gadget/dwc2_udc_otg.c +3 -9
@@ -471,7 +471,7 @@ static void reconfig_usbd(struct dwc2_udc *dev)u32 max_hw_ep;int pdata_hw_ep; -writel (GRSTCTL_CSFTRST , ®->global_regs.grstctl); +dwc2_core_reset (reg);debug ("Resetting OTG controller\n" );
@@ -575,16 +575,10 @@ static void reconfig_usbd(struct dwc2_udc *dev) ®->global_regs.dptxfsizn[i]); }/* Flush the RX FIFO */ -writel (GRSTCTL_RXFFLSH , ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &GRSTCTL_RXFFLSH ) -debug ("%s: waiting for DWC2_UDC_OTG_GRSTCTL\n" , __func__); +dwc2_flush_rx_fifo (reg);/* Flush all the Tx FIFO's */ -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK ,GRSTCTL_TXFNUM_ALL ), ®->global_regs.grstctl); -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK ,GRSTCTL_TXFNUM_ALL ) |GRSTCTL_TXFFLSH , - ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &GRSTCTL_TXFFLSH ) -debug ("%s: waiting for DWC2_UDC_OTG_GRSTCTL\n" , __func__); +dwc2_flush_tx_fifo (reg,GRSTCTL_TXFNUM_ALL );/* 13. Clear NAK bit of EP0, EP1, EP2*/ /* For Slave mode*/
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +1 -5
@@ -164,11 +164,7 @@ static int setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req) pktcnt = (length -1 )/(ep->ep.maxpacket) +1 ;/* Flush the endpoint's Tx FIFO */ -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK , ep->fifo_num), ®->global_regs.grstctl); -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK , ep->fifo_num) |GRSTCTL_TXFFLSH , - ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &GRSTCTL_TXFFLSH ) - ; +dwc2_flush_tx_fifo (reg, ep->fifo_num);writel (phys_to_bus ((unsigned long )ep->dma_buf), ®->device_regs.in_endp[ep_num].diepdma); writel(FIELD_PREP(DXEPTSIZ_PKTCNT_MASK, pktcnt) |
drivers/usb/host/dwc2.c +4 -76
104 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH v4 7/8] usb: dwc2: Unify flush and reset logic with v4.20a support
Quoted 8 lines · Junhui Liu
From: Kongyang Liu <[email protected]>
This patch merges flush and reset logic for both host and gadget code into a common set of functions, reducing duplication. It also adds support for the updated reset logic to compatible with core version since v4.20a.
This patch mainly refers to the patch in the kernel.
Re: [PATCH v4 7/8] usb: dwc2: Unify flush and reset logic with v4.20a support
In reply to Junhui LiuHi Junhui,
Thank you for the patch.
Quoted 6 lines · Junhui Liu
From: Kongyang Liu <[email protected]>
This patch merges flush and reset logic for both host and gadget code into a common set of functions, reducing duplication. It also adds support for the updated reset logic to compatible with core version since v4.20a.
Quoted 6 lines
This patch mainly refers to the patch in the kernel.
Signed-off-by Kongyang Liu <[email protected]>Tested-by Peter Robinson <[email protected]>Signed-off-by Junhui Liu <[email protected]>
Quoted 344 lines
---
This commit does not add the handling of ret returned from thedwc2_core_reset,dwc2_flush_tx_fifoanddwc2_flush_rx_fifo, because this may involve changes to the code logic, I think this should be a separate patch to handle with it.--- drivers/usb/common/Makefile | 2 + drivers/usb/common/dwc2_core.c | 131 +++++++++++++++++++++++++++++ drivers/usb/common/dwc2_core.h | 4 + drivers/usb/gadget/dwc2_udc_otg.c | 12 +-- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 6 +- drivers/usb/host/dwc2.c | 80 +----------------- 6 files changed, 145 insertions(+), 90 deletions(-)drivers/usb/common/Makefile +2
-0@@ -4,6 +4,8 @@ # obj-$(CONFIG_$(XPL_)DM_USB) += common.o +obj-$(CONFIG_USB_DWC2) += dwc2_core.o +obj-$(CONFIG_USB_GADGET_DWC2_OTG) += dwc2_core.o obj-$(CONFIG_USB_ISP1760) += usb_urb.o obj-$(CONFIG_USB_MUSB_HOST) += usb_urb.o obj-$(CONFIG_USB_MUSB_GADGET) += usb_urb.odrivers/usb/common/dwc2_core.c new file +131
-0@@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2024-2025, Kongyang Liu <[email protected]> +*/ + +#include <linux/bitfield.h> +#include <linux/errno.h> +#include <linux/io.h> +#include <wait_bit.h> + +#include "dwc2_core.h" + +int dwc2_core_reset (struct dwc2_core_regs *regs) +{ +u32 snpsid; +int ret; +bool host_mode = false; + +if (!(readl (®s->global_regs.gotgctl) &GOTGCTL_CONID_B ) || + (readl (®s->global_regs.gusbcfg) &GUSBCFG_FORCEDEVMODE )) + host_mode = true; + +/* Core Soft Reset */ + snpsid =readl (®s->global_regs.gsnpsid); +writel (GRSTCTL_CSFTRST , ®s->global_regs.grstctl); +if (FIELD_GET (GSNPSID_VER_MASK , snpsid) <0x420a ) { + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_CSFTRST , + false,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_CSFTRST timeout\n" , __func__); +return ret; + } + }else { + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_CSFTRST_DONE , + true,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_CSFTRST_DONE timeout\n" , __func__); +return ret; + } +clrsetbits_le32 (®s->global_regs.grstctl,GRSTCTL_CSFTRST ,GRSTCTL_CSFTRST_DONE ); + } + +/* Wait for AHB master IDLE state. */ + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_AHBIDLE , + true,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_AHBIDLE timeout\n" , __func__); +return ret; + } + +if (host_mode) { + ret =wait_for_bit_le32 (®s->global_regs.gintsts,GINTSTS_CURMODE_HOST , + host_mode,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GINTSTS_CURMODE_HOST timeout\n" , __func__); +return ret; + } + } + +return 0 ; +} + +int dwc2_flush_tx_fifo (struct dwc2_core_regs *regs,const int num) +{ +int ret; + +log_debug ("Flush Tx FIFO %d\n" , num); + +/* Wait for AHB master IDLE state */ + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_AHBIDLE , true,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_AHBIDLE timeout\n" , __func__); +return ret; + } + +writel (GRSTCTL_TXFFLSH |FIELD_PREP (GRSTCTL_TXFNUM_MASK , num), ®s->global_regs.grstctl); + + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_TXFFLSH , false,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_TXFFLSH timeout\n" , __func__); +return ret; + } + +/* +* Wait for at least 3 PHY clocks. +* +* The PHY clock frequency can be configured to 6/30/48/60 MHz +* based on the speed mode. A fixed delay of 1us ensures that the +* wait time is sufficient even at the lowest PHY clock frequency +* (6 MHz), where 1us corresponds to twice the duration of 3 PHY +* clocks. +*/ +udelay (1 ); + +return 0 ; +} + +int dwc2_flush_rx_fifo (struct dwc2_core_regs *regs) +{ +int ret; + +log_debug ("Flush Rx FIFO\n" ); + +/* Wait for AHB master IDLE state */ + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_AHBIDLE , true,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_AHBIDLE timeout\n" , __func__); +return ret; + } + +writel (GRSTCTL_RXFFLSH , ®s->global_regs.grstctl); + + ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_RXFFLSH , false,1000 , false); +if (ret) { +log_warning ("%s: Waiting for GRSTCTL_RXFFLSH timeout\n" , __func__); +return ret; + } + +/* +* Wait for at least 3 PHY clocks. +* +* The PHY clock frequency can be configured to 6/30/48/60 MHz +* based on the speed mode. A fixed delay of 1us ensures that the +* wait time is sufficient even at the lowest PHY clock frequency +* (6 MHz), where 1us corresponds to twice the duration of 3 PHY +* clocks. +*/ +udelay (1 ); + +return 0 ; +}drivers/usb/common/dwc2_core.h +4
-0@@ -125,6 +125,10 @@ struct dwc2_core_regs {u8 ep_fifo[16 ][0x1000 ];/* 0x1000 */ }; +int dwc2_core_reset (struct dwc2_core_regs *regs); +int dwc2_flush_tx_fifo (struct dwc2_core_regs *regs,const int num); +int dwc2_flush_rx_fifo (struct dwc2_core_regs *regs); +/* Core Global Register */ #define GOTGCTL_CHIRPEN BIT(27)#define GOTGCTL_MULT_VALID_BC_MASK GENMASK(26, 22)drivers/usb/gadget/dwc2_udc_otg.c +3
-9@@ -471,7 +471,7 @@ static void reconfig_usbd(struct dwc2_udc *dev)u32 max_hw_ep;int pdata_hw_ep; -writel (GRSTCTL_CSFTRST , ®->global_regs.grstctl); +dwc2_core_reset (reg);debug ("Resetting OTG controller\n" );@@ -575,16 +575,10 @@ static void reconfig_usbd(struct dwc2_udc *dev) ®->global_regs.dptxfsizn[i]); }/* Flush the RX FIFO */ -writel (GRSTCTL_RXFFLSH , ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &GRSTCTL_RXFFLSH ) -debug ("%s: waiting for DWC2_UDC_OTG_GRSTCTL\n" , __func__); +dwc2_flush_rx_fifo (reg);/* Flush all the Tx FIFO's */ -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK ,GRSTCTL_TXFNUM_ALL ), ®->global_regs.grstctl); -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK ,GRSTCTL_TXFNUM_ALL ) |GRSTCTL_TXFFLSH , - ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &GRSTCTL_TXFFLSH ) -debug ("%s: waiting for DWC2_UDC_OTG_GRSTCTL\n" , __func__); +dwc2_flush_tx_fifo (reg,GRSTCTL_TXFNUM_ALL );/* 13. Clear NAK bit of EP0, EP1, EP2*/ /* For Slave mode*/ drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +1
-5@@ -164,11 +164,7 @@ static int setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req) pktcnt = (length -1 )/(ep->ep.maxpacket) +1 ;/* Flush the endpoint's Tx FIFO */ -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK , ep->fifo_num), ®->global_regs.grstctl); -writel (FIELD_PREP (GRSTCTL_TXFNUM_MASK , ep->fifo_num) |GRSTCTL_TXFFLSH , - ®->global_regs.grstctl); -while (readl (®->global_regs.grstctl) &GRSTCTL_TXFFLSH ) - ; +dwc2_flush_tx_fifo (reg, ep->fifo_num);writel (phys_to_bus ((unsigned long )ep->dma_buf), ®->device_regs.in_endp[ep_num].diepdma); writel(FIELD_PREP(DXEPTSIZ_PKTCNT_MASK, pktcnt) |drivers/usb/host/dwc2.c +4
-76@@ -108,78 +108,6 @@ static void init_fslspclksel(struct dwc2_core_regs *regs) FIELD_PREP(HCFG_FSLSPCLKSEL_MASK, phyclk)); } -/* -* Flush a Tx FIFO. -* -* @param regs Programming view of DWC_otg controller. -* @param num Tx FIFO to flush. -*/ -static void dwc_otg_flush_tx_fifo (struct udevice *dev, -struct dwc2_core_regs *regs,const int num) -{ -int ret; - -writel (GRSTCTL_TXFFLSH |FIELD_PREP (GRSTCTL_TXFNUM_MASK , num), - ®s->global_regs.grstctl); - ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_TXFFLSH , - false,1000 , false); -if (ret) -dev_info (dev,"%s: Timeout!\n" , __func__); - -/* Wait for 3 PHY Clocks */ -udelay (1 ); -} - -/* -* Flush Rx FIFO. -* -* @param regs Programming view of DWC_otg controller. -*/ -static void dwc_otg_flush_rx_fifo (struct udevice *dev, -struct dwc2_core_regs *regs) -{ -int ret; - -writel (GRSTCTL_RXFFLSH , ®s->global_regs.grstctl); - ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_RXFFLSH , - false,1000 , false); -if (ret) -dev_info (dev,"%s: Timeout!\n" , __func__); - -/* Wait for 3 PHY Clocks */ -udelay (1 ); -} - -/* -* Do core a soft reset of the core. Be careful with this because it -* resets all the internal state machines of the core. -*/ -static void dwc_otg_core_reset (struct udevice *dev, -struct dwc2_core_regs *regs) -{ -int ret; - -/* Wait for AHB master IDLE state. */ - ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_AHBIDLE , - true,1000 , false); -if (ret) -dev_info (dev,"%s: Timeout!\n" , __func__); - -/* Core Soft Reset */ -writel (GRSTCTL_CSFTRST , ®s->global_regs.grstctl); - ret =wait_for_bit_le32 (®s->global_regs.grstctl,GRSTCTL_CSFTRST , - false,1000 , false); -if (ret) -dev_info (dev,"%s: Timeout!\n" , __func__); - -/* -* Wait for core to come out of reset. -* NOTE: This long sleep is _very_ important, otherwise the core will -* not stay in host mode after a connector ID change! -*/ -mdelay (100 ); -} -#if CONFIG_IS_ENABLED (DM_USB ) && defined(CONFIG_DM_REGULATOR )static int dwc_vbus_supply_init (struct udevice *dev) {@@ -281,8 +209,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,clrbits_le32 (®s->global_regs.gotgctl,GOTGCTL_HSTSETHNPEN );/* Make sure the FIFOs are flushed. */ -dwc_otg_flush_tx_fifo (dev, regs,GRSTCTL_TXFNUM_ALL );/* All Tx FIFOs */ -dwc_otg_flush_rx_fifo (dev, regs); +dwc2_flush_tx_fifo (regs,GRSTCTL_TXFNUM_ALL );/* All Tx FIFOs */ +dwc2_flush_rx_fifo (regs);/* Flush out any leftover queued requests. */ num_channels =FIELD_GET (GHWCFG2_NUM_HOST_CHAN_MASK ,readl (®s->global_regs.ghwcfg2)) +1 ;@@ -352,7 +280,7 @@ static void dwc_otg_core_init(struct udevice *dev)writel (usbcfg, ®s->global_regs.gusbcfg);/* Reset the Controller */ -dwc_otg_core_reset (dev, regs); +dwc2_core_reset (regs);/* * This programming sequence needs to happen in FS mode before @@ -413,7 +341,7 @@ static void dwc_otg_core_init(struct udevice *dev)writel (usbcfg, ®s->global_regs.gusbcfg);/* Reset after setting the PHY parameters */ -dwc_otg_core_reset (dev, regs); +dwc2_core_reset (regs);#endif usbcfg =readl (®s->global_regs.gusbcfg);Signature · 2 lines
-- 2.47.1
PATCH v4 8/8 usb: dwc2: Replace uint<x>_t types with u<x>
In reply to Junhui LiuFrom: Kongyang Liu <[email protected]>
Updates all instances of uint8_t, uint16_t, and uint32_t to u8, u16, and u32 respectively, ensuring consistent use of kernel-preferred types and resolving checkpatch.pl warnings.
--- drivers/usb/gadget/dwc2_udc_otg.c | 4 +- drivers/usb/host/dwc2.c | 100 +++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 52 deletions(-)
drivers/usb/gadget/dwc2_udc_otg.c +2 -2
@@ -466,8 +466,8 @@ static void reconfig_usbd(struct dwc2_udc *dev)/* 2. Soft-reset OTG Core and then unreset again. */ int i;unsigned int uTemp; -uint32_t dflt_gusbcfg; -uint32_t rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz; +u32 dflt_gusbcfg; +u32 rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz;u32 max_hw_ep;int pdata_hw_ep;
drivers/usb/host/dwc2.c +50 -50
244 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH v4 8/8] usb: dwc2: Replace uint<x>_t types with u<x>
Hi Junhui,
Thank you for the patch.
Quoted 10 lines · Junhui Liu
From: Kongyang Liu <[email protected]>
Updates all instances of
uint8_t,uint16_t, anduint32_tto u8, u16, and u32 respectively, ensuring consistent use of kernel-preferred types and resolving checkpatch.pl warnings.Signed-off-by Kongyang Liu <[email protected]>Reviewed-by Marek Vasut <[email protected]>Tested-by Peter Robinson <[email protected]>Signed-off-by Junhui Liu <[email protected]>
Quoted 291 lines
--- drivers/usb/gadget/dwc2_udc_otg.c | 4 +- drivers/usb/host/dwc2.c | 100 +++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 52 deletions(-)drivers/usb/gadget/dwc2_udc_otg.c +2
-2@@ -466,8 +466,8 @@ static void reconfig_usbd(struct dwc2_udc *dev)/* 2. Soft-reset OTG Core and then unreset again. */ int i;unsigned int uTemp; -uint32_t dflt_gusbcfg; -uint32_t rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz; +u32 dflt_gusbcfg; +u32 rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz;u32 max_hw_ep;int pdata_hw_ep;drivers/usb/host/dwc2.c +50
-50@@ -39,16 +39,16 @@struct dwc2_priv {#if CONFIG_IS_ENABLED (DM_USB ) -uint8_t aligned_buffer[DWC2_DATA_BUF_SIZE ]__aligned(ARCH_DMA_MINALIGN) ; -uint8_t status_buffer[DWC2_STATUS_BUF_SIZE ]__aligned(ARCH_DMA_MINALIGN) ; +u8 aligned_buffer[DWC2_DATA_BUF_SIZE ]__aligned(ARCH_DMA_MINALIGN) ; +u8 status_buffer[DWC2_STATUS_BUF_SIZE ]__aligned(ARCH_DMA_MINALIGN) ;#ifdef CONFIG_DM_REGULATOR struct udevice *vbus_supply;#endif struct phy phy;struct clk_bulk clks;#else -uint8_t *aligned_buffer; -uint8_t *status_buffer; +u8 *aligned_buffer; +u8 *status_buffer;#endif u8 in_data_toggle[MAX_DEVICE ][MAX_ENDPOINT ];u8 out_data_toggle[MAX_DEVICE ][MAX_ENDPOINT ];@@ -67,10 +67,10 @@ struct dwc2_priv {#if !CONFIG_IS_ENABLED (DM_USB )/* We need cacheline-aligned buffers for DMA transfers and dcache support */ -DEFINE_ALIGN_BUFFER (uint8_t, aligned_buffer_addr,DWC2_DATA_BUF_SIZE , -ARCH_DMA_MINALIGN ); -DEFINE_ALIGN_BUFFER (uint8_t, status_buffer_addr,DWC2_STATUS_BUF_SIZE , -ARCH_DMA_MINALIGN ); +DEFINE_ALIGN_BUFFER (u8, aligned_buffer_addr,DWC2_DATA_BUF_SIZE , +ARCH_DMA_MINALIGN ); +DEFINE_ALIGN_BUFFER (u8, status_buffer_addr,DWC2_STATUS_BUF_SIZE , +ARCH_DMA_MINALIGN );static struct dwc2_priv local;#endif @@ -85,7 +85,7 @@ static struct dwc2_priv local;*/ static void init_fslspclksel (struct dwc2_core_regs *regs) { -uint32_t phyclk; +u32 phyclk;#if (DWC2_PHY_TYPE ==DWC2_PHY_TYPE_FS ) phyclk =HCFG_FSLSPCLKSEL_48_MHZ ;/* Full speed PHY */ @@ -95,9 +95,9 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)#endif #ifdef DWC2_ULPI_FS_LS -uint32_t hwcfg2 =readl (®s->global_regs.ghwcfg2); -uint32_t hval =FIELD_GET (GHWCFG2_HS_PHY_TYPE_MASK , ghwcfg2); -uint32_t fval =FIELD_GET (GHWCFG2_FS_PHY_TYPE_MASK , ghwcfg2); +u32 hwcfg2 =readl (®s->global_regs.ghwcfg2); +u32 hval =FIELD_GET (GHWCFG2_HS_PHY_TYPE_MASK , ghwcfg2); +u32 fval =FIELD_GET (GHWCFG2_FS_PHY_TYPE_MASK , ghwcfg2);if (hval ==GHWCFG2_FS_PHY_TYPE_SHARED_UTMI && fval ==GHWCFG2_HS_PHY_TYPE_UTMI ) phyclk =HCFG_FSLSPCLKSEL_48_MHZ ;/* Full speed PHY */ @@ -172,9 +172,9 @@ static int dwc_vbus_supply_exit(struct udevice *dev)static void dwc_otg_core_host_init (struct udevice *dev,struct dwc2_core_regs *regs) { -uint32_t nptxfifosize =0 ; -uint32_t ptxfifosize =0 ; -uint32_t hprt0 =0 ; +u32 nptxfifosize =0 ; +u32 ptxfifosize =0 ; +u32 hprt0 =0 ;int i, ret, num_channels;/* Restart the Phy Clock */ @@ -253,9 +253,9 @@ static void dwc_otg_core_init(struct udevice *dev) {struct dwc2_priv *priv =dev_get_priv (dev);struct dwc2_core_regs *regs = priv->regs; -uint32_t ahbcfg =0 ; -uint32_t usbcfg =0 ; -uint8_t brst_sz =DWC2_DMA_BURST_SIZE ; +u32 ahbcfg =0 ; +u32 usbcfg =0 ; +u8 brst_sz =DWC2_DMA_BURST_SIZE ;/* Common Initialization */ usbcfg =readl (®s->global_regs.gusbcfg);@@ -347,9 +347,9 @@ static void dwc_otg_core_init(struct udevice *dev) usbcfg =readl (®s->global_regs.gusbcfg); usbcfg &= ~(GUSBCFG_ULPI_FS_LS |GUSBCFG_ULPI_CLK_SUSP_M );#ifdef DWC2_ULPI_FS_LS -uint32_t hwcfg2 =readl (®s->global_regs.ghwcfg2); -uint32_t hval =FIELD_GET (GHWCFG2_HS_PHY_TYPE_MASK , ghwcfg2); -uint32_t fval =FIELD_GET (GHWCFG2_FS_PHY_TYPE_MASK , ghwcfg2); +u32 hwcfg2 =readl (®s->global_regs.ghwcfg2); +u32 hval =FIELD_GET (GHWCFG2_HS_PHY_TYPE_MASK , ghwcfg2); +u32 fval =FIELD_GET (GHWCFG2_FS_PHY_TYPE_MASK , ghwcfg2);if (hval ==GHWCFG2_FS_PHY_TYPE_SHARED_UTMI && fval ==GHWCFG2_HS_PHY_TYPE_UTMI ) { usbcfg |=GUSBCFG_ULPI_FS_LS ;@@ -402,9 +402,9 @@ static void dwc_otg_core_init(struct udevice *dev)* @param regs Programming view of DWC_otg controller * @param hc Information needed to initialize the host channel */ -static void dwc_otg_hc_init (struct dwc2_core_regs *regs,uint8_t hc_num, -struct usb_device *dev,uint8_t dev_addr,uint8_t ep_num, -uint8_t ep_is_in,uint8_t ep_type,uint16_t max_packet) +static void dwc_otg_hc_init (struct dwc2_core_regs *regs,u8 hc_num, +struct usb_device *dev,u8 dev_addr,u8 ep_num, +u8 ep_is_in,u8 ep_type,u16 max_packet) {struct dwc2_hc_regs *hc_regs = ®s->host_regs.hc[hc_num]; u32 hcchar = FIELD_PREP(HCCHAR_DEVADDR_MASK, dev_addr) |@@ -427,9 +427,9 @@ static void dwc_otg_hc_init(struct dwc2_core_regs *regs, uint8_t hc_num, }static void dwc_otg_hc_init_split (struct dwc2_hc_regs *hc_regs, -uint8_t hub_devnum,uint8_t hub_port) +u8 hub_devnum,u8 hub_port) { -uint32_t hcsplt =0 ; +u32 hcsplt =0 ; hcsplt =HCSPLT_SPLTENA ; hcsplt |=FIELD_PREP (HCSPLT_HUBADDR_MASK , hub_devnum);@@ -447,24 +447,24 @@ static int dwc_otg_submit_rh_msg_in_status(struct dwc2_core_regs *regs, struct usb_device *dev, void *buffer, int txlen, struct devrequest *cmd) { - uint32_t hprt0 = 0; -uint32_t port_status =0 ; -uint32_t port_change =0 ; + u32 hprt0 = 0; +u32 port_status =0 ; +u32 port_change =0 ;int len =0 ;int stat =0 ;switch (cmd->requesttype & ~USB_DIR_IN ) {case 0 : - *(uint16_t *)buffer =cpu_to_le16 (1 ); + *(u16 *)buffer =cpu_to_le16 (1 ); len =2 ;break ;case USB_RECIP_INTERFACE :case USB_RECIP_ENDPOINT : - *(uint16_t *)buffer =cpu_to_le16 (0 ); + *(u16 *)buffer =cpu_to_le16 (0 ); len =2 ;break ;case USB_TYPE_CLASS : - *(uint32_t *)buffer =cpu_to_le32 (0 ); + *(u32 *)buffer =cpu_to_le32 (0 ); len =4 ;break ;case USB_RECIP_OTHER |USB_TYPE_CLASS :@@ -498,7 +498,7 @@ static int dwc_otg_submit_rh_msg_in_status(struct dwc2_core_regs *regs,if (hprt0 &HPRT0_OVRCURRCHG ) port_change |=USB_PORT_STAT_C_OVERCURRENT ; - *(uint32_t *)buffer =cpu_to_le32 (port_status | + *(u32 *)buffer =cpu_to_le32 (port_status | (port_change <<16 )); len =4 ;break ;@@ -519,11 +519,11 @@ static int dwc_otg_submit_rh_msg_in_descriptor(struct usb_device *dev, struct devrequest *cmd) {unsigned char data[32 ]; -uint32_t dsc; +u32 dsc;int len =0 ;int stat =0 ; -uint16_t wValue =cpu_to_le16 (cmd->value); -uint16_t wLength =cpu_to_le16 (cmd->length); +u16 wValue =cpu_to_le16 (cmd->value); +u16 wLength =cpu_to_le16 (cmd->length);switch (cmd->requesttype & ~USB_DIR_IN ) {case 0 :@@ -606,7 +606,7 @@ static int dwc_otg_submit_rh_msg_in_configuration(struct usb_device *dev,switch (cmd->requesttype & ~USB_DIR_IN ) {case 0 : - *(uint8_t *)buffer =0x01 ; + *(u8 *)buffer =0x01 ; len =1 ;break ;default :@@ -650,8 +650,8 @@ static int dwc_otg_submit_rh_msg_out(struct dwc2_priv *priv,struct dwc2_core_regs *regs = priv->regs;int len =0 ;int stat =0 ; -uint16_t bmrtype_breq = cmd->requesttype | (cmd->request <<8 ); -uint16_t wValue =cpu_to_le16 (cmd->value); +u16 bmrtype_breq = cmd->requesttype | (cmd->request <<8 ); +u16 wValue =cpu_to_le16 (cmd->value);switch (bmrtype_breq & ~USB_DIR_IN ) {case (USB_REQ_CLEAR_FEATURE <<8 ) |USB_RECIP_ENDPOINT :@@ -724,10 +724,10 @@ static int dwc_otg_submit_rh_msg(struct dwc2_priv *priv, struct usb_device *dev,return stat; } -int wait_for_chhltd (struct dwc2_hc_regs *hc_regs,uint32_t *sub,u8 *toggle) +int wait_for_chhltd (struct dwc2_hc_regs *hc_regs,u32 *sub,u8 *toggle) {int ret; -uint32_t hcint, hctsiz; +u32 hcint, hctsiz; ret =wait_for_bit_le32 (&hc_regs->hcint,HCINTMSK_CHHLTD , true,2000 , false);@@ -764,7 +764,7 @@ static int transfer_chunk(struct dwc2_hc_regs *hc_regs, void *aligned_buffer, int xfer_len, int *actual_len, int odd_frame) { int ret = 0; -uint32_t sub; +u32 sub;debug ("%s: chunk: pid %d xfer_len %u pkts %u\n" , __func__, *pid, xfer_len, num_packets);@@ -834,10 +834,10 @@ int chunk_msg(struct dwc2_priv *priv, struct usb_device *dev,int ret =0 ;int do_split =0 ;int complete_split =0 ; -uint32_t xfer_len; -uint32_t num_packets; +u32 xfer_len; +u32 num_packets;int stop_transfer =0 ; -uint32_t max_xfer_len; +u32 max_xfer_len;int ssplit_frame_num =0 ; debug("%s: msg: pipe %lx pid %d in %d len %d\n", __func__, pipe, *pid,@@ -859,9 +859,9 @@ int chunk_msg(struct dwc2_priv *priv, struct usb_device *dev,/* Check if the target is a FS/LS device behind a HS hub */ if (dev->speed !=USB_SPEED_HIGH ) { -uint8_t hub_addr; -uint8_t hub_port; -uint32_t hprt0 =readl (®s->host_regs.hprt0); +u8 hub_addr; +u8 hub_port; +u32 hprt0 =readl (®s->host_regs.hprt0);if (FIELD_GET (HPRT0_SPD_MASK , hprt0) ==HPRT0_SPD_HIGH_SPEED ) { usb_find_usb2_hub_address_port(dev, &hub_addr,@@ -876,7 +876,7 @@ int chunk_msg(struct dwc2_priv *priv, struct usb_device *dev, do { int actual_len = 0; - uint32_t hcint; + u32 hcint; int odd_frame = 0; xfer_len = len - done;@@ -1083,7 +1083,7 @@ static int dwc2_reset(struct udevice *dev)static int dwc2_init_common (struct udevice *dev,struct dwc2_priv *priv) {struct dwc2_core_regs *regs = priv->regs; -uint32_t snpsid; +u32 snpsid;int i, j;int ret;Signature · 2 lines
-- 2.47.1
Hi,
Quoted 5 lines · Junhui Liu
This series improves the USB DWC2 driver by extracting register definitions into a common file for better readability and updating the reset method to reflect changes in version 4.20a, including the new
GRSTCTL_CSFTRST_DONEbit for reset completion indication.
Quoted 8 lines
This series has been tested on two platforms:
- MK808 with RK3066 SoC and dwc2 v2.91a, tested with USB flash drive and connected the board to the PC through the rockusb command. Test log [1].
- K230-CanMV with K230 SoC [2] and dwc2 v4.30a, tested with the onboard rtl8152 USB to net chip and an external rtl8152 adapter connected to the onboard USB-C interface via USB hub. Test log [3].[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu-next)
[1/8] usb: dwc2: Extract register definitions to common header file
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/14f904130964f251e78349a2e370c5069f2af500 [2/8] usb: dwc2: Fix incorrect ULPI_UTMI_SEL bit setting https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/94a1f8fe47e26250dd5704b2c2187622522eca6b [3/8] usb: dwc2: Fix HBstLen setting for external DMA mode https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/bd6ef5097dd6c6219f12c0f2866ee4d578f190e9 [4/8] usb: dwc2: Clean up with bitfield macros https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/a5699130f4ad3f08d5192a459d116cd0ffc9ee4d [5/8] usb: dwc2: Align macros with Linux kernel definitions https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/6def014bba5ee779c7faeec012bc93d2ff90f6d3 [6/8] usb: dwc2: Extract macro definitions to common header https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/24b0e2604e2980dd04078b85a7a8929588dc0988 [7/8] usb: dwc2: Unify flush and reset logic with v4.20a support https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/c5d685b8993cf9e2fa4321dc3f9f866d5655e976 [8/8] usb: dwc2: Replace uint<x>_t types with u<x> https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/bd88148a1bf3457ffe05d3bb0563dc4bfbfeee96
--
Mattijs