Skip to content

Commit

Permalink
phy: qcom: qmp: Add debug prints for register writes
Browse files Browse the repository at this point in the history
These register prints are useful to validate the init sequence against the
Qcom internal documentation and also to share with the Qcom hw engineers to
debug issues related to PHY.

Sample debug prints:

qcom-qmp-pcie-phy 1c0e000.phy: Writing Reg: QSERDES_V5_COM_SYSCLK_EN_SEL Offset: 0x0094 Val: 0xd9
qcom-qmp-pcie-phy 1c0e000.phy: Writing Reg: QSERDES_V5_COM_HSCLK_SEL Offset: 0x0158 Val: 0x11

Signed-off-by: Manivannan Sadhasivam <[email protected]>
Reviewed-by: Dmitry Baryshkov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
  • Loading branch information
Mani-Sadhasivam authored and vinodkoul committed Jul 31, 2024
1 parent f75999c commit 4e92d50
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 60 deletions.
38 changes: 20 additions & 18 deletions drivers/phy/qualcomm/phy-qcom-qmp-combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2190,24 +2190,25 @@ static int qmp_combo_dp_serdes_init(struct qmp_combo *qmp)
void __iomem *serdes = qmp->dp_serdes;
const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;

qmp_configure(serdes, cfg->dp_serdes_tbl, cfg->dp_serdes_tbl_num);
qmp_configure(qmp->dev, serdes, cfg->dp_serdes_tbl,
cfg->dp_serdes_tbl_num);

switch (dp_opts->link_rate) {
case 1620:
qmp_configure(serdes, cfg->serdes_tbl_rbr,
cfg->serdes_tbl_rbr_num);
qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_rbr,
cfg->serdes_tbl_rbr_num);
break;
case 2700:
qmp_configure(serdes, cfg->serdes_tbl_hbr,
cfg->serdes_tbl_hbr_num);
qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_hbr,
cfg->serdes_tbl_hbr_num);
break;
case 5400:
qmp_configure(serdes, cfg->serdes_tbl_hbr2,
cfg->serdes_tbl_hbr2_num);
qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_hbr2,
cfg->serdes_tbl_hbr2_num);
break;
case 8100:
qmp_configure(serdes, cfg->serdes_tbl_hbr3,
cfg->serdes_tbl_hbr3_num);
qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_hbr3,
cfg->serdes_tbl_hbr3_num);
break;
default:
/* Other link rates aren't supported */
Expand Down Expand Up @@ -2807,8 +2808,8 @@ static int qmp_combo_dp_power_on(struct phy *phy)

qmp_combo_dp_serdes_init(qmp);

qmp_configure_lane(tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1);
qmp_configure_lane(tx2, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 2);
qmp_configure_lane(qmp->dev, tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1);
qmp_configure_lane(qmp->dev, tx2, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 2);

/* Configure special DP tx tunings */
cfg->configure_dp_tx(qmp);
Expand Down Expand Up @@ -2850,7 +2851,7 @@ static int qmp_combo_usb_power_on(struct phy *phy)
unsigned int val;
int ret;

qmp_configure(serdes, cfg->serdes_tbl, cfg->serdes_tbl_num);
qmp_configure(qmp->dev, serdes, cfg->serdes_tbl, cfg->serdes_tbl_num);

ret = clk_prepare_enable(qmp->pipe_clk);
if (ret) {
Expand All @@ -2859,16 +2860,17 @@ static int qmp_combo_usb_power_on(struct phy *phy)
}

