Skip to content

Commit

Permalink
phy: qualcomm: phy-qcom-eusb2-repeater: Add tuning overrides
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
  • Loading branch information
konradybcio authored and vinodkoul committed Sep 21, 2023
1 parent 99a517a commit 56156a7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ static int eusb2_repeater_init(struct phy *phy)
{
struct reg_field *regfields = eusb2_repeater_tune_reg_fields;
struct eusb2_repeater *rptr = phy_get_drvdata(phy);
const u32 *init_tbl = rptr->cfg->init_tbl;
struct device_node *np = rptr->dev->of_node;
u32 init_tbl[F_NUM_TUNE_FIELDS] = { 0 };
u8 override;
u32 val;
int ret;
int i;
Expand All @@ -163,6 +165,19 @@ static int eusb2_repeater_init(struct phy *phy)
regmap_field_update_bits(rptr->regs[i], mask, 0);
}
}
memcpy(init_tbl, rptr->cfg->init_tbl, sizeof(init_tbl));

if (!of_property_read_u8(np, "qcom,tune-usb2-amplitude", &override))
init_tbl[F_TUNE_IUSB2] = override;

if (!of_property_read_u8(np, "qcom,tune-usb2-disc-thres", &override))
init_tbl[F_TUNE_HSDISC] = override;

if (!of_property_read_u8(np, "qcom,tune-usb2-preem", &override))
init_tbl[F_TUNE_USB2_PREEM] = override;

for (i = 0; i < F_NUM_TUNE_FIELDS; i++)
regmap_field_update_bits(rptr->regs[i], init_tbl[i], init_tbl[i]);

ret = regmap_field_read_poll_timeout(rptr->regs[F_RPTR_STATUS],
val, val & RPTR_OK, 10, 5);
Expand Down

0 comments on commit 56156a7

Please sign in to comment.