PCI: qcom: Support using the same PHY for both RC and EP
Subsystems (6)
v4 cover PCI: qcom: Support using the same PHY for both RC and EP
Programming of QMP PCIe PHYs slightly differs between RC and EP modes.
Currently both qcom and qcom-ep PCIe controllers setup the PHY in the default mode, making it impossible to select at runtime whether the PHY should be running in RC or in EP modes. Usually this is not an issue, since for most devices only the RC mode is used. Some devices (SDX55) currently support only the EP mode without supporting the RC mode (at this moment).
Nevertheless some of the Qualcomm platforms (e.g. the aforementioned SDX55) would still benefit from being able to switch between RC and EP depending on the driver being used. While it is possible to use different compat strings for the PHY depending on the mode, it seems like an incorrect approach, since the PHY doesn't differ between usecases. It's the PCIe controller, who should decide how to configure the PHY.
This patch series implements the ability to select between RC and EP modes, by allowing the PCIe QMP PHY driver to switch between programming tables.
This patchseries depends on the header from the pre-6.1 phy/next. Thus after the 6.1 the PCIe patches can be applied independently of the PHY part.
Changes since v3:
- Rebased on top of phy/next to pick in newly defined PHY_MODE_PCIE_RC/EP.
- Renamed 'main' to 'common' and 'secondary' to 'extra' to reflect the intention of the split (the 'common' tables and the 'extra for the ... mode' tables).
- Merged the 'pointer' patch into first and second patches to make them more obvious.
Changes since v2:
- Added PHY_SUBMODE_PCIE_RC/EP defines (Vinod),
- Changed primary' table name to main', added extra comments describing that secondary' are the additional tables, not required in most of the cases (following the suggestion by Johan to rename primary' table),
- Changed secondary tables into the pointers to stop wasting extra memory (Vinod),
- Split several functions for programming the PHY using these tables.
Changes since v1:
- Split the if(table) removal to the separate patch
- Expanded commit messages and comments to provide additional details
- Fixed build error on pcie-qcom.c
- Added support for EP mode on sm8450 to demonstrate the usage of this patchset
Changes since RFC:
- Fixed the compilation of PCIe EP driver,
- Changed pri/sec names to primary and secondary,
- Added comments regarding usage of secondary_rc/_ep fields.
Dmitry Baryshkov (6):
phy: qcom-qmp-pcie: split register tables into common and extra parts
phy: qcom-qmp-pcie: split PHY programming to separate functions
phy: qcom-qmp-pcie: support separate tables for EP mode
phy: qcom-qmp-pcie: Support SM8450 PCIe1 PHY in EP mode
PCI: qcom: Setup PHY to work in RC mode
PCI: qcom-ep: Setup PHY to work in EP mode
drivers/pci/controller/dwc/pcie-qcom-ep.c | 5 + drivers/pci/controller/dwc/pcie-qcom.c | 5 + drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 298 +++++++++++++----- .../qualcomm/phy-qcom-qmp-pcs-pcie-v5_20.h | 1 + 4 files changed, 229 insertions(+), 80 deletions(-)
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v4 1/6 phy: qcom-qmp-pcie: split register tables into common and extra parts
SM8250 configuration tables are split into two parts: the common one and the PHY-specific tables. Make this split more formal. Rather than having a blind renamed copy of all QMP table fields, add separate struct qmp_phy_cfg_tables and add two instances of this structure to the struct qmp_phy_cfg. Later on this will be used to support different PHY modes (RC vs EP).
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 129 ++++++++++++++--------- 1 file changed, 77 insertions(+), 52 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +77 -52
@@ -1300,31 +1300,30 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), }; -/* struct qmp_phy_cfg - per-PHY initialization config */ -struct qmp_phy_cfg { -int lanes; - -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num; -const struct qmp_phy_init_tbl *serdes_tbl_sec; -int serdes_tbl_num_sec;const struct qmp_phy_init_tbl *tx_tbl;int tx_tbl_num; -const struct qmp_phy_init_tbl *tx_tbl_sec; -int tx_tbl_num_sec;const struct qmp_phy_init_tbl *rx_tbl;int rx_tbl_num; -const struct qmp_phy_init_tbl *rx_tbl_sec; -int rx_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_tbl_sec; -int pcs_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_misc_tbl;int pcs_misc_tbl_num; -const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; -int pcs_misc_tbl_num_sec; +}; + +/* struct qmp_phy_cfg - per-PHY initialization config */ +struct qmp_phy_cfg { +int lanes; + +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables common; +/* +* Additional init sequence for PHY blocks, providing additional +* register programming. Unless required it can be left omitted. +*/ +struct qmp_phy_cfg_tables *extra;/* clock ids to be requested */ const char *const *clk_list;
@@ -1459,6 +1458,7 @@ static const char * const sdm845_pciephy_reset_l[] = {static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = ipq8074_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (ipq8074_pcie_serdes_tbl), .tx_tbl = ipq8074_pcie_tx_tbl,
@@ -1467,6 +1467,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), .pcs_tbl = ipq8074_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), + }, .clk_list = ipq8074_pciephy_clk_l, .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), .reset_list = ipq8074_pciephy_reset_l,
@@ -1487,6 +1488,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { .lanes =1 , + .common = { .serdes_tbl = ipq8074_pcie_gen3_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (ipq8074_pcie_gen3_serdes_tbl), .tx_tbl = ipq8074_pcie_gen3_tx_tbl,
@@ -1495,6 +1497,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_rx_tbl), .pcs_tbl = ipq8074_pcie_gen3_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_pcs_tbl), + }, .clk_list = ipq8074_pciephy_clk_l, .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), .reset_list = ipq8074_pciephy_reset_l,
@@ -1516,6 +1519,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = ipq6018_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (ipq6018_pcie_serdes_tbl), .tx_tbl = ipq6018_pcie_tx_tbl,
@@ -1526,6 +1530,7 @@ static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { .pcs_tbl_num = ARRAY_SIZE(ipq6018_pcie_pcs_tbl), .pcs_misc_tbl = ipq6018_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(ipq6018_pcie_pcs_misc_tbl), + }, .clk_list = ipq8074_pciephy_clk_l, .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), .reset_list = ipq8074_pciephy_reset_l,
@@ -1545,6 +1550,7 @@ static const struct qmp_phy_cfg ipq6018_pciephy_cfg = {static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = sdm845_qmp_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sdm845_qmp_pcie_serdes_tbl), .tx_tbl = sdm845_qmp_pcie_tx_tbl,
@@ -1555,6 +1561,7 @@ static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { .pcs_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_tbl), .pcs_misc_tbl = sdm845_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1575,6 +1582,7 @@ static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = sdm845_qhp_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sdm845_qhp_pcie_serdes_tbl), .tx_tbl = sdm845_qhp_pcie_tx_tbl,
@@ -1583,6 +1591,7 @@ static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { .rx_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_rx_tbl), .pcs_tbl = sdm845_qhp_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_pcs_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1603,24 +1612,28 @@ static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_serdes_tbl), - .serdes_tbl_sec = sm8250_qmp_gen3x1_pcie_serdes_tbl, - .serdes_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_serdes_tbl), .tx_tbl = sm8250_qmp_pcie_tx_tbl, .tx_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_tx_tbl), .rx_tbl = sm8250_qmp_pcie_rx_tbl, .rx_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_rx_tbl), - .rx_tbl_sec = sm8250_qmp_gen3x1_pcie_rx_tbl, - .rx_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_rx_tbl), .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, .pcs_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_tbl), - .pcs_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_tbl, - .pcs_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_pcs_tbl), .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_misc_tbl), - .pcs_misc_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, - .pcs_misc_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), + }, + .extra = &(struct qmp_phy_cfg_tables ) { + .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_serdes_tbl), + .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl, + .rx_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_rx_tbl), + .pcs_tbl = sm8250_qmp_gen3x1_pcie_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_pcs_tbl), + .pcs_misc_tbl = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, + .pcs_misc_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks =ARRAY_SIZE (sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1641,24 +1654,28 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = {static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { .lanes =2 , + .common = { .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_serdes_tbl), .tx_tbl = sm8250_qmp_pcie_tx_tbl, .tx_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_tx_tbl), - .tx_tbl_sec = sm8250_qmp_gen3x2_pcie_tx_tbl, - .tx_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_tx_tbl), .rx_tbl = sm8250_qmp_pcie_rx_tbl, .rx_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_rx_tbl), - .rx_tbl_sec = sm8250_qmp_gen3x2_pcie_rx_tbl, - .rx_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_rx_tbl), .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, .pcs_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_tbl), - .pcs_tbl_sec = sm8250_qmp_gen3x2_pcie_pcs_tbl, - .pcs_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_tbl), .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_misc_tbl), - .pcs_misc_tbl_sec = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, - .pcs_misc_tbl_num_sec =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), + }, + .extra = &(struct qmp_phy_cfg_tables ) { + .tx_tbl = sm8250_qmp_gen3x2_pcie_tx_tbl, + .tx_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_tx_tbl), + .rx_tbl = sm8250_qmp_gen3x2_pcie_rx_tbl, + .rx_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_rx_tbl), + .pcs_tbl = sm8250_qmp_gen3x2_pcie_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_tbl), + .pcs_misc_tbl = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, + .pcs_misc_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks =ARRAY_SIZE (sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1679,6 +1696,7 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {static const struct qmp_phy_cfg msm8998_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = msm8998_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (msm8998_pcie_serdes_tbl), .tx_tbl = msm8998_pcie_tx_tbl,
@@ -1687,6 +1705,7 @@ static const struct qmp_phy_cfg msm8998_pciephy_cfg = { .rx_tbl_num = ARRAY_SIZE(msm8998_pcie_rx_tbl), .pcs_tbl = msm8998_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl), + }, .clk_list = msm8996_phy_clk_l, .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), .reset_list = ipq8074_pciephy_reset_l,
@@ -1703,6 +1722,7 @@ static const struct qmp_phy_cfg msm8998_pciephy_cfg = {static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = sc8180x_qmp_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sc8180x_qmp_pcie_serdes_tbl), .tx_tbl = sc8180x_qmp_pcie_tx_tbl,
@@ -1713,6 +1733,7 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .pcs_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_tbl), .pcs_misc_tbl = sc8180x_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1732,6 +1753,7 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = {static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { .lanes =2 , + .common = { .serdes_tbl = sdx55_qmp_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sdx55_qmp_pcie_serdes_tbl), .tx_tbl = sdx55_qmp_pcie_tx_tbl,
@@ -1742,6 +1764,7 @@ static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { .pcs_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_tbl), .pcs_misc_tbl = sdx55_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1762,6 +1785,7 @@ static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = sm8450_qmp_gen3x1_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_serdes_tbl), .tx_tbl = sm8450_qmp_gen3x1_pcie_tx_tbl,
@@ -1772,6 +1796,7 @@ static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { .pcs_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_tbl), .pcs_misc_tbl = sm8450_qmp_gen3x1_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1792,6 +1817,7 @@ static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .lanes =2 , + .common = { .serdes_tbl = sm8450_qmp_gen4x2_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_serdes_tbl), .tx_tbl = sm8450_qmp_gen4x2_pcie_tx_tbl,
@@ -1802,6 +1828,7 @@ static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .pcs_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_tbl), .pcs_misc_tbl = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl), + }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
@@ -1854,11 +1881,9 @@ static int qmp_pcie_serdes_init(struct qmp_phy *qphy) {const struct qmp_phy_cfg *cfg = qphy->cfg;void __iomem *serdes = qphy->serdes; -const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; -int serdes_tbl_num = cfg->serdes_tbl_num; -qmp_pcie_configure (serdes, cfg->regs, serdes_tbl, serdes_tbl_num); -qmp_pcie_configure (serdes, cfg->regs, cfg->serdes_tbl_sec, cfg->serdes_tbl_num_sec); +qmp_pcie_configure (serdes, cfg->regs, cfg->common.serdes_tbl, cfg->common.serdes_tbl_num); +qmp_pcie_configure (serdes, cfg->regs, cfg->extra->serdes_tbl, cfg->extra->serdes_tbl_num);return 0 ; }
@@ -1949,31 +1974,31 @@ static int qmp_pcie_power_on(struct phy *phy) }/* Tx, Rx, and PCS configurations */ -qmp_pcie_configure_lane (tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num,1 ); -qmp_pcie_configure_lane (tx, cfg->regs, cfg->tx_tbl_sec, cfg->tx_tbl_num_sec,1 ); +qmp_pcie_configure_lane (tx, cfg->regs, cfg->common.tx_tbl, cfg->common.tx_tbl_num,1 ); +qmp_pcie_configure_lane (tx, cfg->regs, cfg->extra->tx_tbl, cfg->extra->tx_tbl_num,1 );if (cfg->lanes >=2 ) { -qmp_pcie_configure_lane (qphy->tx2, cfg->regs, cfg->tx_tbl, - cfg->tx_tbl_num,2 ); -qmp_pcie_configure_lane (qphy->tx2, cfg->regs, cfg->tx_tbl_sec, - cfg->tx_tbl_num_sec,2 ); +qmp_pcie_configure_lane (qphy->tx2, cfg->regs, cfg->common.tx_tbl, + cfg->common.tx_tbl_num,2 ); +qmp_pcie_configure_lane (qphy->tx2, cfg->regs, cfg->extra->tx_tbl, + cfg->extra->tx_tbl_num,2 ); } -qmp_pcie_configure_lane (rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num,1 ); -qmp_pcie_configure_lane (rx, cfg->regs, cfg->rx_tbl_sec, cfg->rx_tbl_num_sec,1 ); +qmp_pcie_configure_lane (rx, cfg->regs, cfg->common.rx_tbl, cfg->common.rx_tbl_num,1 ); +qmp_pcie_configure_lane (rx, cfg->regs, cfg->extra->rx_tbl, cfg->extra->rx_tbl_num,1 );if (cfg->lanes >=2 ) { -qmp_pcie_configure_lane (qphy->rx2, cfg->regs, cfg->rx_tbl, - cfg->rx_tbl_num,2 ); -qmp_pcie_configure_lane (qphy->rx2, cfg->regs, cfg->rx_tbl_sec, - cfg->rx_tbl_num_sec,2 ); +qmp_pcie_configure_lane (qphy->rx2, cfg->regs, cfg->common.rx_tbl, + cfg->common.rx_tbl_num,2 ); +qmp_pcie_configure_lane (qphy->rx2, cfg->regs, cfg->extra->rx_tbl, + cfg->extra->rx_tbl_num,2 ); } -qmp_pcie_configure (pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); -qmp_pcie_configure (pcs, cfg->regs, cfg->pcs_tbl_sec, cfg->pcs_tbl_num_sec); +qmp_pcie_configure (pcs, cfg->regs, cfg->common.pcs_tbl, cfg->common.pcs_tbl_num); +qmp_pcie_configure (pcs, cfg->regs, cfg->extra->pcs_tbl, cfg->extra->pcs_tbl_num); -qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl, cfg->pcs_misc_tbl_num); -qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, cfg->pcs_misc_tbl_num_sec); +qmp_pcie_configure (pcs_misc, cfg->regs, cfg->common.pcs_misc_tbl, cfg->common.pcs_misc_tbl_num); +qmp_pcie_configure (pcs_misc, cfg->regs, cfg->extra->pcs_misc_tbl, cfg->extra->pcs_misc_tbl_num);/* * Pull out PHY from POWER DOWN state.
@@ -2237,7 +2262,7 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, qphy->pcs_misc = qphy->pcs +0x400 ;if (IS_ERR (qphy->pcs_misc)) { -if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) +if (cfg->common.pcs_misc_tbl || cfg->extra->pcs_misc_tbl)return PTR_ERR (qphy->pcs_misc); }
Signature · 1 line
2.35.1
Re: [PATCH v4 1/6] phy: qcom-qmp-pcie: split register tables into common and extra parts
Quoted 64 lines · Dmitry Baryshkov
SM8250 configuration tables are split into two parts: the common one and the PHY-specific tables. Make this split more formal. Rather than having a blind renamed copy of all QMP table fields, add separate struct
qmp_phy_cfg_tablesand add two instances of this structure to the structqmp_phy_cfg. Later on this will be used to support different PHY modes (RC vs EP).Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 129 ++++++++++++++--------- 1 file changed, 77 insertions(+), 52 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +14
-15@@ -1300,31 +1300,30 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), }; -/* struct qmp_phy_cfg - per-PHY initialization config */ -struct qmp_phy_cfg { -int lanes; - -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num; -const struct qmp_phy_init_tbl *serdes_tbl_sec; -int serdes_tbl_num_sec;const struct qmp_phy_init_tbl *tx_tbl;int tx_tbl_num; -const struct qmp_phy_init_tbl *tx_tbl_sec; -int tx_tbl_num_sec;const struct qmp_phy_init_tbl *rx_tbl;int rx_tbl_num; -const struct qmp_phy_init_tbl *rx_tbl_sec; -int rx_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_tbl_sec; -int pcs_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_misc_tbl;int pcs_misc_tbl_num; -const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; -int pcs_misc_tbl_num_sec; +}; + +/* struct qmp_phy_cfg - per-PHY initialization config */ +struct qmp_phy_cfg { +int lanes; + +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables common; +/* +* Additional init sequence for PHY blocks, providing additional +* register programming. Unless required it can be left omitted. +*/ +struct qmp_phy_cfg_tables *extra;/* clock ids to be requested */ const char *const *clk_list;
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy) · line 1978
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-2@@ -1949,31 +1974,31 @@ static int qmp_pcie_power_on(struct phy *phy) }/* Tx, Rx, and PCS configurations */ -qmp_pcie_configure_lane (tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num,1 ); -qmp_pcie_configure_lane (tx, cfg->regs, cfg->tx_tbl_sec, cfg->tx_tbl_num_sec,1 ); +qmp_pcie_configure_lane (tx, cfg->regs, cfg->common.tx_tbl, cfg->common.tx_tbl_num,1 ); +qmp_pcie_configure_lane (tx, cfg->regs, cfg->extra->tx_tbl, cfg->extra->tx_tbl_num,1 );
Hmm. How did you test this?
With your later versions of this series, cfg->extra is generally NULL so this would dereference a NULL pointer.
Johan
Re: [PATCH v4 1/6] phy: qcom-qmp-pcie: split register tables into common and extra parts
Quoted 75 lines · Johan Hovold
Quoted 64 lines · Dmitry Baryshkov
SM8250 configuration tables are split into two parts: the common one and the PHY-specific tables. Make this split more formal. Rather than having a blind renamed copy of all QMP table fields, add separate struct
qmp_phy_cfg_tablesand add two instances of this structure to the structqmp_phy_cfg. Later on this will be used to support different PHY modes (RC vs EP).Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 129 ++++++++++++++--------- 1 file changed, 77 insertions(+), 52 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +14
-15@@ -1300,31 +1300,30 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), }; -/* struct qmp_phy_cfg - per-PHY initialization config */ -struct qmp_phy_cfg { -int lanes; - -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num; -const struct qmp_phy_init_tbl *serdes_tbl_sec; -int serdes_tbl_num_sec;const struct qmp_phy_init_tbl *tx_tbl;int tx_tbl_num; -const struct qmp_phy_init_tbl *tx_tbl_sec; -int tx_tbl_num_sec;const struct qmp_phy_init_tbl *rx_tbl;int rx_tbl_num; -const struct qmp_phy_init_tbl *rx_tbl_sec; -int rx_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_tbl_sec; -int pcs_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_misc_tbl;int pcs_misc_tbl_num; -const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; -int pcs_misc_tbl_num_sec; +}; + +/* struct qmp_phy_cfg - per-PHY initialization config */ +struct qmp_phy_cfg { +int lanes; + +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables common; +/* +* Additional init sequence for PHY blocks, providing additional +* register programming. Unless required it can be left omitted. +*/ +struct qmp_phy_cfg_tables *extra;/* clock ids to be requested */ const char *const *clk_list;drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy) · line 1978
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-2@@ -1949,31 +1974,31 @@ static int qmp_pcie_power_on(struct phy *phy) }/* Tx, Rx, and PCS configurations */ -qmp_pcie_configure_lane (tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num,1 ); -qmp_pcie_configure_lane (tx, cfg->regs, cfg->tx_tbl_sec, cfg->tx_tbl_num_sec,1 ); +qmp_pcie_configure_lane (tx, cfg->regs, cfg->common.tx_tbl, cfg->common.tx_tbl_num,1 ); +qmp_pcie_configure_lane (tx, cfg->regs, cfg->extra->tx_tbl, cfg->extra->tx_tbl_num,1 );Hmm. How did you test this?
Quoted 2 lines
With your later versions of this series,
cfg->extrais generally NULL so this would dereference a NULL pointer.
I must admit, I tested this only on sm8450. Mea culpa.
Quoted 2 lines
Johan
Signature · 8 lines
With best wishes Dmitry -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH v4 1/6] phy: qcom-qmp-pcie: split register tables into common and extra parts
In reply to Dmitry BaryshkovQuoted 18 lines · Dmitry Baryshkov
SM8250 configuration tables are split into two parts: the common one and the PHY-specific tables. Make this split more formal. Rather than having a blind renamed copy of all QMP table fields, add separate struct
qmp_phy_cfg_tablesand add two instances of this structure to the structqmp_phy_cfg. Later on this will be used to support different PHY modes (RC vs EP).Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 129 ++++++++++++++--------- 1 file changed, 77 insertions(+), 52 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0@@ -1300,31 +1300,30 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e),
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1305
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-5}; -/* struct qmp_phy_cfg - per-PHY initialization config */ -struct qmp_phy_cfg { -int lanes; - -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num;
So I still think you should drop the now redundant "tbl" suffix and infix.
Quoted 16 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-8-const struct qmp_phy_init_tbl *serdes_tbl_sec; -int serdes_tbl_num_sec;const struct qmp_phy_init_tbl *tx_tbl;int tx_tbl_num; -const struct qmp_phy_init_tbl *tx_tbl_sec; -int tx_tbl_num_sec;const struct qmp_phy_init_tbl *rx_tbl;int rx_tbl_num; -const struct qmp_phy_init_tbl *rx_tbl_sec; -int rx_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_tbl_sec; -int pcs_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_misc_tbl;int pcs_misc_tbl_num;
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1321
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +8
-2-const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; -int pcs_misc_tbl_num_sec; +}; + +/* struct qmp_phy_cfg - per-PHY initialization config */ +struct qmp_phy_cfg { +int lanes; + +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables common;
And this could be "tbls_common".
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1326
Quoted 5 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +5
-0+/* +* Additional init sequence for PHY blocks, providing additional +* register programming. Unless required it can be left omitted. +*/ +struct qmp_phy_cfg_tables *extra;
And "tbls_extra".
I guess this table should be const as well.
Quoted 12 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-0/* clock ids to be requested */ const char *const *clk_list;@@ -1459,6 +1458,7 @@ static const char * const sdm845_pciephy_reset_l[] = {static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .lanes =1 , + .common = { .serdes_tbl = ipq8074_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (ipq8074_pcie_serdes_tbl), .tx_tbl = ipq8074_pcie_tx_tbl,
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { · line 1470
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-0@@ -1467,6 +1467,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), .pcs_tbl = ipq8074_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), + },
Shouldn't you indent the members now? The above looks unnecessarily hard to read.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { · line 1473
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0.clk_list = ipq8074_pciephy_clk_l, .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), .reset_list = ipq8074_pciephy_reset_l,
@@ -1603,24 +1612,28 @@ static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
Quoted 14 lines
static const struct
qmp_phy_cfgsm8250_qmp_gen3x1_pciephy_cfg= {drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-4.lanes = 1, + .common = { .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), - .serdes_tbl_sec = sm8250_qmp_gen3x1_pcie_serdes_tbl, - .serdes_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), .tx_tbl = sm8250_qmp_pcie_tx_tbl, .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), .rx_tbl = sm8250_qmp_pcie_rx_tbl, .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), - .rx_tbl_sec = sm8250_qmp_gen3x1_pcie_rx_tbl, - .rx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl),
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { · line 1627
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-4.pcs_tbl = sm8250_qmp_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), - .pcs_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_tbl, - .pcs_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl), .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), - .pcs_misc_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, - .pcs_misc_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), + }, + .extra = &(struct qmp_phy_cfg_tables ) {
const structure?
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { · line 1635
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +8
-0+ .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, + .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), + .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl, + .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl), + .pcs_tbl = sm8250_qmp_gen3x1_pcie_pcs_tbl, + .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl), + .pcs_misc_tbl = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, + .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl),
Indentation.
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-0+ }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_serdes_init(struct qmp_phy *qphy) · line 1886
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-4@@ -1854,11 +1881,9 @@ static int qmp_pcie_serdes_init(struct qmp_phy *qphy) {const struct qmp_phy_cfg *cfg = qphy->cfg;void __iomem *serdes = qphy->serdes; -const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; -int serdes_tbl_num = cfg->serdes_tbl_num; -qmp_pcie_configure (serdes, cfg->regs, serdes_tbl, serdes_tbl_num); -qmp_pcie_configure (serdes, cfg->regs, cfg->serdes_tbl_sec, cfg->serdes_tbl_num_sec); +qmp_pcie_configure (serdes, cfg->regs, cfg->common.serdes_tbl, cfg->common.serdes_tbl_num); +qmp_pcie_configure (serdes, cfg->regs, cfg->extra->serdes_tbl, cfg->extra->serdes_tbl_num);
I already mentioned the NULL-derefs as cfg->extra can be NULL.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2265
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0return 0 ; }drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-1if (IS_ERR (qphy->pcs_misc)) { -if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) +if (cfg->common.pcs_misc_tbl || cfg->extra->pcs_misc_tbl)
Here too.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2267
Quoted 2 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0return PTR_ERR (qphy->pcs_misc); }
Johan
Re: [PATCH v4 1/6] phy: qcom-qmp-pcie: split register tables into common and extra parts
Quoted 53 lines · Johan Hovold
Quoted 18 lines · Dmitry Baryshkov
SM8250 configuration tables are split into two parts: the common one and the PHY-specific tables. Make this split more formal. Rather than having a blind renamed copy of all QMP table fields, add separate struct
qmp_phy_cfg_tablesand add two instances of this structure to the structqmp_phy_cfg. Later on this will be used to support different PHY modes (RC vs EP).Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 129 ++++++++++++++--------- 1 file changed, 77 insertions(+), 52 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0@@ -1300,31 +1300,30 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e),drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1305
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-5}; -/* struct qmp_phy_cfg - per-PHY initialization config */ -struct qmp_phy_cfg { -int lanes; - -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num;So I still think you should drop the now redundant "tbl" suffix and infix.
Quoted 20 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-10-const struct qmp_phy_init_tbl *serdes_tbl_sec; -int serdes_tbl_num_sec;const struct qmp_phy_init_tbl *tx_tbl;int tx_tbl_num; -const struct qmp_phy_init_tbl *tx_tbl_sec; -int tx_tbl_num_sec;const struct qmp_phy_init_tbl *rx_tbl;int rx_tbl_num; -const struct qmp_phy_init_tbl *rx_tbl_sec; -int rx_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_tbl_sec; -int pcs_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_misc_tbl;int pcs_misc_tbl_num; -const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; -int pcs_misc_tbl_num_sec; +}; +
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1321
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +6
-0+/* struct qmp_phy_cfg - per-PHY initialization config */ +struct qmp_phy_cfg { +int lanes; + +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables common;And this could be "
tbls_common".
I'd go for common_tables, if you don't mind.
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1326
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +5
-0+/* +* Additional init sequence for PHY blocks, providing additional +* register programming. Unless required it can be left omitted. +*/ +struct qmp_phy_cfg_tables *extra;And "
tbls_extra".I guess this table should be const as well.
Ack
Quoted 8 lines
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0/* clock ids to be requested */ const char *const *clk_list;@@ -1459,6 +1458,7 @@ static const char * const sdm845_pciephy_reset_l[] = {static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .lanes =1 ,
Quoted 12 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { · line 1470
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-0+ .common = { .serdes_tbl = ipq8074_pcie_serdes_tbl, .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), .tx_tbl = ipq8074_pcie_tx_tbl,@@ -1467,6 +1467,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .rx_tbl_num = ARRAY_SIZE(ipq8074_pcie_rx_tbl), .pcs_tbl = ipq8074_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(ipq8074_pcie_pcs_tbl), + },Shouldn't you indent the members now? The above looks unnecessarily hard to read.
I wanted to keep the indentation to make the patch small enough, but let's indent these lines (while dropping the _tbl from names as you insisted).
Quoted 24 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { · line 1473
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0.clk_list = ipq8074_pciephy_clk_l, .num_clks = ARRAY_SIZE(ipq8074_pciephy_clk_l), .reset_list = ipq8074_pciephy_reset_l,@@ -1603,24 +1612,28 @@ static const struct
qmp_phy_cfgsdm845_qhp_pciephy_cfg= {Quoted 18 lines
static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .lanes = 1,drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-6+ .common = { .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), - .serdes_tbl_sec = sm8250_qmp_gen3x1_pcie_serdes_tbl, - .serdes_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), .tx_tbl = sm8250_qmp_pcie_tx_tbl, .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_tx_tbl), .rx_tbl = sm8250_qmp_pcie_rx_tbl, .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_rx_tbl), - .rx_tbl_sec = sm8250_qmp_gen3x1_pcie_rx_tbl, - .rx_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl), .pcs_tbl = sm8250_qmp_pcie_pcs_tbl, .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_tbl), - .pcs_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_tbl, - .pcs_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl),
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { · line 1627
Quoted 6 lines
.pcs_misc_tbl =
sm8250_qmp_pcie_pcs_misc_tbl,
.pcs_misc_tbl_num =ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-2- .pcs_misc_tbl_sec = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, - .pcs_misc_tbl_num_sec = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl), + }, + .extra = &(struct qmp_phy_cfg_tables) {const structure?
Ack
Quoted 45 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { · line 1635
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +8
-0+ .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, + .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), + .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl, + .rx_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_rx_tbl), + .pcs_tbl = sm8250_qmp_gen3x1_pcie_pcs_tbl, + .pcs_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_tbl), + .pcs_misc_tbl = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, + .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_pcs_misc_tbl),Indentation.
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-0+ }, .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_serdes_init(struct qmp_phy *qphy) · line 1886
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-4@@ -1854,11 +1881,9 @@ static int qmp_pcie_serdes_init(struct qmp_phy *qphy) {const struct qmp_phy_cfg *cfg = qphy->cfg;void __iomem *serdes = qphy->serdes; -const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; -int serdes_tbl_num = cfg->serdes_tbl_num; -qmp_pcie_configure (serdes, cfg->regs, serdes_tbl, serdes_tbl_num); -qmp_pcie_configure (serdes, cfg->regs, cfg->serdes_tbl_sec, cfg->serdes_tbl_num_sec); +qmp_pcie_configure (serdes, cfg->regs, cfg->common.serdes_tbl, cfg->common.serdes_tbl_num); +qmp_pcie_configure (serdes, cfg->regs, cfg->extra->serdes_tbl, cfg->extra->serdes_tbl_num);I already mentioned the NULL-derefs as
cfg->extracan be NULL.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2265
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0return 0 ; }if (IS_ERR(qphy->pcs_misc)) {drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-1-if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) +if (cfg->common.pcs_misc_tbl || cfg->extra->pcs_misc_tbl)Here too.
Quoted 2 lines
return PTR_ERR(qphy->pcs_misc); }Johan
Signature · 8 lines
With best wishes Dmitry -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH v4 1/6] phy: qcom-qmp-pcie: split register tables into common and extra parts
Quoted 63 lines · Dmitry Baryshkov
Quoted 53 lines · Johan Hovold
Quoted 18 lines · Dmitry Baryshkov
SM8250 configuration tables are split into two parts: the common one and the PHY-specific tables. Make this split more formal. Rather than having a blind renamed copy of all QMP table fields, add separate struct
qmp_phy_cfg_tablesand add two instances of this structure to the structqmp_phy_cfg. Later on this will be used to support different PHY modes (RC vs EP).Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 129 ++++++++++++++--------- 1 file changed, 77 insertions(+), 52 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0@@ -1300,31 +1300,30 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e),drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1305
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-5}; -/* struct qmp_phy_cfg - per-PHY initialization config */ -struct qmp_phy_cfg { -int lanes; - -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num;So I still think you should drop the now redundant "tbl" suffix and infix.
Quoted 20 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-10-const struct qmp_phy_init_tbl *serdes_tbl_sec; -int serdes_tbl_num_sec;const struct qmp_phy_init_tbl *tx_tbl;int tx_tbl_num; -const struct qmp_phy_init_tbl *tx_tbl_sec; -int tx_tbl_num_sec;const struct qmp_phy_init_tbl *rx_tbl;int rx_tbl_num; -const struct qmp_phy_init_tbl *rx_tbl_sec; -int rx_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_tbl_sec; -int pcs_tbl_num_sec;const struct qmp_phy_init_tbl *pcs_misc_tbl;int pcs_misc_tbl_num; -const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; -int pcs_misc_tbl_num_sec; +}; +Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { · line 1321
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +6
-0+/* struct qmp_phy_cfg - per-PHY initialization config */ +struct qmp_phy_cfg { +int lanes; + +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +struct qmp_phy_cfg_tables common;And this could be "
tbls_common".
Quoted 1 line
I'd go for
common_tables, if you don't mind.
Sure, if you prefer.
struct qmp_phy_cfg_tables tables; struct qmp_phy_cfg_tables tables_ep; struct qmp_phy_cfg_tables tables_rc;
Could also be an alternative. Not sure the "common" prefix/suffix really adds anything.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v4 2/6 phy: qcom-qmp-pcie: split PHY programming to separate functions
In reply to Dmitry BaryshkovSplit the code using PHY programming tables into separate functions, which take a single struct qmp_phy_cfg_tables instance.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 80 ++++++++++++++---------- 1 file changed, 48 insertions(+), 32 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +48 -32
@@ -1877,15 +1877,53 @@ static void qmp_pcie_configure(void __iomem *base,qmp_pcie_configure_lane (base, regs, tbl, num,0xff ); } -static int qmp_pcie_serdes_init (struct qmp_phy *qphy) +static void qmp_pcie_serdes_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) {const struct qmp_phy_cfg *cfg = qphy->cfg;void __iomem *serdes = qphy->serdes; -qmp_pcie_configure (serdes, cfg->regs, cfg->common.serdes_tbl, cfg->common.serdes_tbl_num); -qmp_pcie_configure (serdes, cfg->regs, cfg->extra->serdes_tbl, cfg->extra->serdes_tbl_num); +if (!tables) +return ; -return 0 ; +qmp_pcie_configure (serdes, cfg->regs, tables->serdes_tbl, tables->serdes_tbl_num); +} + +static void qmp_pcie_lanes_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) +{ +const struct qmp_phy_cfg *cfg = qphy->cfg; +void __iomem *tx = qphy->tx; +void __iomem *rx = qphy->rx; + +if (!tables) +return ; + +qmp_pcie_configure_lane (tx, cfg->regs, + tables->tx_tbl, tables->tx_tbl_num,1 ); + +if (cfg->lanes >=2 ) +qmp_pcie_configure_lane (qphy->tx2, cfg->regs, + tables->tx_tbl, tables->tx_tbl_num,2 ); + +qmp_pcie_configure_lane (rx, cfg->regs, + tables->rx_tbl, tables->rx_tbl_num,1 ); +if (cfg->lanes >=2 ) +qmp_pcie_configure_lane (qphy->rx2, cfg->regs, + tables->rx_tbl, tables->rx_tbl_num,2 ); +} + +static void qmp_pcie_pcs_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) +{ +const struct qmp_phy_cfg *cfg = qphy->cfg; +void __iomem *pcs = qphy->pcs; +void __iomem *pcs_misc = qphy->pcs_misc; + +if (!tables) +return ; + +qmp_pcie_configure (pcs, cfg->regs, + tables->pcs_tbl, tables->pcs_tbl_num); +qmp_pcie_configure (pcs_misc, cfg->regs, + tables->pcs_misc_tbl, tables->pcs_misc_tbl_num); }static int qmp_pcie_init (struct phy *phy)
@@ -1957,15 +1995,13 @@ static int qmp_pcie_power_on(struct phy *phy)struct qmp_phy *qphy =phy_get_drvdata (phy);struct qcom_qmp *qmp = qphy->qmp;const struct qmp_phy_cfg *cfg = qphy->cfg; -void __iomem *tx = qphy->tx; -void __iomem *rx = qphy->rx;void __iomem *pcs = qphy->pcs; -void __iomem *pcs_misc = qphy->pcs_misc;void __iomem *status;unsigned int mask, val, ready;int ret; -qmp_pcie_serdes_init (qphy); +qmp_pcie_serdes_init (qphy, &cfg->common); +qmp_pcie_serdes_init (qphy, cfg->extra); ret =clk_prepare_enable (qphy->pipe_clk);if (ret) {
@@ -1974,31 +2010,11 @@ static int qmp_pcie_power_on(struct phy *phy) }/* Tx, Rx, and PCS configurations */ -qmp_pcie_configure_lane (tx, cfg->regs, cfg->common.tx_tbl, cfg->common.tx_tbl_num,1 ); -qmp_pcie_configure_lane (tx, cfg->regs, cfg->extra->tx_tbl, cfg->extra->tx_tbl_num,1 ); - -if (cfg->lanes >=2 ) { -qmp_pcie_configure_lane (qphy->tx2, cfg->regs, cfg->common.tx_tbl, - cfg->common.tx_tbl_num,2 ); -qmp_pcie_configure_lane (qphy->tx2, cfg->regs, cfg->extra->tx_tbl, - cfg->extra->tx_tbl_num,2 ); - } - -qmp_pcie_configure_lane (rx, cfg->regs, cfg->common.rx_tbl, cfg->common.rx_tbl_num,1 ); -qmp_pcie_configure_lane (rx, cfg->regs, cfg->extra->rx_tbl, cfg->extra->rx_tbl_num,1 ); - -if (cfg->lanes >=2 ) { -qmp_pcie_configure_lane (qphy->rx2, cfg->regs, cfg->common.rx_tbl, - cfg->common.rx_tbl_num,2 ); -qmp_pcie_configure_lane (qphy->rx2, cfg->regs, cfg->extra->rx_tbl, - cfg->extra->rx_tbl_num,2 ); - } - -qmp_pcie_configure (pcs, cfg->regs, cfg->common.pcs_tbl, cfg->common.pcs_tbl_num); -qmp_pcie_configure (pcs, cfg->regs, cfg->extra->pcs_tbl, cfg->extra->pcs_tbl_num); +qmp_pcie_lanes_init (qphy, &cfg->common); +qmp_pcie_lanes_init (qphy, cfg->extra); -qmp_pcie_configure (pcs_misc, cfg->regs, cfg->common.pcs_misc_tbl, cfg->common.pcs_misc_tbl_num); -qmp_pcie_configure (pcs_misc, cfg->regs, cfg->extra->pcs_misc_tbl, cfg->extra->pcs_misc_tbl_num); +qmp_pcie_pcs_init (qphy, &cfg->common); +qmp_pcie_pcs_init (qphy, cfg->extra);/* * Pull out PHY from POWER DOWN state.
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH v4 2/6] phy: qcom-qmp-pcie: split PHY programming to separate functions
Quoted 19 lines · Dmitry Baryshkov
Split the code using PHY programming tables into separate functions, which take a single struct
qmp_phy_cfg_tablesinstance.Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 80 ++++++++++++++---------- 1 file changed, 48 insertions(+), 32 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-1@@ -1877,15 +1877,53 @@ static void qmp_pcie_configure(void __iomem *base,qmp_pcie_configure_lane (base, regs, tbl, num,0xff ); } -static int qmp_pcie_serdes_init (struct qmp_phy *qphy) +static void qmp_pcie_serdes_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) {
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static void qmp_pcie_configure(void __iomem *base, · line 1888
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +3
-3const struct qmp_phy_cfg *cfg = qphy->cfg;void __iomem *serdes = qphy->serdes; -qmp_pcie_configure (serdes, cfg->regs, cfg->common.serdes_tbl, cfg->common.serdes_tbl_num); -qmp_pcie_configure (serdes, cfg->regs, cfg->extra->serdes_tbl, cfg->extra->serdes_tbl_num); +if (!tables) +return ; -return 0 ; +qmp_pcie_configure (serdes, cfg->regs, tables->serdes_tbl, tables->serdes_tbl_num);
See what I mean about "_tbl" being redundant in "tables->serdes_tbl"?
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-1+}static int qmp_pcie_init (struct phy *phy)@@ -1957,15 +1995,13 @@ static int qmp_pcie_power_on(struct phy *phy)struct qmp_phy *qphy =phy_get_drvdata (phy);struct qcom_qmp *qmp = qphy->qmp;const struct qmp_phy_cfg *cfg = qphy->cfg; -void __iomem *tx = qphy->tx;
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy) · line 2004
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2
-3-void __iomem *rx = qphy->rx;void __iomem *pcs = qphy->pcs; -void __iomem *pcs_misc = qphy->pcs_misc;void __iomem *status;unsigned int mask, val, ready;int ret; -qmp_pcie_serdes_init (qphy); +qmp_pcie_serdes_init (qphy, &cfg->common); +qmp_pcie_serdes_init (qphy, cfg->extra);
And "common" and "extra" doesn't really say what it is you're passing here.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy) · line 2007
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0ret =clk_prepare_enable (qphy->pipe_clk);if (ret) {
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v4 3/6 phy: qcom-qmp-pcie: support separate tables for EP mode
In reply to Dmitry BaryshkovThe PCIe QMP PHY requires different programming sequences when being used for the RC (Root Complex) or for the EP (End Point) modes. Allow selecting the submode and thus selecting a set of PHY programming tables.
Since the RC and EP modes share common some common init sequence, the common sequence is kept in the main table and the sequence differences are pushed to the extra tables.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 67 ++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +58 -9
@@ -1320,10 +1320,14 @@ struct qmp_phy_cfg {/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ struct qmp_phy_cfg_tables common;/* -* Additional init sequence for PHY blocks, providing additional -* register programming. Unless required it can be left omitted. +* Additional init sequences for PHY blocks, providing additional +* register programming. They are used for providing separate sequences +* for the Root Complex and for the End Point usecases. +* +* If EP mode is not supported, both tables can be left empty. */ -struct qmp_phy_cfg_tables *extra; +struct qmp_phy_cfg_tables *extra_rc;/* for the RC only */ +struct qmp_phy_cfg_tables *extra_ep;/* for the EP only */ /* clock ids to be requested */ const char *const *clk_list;
@@ -1367,6 +1371,7 @@ struct qmp_phy_cfg {* @pcs_misc: iomapped memory space for lane's pcs_misc * @pipe_clk: pipe clock * @qmp: QMP phy to which this lane belongs +* @extra: currently selected PHY extra init table set */ struct qmp_phy {struct phy *phy;
@@ -1379,6 +1384,7 @@ struct qmp_phy {void __iomem *rx2;void __iomem *pcs_misc;struct clk *pipe_clk; +const struct qmp_phy_cfg_tables *extra;struct qcom_qmp *qmp; };
@@ -1624,7 +1630,15 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), }, - .extra = &(struct qmp_phy_cfg_tables ) { +/* +* For sm8250 the split between the primary and extra_rc tables is +* historical, it reflects the programming sequence common to all PCIe +* PHYs on this platform and a sequence required for this particular +* PHY type. If EP support for sm8250 is required, the +* primary/extra_rc split is to be reconsidered and adjusted +* according to EP programming sequence. +*/ + .extra_rc = &(struct qmp_phy_cfg_tables ) { .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_serdes_tbl), .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl,
@@ -1666,7 +1680,15 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), }, - .extra = &(struct qmp_phy_cfg_tables ) { +/* +* For sm8250 the split between the primary and extra_rc tables is +* historical, it reflects the programming sequence common to all PCIe +* PHYs on this platform and a sequence required for this particular +* PHY type. If EP support for sm8250 is required, the +* primary/extra_rc split is to be reconsidered and adjusted +* according to EP programming sequence. +*/ + .extra_rc = &(struct qmp_phy_cfg_tables ) { .tx_tbl = sm8250_qmp_gen3x2_pcie_tx_tbl, .tx_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_tx_tbl), .rx_tbl = sm8250_qmp_gen3x2_pcie_rx_tbl,
@@ -2000,8 +2022,12 @@ static int qmp_pcie_power_on(struct phy *phy)unsigned int mask, val, ready;int ret; +/* Default to RC mode if the mode was not selected using phy_set_mode_ext() */ +if (!qphy->extra) + qphy->extra = cfg->extra_rc; +qmp_pcie_serdes_init (qphy, &cfg->common); -qmp_pcie_serdes_init (qphy, cfg->extra); +qmp_pcie_serdes_init (qphy, qphy->extra); ret =clk_prepare_enable (qphy->pipe_clk);if (ret) {
@@ -2011,10 +2037,10 @@ static int qmp_pcie_power_on(struct phy *phy)/* Tx, Rx, and PCS configurations */ qmp_pcie_lanes_init (qphy, &cfg->common); -qmp_pcie_lanes_init (qphy, cfg->extra); +qmp_pcie_lanes_init (qphy, qphy->extra);qmp_pcie_pcs_init (qphy, &cfg->common); -qmp_pcie_pcs_init (qphy, cfg->extra); +qmp_pcie_pcs_init (qphy, qphy->extra);/* * Pull out PHY from POWER DOWN state.
@@ -2101,6 +2127,26 @@ static int qmp_pcie_disable(struct phy *phy)return qmp_pcie_exit (phy); } +static int qmp_pcie_set_mode (struct phy *phy, +enum phy_mode mode,int submode) +{ +struct qmp_phy *qphy =phy_get_drvdata (phy); + +switch (submode) { +case PHY_MODE_PCIE_RC : + qphy->extra = qphy->cfg->extra_rc; +break ; +case PHY_MODE_PCIE_EP : + qphy->extra = qphy->cfg->extra_ep; +break ; +default : +dev_err (&phy->dev,"Unuspported submode %d\n" , submode); +return -EINVAL ; + } + +return 0 ; +} +static int qmp_pcie_vreg_init (struct device *dev,const struct qmp_phy_cfg *cfg) {struct qcom_qmp *qmp =dev_get_drvdata (dev);
@@ -2224,6 +2270,7 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)static const struct phy_ops qmp_pcie_ops = { .power_on = qmp_pcie_enable, .power_off = qmp_pcie_disable, + .set_mode = qmp_pcie_set_mode, .owner =THIS_MODULE , };
@@ -2278,7 +2325,9 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, qphy->pcs_misc = qphy->pcs +0x400 ;if (IS_ERR (qphy->pcs_misc)) { -if (cfg->common.pcs_misc_tbl || cfg->extra->pcs_misc_tbl) +if (cfg->common.pcs_misc_tbl || + cfg->extra_rc->pcs_misc_tbl || + cfg->extra_ep->pcs_misc_tbl)return PTR_ERR (qphy->pcs_misc); }
Signature · 1 line
2.35.1
Re: [PATCH v4 3/6] phy: qcom-qmp-pcie: support separate tables for EP mode
Quoted 35 lines · Dmitry Baryshkov
The PCIe QMP PHY requires different programming sequences when being used for the RC (Root Complex) or for the EP (End Point) modes. Allow selecting the submode and thus selecting a set of PHY programming tables.
Since the RC and EP modes share common some common init sequence, the common sequence is kept in the main table and the sequence differences are pushed to the extra tables.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 67 ++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +7
-3@@ -1320,10 +1320,14 @@ struct qmp_phy_cfg {/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ struct qmp_phy_cfg_tables common;/* -* Additional init sequence for PHY blocks, providing additional -* register programming. Unless required it can be left omitted. +* Additional init sequences for PHY blocks, providing additional +* register programming. They are used for providing separate sequences +* for the Root Complex and for the End Point usecases. +* +* If EP mode is not supported, both tables can be left empty. */ -struct qmp_phy_cfg_tables *extra; +struct qmp_phy_cfg_tables *extra_rc;/* for the RC only */ +struct qmp_phy_cfg_tables *extra_ep;/* for the EP only */
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2330
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +3
-1@@ -2278,7 +2325,9 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, qphy->pcs_misc = qphy->pcs +0x400 ;if (IS_ERR (qphy->pcs_misc)) { -if (cfg->common.pcs_misc_tbl || cfg->extra->pcs_misc_tbl) +if (cfg->common.pcs_misc_tbl || + cfg->extra_rc->pcs_misc_tbl || + cfg->extra_ep->pcs_misc_tbl)
More NULL derefs.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2332
Quoted 2 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0return PTR_ERR (qphy->pcs_misc); }
Johan
Re: [PATCH v4 3/6] phy: qcom-qmp-pcie: support separate tables for EP mode
In reply to Dmitry BaryshkovQuoted 23 lines · Dmitry Baryshkov
The PCIe QMP PHY requires different programming sequences when being used for the RC (Root Complex) or for the EP (End Point) modes. Allow selecting the submode and thus selecting a set of PHY programming tables.
Since the RC and EP modes share common some common init sequence, the common sequence is kept in the main table and the sequence differences are pushed to the extra tables.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 67 ++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-1@@ -1320,10 +1320,14 @@ struct qmp_phy_cfg {/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ struct qmp_phy_cfg_tables common;/* -* Additional init sequence for PHY blocks, providing additional
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c struct qmp_phy_cfg { · line 1330
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +7
-2-* register programming. Unless required it can be left omitted. +* Additional init sequences for PHY blocks, providing additional +* register programming. They are used for providing separate sequences +* for the Root Complex and for the End Point usecases. +* +* If EP mode is not supported, both tables can be left empty. */ -struct qmp_phy_cfg_tables *extra; +struct qmp_phy_cfg_tables *extra_rc;/* for the RC only */ +struct qmp_phy_cfg_tables *extra_ep;/* for the EP only */
So with the additional "_rc" and "_ep" suffixes this would be more obvious as for example:
struct qmp_phy_cfg_tables tbls_common; struct qmp_phy_cfg_tables tbls_rc; struct qmp_phy_cfg_tables tbls_ep;
The "for the RC only" comments doesn't really add anything.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c struct qmp_phy_cfg { · line 1374
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-0/* clock ids to be requested */ const char *const *clk_list;@@ -1367,6 +1371,7 @@ struct qmp_phy_cfg {* @pcs_misc: iomapped memory space for lane's pcs_misc * @pipe_clk: pipe clock * @qmp: QMP phy to which this lane belongs +* @extra: currently selected PHY extra init table set
"extra" is not a descriptive name here either.
Quoted 14 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-0*/ struct qmp_phy {struct phy *phy;@@ -1379,6 +1384,7 @@ struct qmp_phy {void __iomem *rx2;void __iomem *pcs_misc;struct clk *pipe_clk; +const struct qmp_phy_cfg_tables *extra;struct qcom_qmp *qmp; };@@ -1624,7 +1630,15 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl),
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { · line 1640
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +8
-1}, - .extra = &(struct qmp_phy_cfg_tables) { +/* +* For sm8250 the split between the primary and extra_rc tables is +* historical, it reflects the programming sequence common to all PCIe +* PHYs on this platform and a sequence required for this particular +* PHY type. If EP support for sm8250 is required, the +* primary/extra_rc split is to be reconsidered and adjusted +* according to EP programming sequence. +*/
Not sure this is needed either. I'm currently using the "_sec" tables (future "extra") for sc8280xp as well to handle minor variations in init sequences between the different PHY types.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy) · line 2027
Quoted 12 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +4
-0+ .extra_rc = &(struct qmp_phy_cfg_tables) { .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, .serdes_tbl_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_serdes_tbl), .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl,@@ -2000,8 +2022,12 @@ static int qmp_pcie_power_on(struct phy *phy)unsigned int mask, val, ready;int ret; +/* Default to RC mode if the mode was not selected using phy_set_mode_ext() */ +if (!qphy->extra) + qphy->extra = cfg->extra_rc;
It would probably be better to just store the submode in phy_set_mode_ext() and pick the right table here.
That way you don't need to describe what's really going on in a comment as it would be apparent from the code.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy)
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +3
-1+qmp_pcie_serdes_init (qphy, &cfg->common); -qmp_pcie_serdes_init (qphy, cfg->extra); +qmp_pcie_serdes_init (qphy, qphy->extra); ret =clk_prepare_enable (qphy->pipe_clk);if (ret) { +static int qmp_pcie_set_mode(struct phy *phy,
Do you really need a line break?
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_disable(struct phy *phy) · line 2143
Quoted 13 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +13
-0+ enum phy_mode mode, int submode) +{ +struct qmp_phy *qphy =phy_get_drvdata (phy); + +switch (submode) { +case PHY_MODE_PCIE_RC : + qphy->extra = qphy->cfg->extra_rc; +break ; +case PHY_MODE_PCIE_EP : + qphy->extra = qphy->cfg->extra_ep; +break ; +default : +dev_err (&phy->dev,"Unuspported submode %d\n" , submode);
Typo: unsupported
Quoted 18 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +7
-0+return -EINVAL ; + } + +return 0 ; +} +static int qmp_pcie_vreg_init (struct device *dev,const struct qmp_phy_cfg *cfg) {struct qcom_qmp *qmp =dev_get_drvdata (dev);@@ -2224,6 +2270,7 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)static const struct phy_ops qmp_pcie_ops = { .power_on = qmp_pcie_enable, .power_off = qmp_pcie_disable, + .set_mode = qmp_pcie_set_mode, .owner =THIS_MODULE , };
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2330
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +3
-1@@ -2278,7 +2325,9 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, qphy->pcs_misc = qphy->pcs +0x400 ;if (IS_ERR (qphy->pcs_misc)) { -if (cfg->common.pcs_misc_tbl || cfg->extra->pcs_misc_tbl) +if (cfg->common.pcs_misc_tbl || + cfg->extra_rc->pcs_misc_tbl || + cfg->extra_ep->pcs_misc_tbl)
I already pointed out the NULL deref here.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, · line 2332
Quoted 2 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0return PTR_ERR (qphy->pcs_misc); }
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v4 4/6 phy: qcom-qmp-pcie: Support SM8450 PCIe1 PHY in EP mode
In reply to Dmitry BaryshkovAdd support for using PCIe1 (gen4x2) in EP mode on SM8450. The tables to program are mostly common with the RC mode tables, so only register difference are split into separate RC and EP tables.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 78 +++++++++++++++---- .../qualcomm/phy-qcom-qmp-pcs-pcie-v5_20.h | 1 + 2 files changed, 64 insertions(+), 15 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +63 -15
@@ -1184,15 +1184,29 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen3x1_pcie_pcs_misc_tbl[] = { };static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_IVCO ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP_EN ,0x46 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP_CFG ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_TUNE_MAP ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_HSCLK_SEL ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CORECLK_DIV_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CORECLK_DIV_MODE1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CMN_MISC1 ,0x88 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CMN_CONFIG ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CMN_MODE ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_DC_LEVEL_CTRL ,0x0f ), +}; + +static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_PER1 ,0x31 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_PER2 ,0x01 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0 ,0xde ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0 ,0x07 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1 ,0x97 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1 ,0x0c ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN ,0x14 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_CLK_ENABLE1 ,0x90 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_IVCO ,0x0f ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_CP_CTRL_MODE0 ,0x06 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_CP_CTRL_MODE1 ,0x06 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_RCTRL_MODE0 ,0x16 ),
@@ -1200,8 +1214,6 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_CCTRL_MODE0 ,0x36 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_CCTRL_MODE1 ,0x36 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SYSCLK_EN_SEL ,0x08 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP_EN ,0x46 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP_CFG ,0x04 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP1_MODE0 ,0x0a ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP2_MODE0 ,0x1a ), QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x14),
@@ -1214,17 +1226,8 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START1_MODE1 ,0x55 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START2_MODE1 ,0x55 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START3_MODE1 ,0x05 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_TUNE_MAP ,0x02 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_CLK_SELECT ,0x34 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_HSCLK_SEL ,0x12 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL ,0x00 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_CORECLK_DIV_MODE0 ,0x0a ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_CORECLK_DIV_MODE1 ,0x04 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_CMN_MISC1 ,0x88 ), QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x20), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_CMN_CONFIG ,0x06 ), -QMP_PHY_INIT_CFG (QSERDES_V5_COM_CMN_MODE ,0x14 ), - QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_DC_LEVEL_CTRL, 0x0f), }; static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_tx_tbl[] = {
@@ -1292,14 +1295,44 @@ static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_tbl[] = { };static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_pcs_misc_tbl[] = { -QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE ,0xc1 ), -QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS ,0x00 ),QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5 ,0x02 ),QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_EQ_CONFIG1 ,0x16 ),QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_RX_MARGINING_CONFIG3 ,0x28 ),QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN ,0x2e ), }; +static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE ,0xc1 ), +QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS ,0x00 ), +}; + +static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BG_TIMER ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_SYS_CLK_CTRL ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CP_CTRL_MODE0 ,0x27 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CP_CTRL_MODE1 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_RCTRL_MODE0 ,0x17 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_RCTRL_MODE1 ,0x19 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_CCTRL_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_CCTRL_MODE1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_SYSCLK_EN_SEL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP1_MODE0 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP2_MODE0 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP1_MODE1 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP2_MODE1 ,0x09 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DEC_START_MODE0 ,0x19 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DEC_START_MODE1 ,0x28 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE0 ,0xfb ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE0 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE1 ,0xfb ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_INTEGLOOP_GAIN1_MODE1 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CORE_CLK_EN ,0x60 ), +}; + +static const struct qmp_phy_init_tbl sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V5_20_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5 ,0x08 ), +}; +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes_tbl;int serdes_tbl_num;
@@ -1851,6 +1884,21 @@ static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .pcs_misc_tbl = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl), }, + + .extra_rc = &(struct qmp_phy_cfg_tables ) { + .serdes_tbl = sm8450_qmp_gen4x2_pcie_rc_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_rc_serdes_tbl), + .pcs_misc_tbl = sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl, + .pcs_misc_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl), + }, + + .extra_ep = &(struct qmp_phy_cfg_tables ) { + .serdes_tbl = sm8450_qmp_gen4x2_pcie_ep_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_ep_serdes_tbl), + .pcs_misc_tbl = sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl, + .pcs_misc_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl), + }, + .clk_list = sdm845_pciephy_clk_l, .num_clks = ARRAY_SIZE(sdm845_pciephy_clk_l), .reset_list = sdm845_pciephy_reset_l,
drivers/phy/qualcomm/phy-qcom-qmp-pcs-pcie-v5_20.h +1 -0
@@ -8,6 +8,7 @@/* Only for QMP V5_20 PHY - PCIe PCS registers */ #define QPHY_V5_20_PCS_PCIE_ENDPOINT_REFCLK_DRIVE 0x01c +#define QPHY_V5_20_PCS_PCIE_OSC_DTCT_MODE2_CONFIG5 0x084#define QPHY_V5_20_PCS_PCIE_OSC_DTCT_ACTIONS 0x090#define QPHY_V5_20_PCS_PCIE_EQ_CONFIG1 0x0a0#define QPHY_V5_20_PCS_PCIE_G4_EQ_CONFIG5 0x108
Signature · 1 line
2.35.1
PATCH v4 5/6 PCI: qcom: Setup PHY to work in RC mode
In reply to Dmitry BaryshkovCall phy_set_mode_ext() to notify the PHY driver that the PHY is being used in the RC mode.
--- drivers/pci/controller/dwc/pcie-qcom.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/controller/dwc/pcie-qcom.c +5 -0
@@ -22,6 +22,7 @@#include <linux/pci.h> #include <linux/pm_runtime.h> #include <linux/platform_device.h> +#include <linux/phy/pcie.h> #include <linux/phy/phy.h> #include <linux/regulator/consumer.h> #include <linux/reset.h>
@@ -1494,6 +1495,10 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)if (ret)return ret; + ret =phy_set_mode_ext (pcie->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_RC ); +if (ret) + goto err_deinit; + ret =phy_power_on (pcie->phy);if (ret) goto err_deinit;
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH v4 5/6] PCI: qcom: Setup PHY to work in RC mode
Quoted 5 lines · On Sat, Sep 24, 2022 Dmitry Baryshkov <[email protected]> wrote:
Call
phy_set_mode_ext()to notify the PHY driver that the PHY is being used in the RC mode.Signed-off-by Dmitry Baryshkov <[email protected]>
Best regards,
Jingoo Han
Quoted 30 lines
--- drivers/pci/controller/dwc/pcie-qcom.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/controller/dwc/pcie-qcom.c +5
-1@@ -22,6 +22,7 @@#include <linux/pci.h> #include <linux/pm_runtime.h> #include <linux/platform_device.h> +#include <linux/phy/pcie.h> #include <linux/phy/phy.h> #include <linux/regulator/consumer.h> #include <linux/reset.h> @@ -1494,6 +1495,10 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)if (ret)return ret; + ret =phy_set_mode_ext (pcie->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_RC ); +if (ret) + goto err_deinit; + ret =phy_power_on (pcie->phy);if (ret) goto err_deinit; --2.35.1
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v4 6/6 PCI: qcom-ep: Setup PHY to work in EP mode
In reply to Dmitry BaryshkovCall phy_set_mode_ext() to notify the PHY driver that the PHY is being used in the EP mode.
--- drivers/pci/controller/dwc/pcie-qcom-ep.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/controller/dwc/pcie-qcom-ep.c +5 -0
@@ -13,6 +13,7 @@#include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/mfd/syscon.h> +#include <linux/phy/pcie.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/pm_domain.h>
@@ -240,6 +241,10 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)if (ret) goto err_disable_clk; + ret =phy_set_mode_ext (pcie_ep->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_EP ); +if (ret) + goto err_phy_exit; + ret =phy_power_on (pcie_ep->phy);if (ret) goto err_phy_exit;
Signature · 1 line
2.35.1
Re: [PATCH v4 6/6] PCI: qcom-ep: Setup PHY to work in EP mode
Quoted 6 lines · On Sat, Sep 24, 2022 Dmitry Baryshkov <[email protected]> wrote:
Call
phy_set_mode_ext()to notify the PHY driver that the PHY is being used in the EP mode.Reviewed-by Manivannan Sadhasivam <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>
Best regards,
Jingoo Han
Quoted 30 lines
--- drivers/pci/controller/dwc/pcie-qcom-ep.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/controller/dwc/pcie-qcom-ep.c +5
-1@@ -13,6 +13,7 @@#include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/mfd/syscon.h> +#include <linux/phy/pcie.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> @@ -240,6 +241,10 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)if (ret) goto err_disable_clk; + ret =phy_set_mode_ext (pcie_ep->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_EP ); +if (ret) + goto err_phy_exit; + ret =phy_power_on (pcie_ep->phy);if (ret) goto err_phy_exit; --2.35.1