ipq8064: Fix dwc3 module unloading
authorThomas Reifferscheid <thomas@reifferscheid.org>
Mon, 27 Mar 2017 21:52:06 +0000 (23:52 +0200)
committerJohn Crispin <john@phrozen.org>
Tue, 28 Mar 2017 07:02:38 +0000 (09:02 +0200)
Allow module unloading by fixing a mistake.
qcom_dwc3_phy_write_readback() is expecting (phy, offset, mask, value)
while the mistake was calling it with       (phy, offset, value, mask)

The patch is swapping value and mask.

Without the patch unloading the dwc3 module was showing a
write to QSCRATCH failed and repeated module loading was
failing:

root@LEDE:/# rmmod dwc3
[   19.167998] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   19.168084] usb usb4: USB disconnect, device number 1
[   19.173371] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[   19.177134] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   19.182960] usb usb3: USB disconnect, device number 1
[   19.189023] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered
[   19.192989] qcom-dwc3-usb-phy 110f8830.phy: write: 8000000 to QSCRATCH: 0 FAILED
[   19.199064] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   19.205912] usb usb2: USB disconnect, device number 1
[   19.211611] xhci-hcd xhci-hcd.0.auto: USB bus 2 deregistered
[   19.215905] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   19.221751] usb usb1: USB disconnect, device number 1
[   19.227307] xhci-hcd xhci-hcd.0.auto: USB bus 1 deregistered
[   19.231795] qcom-dwc3-usb-phy 100f8830.phy: write: 8000000 to QSCRATCH: 0 FAILED
root@LEDE:/# modprobe dwc3
[   29.583343] phy phy-100f8830.phy.4: phy init failed --> -110
[   29.583399] dwc3 10000000.dwc3: failed to initialize core
[   29.588169] dwc3: probe of 10000000.dwc3 failed with error -110
[   29.652943] phy phy-110f8830.phy.2: phy init failed --> -110
[   29.652988] dwc3 11000000.dwc3: failed to initialize core
[   29.657735] dwc3: probe of 11000000.dwc3 failed with error -110
root@LEDE:/#

With patch repeated module unloading and loading is working good:
root@LEDE:/# rmmod dwc3
[   22.622214] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   22.622298] usb usb4: USB disconnect, device number 1
[   22.627401] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[   22.631492] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   22.637054] usb usb3: USB disconnect, device number 1
[   22.643721] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered
[   22.647421] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   22.652910] usb usb2: USB disconnect, device number 1
[   22.659219] xhci-hcd xhci-hcd.0.auto: USB bus 2 deregistered
[   22.662768] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   22.668604] usb usb1: USB disconnect, device number 1
[   22.674803] xhci-hcd xhci-hcd.0.auto: USB bus 1 deregistered
root@LEDE:/# modprobe dwc3
[   25.404592] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[   25.404694] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[   25.409444] xhci-hcd xhci-hcd.0.auto: hcc params 0x0228f065 hci version 0x100 quirks 0x00010010
[   25.416589] xhci-hcd xhci-hcd.0.auto: irq 168, io mem 0x10000000
[   25.426509] hub 1-0:1.0: USB hub found
[   25.431626] hub 1-0:1.0: 1 port detected
[   25.435472] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[   25.439206] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2
[   25.444573] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[   25.452926] hub 2-0:1.0: USB hub found
[   25.460420] hub 2-0:1.0: 1 port detected
[   25.525037] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[   25.525099] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 3
[   25.529750] xhci-hcd xhci-hcd.1.auto: hcc params 0x0228f065 hci version 0x100 quirks 0x00010010
[   25.537002] xhci-hcd xhci-hcd.1.auto: irq 169, io mem 0x11000000
[   25.546583] hub 3-0:1.0: USB hub found
[   25.551997] hub 3-0:1.0: 1 port detected
[   25.555734] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[   25.559621] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 4
[   25.564942] usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
[   25.573063] hub 4-0:1.0: USB hub found
[   25.580842] hub 4-0:1.0: 1 port detected
root@LEDE:/#

Fixes: dwc3 module unloading
Signed-off-by: Thomas Reifferscheid <thomas@reifferscheid.org>
target/linux/ipq806x/patches-4.9/0032-phy-add-qcom-dwc3-phy.patch

index 314631d3c0d4a5de9e24d700ffb81653fee9f60b..39e918f193ec4586150b54ae93912fcaa8d4db1c 100644 (file)
@@ -420,7 +420,7 @@ Signed-off-by: Andy Gross <agross@codeaurora.org>
 +      qcom_dwc3_phy_write_readback(phy_dwc3, SSUSB_PHY_CTRL_REG,
 +              SSUSB_CTRL_REF_USE_PAD, 0x0);
 +      qcom_dwc3_phy_write_readback(phy_dwc3, SSUSB_PHY_CTRL_REG,
-+              0x0, SSUSB_CTRL_TEST_POWERDOWN);
++              SSUSB_CTRL_TEST_POWERDOWN, 0x0);
 +
 +      return 0;
 +}