[PATCH v2 6/8] usb: dwc2: Extract macro definitions to common header

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu 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 Signed-off-by: Junhui Liu --- drivers/usb/common/dwc2_core.h

[PATCH v2 8/8] usb: dwc2: Replace uint_t types with u

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu 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. Signed-off-by: Kongyang Liu Signed-off-by: Junhui Liu --- drivers/usb/gadget/dwc2_udc_otg.c |

[PATCH v2 5/8] usb: dwc2: Align macros with Linux kernel definitions

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu 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. Signed-off-by: Kongyang Liu Signed-off-by: Junhui Liu --- drivers/usb/gadget/dwc2_udc_otg.c |

[PATCH v2 1/8] usb: dwc2: Extract register definitions to common header file

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu 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. Signed-off-by: Kongyang Li

[PATCH v2 4/8] usb: dwc2: Clean up with bitfield macros

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu Use FIELD_PREP, FIELD_GET, BIT, and GENMASK macros to standardize bit manipulation across the DWC2 code, improving readability and maintainability without altering functionality. Signed-off-by: Kongyang Liu Signed-off-by: Junhui Liu --- drivers/usb/gadget/dwc2_udc_otg.c

[PATCH v2 3/8] USB: dwc2: Fix HBstLen setting for external DMA mode

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu 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://r

[PATCH v2 2/8] usb: dwc2: Fix incorrect ULPI_UTMI_SEL bit setting

2024-12-30 Thread Junhui Liu via B4 Relay
From: Junhui Liu The 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

[PATCH v2 7/8] usb: dwc2: Unify flush and reset logic with v4.20a support

2024-12-30 Thread Junhui Liu via B4 Relay
From: Kongyang Liu 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. link:

[PATCH v2 0/8] usb: dwc2: Refactor and update USB DWC2 driver

2024-12-30 Thread Junhui Liu via B4 Relay
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 pl