diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 366738c582bf..2ef7ffdc61df 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -729,6 +729,22 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); + if (dwc->grxthrcfg[0] > 0) { + reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG); + reg |= DWC3_GRXTHRCFG_PKTCNTSEL | + DWC3_GRXTHRCFG_RXPKTCNT(dwc->grxthrcfg[0]) | + DWC3_GRXTHRCFG_MAXRXBURSTSIZE(dwc->grxthrcfg[1]); + dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg); + } + + if (dwc->gtxthrcfg[0] > 0) { + reg = dwc3_readl(dwc->regs, DWC3_GTXTHRCFG); + reg |= DWC3_GTXTHRCFG_PKTCNTSEL | + DWC3_GTXTHRCFG_TXPKTCNT(dwc->gtxthrcfg[0]) | + DWC3_GTXTHRCFG_MAXRXBURSTSIZE(dwc->gtxthrcfg[1]); + dwc3_writel(dwc->regs, DWC3_GTXTHRCFG, reg); + } + return 0; err4: @@ -1023,6 +1039,11 @@ static int dwc3_probe(struct platform_device *pdev) &dwc->hsphy_interface); device_property_read_u32(dev, "snps,quirk-frame-length-adjustment", &dwc->fladj); + device_property_read_u32_array(dev, "snps,gtx-threshold-cfg", + dwc->gtxthrcfg, 2); + + device_property_read_u32_array(dev, "snps,grx-threshold-cfg", + dwc->grxthrcfg, 2); /* default to superspeed if no maximum_speed passed */ if (dwc->maximum_speed == USB_SPEED_UNKNOWN) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 73176a6e2d8f..c025c3c007bc 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -166,6 +166,11 @@ #define DWC3_DESCFETCHQ 13 #define DWC3_EVENTQ 15 +/* Global TX Threshold Configuration Register */ +#define DWC3_GTXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0xff) << 16) +#define DWC3_GTXTHRCFG_TXPKTCNT(n) (((n) & 0xf) << 24) +#define DWC3_GTXTHRCFG_PKTCNTSEL BIT(29) + /* Global RX Threshold Configuration Register */ #define DWC3_GRXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0x1f) << 19) #define DWC3_GRXTHRCFG_RXPKTCNT(n) (((n) & 0xf) << 24) @@ -785,6 +790,8 @@ struct dwc3_scratchpad_array { * @test_mode_nr: test feature selector * @lpm_nyet_threshold: LPM NYET response threshold * @hird_threshold: HIRD threshold + * @grxthrcfg: global Tx threshold config + * @gtxthrcfg: global Rx threshold config * @hsphy_interface: "utmi" or "ulpi" * @connected: true when we're connected to a host, false otherwise * @delayed_status: true when gadget driver asks for delayed status @@ -943,6 +950,8 @@ struct dwc3 { u8 test_mode_nr; u8 lpm_nyet_threshold; u8 hird_threshold; + u32 grxthrcfg[2]; + u32 gtxthrcfg[2]; const char *hsphy_interface;