Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: qualcomm: phy-qcom-eusb2-repeater: Add tuning overrides

There are devices in the wild, like the Sony Xperia 1 V that *require*
different tuning than the base design for USB to work.

Add support for overriding the necessary tuning values.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230830-topic-eusb2_override-v2-4-7d8c893d93f6@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Konrad Dybcio and committed by
Vinod Koul
56156a76 99a517a5

+16 -1
+16 -1
drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
··· 142 142 { 143 143 struct reg_field *regfields = eusb2_repeater_tune_reg_fields; 144 144 struct eusb2_repeater *rptr = phy_get_drvdata(phy); 145 - const u32 *init_tbl = rptr->cfg->init_tbl; 145 + struct device_node *np = rptr->dev->of_node; 146 + u32 init_tbl[F_NUM_TUNE_FIELDS] = { 0 }; 147 + u8 override; 146 148 u32 val; 147 149 int ret; 148 150 int i; ··· 165 163 regmap_field_update_bits(rptr->regs[i], mask, 0); 166 164 } 167 165 } 166 + memcpy(init_tbl, rptr->cfg->init_tbl, sizeof(init_tbl)); 167 + 168 + if (!of_property_read_u8(np, "qcom,tune-usb2-amplitude", &override)) 169 + init_tbl[F_TUNE_IUSB2] = override; 170 + 171 + if (!of_property_read_u8(np, "qcom,tune-usb2-disc-thres", &override)) 172 + init_tbl[F_TUNE_HSDISC] = override; 173 + 174 + if (!of_property_read_u8(np, "qcom,tune-usb2-preem", &override)) 175 + init_tbl[F_TUNE_USB2_PREEM] = override; 176 + 177 + for (i = 0; i < F_NUM_TUNE_FIELDS; i++) 178 + regmap_field_update_bits(rptr->regs[i], init_tbl[i], init_tbl[i]); 168 179 169 180 ret = regmap_field_read_poll_timeout(rptr->regs[F_RPTR_STATUS], 170 181 val, val & RPTR_OK, 10, 5);