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

Configure Feed

Select the types of activity you want to include in your feed.

phy: qualcomm: phy-qcom-eusb2-repeater: Don't zero-out registers

Zeroing out registers does not happen in the downstream kernel, and will
"tune" the repeater in surely unexpected ways since most registers don't
have a reset value of 0x0.

Stop doing that and instead just set the registers that are in the init
sequence (though long term I don't think there's actually PMIC-specific
init sequences, there's board specific tuning, but that's a story for
another day).

Fixes: 99a517a582fc ("phy: qualcomm: phy-qcom-eusb2-repeater: Zero out untouched tuning regs")
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20250617-eusb2-repeater-tuning-v2-2-ed6c484f18ee@fairphone.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Luca Weiss and committed by
Vinod Koul
31bc94de db9f3e3f

+30 -53
+30 -53
drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
··· 37 37 #define EUSB2_TUNE_EUSB_EQU 0x5A 38 38 #define EUSB2_TUNE_EUSB_HS_COMP_CUR 0x5B 39 39 40 - enum eusb2_reg_layout { 41 - TUNE_EUSB_HS_COMP_CUR, 42 - TUNE_EUSB_EQU, 43 - TUNE_EUSB_SLEW, 44 - TUNE_USB2_HS_COMP_CUR, 45 - TUNE_USB2_PREEM, 46 - TUNE_USB2_EQU, 47 - TUNE_USB2_SLEW, 48 - TUNE_SQUELCH_U, 49 - TUNE_HSDISC, 50 - TUNE_RES_FSDIF, 51 - TUNE_IUSB2, 52 - TUNE_USB2_CROSSOVER, 53 - NUM_TUNE_FIELDS, 54 - 55 - FORCE_VAL_5 = NUM_TUNE_FIELDS, 56 - FORCE_EN_5, 57 - 58 - EN_CTL1, 59 - 60 - RPTR_STATUS, 61 - LAYOUT_SIZE, 40 + struct eusb2_repeater_init_tbl_reg { 41 + unsigned int reg; 42 + unsigned int value; 62 43 }; 63 44 64 45 struct eusb2_repeater_cfg { 65 - const u32 *init_tbl; 46 + const struct eusb2_repeater_init_tbl_reg *init_tbl; 66 47 int init_tbl_num; 67 48 const char * const *vreg_list; 68 49 int num_vregs; ··· 63 82 "vdd18", "vdd3", 64 83 }; 65 84 66 - static const u32 pm8550b_init_tbl[NUM_TUNE_FIELDS] = { 67 - [TUNE_IUSB2] = 0x8, 68 - [TUNE_SQUELCH_U] = 0x3, 69 - [TUNE_USB2_PREEM] = 0x5, 85 + static const struct eusb2_repeater_init_tbl_reg pm8550b_init_tbl[] = { 86 + { EUSB2_TUNE_IUSB2, 0x8 }, 87 + { EUSB2_TUNE_SQUELCH_U, 0x3 }, 88 + { EUSB2_TUNE_USB2_PREEM, 0x5 }, 70 89 }; 71 90 72 - static const u32 smb2360_init_tbl[NUM_TUNE_FIELDS] = { 73 - [TUNE_IUSB2] = 0x5, 74 - [TUNE_SQUELCH_U] = 0x3, 75 - [TUNE_USB2_PREEM] = 0x2, 91 + static const struct eusb2_repeater_init_tbl_reg smb2360_init_tbl[] = { 92 + { EUSB2_TUNE_IUSB2, 0x5 }, 93 + { EUSB2_TUNE_SQUELCH_U, 0x3 }, 94 + { EUSB2_TUNE_USB2_PREEM, 0x2 }, 76 95 }; 77 96 78 97 static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = { ··· 110 129 struct eusb2_repeater *rptr = phy_get_drvdata(phy); 111 130 struct device_node *np = rptr->dev->of_node; 112 131 struct regmap *regmap = rptr->regmap; 113 - const u32 *init_tbl = rptr->cfg->init_tbl; 114 - u8 tune_usb2_preem = init_tbl[TUNE_USB2_PREEM]; 115 - u8 tune_hsdisc = init_tbl[TUNE_HSDISC]; 116 - u8 tune_iusb2 = init_tbl[TUNE_IUSB2]; 117 132 u32 base = rptr->base; 118 - u32 val; 133 + u32 poll_val; 119 134 int ret; 120 - 121 - of_property_read_u8(np, "qcom,tune-usb2-amplitude", &tune_iusb2); 122 - of_property_read_u8(np, "qcom,tune-usb2-disc-thres", &tune_hsdisc); 123 - of_property_read_u8(np, "qcom,tune-usb2-preem", &tune_usb2_preem); 135 + u8 val; 124 136 125 137 ret = regulator_bulk_enable(rptr->cfg->num_vregs, rptr->vregs); 126 138 if (ret) ··· 121 147 122 148 regmap_write(regmap, base + EUSB2_EN_CTL1, EUSB2_RPTR_EN); 123 149 124 - regmap_write(regmap, base + EUSB2_TUNE_EUSB_HS_COMP_CUR, init_tbl[TUNE_EUSB_HS_COMP_CUR]); 125 - regmap_write(regmap, base + EUSB2_TUNE_EUSB_EQU, init_tbl[TUNE_EUSB_EQU]); 126 - regmap_write(regmap, base + EUSB2_TUNE_EUSB_SLEW, init_tbl[TUNE_EUSB_SLEW]); 127 - regmap_write(regmap, base + EUSB2_TUNE_USB2_HS_COMP_CUR, init_tbl[TUNE_USB2_HS_COMP_CUR]); 128 - regmap_write(regmap, base + EUSB2_TUNE_USB2_EQU, init_tbl[TUNE_USB2_EQU]); 129 - regmap_write(regmap, base + EUSB2_TUNE_USB2_SLEW, init_tbl[TUNE_USB2_SLEW]); 130 - regmap_write(regmap, base + EUSB2_TUNE_SQUELCH_U, init_tbl[TUNE_SQUELCH_U]); 131 - regmap_write(regmap, base + EUSB2_TUNE_RES_FSDIF, init_tbl[TUNE_RES_FSDIF]); 132 - regmap_write(regmap, base + EUSB2_TUNE_USB2_CROSSOVER, init_tbl[TUNE_USB2_CROSSOVER]); 150 + /* Write registers from init table */ 151 + for (int i = 0; i < rptr->cfg->init_tbl_num; i++) 152 + regmap_write(regmap, base + rptr->cfg->init_tbl[i].reg, 153 + rptr->cfg->init_tbl[i].value); 133 154 134 - regmap_write(regmap, base + EUSB2_TUNE_USB2_PREEM, tune_usb2_preem); 135 - regmap_write(regmap, base + EUSB2_TUNE_HSDISC, tune_hsdisc); 136 - regmap_write(regmap, base + EUSB2_TUNE_IUSB2, tune_iusb2); 155 + /* Override registers from devicetree values */ 156 + if (!of_property_read_u8(np, "qcom,tune-usb2-amplitude", &val)) 157 + regmap_write(regmap, base + EUSB2_TUNE_USB2_PREEM, val); 137 158 138 - ret = regmap_read_poll_timeout(regmap, base + EUSB2_RPTR_STATUS, val, val & RPTR_OK, 10, 5); 159 + if (!of_property_read_u8(np, "qcom,tune-usb2-disc-thres", &val)) 160 + regmap_write(regmap, base + EUSB2_TUNE_HSDISC, val); 161 + 162 + if (!of_property_read_u8(np, "qcom,tune-usb2-preem", &val)) 163 + regmap_write(regmap, base + EUSB2_TUNE_IUSB2, val); 164 + 165 + /* Wait for status OK */ 166 + ret = regmap_read_poll_timeout(regmap, base + EUSB2_RPTR_STATUS, poll_val, 167 + poll_val & RPTR_OK, 10, 5); 139 168 if (ret) 140 169 dev_err(rptr->dev, "initialization timed-out\n"); 141 170