]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
usb: dwc3: core: Enable CCI support in dwc3 core driver
authorManish Narani <manish.narani@xilinx.com>
Tue, 28 Mar 2017 10:31:52 +0000 (16:01 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 28 Mar 2017 11:33:59 +0000 (13:33 +0200)
This patch adds CCI support in DWC3 driver when CCI is enabled in the
design. There are couple of registers which need to be modified for
making CCI enabled transfers in USB. This patch add the support for
the same.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/usb/dwc3/core.c

index 6d69eb729d64a9cf6f96063f7e7b6fddbd8fedf7..322a82367a5c7b20a9f97aa2ce0add90a3f490b2 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/of.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/of_address.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -461,6 +462,33 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
        parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
 }
 
+static int dwc3_config_soc_bus(struct dwc3 *dwc)
+{
+       int ret;
+
+       /*
+        * Check if CCI is enabled for USB. Returns true
+        * if the node has property 'dma-coherent'. Otherwise
+        * returns false.
+        */
+       if (of_dma_is_coherent(dwc->dev->of_node)) {
+               u32 reg;
+
+               reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+               reg |= DWC3_GSBUSCFG0_DATRDREQINFO |
+                       DWC3_GSBUSCFG0_DESRDREQINFO |
+                       DWC3_GSBUSCFG0_DATWRREQINFO |
+                       DWC3_GSBUSCFG0_DESWRREQINFO;
+               dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+
+               ret = dwc3_enable_hw_coherency(dwc->dev);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 /**
  * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
  * @dwc: Pointer to our controller context structure
@@ -656,6 +684,10 @@ static int dwc3_core_init(struct dwc3 *dwc)
        if (ret)
                goto err0;
 
+       ret = dwc3_config_soc_bus(dwc);
+       if (ret)
+               goto err0;
+
        ret = dwc3_phy_setup(dwc);
        if (ret)
                goto err0;