PCI: qcom: Support using the same PHY for both RC and EP
Subsystems (6)
v6 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 v5:
- Fixed typos (Johan)
- Added R-B tags which I missed in v5
Changes since v4:
- Fixed the possible oops in probe (Johan)
- Renamed the tables struct and individual table fields (Johan)
- Squashed the 'separate funtions' patch to lower the possible confusion.
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 (5):
phy: qcom-qmp-pcie: split register tables into common and extra parts
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 | 518 +++++++++++------- .../qualcomm/phy-qcom-qmp-pcs-pcie-v5_20.h | 1 + 4 files changed, 330 insertions(+), 199 deletions(-)
Signature · 1 line
2.35.1
PATCH v6 1/5 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 | 406 +++++++++++++---------- 1 file changed, 222 insertions(+), 184 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +222 -184
@@ -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_tables { +const struct qmp_phy_init_tbl *serdes; +int serdes_num; +const struct qmp_phy_init_tbl *tx; +int tx_num; +const struct qmp_phy_init_tbl *rx; +int rx_num; +const struct qmp_phy_init_tbl *pcs; +int pcs_num; +const struct qmp_phy_init_tbl *pcs_misc; +int pcs_misc_num; +}; +/* struct qmp_phy_cfg - per-PHY initialization config */ struct qmp_phy_cfg {int lanes; -/* Init sequence for PHY blocks - serdes, tx, rx, pcs */ -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; +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ +const struct qmp_phy_cfg_tables tables; +/* +* Additional init sequence for PHY blocks, providing additional +* register programming. Unless required it can be left omitted. +*/ +const struct qmp_phy_cfg_tables *tables_rc;/* clock ids to be requested */ const char *const *clk_list;
@@ -1459,14 +1458,16 @@ static const char * const sdm845_pciephy_reset_l[] = {static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .lanes =1 , - .serdes_tbl = ipq8074_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (ipq8074_pcie_serdes_tbl), - .tx_tbl = ipq8074_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (ipq8074_pcie_tx_tbl), - .rx_tbl = ipq8074_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (ipq8074_pcie_rx_tbl), - .pcs_tbl = ipq8074_pcie_pcs_tbl, - .pcs_tbl_num =ARRAY_SIZE (ipq8074_pcie_pcs_tbl), + .tables = { + .serdes = ipq8074_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (ipq8074_pcie_serdes_tbl), + .tx = ipq8074_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (ipq8074_pcie_tx_tbl), + .rx = ipq8074_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (ipq8074_pcie_rx_tbl), + .pcs = ipq8074_pcie_pcs_tbl, + .pcs_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,14 +1488,16 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { .lanes =1 , - .serdes_tbl = ipq8074_pcie_gen3_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (ipq8074_pcie_gen3_serdes_tbl), - .tx_tbl = ipq8074_pcie_gen3_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (ipq8074_pcie_gen3_tx_tbl), - .rx_tbl = ipq8074_pcie_gen3_rx_tbl, - .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), + .tables = { + .serdes = ipq8074_pcie_gen3_serdes_tbl, + .serdes_num =ARRAY_SIZE (ipq8074_pcie_gen3_serdes_tbl), + .tx = ipq8074_pcie_gen3_tx_tbl, + .tx_num =ARRAY_SIZE (ipq8074_pcie_gen3_tx_tbl), + .rx = ipq8074_pcie_gen3_rx_tbl, + .rx_num =ARRAY_SIZE (ipq8074_pcie_gen3_rx_tbl), + .pcs = ipq8074_pcie_gen3_pcs_tbl, + .pcs_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,16 +1519,18 @@ static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { .lanes =1 , - .serdes_tbl = ipq6018_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (ipq6018_pcie_serdes_tbl), - .tx_tbl = ipq6018_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (ipq6018_pcie_tx_tbl), - .rx_tbl = ipq6018_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (ipq6018_pcie_rx_tbl), - .pcs_tbl = ipq6018_pcie_pcs_tbl, - .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), + .tables = { + .serdes = ipq6018_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (ipq6018_pcie_serdes_tbl), + .tx = ipq6018_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (ipq6018_pcie_tx_tbl), + .rx = ipq6018_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (ipq6018_pcie_rx_tbl), + .pcs = ipq6018_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (ipq6018_pcie_pcs_tbl), + .pcs_misc = ipq6018_pcie_pcs_misc_tbl, + .pcs_misc_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,16 +1550,18 @@ static const struct qmp_phy_cfg ipq6018_pciephy_cfg = {static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { .lanes =1 , - .serdes_tbl = sdm845_qmp_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (sdm845_qmp_pcie_serdes_tbl), - .tx_tbl = sdm845_qmp_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (sdm845_qmp_pcie_tx_tbl), - .rx_tbl = sdm845_qmp_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (sdm845_qmp_pcie_rx_tbl), - .pcs_tbl = sdm845_qmp_pcie_pcs_tbl, - .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), + .tables = { + .serdes = sdm845_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sdm845_qmp_pcie_serdes_tbl), + .tx = sdm845_qmp_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sdm845_qmp_pcie_tx_tbl), + .rx = sdm845_qmp_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sdm845_qmp_pcie_rx_tbl), + .pcs = sdm845_qmp_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sdm845_qmp_pcie_pcs_tbl), + .pcs_misc = sdm845_qmp_pcie_pcs_misc_tbl, + .pcs_misc_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,14 +1582,16 @@ static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { .lanes =1 , - .serdes_tbl = sdm845_qhp_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (sdm845_qhp_pcie_serdes_tbl), - .tx_tbl = sdm845_qhp_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (sdm845_qhp_pcie_tx_tbl), - .rx_tbl = sdm845_qhp_pcie_rx_tbl, - .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), + .tables = { + .serdes = sdm845_qhp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sdm845_qhp_pcie_serdes_tbl), + .tx = sdm845_qhp_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sdm845_qhp_pcie_tx_tbl), + .rx = sdm845_qhp_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sdm845_qhp_pcie_rx_tbl), + .pcs = sdm845_qhp_pcie_pcs_tbl, + .pcs_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 , - .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), + .tables = { + .serdes = sm8250_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8250_qmp_pcie_serdes_tbl), + .tx = sm8250_qmp_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8250_qmp_pcie_tx_tbl), + .rx = sm8250_qmp_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8250_qmp_pcie_rx_tbl), + .pcs = sm8250_qmp_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_tbl), + .pcs_misc = sm8250_qmp_pcie_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_misc_tbl), + }, + .tables_rc = &(const struct qmp_phy_cfg_tables ) { + .serdes = sm8250_qmp_gen3x1_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_serdes_tbl), + .rx = sm8250_qmp_gen3x1_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_rx_tbl), + .pcs = sm8250_qmp_gen3x1_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8250_qmp_gen3x1_pcie_pcs_tbl), + .pcs_misc = sm8250_qmp_gen3x1_pcie_pcs_misc_tbl, + .pcs_misc_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 , - .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), + .tables = { + .serdes = sm8250_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8250_qmp_pcie_serdes_tbl), + .tx = sm8250_qmp_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8250_qmp_pcie_tx_tbl), + .rx = sm8250_qmp_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8250_qmp_pcie_rx_tbl), + .pcs = sm8250_qmp_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_tbl), + .pcs_misc = sm8250_qmp_pcie_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sm8250_qmp_pcie_pcs_misc_tbl), + }, + .tables_rc = &(const struct qmp_phy_cfg_tables ) { + .tx = sm8250_qmp_gen3x2_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_tx_tbl), + .rx = sm8250_qmp_gen3x2_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_rx_tbl), + .pcs = sm8250_qmp_gen3x2_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_tbl), + .pcs_misc = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, + .pcs_misc_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,14 +1696,16 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {static const struct qmp_phy_cfg msm8998_pciephy_cfg = { .lanes =1 , - .serdes_tbl = msm8998_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (msm8998_pcie_serdes_tbl), - .tx_tbl = msm8998_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (msm8998_pcie_tx_tbl), - .rx_tbl = msm8998_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (msm8998_pcie_rx_tbl), - .pcs_tbl = msm8998_pcie_pcs_tbl, - .pcs_tbl_num =ARRAY_SIZE (msm8998_pcie_pcs_tbl), + .tables = { + .serdes = msm8998_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (msm8998_pcie_serdes_tbl), + .tx = msm8998_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (msm8998_pcie_tx_tbl), + .rx = msm8998_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (msm8998_pcie_rx_tbl), + .pcs = msm8998_pcie_pcs_tbl, + .pcs_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,16 +1722,18 @@ static const struct qmp_phy_cfg msm8998_pciephy_cfg = {static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .lanes =1 , - .serdes_tbl = sc8180x_qmp_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (sc8180x_qmp_pcie_serdes_tbl), - .tx_tbl = sc8180x_qmp_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (sc8180x_qmp_pcie_tx_tbl), - .rx_tbl = sc8180x_qmp_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (sc8180x_qmp_pcie_rx_tbl), - .pcs_tbl = sc8180x_qmp_pcie_pcs_tbl, - .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), + .tables = { + .serdes = sc8180x_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sc8180x_qmp_pcie_serdes_tbl), + .tx = sc8180x_qmp_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sc8180x_qmp_pcie_tx_tbl), + .rx = sc8180x_qmp_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sc8180x_qmp_pcie_rx_tbl), + .pcs = sc8180x_qmp_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sc8180x_qmp_pcie_pcs_tbl), + .pcs_misc = sc8180x_qmp_pcie_pcs_misc_tbl, + .pcs_misc_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,16 +1753,18 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = {static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { .lanes =2 , - .serdes_tbl = sdx55_qmp_pcie_serdes_tbl, - .serdes_tbl_num =ARRAY_SIZE (sdx55_qmp_pcie_serdes_tbl), - .tx_tbl = sdx55_qmp_pcie_tx_tbl, - .tx_tbl_num =ARRAY_SIZE (sdx55_qmp_pcie_tx_tbl), - .rx_tbl = sdx55_qmp_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (sdx55_qmp_pcie_rx_tbl), - .pcs_tbl = sdx55_qmp_pcie_pcs_tbl, - .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), + .tables = { + .serdes = sdx55_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sdx55_qmp_pcie_serdes_tbl), + .tx = sdx55_qmp_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sdx55_qmp_pcie_tx_tbl), + .rx = sdx55_qmp_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sdx55_qmp_pcie_rx_tbl), + .pcs = sdx55_qmp_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sdx55_qmp_pcie_pcs_tbl), + .pcs_misc = sdx55_qmp_pcie_pcs_misc_tbl, + .pcs_misc_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,16 +1785,18 @@ static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { .lanes =1 , - .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, - .tx_tbl_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_tx_tbl), - .rx_tbl = sm8450_qmp_gen3x1_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_rx_tbl), - .pcs_tbl = sm8450_qmp_gen3x1_pcie_pcs_tbl, - .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), + .tables = { + .serdes = sm8450_qmp_gen3x1_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_serdes_tbl), + .tx = sm8450_qmp_gen3x1_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_tx_tbl), + .rx = sm8450_qmp_gen3x1_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_rx_tbl), + .pcs = sm8450_qmp_gen3x1_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8450_qmp_gen3x1_pcie_pcs_tbl), + .pcs_misc = sm8450_qmp_gen3x1_pcie_pcs_misc_tbl, + .pcs_misc_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,16 +1817,18 @@ static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .lanes =2 , - .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, - .tx_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_tx_tbl), - .rx_tbl = sm8450_qmp_gen4x2_pcie_rx_tbl, - .rx_tbl_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_rx_tbl), - .pcs_tbl = sm8450_qmp_gen4x2_pcie_pcs_tbl, - .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), + .tables = { + .serdes = sm8450_qmp_gen4x2_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_serdes_tbl), + .tx = sm8450_qmp_gen4x2_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_tx_tbl), + .rx = sm8450_qmp_gen4x2_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_rx_tbl), + .pcs = sm8450_qmp_gen4x2_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_pcs_tbl), + .pcs_misc = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, + .pcs_misc_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,
@@ -1850,17 +1877,49 @@ 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; -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); +if (!tables) +return ; -return 0 ; +qmp_pcie_configure (serdes, cfg->regs, tables->serdes, tables->serdes_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, tables->tx_num,1 ); + +if (cfg->lanes >=2 ) +qmp_pcie_configure_lane (qphy->tx2, cfg->regs, tables->tx, tables->tx_num,2 ); + +qmp_pcie_configure_lane (rx, cfg->regs, tables->rx, tables->rx_num,1 ); +if (cfg->lanes >=2 ) +qmp_pcie_configure_lane (qphy->rx2, cfg->regs, tables->rx, tables->rx_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, tables->pcs_num); +qmp_pcie_configure (pcs_misc, cfg->regs, + tables->pcs_misc, tables->pcs_misc_num); }static int qmp_pcie_init (struct phy *phy)
@@ -1932,15 +1991,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->tables); +qmp_pcie_serdes_init (qphy, cfg->tables_rc); ret =clk_prepare_enable (qphy->pipe_clk);if (ret) {
@@ -1949,31 +2006,11 @@ 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 ); - -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 (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 ); - -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 (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_lanes_init (qphy, &cfg->tables); +qmp_pcie_lanes_init (qphy, cfg->tables_rc); -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_pcs_init (qphy, &cfg->tables); +qmp_pcie_pcs_init (qphy, cfg->tables_rc);/* * Pull out PHY from POWER DOWN state.
@@ -2240,7 +2277,8 @@ 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->tables.pcs_misc || + (cfg->tables_rc && cfg->tables_rc->pcs_misc))return PTR_ERR (qphy->pcs_misc); }
Signature · 1 line
2.35.1
Re: [PATCH v6 1/5] phy: qcom-qmp-pcie: split register tables into common and extra parts
Quoted 14 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).Reviewed-by Johan Hovold <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>---
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +3
-0+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;
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static void qmp_pcie_configure(void __iomem *base, · line 1922
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +10
-0+void __iomem *pcs = qphy->pcs; +void __iomem *pcs_misc = qphy->pcs_misc; + +if (!tables) +return ; + +qmp_pcie_configure (pcs, cfg->regs, + tables->pcs, tables->pcs_num); +qmp_pcie_configure (pcs_misc, cfg->regs, + tables->pcs_misc, tables->pcs_misc_num);
nit: You missed the above unnecessary line breaks.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v6 2/5 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 | 46 ++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +40 -6
@@ -14,6 +14,7 @@#include <linux/of.h> #include <linux/of_device.h> #include <linux/of_address.h> +#include <linux/phy/pcie.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/regulator/consumer.h>
@@ -1320,10 +1321,14 @@ struct qmp_phy_cfg {/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ const struct qmp_phy_cfg_tables tables;/* -* 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 End Point use cases. +* +* If EP mode is not supported, both tables can be left unset. */ const struct qmp_phy_cfg_tables *tables_rc; +const struct qmp_phy_cfg_tables *tables_ep;/* clock ids to be requested */ const char *const *clk_list;
@@ -1367,6 +1372,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 +* @mode: currently selected PHY mode */ struct qmp_phy {struct phy *phy;
@@ -1380,6 +1386,7 @@ struct qmp_phy {void __iomem *pcs_misc;struct clk *pipe_clk;struct qcom_qmp *qmp; +int mode; };/**
@@ -1991,13 +1998,19 @@ 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; +const struct qmp_phy_cfg_tables *mode_tables;void __iomem *pcs = qphy->pcs;void __iomem *status;unsigned int mask, val, ready;int ret; +if (qphy->mode ==PHY_MODE_PCIE_RC ) + mode_tables = cfg->tables_rc; +else + mode_tables = cfg->tables_ep; +qmp_pcie_serdes_init (qphy, &cfg->tables); -qmp_pcie_serdes_init (qphy, cfg->tables_rc); +qmp_pcie_serdes_init (qphy, mode_tables); ret =clk_prepare_enable (qphy->pipe_clk);if (ret) {
@@ -2007,10 +2020,10 @@ static int qmp_pcie_power_on(struct phy *phy)/* Tx, Rx, and PCS configurations */ qmp_pcie_lanes_init (qphy, &cfg->tables); -qmp_pcie_lanes_init (qphy, cfg->tables_rc); +qmp_pcie_lanes_init (qphy, mode_tables);qmp_pcie_pcs_init (qphy, &cfg->tables); -qmp_pcie_pcs_init (qphy, cfg->tables_rc); +qmp_pcie_pcs_init (qphy, mode_tables);/* * Pull out PHY from POWER DOWN state.
@@ -2097,6 +2110,23 @@ 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 : +case PHY_MODE_PCIE_EP : + qphy->mode = submode; +break ; +default : +dev_err (&phy->dev,"Unsupported 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);
@@ -2220,6 +2250,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 , };
@@ -2235,6 +2266,8 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,if (!qphy)return -ENOMEM ; + qphy->mode =PHY_MODE_PCIE_RC ; + qphy->cfg = cfg; qphy->serdes = serdes;/*
@@ -2278,7 +2311,8 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,if (IS_ERR (qphy->pcs_misc)) {if (cfg->tables.pcs_misc || - (cfg->tables_rc && cfg->tables_rc->pcs_misc)) + (cfg->tables_rc && cfg->tables_rc->pcs_misc) || + (cfg->tables_ep && cfg->tables_ep->pcs_misc))return PTR_ERR (qphy->pcs_misc); }
Signature · 1 line
2.35.1
PATCH v6 3/5 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
@@ -1185,15 +1185,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 ),
@@ -1201,8 +1215,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),
@@ -1215,17 +1227,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[] = {
@@ -1293,14 +1296,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;int serdes_num;
@@ -1836,6 +1869,21 @@ static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .pcs_misc = sm8450_qmp_gen4x2_pcie_pcs_misc_tbl, .pcs_misc_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_pcs_misc_tbl), }, + + .tables_rc = &(const struct qmp_phy_cfg_tables ) { + .serdes = sm8450_qmp_gen4x2_pcie_rc_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_rc_serdes_tbl), + .pcs_misc = sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_rc_pcs_misc_tbl), + }, + + .tables_ep = &(const struct qmp_phy_cfg_tables ) { + .serdes = sm8450_qmp_gen4x2_pcie_ep_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8450_qmp_gen4x2_pcie_ep_serdes_tbl), + .pcs_misc = sm8450_qmp_gen4x2_pcie_ep_pcs_misc_tbl, + .pcs_misc_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 v6 4/5 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 · 1 line
2.35.1
Re: [PATCH v6 4/5] PCI: qcom: Setup PHY to work in RC mode
Quoted 9 lines · Dmitry Baryshkov
Call
phy_set_mode_ext()to notify the PHY driver that the PHY is being used in the RC mode.Reviewed-by Jingoo Han <[email protected]>Reviewed-by Johan Hovold <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/pci/controller/dwc/pcie-qcom.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 26 lines
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 · 1 line
2.35.1
PATCH v6 5/5 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 v6 5/5] PCI: qcom-ep: Setup PHY to work in EP mode
Quoted 10 lines · Dmitry Baryshkov
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]>Reviewed-by Jingoo Han <[email protected]>Reviewed-by Johan Hovold <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/pci/controller/dwc/pcie-qcom-ep.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 26 lines
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
Quoted 17 lines · Dmitry Baryshkov
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.
Quoted 7 lines
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.
Applied, thanks
Signature · 1 line
~Vinod