[PATCH 08/11] usb: dwc3: Add Allwinner A733 DWC3 support

From: Alastair D'Silva

Date: Fri Nov 27 2026 - 02:33:47 EST


Add inverted sync header support, A733 match data, and post-reset PHY
calibration on host start.

Signed-off-by: Alastair D'Silva <alastair@xxxxxxxxxxx>
---
drivers/usb/dwc3/core.c | 18 +++++++++++++++---
drivers/usb/dwc3/core.h | 8 ++++++++
drivers/usb/dwc3/dwc3-generic-plat.c | 15 +++++++++++++--
drivers/usb/dwc3/glue.h | 6 ++++++
drivers/usb/dwc3/host.c | 10 ++++++++++
5 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index f4aa6a01e500..3fe68d085a85 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1503,13 +1503,16 @@ int dwc3_core_init(struct dwc3 *dwc)
dwc3_config_threshold(dwc);

if (hw_mode != DWC3_GHWPARAMS0_MODE_GADGET &&
- (DWC3_IP_IS(DWC31)) &&
- dwc->maximum_speed == USB_SPEED_SUPER) {
+ DWC3_IP_IS(DWC31) &&
+ (dwc->maximum_speed == USB_SPEED_SUPER || dwc->inv_sync_hdr)) {
int i;

for (i = 0; i < dwc->num_usb3_ports; i++) {
reg = dwc3_readl(dwc, DWC3_LLUCTL(i));
- reg |= DWC3_LLUCTL_FORCE_GEN1;
+ if (dwc->maximum_speed == USB_SPEED_SUPER)
+ reg |= DWC3_LLUCTL_FORCE_GEN1;
+ if (dwc->inv_sync_hdr)
+ reg |= DWC3_LLUCTL_INV_SYNC_HDR;
dwc3_writel(dwc, DWC3_LLUCTL(i), reg);
}
}
@@ -1694,6 +1697,15 @@ static void dwc3_get_software_properties(struct dwc3 *dwc,
if (properties->needs_full_reinit)
dwc->needs_full_reinit = true;

+ if (properties->inv_sync_hdr)
+ dwc->inv_sync_hdr = true;
+
+ if (properties->calibrate_on_start)
+ dwc->calibrate_on_start = true;
+
+ if (properties->xhci_w1c_port_change)
+ dwc->xhci_w1c_port_change = true;
+
dwc->gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED;

if (properties->gsbuscfg0_reqinfo !=
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index f635a9fbc151..e65629f9d437 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -677,6 +677,8 @@

/* Force Gen1 speed on Gen2 link */
#define DWC3_LLUCTL_FORCE_GEN1 BIT(10)
+/* Invert sync header on Cadence SerDes */
+#define DWC3_LLUCTL_INV_SYNC_HDR BIT(30)

/* Structures */

@@ -1151,6 +1153,9 @@ struct dwc3_glue_ops {
* @dis_u1_entry_quirk: set if link entering into U1 state needs to be disabled.
* @dis_u2_entry_quirk: set if link entering into U2 state needs to be disabled.
* @dis_rxdet_inp3_quirk: set if we disable Rx.Detect in P3
+ * @inv_sync_hdr: set if Cadence SerDes requires inverted sync header
+ * @calibrate_on_start: calibrate USB3 PHYs after xHCI reset
+ * @xhci_w1c_port_change: enable xHCI W1C port change quirk
* @async_callbacks: if set, indicate that async callbacks will be used.
*
* @dis_u2_freeclk_exists_quirk : set if we clear u2_freeclk_exists
@@ -1419,6 +1424,9 @@ struct dwc3 {
unsigned dis_u1_entry_quirk:1;
unsigned dis_u2_entry_quirk:1;
unsigned dis_rxdet_inp3_quirk:1;
+ unsigned inv_sync_hdr:1;
+ unsigned calibrate_on_start:1;
+ unsigned xhci_w1c_port_change:1;
unsigned dis_u2_freeclk_exists_quirk:1;
unsigned dis_del_phy_power_chg_quirk:1;
unsigned dis_tx_ipgap_linecheck_quirk:1;
diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index 3e90ddf25809..568fa1a26379 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -72,7 +72,7 @@ static int dwc3_eic7700_init(struct dwc3_generic *dwc3g)
return 0;
}

-static int dwc3_spacemit_k1_init(struct dwc3_generic *dwc3g)
+static int dwc3_host_vbus_init(struct dwc3_generic *dwc3g)
{
struct device *dev = dwc3g->dev;

@@ -219,10 +219,20 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
};

static const struct dwc3_generic_config spacemit_k1_dwc3 = {
- .init = dwc3_spacemit_k1_init,
+ .init = dwc3_host_vbus_init,
.properties = DWC3_DEFAULT_PROPERTIES,
};

+static const struct dwc3_generic_config sun60i_a733_dwc3 = {
+ .init = dwc3_host_vbus_init,
+ .properties = {
+ .gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED,
+ .inv_sync_hdr = true,
+ .calibrate_on_start = true,
+ .xhci_w1c_port_change = true,
+ },
+};
+
static const struct dwc3_generic_config fsl_ls1028_dwc3 = {
.properties.gsbuscfg0_reqinfo = 0x2222,
};
@@ -233,6 +243,7 @@ static const struct dwc3_generic_config eic7700_dwc3 = {
};

static const struct of_device_id dwc3_generic_of_match[] = {
+ { .compatible = "allwinner,sun60i-a733-dwc3", &sun60i_a733_dwc3 },
{ .compatible = "spacemit,k1-dwc3", &spacemit_k1_dwc3},
{ .compatible = "spacemit,k3-dwc3", },
{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
index a1284c481390..12a24e9016eb 100644
--- a/drivers/usb/dwc3/glue.h
+++ b/drivers/usb/dwc3/glue.h
@@ -14,10 +14,16 @@
* @gsbuscfg0_reqinfo: Value to be programmed in the GSBUSCFG0.REQINFO field
* @needs_full_reinit: indicate the controller may not remain power during system
* pm and need full initialization
+ * @inv_sync_hdr: set DWC3_LLUCTL_INV_SYNC_HDR for Cadence SerDes
+ * @calibrate_on_start: calibrate USB3 PHYs after xHCI reset
+ * @xhci_w1c_port_change: enable xHCI W1C port change quirk
*/
struct dwc3_properties {
u32 gsbuscfg0_reqinfo;
unsigned needs_full_reinit:1;
+ unsigned inv_sync_hdr:1;
+ unsigned calibrate_on_start:1;
+ unsigned xhci_w1c_port_change:1;
};

#define DWC3_DEFAULT_PROPERTIES ((struct dwc3_properties){ \
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index cd1e5204ac3a..e45d8b14b60c 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -68,6 +68,7 @@ static void dwc3_xhci_plat_start(struct usb_hcd *hcd)
{
struct platform_device *pdev;
struct dwc3 *dwc;
+ int i;

if (!usb_hcd_is_primary_hcd(hcd))
return;
@@ -75,6 +76,12 @@ static void dwc3_xhci_plat_start(struct usb_hcd *hcd)
pdev = to_platform_device(hcd->self.controller);
dwc = dev_get_drvdata(pdev->dev.parent);

+ /* Calibrate PHYs after xHCI reset to complete clock handover. */
+ if (dwc->calibrate_on_start) {
+ for (i = 0; i < dwc->num_usb3_ports; i++)
+ phy_calibrate(dwc->usb3_generic_phy[i]);
+ }
+
dwc3_enable_susphy(dwc, true);
}

@@ -174,6 +181,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->usb2_lpm_disable)
props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb2-lpm-disable");

+ if (dwc->xhci_w1c_port_change)
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-w1c-port-change-quirk");
+
/**
* WORKAROUND: dwc3 revisions <=3.00a have a limitation
* where Port Disable command doesn't work.
--
2.53.0