/* Tx, Rx, and PCS configurations */
qmp_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);
qmp_configure_lane(qmp->dev, tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(qmp->dev, tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);

qmp_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
qmp_configure_lane(rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2);
qmp_configure_lane(qmp->dev, rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
qmp_configure_lane(qmp->dev, rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2);

qmp_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
qmp_configure(qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);

if (pcs_usb)
qmp_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num);
qmp_configure(qmp->dev, pcs_usb, cfg->pcs_usb_tbl,
cfg->pcs_usb_tbl_num);

if (cfg->has_pwrdn_delay)
usleep_range(10, 20);
Expand Down
19 changes: 11 additions & 8 deletions drivers/phy/qualcomm/phy-qcom-qmp-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
struct qmp_phy_init_tbl {
unsigned int offset;
unsigned int val;
char *name;
/*
* mask of lanes for which this register is written
* for cases when second lane needs different values
Expand All @@ -20,20 +21,21 @@ struct qmp_phy_init_tbl {
{ \
.offset = o, \
.val = v, \
.name = #o, \
.lane_mask = 0xff, \
}

#define QMP_PHY_INIT_CFG_LANE(o, v, l) \
{ \
.offset = o, \
.val = v, \
.name = #o, \
.lane_mask = l, \
}

static inline void qmp_configure_lane(void __iomem *base,
const struct qmp_phy_init_tbl tbl[],
int num,
u8 lane_mask)
static inline void qmp_configure_lane(struct device *dev, void __iomem *base,
const struct qmp_phy_init_tbl tbl[],
int num, u8 lane_mask)
{
int i;
const struct qmp_phy_init_tbl *t = tbl;
Expand All @@ -45,15 +47,16 @@ static inline void qmp_configure_lane(void __iomem *base,
if (!(t->lane_mask & lane_mask))
continue;

dev_dbg(dev, "Writing Reg: %s Offset: 0x%04x Val: 0x%02x\n",
t->name, t->offset, t->val);
writel(t->val, base + t->offset);
}
}

static inline void qmp_configure(void __iomem *base,
const struct qmp_phy_init_tbl tbl[],
int num)
static inline void qmp_configure(struct device *dev, void __iomem *base,
const struct qmp_phy_init_tbl tbl[], int num)
{
qmp_configure_lane(base, tbl, num, 0xff);
qmp_configure_lane(dev, base, tbl, num, 0xff);
}

#endif
8 changes: 4 additions & 4 deletions drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static int qmp_pcie_msm8996_serdes_init(struct qmp_phy *qphy)
unsigned int val;
int ret;

qmp_configure(serdes, serdes_tbl, serdes_tbl_num);
qmp_configure(qmp->dev, serdes, serdes_tbl, serdes_tbl_num);

qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], SW_RESET);
qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL],
Expand Down Expand Up @@ -431,9 +431,9 @@ static int qmp_pcie_msm8996_power_on(struct phy *phy)
}

/* Tx, Rx, and PCS configurations */
qmp_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
qmp_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
qmp_configure_lane(qmp->dev, tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(qmp->dev, rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
qmp_configure(qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);

/*
* Pull out PHY from POWER DOWN state.
Expand Down
27 changes: 14 additions & 13 deletions drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -3667,11 +3667,11 @@ static void qmp_pcie_init_port_b(struct qmp_pcie *qmp, const struct qmp_phy_cfg_
tx4 = qmp->port_b + offs->tx2;
rx4 = qmp->port_b + offs->rx2;

qmp_configure_lane(tx3, tbls->tx, tbls->tx_num, 1);
qmp_configure_lane(rx3, tbls->rx, tbls->rx_num, 1);
qmp_configure_lane(qmp->dev, tx3, tbls->tx, tbls->tx_num, 1);
qmp_configure_lane(qmp->dev, rx3, tbls->rx, tbls->rx_num, 1);

qmp_configure_lane(tx4, tbls->tx, tbls->tx_num, 2);
qmp_configure_lane(rx4, tbls->rx, tbls->rx_num, 2);
qmp_configure_lane(qmp->dev, tx4, tbls->tx, tbls->tx_num, 2);
qmp_configure_lane(qmp->dev, rx4, tbls->rx, tbls->rx_num, 2);
}

static void qmp_pcie_init_registers(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tbls *tbls)
Expand All @@ -3689,25 +3689,26 @@ static void qmp_pcie_init_registers(struct qmp_pcie *qmp, const struct qmp_phy_c
if (!tbls)
return;

qmp_configure(serdes, tbls->serdes, tbls->serdes_num);
qmp_configure(qmp->dev, serdes, tbls->serdes, tbls->serdes_num);

qmp_configure_lane(tx, tbls->tx, tbls->tx_num, 1);
qmp_configure_lane(rx, tbls->rx, tbls->rx_num, 1);
qmp_configure_lane(qmp->dev, tx, tbls->tx, tbls->tx_num, 1);
qmp_configure_lane(qmp->dev, rx, tbls->rx, tbls->rx_num, 1);

if (cfg->lanes >= 2) {
qmp_configure_lane(tx2, tbls->tx, tbls->tx_num, 2);
qmp_configure_lane(rx2, tbls->rx, tbls->rx_num, 2);
qmp_configure_lane(qmp->dev, tx2, tbls->tx, tbls->tx_num, 2);
qmp_configure_lane(qmp->dev, rx2, tbls->rx, tbls->rx_num, 2);
}

qmp_configure(pcs, tbls->pcs, tbls->pcs_num);
qmp_configure(pcs_misc, tbls->pcs_misc, tbls->pcs_misc_num);
qmp_configure(qmp->dev, pcs, tbls->pcs, tbls->pcs_num);
qmp_configure(qmp->dev, pcs_misc, tbls->pcs_misc, tbls->pcs_misc_num);

if (cfg->lanes >= 4 && qmp->tcsr_4ln_config) {
qmp_configure(serdes, cfg->serdes_4ln_tbl, cfg->serdes_4ln_num);
qmp_configure(qmp->dev, serdes, cfg->serdes_4ln_tbl,
cfg->serdes_4ln_num);
qmp_pcie_init_port_b(qmp, tbls);
}

qmp_configure(ln_shrd, tbls->ln_shrd, tbls->ln_shrd_num);
qmp_configure(qmp->dev, ln_shrd, tbls->ln_shrd, tbls->ln_shrd_num);
}

static int qmp_pcie_init(struct phy *phy)
Expand Down
12 changes: 6 additions & 6 deletions drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ static void qmp_ufs_serdes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tb
{
void __iomem *serdes = qmp->serdes;

qmp_configure(serdes, tbls->serdes, tbls->serdes_num);
qmp_configure(qmp->dev, serdes, tbls->serdes, tbls->serdes_num);
}

static void qmp_ufs_lanes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls)
Expand All @@ -1536,20 +1536,20 @@ static void qmp_ufs_lanes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbl
void __iomem *tx = qmp->tx;
void __iomem *rx = qmp->rx;

qmp_configure_lane(tx, tbls->tx, tbls->tx_num, 1);
qmp_configure_lane(rx, tbls->rx, tbls->rx_num, 1);
qmp_configure_lane(qmp->dev, tx, tbls->tx, tbls->tx_num, 1);
qmp_configure_lane(qmp->dev, rx, tbls->rx, tbls->rx_num, 1);

if (cfg->lanes >= 2) {
qmp_configure_lane(qmp->tx2, tbls->tx, tbls->tx_num, 2);
qmp_configure_lane(qmp->rx2, tbls->rx, tbls->rx_num, 2);
qmp_configure_lane(qmp->dev, qmp->tx2, tbls->tx, tbls->tx_num, 2);
qmp_configure_lane(qmp->dev, qmp->rx2, tbls->rx, tbls->rx_num, 2);
}
}

static void qmp_ufs_pcs_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls)
{
void __iomem *pcs = qmp->pcs;

qmp_configure(pcs, tbls->pcs, tbls->pcs_num);
qmp_configure(qmp->dev, pcs, tbls->pcs, tbls->pcs_num);
}

static int qmp_ufs_get_gear_overlay(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg)
Expand Down
10 changes: 5 additions & 5 deletions drivers/phy/qualcomm/phy-qcom-qmp-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ static int qmp_usb_serdes_init(struct qmp_usb *qmp)
const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl;
int serdes_tbl_num = cfg->serdes_tbl_num;

qmp_configure(serdes, serdes_tbl, serdes_tbl_num);
qmp_configure(qmp->dev, serdes, serdes_tbl, serdes_tbl_num);

return 0;
}
Expand Down Expand Up @@ -1730,13 +1730,13 @@ static int qmp_usb_power_on(struct phy *phy)
}

/* Tx, Rx, and PCS configurations */
qmp_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
qmp_configure_lane(qmp->dev, tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(qmp->dev, rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);

qmp_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
qmp_configure(qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);

if (pcs_usb)
qmp_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num);
qmp_configure(qmp->dev, pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num);

if (cfg->has_pwrdn_delay)
usleep_range(10, 20);
Expand Down
13 changes: 7 additions & 6 deletions drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ static int qmp_usbc_power_on(struct phy *phy)
unsigned int val;
int ret;

qmp_configure(qmp->serdes, cfg->serdes_tbl, cfg->serdes_tbl_num);
qmp_configure(qmp->dev, qmp->serdes, cfg->serdes_tbl,
cfg->serdes_tbl_num);

ret = clk_prepare_enable(qmp->pipe_clk);
if (ret) {
Expand All @@ -535,13 +536,13 @@ static int qmp_usbc_power_on(struct phy *phy)
}

/* Tx, Rx, and PCS configurations */
qmp_configure_lane(qmp->tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(qmp->rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
qmp_configure_lane(qmp->dev, qmp->tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
qmp_configure_lane(qmp->dev, qmp->rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);

qmp_configure_lane(qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);
qmp_configure_lane(qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2);
qmp_configure_lane(qmp->dev, qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);
qmp_configure_lane(qmp->dev, qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2);

qmp_configure(qmp->pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
qmp_configure(qmp->dev, qmp->pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);

/* Pull PHY out of reset state */
qphy_clrbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
Expand Down

0 comments on commit 4e92d50

Please sign in to comment.