FROMLIST: usb: dwc3: Enable support for 64-bit system
authorWu Liang feng <wulf@rock-chips.com>
Sun, 6 Mar 2016 15:18:30 +0000 (23:18 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 7 Mar 2016 07:26:35 +0000 (15:26 +0800)
Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Change-Id: I6d8e0e35ed606aa38d1dbadbb48f5629c1b39552
Signed-off-by: Thang Q. Nguyen <tqnguyen@apm.com>
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
(am from https://patchwork.kernel.org/patch/8109031/)

drivers/usb/dwc3/core.c

index de5e01f41bc2190560d63a59df5c9b2c4011ff1f..2479c241945c3c3a3f825723df171090cfa74df4 100644 (file)
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
        dwc->mem = mem;
        dwc->dev = dev;
 
+       /* Try to set 64-bit DMA first */
+       if (!pdev->dev.dma_mask)
+               /* Platform did not initialize dma_mask */
+               ret = dma_coerce_mask_and_coherent(&pdev->dev,
+                                                  DMA_BIT_MASK(64));
+       else
+               ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+
+       /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+       if (ret) {
+               ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+               if (ret)
+                       return ret;
+       }
+
        res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (!res) {
                dev_err(dev, "missing IRQ\n");