Now that the gadget driver automatically detects DMA modes, we need to
provide a way to disable them. Certain platforms may still have issues
with DMA and require it to be disabled. It is also needed for IP
validation purposes.

Signed-off-by: John Youn <johny...@synopsys.com>
---
 Documentation/devicetree/bindings/usb/dwc2.txt | 2 ++
 drivers/usb/dwc2/params.c                      | 9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index 389bb13..10a2a4b 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -26,6 +26,8 @@ Refer to phy/phy-bindings.txt for generic phy consumer 
properties
 - dr_mode: shall be one of "host", "peripheral" and "otg"
   Refer to usb/generic.txt
 - snps,host-dma-disable: disable host DMA mode.
+- snps,gadget-dma-disable: disable gadget DMA mode.
+- snps,gadget-dma-desc-disable: disable gadget DMA descriptor mode.
 - g-rx-fifo-size: size of rx fifo size in gadget mode.
 - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
 - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget 
mode.
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 2f18a7b..64d5c66 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -1091,17 +1091,22 @@ static void dwc2_set_gadget_dma(struct dwc2_hsotg 
*hsotg)
        struct dwc2_hw_params *hw = &hsotg->hw_params;
        struct dwc2_core_params *p = &hsotg->params;
        bool dma_capable = !(hw->arch == GHWCFG2_SLAVE_ONLY_ARCH);
+       bool disable;
 
        /* Buffer DMA */
+       disable = device_property_read_bool(hsotg->dev,
+                                           "snps,gadget-dma-disable");
        dwc2_set_param_bool(hsotg, &p->g_dma,
                            false, "gadget-dma",
-                           true, false,
+                           !disable, false,
                            dma_capable);
 
        /* DMA Descriptor */
+       disable = device_property_read_bool(hsotg->dev,
+                                           "snps,gadget-dma-desc-disable");
        dwc2_set_param_bool(hsotg, &p->g_dma_desc, false,
                            "gadget-dma-desc",
-                           p->g_dma, false,
+                           p->g_dma && !disable, false,
                            !!hw->dma_desc_enable);
 }
 
-- 
2.10.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to