]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
usb: dwc3: Check for ESS TX/RX threshold config
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Fri, 16 Mar 2018 22:35:44 +0000 (15:35 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 22 Mar 2018 08:48:59 +0000 (10:48 +0200)
Check and configure TX/RX threshold for DWC_usb31. Update dwc3 structure
with new fields to store these threshold configurations.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/core.c
drivers/usb/dwc3/core.h

index 5491d9678d7052e651143bb12a040131d31198e3..7c8d3bedf802c31e1bf7613c66b97f287809bdeb 100644 (file)
@@ -872,6 +872,43 @@ static int dwc3_core_init(struct dwc3 *dwc)
                dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
        }
 
+       /*
+        * Must config both number of packets and max burst settings to enable
+        * RX and/or TX threshold.
+        */
+       if (dwc3_is_usb31(dwc) && dwc->dr_mode == USB_DR_MODE_HOST) {
+               u8 rx_thr_num = dwc->rx_thr_num_pkt_prd;
+               u8 rx_maxburst = dwc->rx_max_burst_prd;
+               u8 tx_thr_num = dwc->tx_thr_num_pkt_prd;
+               u8 tx_maxburst = dwc->tx_max_burst_prd;
+
+               if (rx_thr_num && rx_maxburst) {
+                       reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG);
+                       reg |= DWC31_RXTHRNUMPKTSEL_PRD;
+
+                       reg &= ~DWC31_RXTHRNUMPKT_PRD(~0);
+                       reg |= DWC31_RXTHRNUMPKT_PRD(rx_thr_num);
+
+                       reg &= ~DWC31_MAXRXBURSTSIZE_PRD(~0);
+                       reg |= DWC31_MAXRXBURSTSIZE_PRD(rx_maxburst);
+
+                       dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg);
+               }
+
+               if (tx_thr_num && tx_maxburst) {
+                       reg = dwc3_readl(dwc->regs, DWC3_GTXTHRCFG);
+                       reg |= DWC31_TXTHRNUMPKTSEL_PRD;
+
+                       reg &= ~DWC31_TXTHRNUMPKT_PRD(~0);
+                       reg |= DWC31_TXTHRNUMPKT_PRD(tx_thr_num);
+
+                       reg &= ~DWC31_MAXTXBURSTSIZE_PRD(~0);
+                       reg |= DWC31_MAXTXBURSTSIZE_PRD(tx_maxburst);
+
+                       dwc3_writel(dwc->regs, DWC3_GTXTHRCFG, reg);
+               }
+       }
+
        return 0;
 
 err4:
@@ -1042,6 +1079,10 @@ static void dwc3_get_properties(struct dwc3 *dwc)
        u8                      lpm_nyet_threshold;
        u8                      tx_de_emphasis;
        u8                      hird_threshold;
+       u8                      rx_thr_num_pkt_prd;
+       u8                      rx_max_burst_prd;
+       u8                      tx_thr_num_pkt_prd;
+       u8                      tx_max_burst_prd;
 
        /* default to highest possible threshold */
        lpm_nyet_threshold = 0xff;
@@ -1076,6 +1117,14 @@ static void dwc3_get_properties(struct dwc3 *dwc)
                                &hird_threshold);
        dwc->usb3_lpm_capable = device_property_read_bool(dev,
                                "snps,usb3_lpm_capable");
+       device_property_read_u8(dev, "snps,rx-thr-num-pkt-prd",
+                               &rx_thr_num_pkt_prd);
+       device_property_read_u8(dev, "snps,rx-max-burst-prd",
+                               &rx_max_burst_prd);
+       device_property_read_u8(dev, "snps,tx-thr-num-pkt-prd",
+                               &tx_thr_num_pkt_prd);
+       device_property_read_u8(dev, "snps,tx-max-burst-prd",
+                               &tx_max_burst_prd);
 
        dwc->disable_scramble_quirk = device_property_read_bool(dev,
                                "snps,disable_scramble_quirk");
@@ -1126,6 +1175,12 @@ static void dwc3_get_properties(struct dwc3 *dwc)
        dwc->hird_threshold = hird_threshold
                | (dwc->is_utmi_l1_suspend << 4);
 
+       dwc->rx_thr_num_pkt_prd = rx_thr_num_pkt_prd;
+       dwc->rx_max_burst_prd = rx_max_burst_prd;
+
+       dwc->tx_thr_num_pkt_prd = tx_thr_num_pkt_prd;
+       dwc->tx_max_burst_prd = tx_max_burst_prd;
+
        dwc->imod_interval = 0;
 }
 
index ce9edcf177388a48ed9854444ad79c6b8596c11c..28d6f6511f6f91aa0b8a16143133bfaf193f4ed7 100644 (file)
@@ -929,6 +929,10 @@ struct dwc3_scratchpad_array {
  * @test_mode_nr: test feature selector
  * @lpm_nyet_threshold: LPM NYET response threshold
  * @hird_threshold: HIRD threshold
+ * @rx_thr_num_pkt_prd: periodic ESS receive packet count
+ * @rx_max_burst_prd: max periodic ESS receive burst size
+ * @tx_thr_num_pkt_prd: periodic ESS transmit packet count
+ * @tx_max_burst_prd: max periodic ESS transmit burst size
  * @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
@@ -1096,6 +1100,10 @@ struct dwc3 {
        u8                      test_mode_nr;
        u8                      lpm_nyet_threshold;
        u8                      hird_threshold;
+       u8                      rx_thr_num_pkt_prd;
+       u8                      rx_max_burst_prd;
+       u8                      tx_thr_num_pkt_prd;
+       u8                      tx_max_burst_prd;
 
        const char              *hsphy_interface;