Merge "USB: dwc3-msm: Add support for overriding SSPHY deemphasis setting"
diff --git a/Documentation/devicetree/bindings/usb/msm-ssusb.txt b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
index 53e912a..a7a646d 100644
--- a/Documentation/devicetree/bindings/usb/msm-ssusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
@@ -56,6 +56,8 @@
TX fifo allocation in bytes
- qcom,dwc-usb3-msm-qdss-tx-fifo-size: If present, represent RAM size available
for TX fifo allocation in QDSS composition
+- qcom,dwc-ssphy-deemphasis-value: This property if present represents ss phy
+ deemphasis value to be used for overriding into SSPHY register.
Sub nodes:
- Sub node for "DWC3- USB3 controller".
@@ -82,6 +84,7 @@
qcom,dwc_usb3-adc_tm = <&pm8941_adc_tm>;
qcom,dwc-usb3-msm-tx-fifo-size = <29696>;
qcom,dwc-usb3-msm-qdss-tx-fifo-size = <16384>;
+ qcom,dwc-ssphy-deemphasis-value = <26>;
qcom,msm_bus,name = "usb3";
qcom,msm_bus,num_cases = <2>;
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index 60d7119..bda1093 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -69,6 +69,10 @@
module_param(override_phy_init, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(override_phy_init, "Override HSPHY Init Seq");
+static int ss_phy_override_deemphasis;
+module_param(ss_phy_override_deemphasis, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(ss_phy_override_deemphasis, "Override SSPHY demphasis value");
+
/* Enable Proprietary charger detection */
static bool prop_chg_detect;
module_param(prop_chg_detect, bool, S_IRUGO | S_IWUSR);
@@ -198,6 +202,7 @@
atomic_t in_lpm;
int hs_phy_irq;
int hsphy_init_seq;
+ int deemphasis_val;
bool lpm_irq_seen;
struct delayed_work resume_work;
struct work_struct restart_usb_work;
@@ -1416,7 +1421,12 @@
*/
data = dwc3_msm_ssusb_read_phycreg(mdwc->base, 0x1002);
data &= ~0x3F80;
- data |= (0x16 << 7);
+ if (ss_phy_override_deemphasis)
+ mdwc->deemphasis_val = ss_phy_override_deemphasis;
+ if (mdwc->deemphasis_val)
+ data |= (mdwc->deemphasis_val << 7);
+ else
+ data |= (0x16 << 7);
data &= ~0x7F;
data |= (0x7F | (1 << 14));
dwc3_msm_ssusb_write_phycreg(mdwc->base, 0x1002, data);
@@ -2978,6 +2988,10 @@
else if (!mdwc->hsphy_init_seq)
dev_warn(&pdev->dev, "incorrect hsphyinitseq.Using PORvalue\n");
+ if (of_property_read_u32(node, "qcom,dwc-ssphy-deemphasis-value",
+ &mdwc->deemphasis_val))
+ dev_dbg(&pdev->dev, "unable to read ssphy deemphasis value\n");
+
pm_runtime_set_active(mdwc->dev);
pm_runtime_enable(mdwc->dev);