phy: qcom-qmp-pcie: add support for sc8280xp
cover phy: qcom-qmp-pcie: add support for sc8280xp
This series adds support for the PCIe PHYs on SC8280XP including its four-lane PHYs.
The first half of the series clean up the driver in preparation for supporting SC8280XP and its new devicetree bindings that drops the legacy child node and the (incomplete) description of register subregions.
The other QMP bindings suffer from similar problems and follow-on series will do corresponding changes to the UFS, USB and combo QMP bindings and drivers.
Note that these patches depend on the linux-phy next branch of today and the following two series:
1. [PATCH v2 00/14] phy: qcom-qmp: further prep cleanups
https://lore.kernel.org/lkml/[email protected]
2. [PATCH 00/20] phy: qcom-qmp: further prep fixes and cleanups (set 3)
https://lore.kernel.org/lkml/[email protected]
Johan
Johan Hovold (15):
phy: qcom-qmp-pcie: sort device-id table
phy: qcom-qmp-pcie: move device-id table
phy: qcom-qmp-pcie: merge driver data
phy: qcom-qmp-pcie: clean up device-tree parsing
phy: qcom-qmp-pcie: clean up probe initialisation
phy: qcom-qmp-pcie: rename PHY ops structure
phy: qcom-qmp-pcie: clean up PHY lane init
phy: qcom-qmp-pcie: add register init helper
dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
dt-bindings: phy: qcom,qmp-pcie: add sc8280xp bindings
phy: qcom-qmp-pcie: restructure PHY creation
phy: qcom-qmp-pcie: fix initialisation reset
phy: qcom-qmp-pcie: add support for pipediv2 clock
phy: qcom-qmp-pcie: add support for sc8280xp
phy: qcom-qmp-pcie: add support for sc8280xp 4-lane PHYs
.../phy/qcom,qmp-pcie-phy-legacy.yaml | 296 ++++++ .../bindings/phy/qcom,qmp-pcie-phy.yaml | 331 ++----- drivers/phy/qualcomm/Kconfig | 1 + drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 853 ++++++++++++------ .../phy/qualcomm/phy-qcom-qmp-pcs-pcie-v5.h | 2 + 5 files changed, 999 insertions(+), 484 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy-legacy.yaml
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 1/15 phy: qcom-qmp-pcie: sort device-id table
Sort the device-id table by compatible string to make it easier to find and add new entries.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +10 -10
@@ -2282,17 +2282,17 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,static const struct of_device_id qmp_pcie_of_match_table[] = { { - .compatible ="qcom,msm8998-qmp-pcie-phy" , - .data = &msm8998_pciephy_cfg, - }, { - .compatible ="qcom,ipq8074-qmp-pcie-phy" , - .data = &ipq8074_pciephy_cfg, + .compatible ="qcom,ipq6018-qmp-pcie-phy" , + .data = &ipq6018_pciephy_cfg, }, { .compatible ="qcom,ipq8074-qmp-gen3-pcie-phy" , .data = &ipq8074_pciephy_gen3_cfg, }, { - .compatible ="qcom,ipq6018-qmp-pcie-phy" , - .data = &ipq6018_pciephy_cfg, + .compatible ="qcom,ipq8074-qmp-pcie-phy" , + .data = &ipq8074_pciephy_cfg, + }, { + .compatible ="qcom,msm8998-qmp-pcie-phy" , + .data = &msm8998_pciephy_cfg, }, { .compatible ="qcom,sc8180x-qmp-pcie-phy" , .data = &sc8180x_pciephy_cfg,
@@ -2302,6 +2302,9 @@ static const struct of_device_id qmp_pcie_of_match_table[] = { }, { .compatible = "qcom,sdm845-qmp-pcie-phy", .data = &sdm845_qmp_pciephy_cfg, + }, { + .compatible = "qcom,sdx55-qmp-pcie-phy", + .data = &sdx55_qmp_pciephy_cfg, }, { .compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy", .data = &sm8250_qmp_gen3x1_pciephy_cfg,
@@ -2311,9 +2314,6 @@ static const struct of_device_id qmp_pcie_of_match_table[] = { }, { .compatible = "qcom,sm8250-qmp-modem-pcie-phy", .data = &sm8250_qmp_gen3x2_pciephy_cfg, - }, { - .compatible = "qcom,sdx55-qmp-pcie-phy", - .data = &sdx55_qmp_pciephy_cfg, }, { .compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy", .data = &sm8450_qmp_gen3x1_pciephy_cfg,
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 2/15 phy: qcom-qmp-pcie: move device-id table
In reply to Johan HovoldMove the device-id table below probe() and next to the driver structure to keep the driver callback functions grouped together.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 90 ++++++++++++------------ 1 file changed, 45 insertions(+), 45 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +45 -45
@@ -2280,51 +2280,6 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,return 0 ; } -static const struct of_device_id qmp_pcie_of_match_table[] = { - { - .compatible ="qcom,ipq6018-qmp-pcie-phy" , - .data = &ipq6018_pciephy_cfg, - }, { - .compatible ="qcom,ipq8074-qmp-gen3-pcie-phy" , - .data = &ipq8074_pciephy_gen3_cfg, - }, { - .compatible ="qcom,ipq8074-qmp-pcie-phy" , - .data = &ipq8074_pciephy_cfg, - }, { - .compatible ="qcom,msm8998-qmp-pcie-phy" , - .data = &msm8998_pciephy_cfg, - }, { - .compatible ="qcom,sc8180x-qmp-pcie-phy" , - .data = &sc8180x_pciephy_cfg, - }, { - .compatible ="qcom,sdm845-qhp-pcie-phy" , - .data = &sdm845_qhp_pciephy_cfg, - }, { - .compatible ="qcom,sdm845-qmp-pcie-phy" , - .data = &sdm845_qmp_pciephy_cfg, - }, { - .compatible ="qcom,sdx55-qmp-pcie-phy" , - .data = &sdx55_qmp_pciephy_cfg, - }, { - .compatible ="qcom,sm8250-qmp-gen3x1-pcie-phy" , - .data = &sm8250_qmp_gen3x1_pciephy_cfg, - }, { - .compatible ="qcom,sm8250-qmp-gen3x2-pcie-phy" , - .data = &sm8250_qmp_gen3x2_pciephy_cfg, - }, { - .compatible ="qcom,sm8250-qmp-modem-pcie-phy" , - .data = &sm8250_qmp_gen3x2_pciephy_cfg, - }, { - .compatible ="qcom,sm8450-qmp-gen3x1-pcie-phy" , - .data = &sm8450_qmp_gen3x1_pciephy_cfg, - }, { - .compatible ="qcom,sm8450-qmp-gen4x2-pcie-phy" , - .data = &sm8450_qmp_gen4x2_pciephy_cfg, - }, - { }, -}; -MODULE_DEVICE_TABLE (of, qmp_pcie_of_match_table); -static int qmp_pcie_probe (struct platform_device *pdev) {struct qcom_qmp *qmp;
@@ -2408,6 +2363,51 @@ static int qmp_pcie_probe(struct platform_device *pdev)return ret; } +static const struct of_device_id qmp_pcie_of_match_table[] = { + { + .compatible ="qcom,ipq6018-qmp-pcie-phy" , + .data = &ipq6018_pciephy_cfg, + }, { + .compatible ="qcom,ipq8074-qmp-gen3-pcie-phy" , + .data = &ipq8074_pciephy_gen3_cfg, + }, { + .compatible ="qcom,ipq8074-qmp-pcie-phy" , + .data = &ipq8074_pciephy_cfg, + }, { + .compatible ="qcom,msm8998-qmp-pcie-phy" , + .data = &msm8998_pciephy_cfg, + }, { + .compatible ="qcom,sc8180x-qmp-pcie-phy" , + .data = &sc8180x_pciephy_cfg, + }, { + .compatible ="qcom,sdm845-qhp-pcie-phy" , + .data = &sdm845_qhp_pciephy_cfg, + }, { + .compatible ="qcom,sdm845-qmp-pcie-phy" , + .data = &sdm845_qmp_pciephy_cfg, + }, { + .compatible ="qcom,sdx55-qmp-pcie-phy" , + .data = &sdx55_qmp_pciephy_cfg, + }, { + .compatible ="qcom,sm8250-qmp-gen3x1-pcie-phy" , + .data = &sm8250_qmp_gen3x1_pciephy_cfg, + }, { + .compatible ="qcom,sm8250-qmp-gen3x2-pcie-phy" , + .data = &sm8250_qmp_gen3x2_pciephy_cfg, + }, { + .compatible ="qcom,sm8250-qmp-modem-pcie-phy" , + .data = &sm8250_qmp_gen3x2_pciephy_cfg, + }, { + .compatible ="qcom,sm8450-qmp-gen3x1-pcie-phy" , + .data = &sm8450_qmp_gen3x1_pciephy_cfg, + }, { + .compatible ="qcom,sm8450-qmp-gen4x2-pcie-phy" , + .data = &sm8450_qmp_gen4x2_pciephy_cfg, + }, + { }, +}; +MODULE_DEVICE_TABLE (of, qmp_pcie_of_match_table); +static struct platform_driver qmp_pcie_driver = { .probe = qmp_pcie_probe, .driver = {
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 3/15 phy: qcom-qmp-pcie: merge driver data
In reply to Johan HovoldThe PCIe QMP PHY driver only manages a single PHY so merge the old qcom_qmp and qmp_phy structures and drop the PHY array.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 218 +++++++++-------------- 1 file changed, 88 insertions(+), 130 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +88 -130
@@ -1365,56 +1365,26 @@ struct qmp_phy_cfg {unsigned long pipe_clock_rate; }; -/** -* struct qmp_phy - per-lane phy descriptor -* -* @phy: generic phy -* @cfg: phy specific configuration -* @serdes: iomapped memory space for phy's serdes (i.e. PLL) -* @tx: iomapped memory space for lane's tx -* @rx: iomapped memory space for lane's rx -* @pcs: iomapped memory space for lane's pcs -* @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) -* @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) -* @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; +struct qmp_pcie { +struct device *dev; +const struct qmp_phy_cfg *cfg; +void __iomem *serdes; +void __iomem *pcs; +void __iomem *pcs_misc;void __iomem *tx;void __iomem *rx; -void __iomem *pcs;void __iomem *tx2;void __iomem *rx2; -void __iomem *pcs_misc; -struct clk *pipe_clk; -struct qcom_qmp *qmp; -int mode; -}; - -/** -* struct qcom_qmp - structure holding QMP phy block attributes -* -* @dev: device -* -* @clks: array of clocks required by phy -* @resets: array of resets required by phy -* @vregs: regulator supplies bulk data -* -* @phys: array of per-lane phy descriptors -*/ -struct qcom_qmp { -struct device *dev; +struct clk *pipe_clk;struct clk_bulk_data *clks;struct reset_control_bulk_data *resets;struct regulator_bulk_data *vregs; -struct qmp_phy **phys; +struct phy *phy; +int mode; };static inline void qphy_setbits (void __iomem *base,u32 offset,u32 val)
@@ -1850,9 +1820,9 @@ static void qmp_pcie_configure(void __iomem *base,qmp_pcie_configure_lane (base, tbl, num,0xff ); } -static void qmp_pcie_serdes_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) +static void qmp_pcie_serdes_init (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tables) { -void __iomem *serdes = qphy->serdes; +void __iomem *serdes = qmp->serdes;if (!tables)return ;
@@ -1860,11 +1830,11 @@ static void qmp_pcie_serdes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_qmp_pcie_configure (serdes, tables->serdes, tables->serdes_num); } -static void qmp_pcie_lanes_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) +static void qmp_pcie_lanes_init (struct qmp_pcie *qmp,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; +const struct qmp_phy_cfg *cfg = qmp->cfg; +void __iomem *tx = qmp->tx; +void __iomem *rx = qmp->rx;if (!tables)return ;
@@ -1872,17 +1842,17 @@ static void qmp_pcie_lanes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tqmp_pcie_configure_lane (tx, tables->tx, tables->tx_num,1 );if (cfg->lanes >=2 ) -qmp_pcie_configure_lane (qphy->tx2, tables->tx, tables->tx_num,2 ); +qmp_pcie_configure_lane (qmp->tx2, tables->tx, tables->tx_num,2 );qmp_pcie_configure_lane (rx, tables->rx, tables->rx_num,1 );if (cfg->lanes >=2 ) -qmp_pcie_configure_lane (qphy->rx2, tables->rx, tables->rx_num,2 ); +qmp_pcie_configure_lane (qmp->rx2, tables->rx, tables->rx_num,2 ); } -static void qmp_pcie_pcs_init (struct qmp_phy *qphy,const struct qmp_phy_cfg_tables *tables) +static void qmp_pcie_pcs_init (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tables) { -void __iomem *pcs = qphy->pcs; -void __iomem *pcs_misc = qphy->pcs_misc; +void __iomem *pcs = qmp->pcs; +void __iomem *pcs_misc = qmp->pcs_misc;if (!tables)return ;
@@ -1893,9 +1863,8 @@ static void qmp_pcie_pcs_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tabstatic int qmp_pcie_init (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; +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg;int ret; ret =regulator_bulk_enable (cfg->num_vregs, qmp->vregs);
@@ -1932,9 +1901,8 @@ static int qmp_pcie_init(struct phy *phy)static int qmp_pcie_exit (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; +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg;reset_control_bulk_assert (cfg->num_resets, qmp->resets);
@@ -1947,11 +1915,10 @@ static int qmp_pcie_exit(struct phy *phy)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; +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg;const struct qmp_phy_cfg_tables *mode_tables; -void __iomem *pcs = qphy->pcs; +void __iomem *pcs = qmp->pcs;void __iomem *status;unsigned int mask, val;int ret;
@@ -1959,26 +1926,26 @@ static int qmp_pcie_power_on(struct phy *phy)qphy_setbits (pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], cfg->pwrdn_ctrl); -if (qphy->mode ==PHY_MODE_PCIE_RC ) +if (qmp->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, mode_tables); +qmp_pcie_serdes_init (qmp, &cfg->tables); +qmp_pcie_serdes_init (qmp, mode_tables); - ret =clk_prepare_enable (qphy->pipe_clk); + ret =clk_prepare_enable (qmp->pipe_clk);if (ret) {dev_err (qmp->dev,"pipe_clk enable failed err=%d\n" , ret);return ret; }/* Tx, Rx, and PCS configurations */ -qmp_pcie_lanes_init (qphy, &cfg->tables); -qmp_pcie_lanes_init (qphy, mode_tables); +qmp_pcie_lanes_init (qmp, &cfg->tables); +qmp_pcie_lanes_init (qmp, mode_tables); -qmp_pcie_pcs_init (qphy, &cfg->tables); -qmp_pcie_pcs_init (qphy, mode_tables); +qmp_pcie_pcs_init (qmp, &cfg->tables); +qmp_pcie_pcs_init (qmp, mode_tables);/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
@@ -2001,27 +1968,27 @@ static int qmp_pcie_power_on(struct phy *phy)return 0 ; err_disable_pipe_clk: -clk_disable_unprepare (qphy->pipe_clk); +clk_disable_unprepare (qmp->pipe_clk);return ret; }static int qmp_pcie_power_off (struct phy *phy) { -struct qmp_phy *qphy =phy_get_drvdata (phy); -const struct qmp_phy_cfg *cfg = qphy->cfg; +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg; -clk_disable_unprepare (qphy->pipe_clk); +clk_disable_unprepare (qmp->pipe_clk);/* PHY reset */ -qphy_setbits (qphy->pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET ); +qphy_setbits (qmp->pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );/* stop SerDes and Phy-Coding-Sublayer */ -qphy_clrbits (qphy->pcs, cfg->regs[QPHY_START_CTRL ], +qphy_clrbits (qmp->pcs, cfg->regs[QPHY_START_CTRL ],SERDES_START |PCS_START );/* Put PHY into POWER DOWN state: active low */ -qphy_clrbits (qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], +qphy_clrbits (qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], cfg->pwrdn_ctrl);return 0 ;
@@ -2055,12 +2022,12 @@ static int qmp_pcie_disable(struct phy *phy)static int qmp_pcie_set_mode (struct phy *phy,enum phy_mode mode,int submode) { -struct qmp_phy *qphy =phy_get_drvdata (phy); +struct qmp_pcie *qmp =phy_get_drvdata (phy);switch (submode) {case PHY_MODE_PCIE_RC :case PHY_MODE_PCIE_EP : - qphy->mode = submode; + qmp->mode = submode;break ;default :dev_err (&phy->dev,"Unsupported submode %d\n" , submode);
@@ -2072,7 +2039,7 @@ static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)static int qmp_pcie_vreg_init (struct device *dev,const struct qmp_phy_cfg *cfg) { -struct qcom_qmp *qmp =dev_get_drvdata (dev); +struct qmp_pcie *qmp =dev_get_drvdata (dev);int num = cfg->num_vregs;int i;
@@ -2088,7 +2055,7 @@ static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)static int qmp_pcie_reset_init (struct device *dev,const struct qmp_phy_cfg *cfg) { -struct qcom_qmp *qmp =dev_get_drvdata (dev); +struct qmp_pcie *qmp =dev_get_drvdata (dev);int i;int ret;
@@ -2109,7 +2076,7 @@ static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfgstatic int qmp_pcie_clk_init (struct device *dev,const struct qmp_phy_cfg *cfg) { -struct qcom_qmp *qmp =dev_get_drvdata (dev); +struct qmp_pcie *qmp =dev_get_drvdata (dev);int num = cfg->num_clks;int i;
@@ -2146,7 +2113,7 @@ static void phy_clk_release_provider(void *res)* clk | +-------+ | +-----+ * +---------------+ */ -static int phy_pipe_clk_register (struct qcom_qmp *qmp,struct device_node *np) +static int phy_pipe_clk_register (struct qmp_pcie *qmp,struct device_node *np) {struct clk_fixed_rate *fixed;struct clk_init_data init = { };
@@ -2168,8 +2135,8 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)* Controllers using QMP PHY-s use 125MHz pipe clock interface * unless other frequency is specified in the PHY config. */ -if (qmp->phys[0 ]->cfg->pipe_clock_rate) - fixed->fixed_rate = qmp->phys[0 ]->cfg->pipe_clock_rate; +if (qmp->cfg->pipe_clock_rate) + fixed->fixed_rate = qmp->cfg->pipe_clock_rate;else fixed->fixed_rate =125000000 ;
@@ -2197,97 +2164,92 @@ static const struct phy_ops qmp_pcie_ops = { .owner = THIS_MODULE, }; -static int qmp_pcie_create (struct device *dev,struct device_node *np,int id, +static int qmp_pcie_create (struct device *dev,struct device_node *np,void __iomem *serdes,const struct qmp_phy_cfg *cfg) { -struct qcom_qmp *qmp =dev_get_drvdata (dev); +struct qmp_pcie *qmp =dev_get_drvdata (dev);struct phy *generic_phy; -struct qmp_phy *qphy;int ret; - qphy =devm_kzalloc (dev,sizeof (*qphy),GFP_KERNEL ); -if (!qphy) -return -ENOMEM ; + qmp->mode =PHY_MODE_PCIE_RC ; - qphy->mode =PHY_MODE_PCIE_RC ; + qmp->cfg = cfg; + qmp->serdes = serdes; - qphy->cfg = cfg; - qphy->serdes = serdes;/* * Get memory resources for the PHY: * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =devm_of_iomap (dev, np,0 ,NULL ); -if (IS_ERR (qphy->tx)) -return PTR_ERR (qphy->tx); + qmp->tx =devm_of_iomap (dev, np,0 ,NULL ); +if (IS_ERR (qmp->tx)) +return PTR_ERR (qmp->tx);if (of_device_is_compatible (dev->of_node,"qcom,sdm845-qhp-pcie-phy" )) - qphy->rx = qphy->tx; + qmp->rx = qmp->tx;else - qphy->rx =devm_of_iomap (dev, np,1 ,NULL ); -if (IS_ERR (qphy->rx)) -return PTR_ERR (qphy->rx); + qmp->rx =devm_of_iomap (dev, np,1 ,NULL ); +if (IS_ERR (qmp->rx)) +return PTR_ERR (qmp->rx); - qphy->pcs =devm_of_iomap (dev, np,2 ,NULL ); -if (IS_ERR (qphy->pcs)) -return PTR_ERR (qphy->pcs); + qmp->pcs =devm_of_iomap (dev, np,2 ,NULL ); +if (IS_ERR (qmp->pcs)) +return PTR_ERR (qmp->pcs);if (cfg->lanes >=2 ) { - qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); -if (IS_ERR (qphy->tx2)) -return PTR_ERR (qphy->tx2); + qmp->tx2 =devm_of_iomap (dev, np,3 ,NULL ); +if (IS_ERR (qmp->tx2)) +return PTR_ERR (qmp->tx2); - qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); -if (IS_ERR (qphy->rx2)) -return PTR_ERR (qphy->rx2); + qmp->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qmp->rx2)) +return PTR_ERR (qmp->rx2); - qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); + qmp->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); }else { - qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); + qmp->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); } -if (IS_ERR (qphy->pcs_misc) && +if (IS_ERR (qmp->pcs_misc) &&of_device_is_compatible (dev->of_node,"qcom,ipq6018-qmp-pcie-phy" )) - qphy->pcs_misc = qphy->pcs +0x400 ; + qmp->pcs_misc = qmp->pcs +0x400 ; -if (IS_ERR (qphy->pcs_misc)) { +if (IS_ERR (qmp->pcs_misc)) {if (cfg->tables.pcs_misc || (cfg->tables_rc && cfg->tables_rc->pcs_misc) || - (cfg->tables_ep && cfg->tables_ep->pcs_misc)) -return PTR_ERR (qphy->pcs_misc); + (cfg->tables_ep && cfg->tables_ep->pcs_misc)) { +return PTR_ERR (qmp->pcs_misc); + } } - qphy->pipe_clk =devm_get_clk_from_child (dev, np,NULL ); -if (IS_ERR (qphy->pipe_clk)) { -return dev_err_probe (dev,PTR_ERR (qphy->pipe_clk), -"failed to get lane%d pipe clock\n" , id); + qmp->pipe_clk =devm_get_clk_from_child (dev, np,NULL ); +if (IS_ERR (qmp->pipe_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), +"failed to get pipe clock\n" ); } generic_phy =devm_phy_create (dev, np, &qmp_pcie_ops);if (IS_ERR (generic_phy)) { ret =PTR_ERR (generic_phy); -dev_err (dev,"failed to create qphy %d\n" , ret); +dev_err (dev,"failed to create PHY: %d\n" , ret);return ret; } - qphy->phy = generic_phy; - qphy->qmp = qmp; - qmp->phys[id] = qphy; -phy_set_drvdata (generic_phy, qphy); + qmp->phy = generic_phy; +phy_set_drvdata (generic_phy, qmp);return 0 ; }static int qmp_pcie_probe (struct platform_device *pdev) { -struct qcom_qmp *qmp;struct device *dev = &pdev->dev;struct device_node *child;struct phy_provider *phy_provider;void __iomem *serdes;const struct qmp_phy_cfg *cfg =NULL ; +struct qmp_pcie *qmp;int num, id;int ret;
@@ -2326,14 +2288,10 @@ static int qmp_pcie_probe(struct platform_device *pdev)if (num >1 )return -EINVAL ; - qmp->phys =devm_kcalloc (dev, num,sizeof (*qmp->phys),GFP_KERNEL ); -if (!qmp->phys) -return -ENOMEM ; - id =0 ;for_each_available_child_of_node (dev->of_node, child) {/* Create per-lane phy */ - ret =qmp_pcie_create (dev, child, id, serdes, cfg); + ret =qmp_pcie_create (dev, child, serdes, cfg);if (ret) {dev_err (dev,"failed to create lane%d phy, %d\n" , id, ret);
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 4/15 phy: qcom-qmp-pcie: clean up device-tree parsing
In reply to Johan HovoldSince the QMP driver split there will be at most a single child node so drop the obsolete iteration construct.
While at it, drop the verbose error logging that would have been printed also on probe deferrals.
Note that there's no need to check if there are additional child nodes (the kernel is not a devicetree validator), but let's return an error if there are no child nodes at all for now.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 34 +++++++----------------- 1 file changed, 9 insertions(+), 25 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +9 -25
@@ -2250,7 +2250,6 @@ static int qmp_pcie_probe(struct platform_device *pdev)void __iomem *serdes;const struct qmp_phy_cfg *cfg =NULL ;struct qmp_pcie *qmp; -int num, id;int ret; qmp =devm_kzalloc (dev,sizeof (*qmp),GFP_KERNEL );
@@ -2283,34 +2282,19 @@ static int qmp_pcie_probe(struct platform_device *pdev)if (ret)return ret; - num =of_get_available_child_count (dev->of_node); -/* do we have a rogue child node ? */ -if (num >1 ) + child =of_get_next_available_child (dev->of_node,NULL ); +if (!child)return -EINVAL ; - id =0 ; -for_each_available_child_of_node (dev->of_node, child) { -/* Create per-lane phy */ - ret =qmp_pcie_create (dev, child, serdes, cfg); -if (ret) { -dev_err (dev,"failed to create lane%d phy, %d\n" , - id, ret); - goto err_node_put; - } + ret =qmp_pcie_create (dev, child, serdes, cfg); +if (ret) + goto err_node_put; -/* -* Register the pipe clock provided by phy. -* See function description to see details of this pipe clock. -*/ - ret =phy_pipe_clk_register (qmp, child); -if (ret) { -dev_err (qmp->dev, -"failed to register pipe clock source\n" ); - goto err_node_put; - } + ret =phy_pipe_clk_register (qmp, child); +if (ret) + goto err_node_put; - id++; - } +of_node_put (child); phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate);
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 5/15 phy: qcom-qmp-pcie: clean up probe initialisation
In reply to Johan HovoldStop abusing the driver data pointer and instead pass the driver state structure directly to the initialisation helpers during probe.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 49 +++++++++++------------- 1 file changed, 23 insertions(+), 26 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +23 -26
@@ -2037,9 +2037,10 @@ static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)return 0 ; } -static int qmp_pcie_vreg_init (struct device *dev,const struct qmp_phy_cfg *cfg) +static int qmp_pcie_vreg_init (struct qmp_pcie *qmp) { -struct qmp_pcie *qmp =dev_get_drvdata (dev); +const struct qmp_phy_cfg *cfg = qmp->cfg; +struct device *dev = qmp->dev;int num = cfg->num_vregs;int i;
@@ -2053,9 +2054,10 @@ static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)return devm_regulator_bulk_get (dev, num, qmp->vregs); } -static int qmp_pcie_reset_init (struct device *dev,const struct qmp_phy_cfg *cfg) +static int qmp_pcie_reset_init (struct qmp_pcie *qmp) { -struct qmp_pcie *qmp =dev_get_drvdata (dev); +const struct qmp_phy_cfg *cfg = qmp->cfg; +struct device *dev = qmp->dev;int i;int ret;
@@ -2074,9 +2076,10 @@ static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfgreturn 0 ; } -static int qmp_pcie_clk_init (struct device *dev,const struct qmp_phy_cfg *cfg) +static int qmp_pcie_clk_init (struct qmp_pcie *qmp) { -struct qmp_pcie *qmp =dev_get_drvdata (dev); +const struct qmp_phy_cfg *cfg = qmp->cfg; +struct device *dev = qmp->dev;int num = cfg->num_clks;int i;
@@ -2164,18 +2167,15 @@ static const struct phy_ops qmp_pcie_ops = { .owner = THIS_MODULE, }; -static int qmp_pcie_create (struct device *dev,struct device_node *np, -void __iomem *serdes,const struct qmp_phy_cfg *cfg) +static int qmp_pcie_create (struct qmp_pcie *qmp,struct device_node *np) { -struct qmp_pcie *qmp =dev_get_drvdata (dev); +const struct qmp_phy_cfg *cfg = qmp->cfg; +struct device *dev = qmp->dev;struct phy *generic_phy;int ret; qmp->mode =PHY_MODE_PCIE_RC ; - qmp->cfg = cfg; - qmp->serdes = serdes; -/* * Get memory resources for the PHY: * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
@@ -2247,8 +2247,6 @@ static int qmp_pcie_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *child;struct phy_provider *phy_provider; -void __iomem *serdes; -const struct qmp_phy_cfg *cfg =NULL ;struct qmp_pcie *qmp;int ret;
@@ -2257,28 +2255,27 @@ static int qmp_pcie_probe(struct platform_device *pdev)return -ENOMEM ; qmp->dev = dev; -dev_set_drvdata (dev, qmp); - cfg =of_device_get_match_data (dev); -if (!cfg) + qmp->cfg =of_device_get_match_data (dev); +if (!qmp->cfg)return -EINVAL ; -WARN_ON_ONCE (!cfg->pwrdn_ctrl); -WARN_ON_ONCE (!cfg->phy_status); +WARN_ON_ONCE (!qmp->cfg->pwrdn_ctrl); +WARN_ON_ONCE (!qmp->cfg->phy_status); - serdes =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (serdes)) -return PTR_ERR (serdes); + qmp->serdes =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (qmp->serdes)) +return PTR_ERR (qmp->serdes); - ret =qmp_pcie_clk_init (dev, cfg); + ret =qmp_pcie_clk_init (qmp);if (ret)return ret; - ret =qmp_pcie_reset_init (dev, cfg); + ret =qmp_pcie_reset_init (qmp);if (ret)return ret; - ret =qmp_pcie_vreg_init (dev, cfg); + ret =qmp_pcie_vreg_init (qmp);if (ret)return ret;
@@ -2286,7 +2283,7 @@ static int qmp_pcie_probe(struct platform_device *pdev)if (!child)return -EINVAL ; - ret =qmp_pcie_create (dev, child, serdes, cfg); + ret =qmp_pcie_create (qmp, child);if (ret) goto err_node_put;
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 6/15 phy: qcom-qmp-pcie: rename PHY ops structure
In reply to Johan HovoldRename the PHY operation structure so that it has a "phy_ops" suffix and move it next to the implementation.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +8 -8
@@ -2037,6 +2037,13 @@ static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)return 0 ; } +static const struct phy_ops qmp_pcie_phy_ops = { + .power_on = qmp_pcie_enable, + .power_off = qmp_pcie_disable, + .set_mode = qmp_pcie_set_mode, + .owner =THIS_MODULE , +}; +static int qmp_pcie_vreg_init (struct qmp_pcie *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -2160,13 +2167,6 @@ static int phy_pipe_clk_register(struct qmp_pcie *qmp, struct device_node *np)return devm_add_action_or_reset (qmp->dev, phy_clk_release_provider, 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 , -}; -static int qmp_pcie_create (struct qmp_pcie *qmp,struct device_node *np) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -2229,7 +2229,7 @@ static int qmp_pcie_create(struct qmp_pcie *qmp, struct device_node *np) "failed to get pipe clock\n"); } - generic_phy =devm_phy_create (dev, np, &qmp_pcie_ops); + generic_phy =devm_phy_create (dev, np, &qmp_pcie_phy_ops);if (IS_ERR (generic_phy)) { ret =PTR_ERR (generic_phy);dev_err (dev,"failed to create PHY: %d\n" , ret);
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 7/15 phy: qcom-qmp-pcie: clean up PHY lane init
In reply to Johan HovoldClean up the PHY lane initialisation somewhat by adding further temporary variables and programming both tx and rx for the second lane after the first lane.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +7 -6
@@ -1835,18 +1835,19 @@ static void qmp_pcie_lanes_init(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tconst struct qmp_phy_cfg *cfg = qmp->cfg;void __iomem *tx = qmp->tx;void __iomem *rx = qmp->rx; +void __iomem *tx2 = qmp->tx2; +void __iomem *rx2 = qmp->rx2;if (!tables)return ;qmp_pcie_configure_lane (tx, tables->tx, tables->tx_num,1 ); - -if (cfg->lanes >=2 ) -qmp_pcie_configure_lane (qmp->tx2, tables->tx, tables->tx_num,2 ); -qmp_pcie_configure_lane (rx, tables->rx, tables->rx_num,1 ); -if (cfg->lanes >=2 ) -qmp_pcie_configure_lane (qmp->rx2, tables->rx, tables->rx_num,2 ); + +if (cfg->lanes >=2 ) { +qmp_pcie_configure_lane (tx2, tables->tx, tables->tx_num,2 ); +qmp_pcie_configure_lane (rx2, tables->rx, tables->rx_num,2 ); + } }static void qmp_pcie_pcs_init (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tables)
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 8/15 phy: qcom-qmp-pcie: add register init helper
In reply to Johan HovoldGeneralise the serdes initialisation helper so that it can be used to initialise all the PHY registers (e.g. serdes, tx, rx, pcs).
Note that this defers the ungating of the PIPE clock somewhat, which is fine as it isn't needed until starting the PHY.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 51 +++++++----------------- 1 file changed, 15 insertions(+), 36 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +15 -36
@@ -1820,46 +1820,32 @@ static void qmp_pcie_configure(void __iomem *base,qmp_pcie_configure_lane (base, tbl, num,0xff ); } -static void qmp_pcie_serdes_init (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tables) -{ -void __iomem *serdes = qmp->serdes; - -if (!tables) -return ; - -qmp_pcie_configure (serdes, tables->serdes, tables->serdes_num); -} - -static void qmp_pcie_lanes_init (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tables) +static void qmp_pcie_init_registers (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tbls) {const struct qmp_phy_cfg *cfg = qmp->cfg; +void __iomem *serdes = qmp->serdes;void __iomem *tx = qmp->tx;void __iomem *rx = qmp->rx;void __iomem *tx2 = qmp->tx2;void __iomem *rx2 = qmp->rx2; +void __iomem *pcs = qmp->pcs; +void __iomem *pcs_misc = qmp->pcs_misc; -if (!tables) +if (!tbls)return ; -qmp_pcie_configure_lane (tx, tables->tx, tables->tx_num,1 ); -qmp_pcie_configure_lane (rx, tables->rx, tables->rx_num,1 ); +qmp_pcie_configure (serdes, tbls->serdes, tbls->serdes_num); + +qmp_pcie_configure_lane (tx, tbls->tx, tbls->tx_num,1 ); +qmp_pcie_configure_lane (rx, tbls->rx, tbls->rx_num,1 );if (cfg->lanes >=2 ) { -qmp_pcie_configure_lane (tx2, tables->tx, tables->tx_num,2 ); -qmp_pcie_configure_lane (rx2, tables->rx, tables->rx_num,2 ); +qmp_pcie_configure_lane (tx2, tbls->tx, tbls->tx_num,2 ); +qmp_pcie_configure_lane (rx2, tbls->rx, tbls->rx_num,2 ); } -} - -static void qmp_pcie_pcs_init (struct qmp_pcie *qmp,const struct qmp_phy_cfg_tables *tables) -{ -void __iomem *pcs = qmp->pcs; -void __iomem *pcs_misc = qmp->pcs_misc; - -if (!tables) -return ; -qmp_pcie_configure (pcs, tables->pcs, tables->pcs_num); -qmp_pcie_configure (pcs_misc, tables->pcs_misc, tables->pcs_misc_num); +qmp_pcie_configure (pcs, tbls->pcs, tbls->pcs_num); +qmp_pcie_configure (pcs_misc, tbls->pcs_misc, tbls->pcs_misc_num); }static int qmp_pcie_init (struct phy *phy)
@@ -1932,8 +1918,8 @@ static int qmp_pcie_power_on(struct phy *phy)else mode_tables = cfg->tables_ep; -qmp_pcie_serdes_init (qmp, &cfg->tables); -qmp_pcie_serdes_init (qmp, mode_tables); +qmp_pcie_init_registers (qmp, &cfg->tables); +qmp_pcie_init_registers (qmp, mode_tables); ret =clk_prepare_enable (qmp->pipe_clk);if (ret) {
@@ -1941,13 +1927,6 @@ static int qmp_pcie_power_on(struct phy *phy)return ret; } -/* Tx, Rx, and PCS configurations */ -qmp_pcie_lanes_init (qmp, &cfg->tables); -qmp_pcie_lanes_init (qmp, mode_tables); - -qmp_pcie_pcs_init (qmp, &cfg->tables); -qmp_pcie_pcs_init (qmp, mode_tables); -/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 9/15 dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
In reply to Johan HovoldThe current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
---
.../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
rename Documentation/devicetree/bindings/phy/{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} (98%)Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy-legacy.yaml renamed from Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml +2 -2
@@ -1,10 +1,10 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/phy/qcom,qmp-pcie-phy.yaml# +$id: http://devicetree.org/schemas/phy/qcom,qmp-pcie-phy-legacy.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Qualcomm QMP PHY controller (PCIe) +title: Qualcomm QMP PHY controller (PCIe legacy bindings) maintainers: - Vinod Koul <[email protected]>
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 18 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
Quoted 6 lines
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++--
I don't think we should rename anything as legacy. These are "normal" platforms, not legacy ones. SM8450 is not even that old.
The recommendation is to keep names matching the compatibles, not adding some legacy/newer/newest suffixes.
Best regards,
Krzysztof
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 22 lines · Krzysztof Kozlowski
Quoted 21 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Quoted 6 lines
Quoted 3 lines
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++--I don't think we should rename anything as legacy. These are "normal" platforms, not legacy ones. SM8450 is not even that old.
I'm not really referring to the platforms as legacy, but the rather the format of the bindings. The intent is that by marking the current ones as such, people will not base new bindings on the old scheme.
There's no problem supporting both schemes in the driver also for the current compatibles, but expressing such a deprecation in DT schema sounds like it would be painful. We instead decided to simple draw the line at SC8280XP and have future bindings be based on its binding.
Quoted 2 lines
The recommendation is to keep names matching the compatibles, not adding some legacy/newer/newest suffixes.
Yeah, I know, but that's not what the current bindings do. And if we keep
qcom,qmp-pcie-phy.yaml
and add
qcom,sc8280xp-qmp-pcie-phy.yaml
then I fear that people will base their bindings on the former rather than the latter.
I guess I can just add a comment in the old schema file with a reference to the sc8280xp bindings to try to prevent people from adding new ones in the wrong place.
If I understand you correctly this is what you are suggesting? And that the new file should still be named "qcom,sc8280xp-qmp-pcie-phy.yaml" also as new bindings are added to that file?
I could also rename the old schema file after one of the old platforms platforms therein (e.g. qcom,msm8998-qmp-pcie-phy) to make it sounds less like a generic schema for new bindings.
That is
qcom,msm8998-qmp-pcie-phy.yaml + comment (for current bindings) qcom,sc8280xp-qmp-pcie-phy.yaml (for new bindings)
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 45 lines · Johan Hovold
Quoted 22 lines · Krzysztof Kozlowski
Quoted 21 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Quoted 6 lines
Quoted 3 lines
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++--I don't think we should rename anything as legacy. These are "normal" platforms, not legacy ones. SM8450 is not even that old.
I'm not really referring to the platforms as legacy, but the rather the format of the bindings. The intent is that by marking the current ones as such, people will not base new bindings on the old scheme.
There's no problem supporting both schemes in the driver also for the current compatibles, but expressing such a deprecation in DT schema sounds like it would be painful. We instead decided to simple draw the line at SC8280XP and have future bindings be based on its binding.
Quoted 2 lines
The recommendation is to keep names matching the compatibles, not adding some legacy/newer/newest suffixes.
Yeah, I know, but that's not what the current bindings do. And if we keep
Quoted 8 lines
qcom,qmp-pcie-phy.yaml
and add
qcom,sc8280xp-qmp-pcie-phy.yamlthen I fear that people will base their bindings on the former rather than the latter.
Then how about renaming this file to something matching the oldest supported SoC? Like: qcom,msm8998-qmp-pcie-phy.yaml
(I don't know which one is the oldest there)
Or ipq6018 as the first one appearing in the list.
Quoted 4 lines
I guess I can just add a comment in the old schema file with a reference to the sc8280xp bindings to try to prevent people from adding new ones in the wrong place.
Yes, that's also works for me. You can change the description part to have something like:
"QMP PHY controller on SoCs like sc8180x and older. For newer SoCs, please look at xxxxx.yaml"
Quoted 3 lines
If I understand you correctly this is what you are suggesting? And that the new file should still be named "qcom,sc8280xp-qmp-pcie-phy.yaml" also as new bindings are added to that file?
Yes.
Quoted 4 lines
I could also rename the old schema file after one of the old platforms platforms therein (e.g. qcom,msm8998-qmp-pcie-phy) to make it sounds less like a generic schema for new bindings.
Oh, we thought about the same.
Quoted 5 lines
That is
qcom,msm8998-qmp-pcie-phy.yaml + comment (for current bindings) qcom,sc8280xp-qmp-pcie-phy.yaml (for new bindings)
Yes, please.
Best regards,
Krzysztof
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 38 lines · Krzysztof Kozlowski
Quoted 37 lines · Johan Hovold
Quoted 8 lines · Krzysztof Kozlowski
Quoted 7 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Quoted 6 lines
Quoted 3 lines
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++--I don't think we should rename anything as legacy. These are "normal" platforms, not legacy ones. SM8450 is not even that old.
I'm not really referring to the platforms as legacy, but the rather the format of the bindings. The intent is that by marking the current ones as such, people will not base new bindings on the old scheme.
There's no problem supporting both schemes in the driver also for the current compatibles, but expressing such a deprecation in DT schema sounds like it would be painful. We instead decided to simple draw the line at SC8280XP and have future bindings be based on its binding.
Quoted 2 lines
The recommendation is to keep names matching the compatibles, not adding some legacy/newer/newest suffixes.
Yeah, I know, but that's not what the current bindings do. And if we keep
qcom,qmp-pcie-phy.yaml
and add
qcom,sc8280xp-qmp-pcie-phy.yaml
Quoted 8 lines
Quoted 2 lines
then I fear that people will base their bindings on the former rather than the latter.
Then how about renaming this file to something matching the oldest supported SoC? Like: qcom,msm8998-qmp-pcie-phy.yaml
(I don't know which one is the oldest there)Or ipq6018 as the first one appearing in the list.
Sounds good. :)
Quoted 7 lines
Quoted 3 lines
I could also rename the old schema file after one of the old platforms platforms therein (e.g. qcom,msm8998-qmp-pcie-phy) to make it sounds less like a generic schema for new bindings.
Oh, we thought about the same.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
That is
qcom,msm8998-qmp-pcie-phy.yaml + comment (for current bindings) qcom,sc8280xp-qmp-pcie-phy.yaml (for new bindings)Yes, please.
I'll go with that then. Thanks!
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
In reply to Johan HovoldHi,
Quoted 12 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
Quoted 6 lines
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
I'd like to point out that it's not only a problem peculiar to the PCIe PHYs. Other QMP PHY families also follow the same approach of separating the serdes into the common part and rx/tx/PCS/whatever into the PHY subnodes.
For the USB+DP combo PHYs we have to have subnodes, however it would also be logical to move serdes register to the subnode devices, leaving only DP_COM in the base node.
That said, I think we should rethink and agree on QMP PHY bindings, before renaming the bindings. And yes, I think we should also upgrade older DTs, keeping drivers backwards compatible (for some time?).
Quoted 8 lines
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Documentation/devicetree/bindings/phy/{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} (98%)
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 22 lines · Dmitry Baryshkov
Hi,
Quoted 12 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
Quoted 6 lines
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
Quoted 4 lines
I'd like to point out that it's not only a problem peculiar to the PCIe PHYs. Other QMP PHY families also follow the same approach of separating the serdes into the common part and rx/tx/PCS/whatever into the PHY subnodes.
Yeah, I already mentioned that in the cover letter.
Quoted 3 lines
For the USB+DP combo PHYs we have to have subnodes, however it would also be logical to move serdes register to the subnode devices, leaving only
DP_COMin the base node.
No, not at all. First, we may not even need the subnodes (the individual PHYs can be indexed), but even if we do keep them for the combo case, the register block should go in the wrapper node as the registers can be and are shared (e.g. for sc8280xp for which the current binding is completely broken).
Quoted 2 lines
That said, I think we should rethink and agree on QMP PHY bindings, before renaming the bindings.
Isn't that what we are doing just now?
Quoted 2 lines
And yes, I think we should also upgrade
older DTs, keeping drivers backwards compatible (for some time?).
Possibly, but I'm not sure it's worth the dts churn. As I mentioned elsewhere, supporting both the old and new binding in the driver is mostly trivial, while encoding the deprecated bindings in DT schema sounds like it would be painful.
On the other hand, adding support for new features to (or fixing bugs in) old platforms using the current bindings may potentially become easier if they are also converted.
Quoted 8 lines
Quoted 8 lines
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Documentation/devicetree/bindings/phy/{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} (98%)
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 35 lines · Johan Hovold
Quoted 22 lines · Dmitry Baryshkov
Hi,
Quoted 12 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
Quoted 6 lines
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
Quoted 4 lines
I'd like to point out that it's not only a problem peculiar to the PCIe PHYs. Other QMP PHY families also follow the same approach of separating the serdes into the common part and rx/tx/PCS/whatever into the PHY subnodes.
Yeah, I already mentioned that in the cover letter.
Quoted 3 lines
For the USB+DP combo PHYs we have to have subnodes, however it would also be logical to move serdes register to the subnode devices, leaving only
DP_COMin the base node.
Quoted 5 lines
No, not at all. First, we may not even need the subnodes (the individual PHYs can be indexed), but even if we do keep them for the combo case, the register block should go in the wrapper node as the registers can be and are shared (e.g. for sc8280xp for which the current binding is completely broken).
Hmm, which register blocks are shared on the sc8280xp combo PHY? Could you please lightly describe it, if possible?
Quoted 4 lines
Quoted 2 lines
That said, I think we should rethink and agree on QMP PHY bindings, before renaming the bindings.
Isn't that what we are doing just now?
Yeah, thanks for starting the discussion!
Quoted 7 lines
Quoted 2 lines
And yes, I think we should also upgrade
older DTs, keeping drivers backwards compatible (for some time?).Possibly, but I'm not sure it's worth the dts churn. As I mentioned elsewhere, supporting both the old and new binding in the driver is mostly trivial, while encoding the deprecated bindings in DT schema sounds like it would be painful.
This is probably the time where Krzysztof can advise us. I'm still not sure when it is expected to encode both old and new bindings in the schema and when we can update both the schema and the DT.
Quoted 3 lines
On the other hand, adding support for new features to (or fixing bugs in) old platforms using the current bindings may potentially become easier if they are also converted.
Yes!
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
In preparation for adding new bindings for SC8280XP which further bindings can be based on, mark the current bindings as "legacy".
Signed-off-by Johan Hovold <[email protected]>--- .../{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Documentation/devicetree/bindings/phy/{qcom,qmp-pcie-phy.yaml => qcom,qmp-pcie-phy-legacy.yaml} (98%)Johan
Signature · 7 lines
With best wishes Dmitry -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 36 lines · Dmitry Baryshkov
Quoted 35 lines · Johan Hovold
Quoted 22 lines · Dmitry Baryshkov
Hi,
Quoted 12 lines · Johan Hovold
The current QMP PCIe PHY bindings are based on the original MSM8996 binding which provided multiple PHYs per IP block and these in turn were described by child nodes.
Later QMP PCIe PHY blocks only provide a single PHY and the remnant child node does not really reflect the hardware.
The original MSM8996 binding also ended up describing the individual register blocks as belonging to either the wrapper node or the PHY child nodes.
Quoted 6 lines
This is an unnecessary level of detail which has lead to problems when later IP blocks using different register layouts have been forced to fit the original mould rather than updating the binding. The bindings are arguable also incomplete as they only the describe register blocks used by the current Linux drivers (e.g. does not include the per lane PCS registers).
Quoted 4 lines
I'd like to point out that it's not only a problem peculiar to the PCIe PHYs. Other QMP PHY families also follow the same approach of separating the serdes into the common part and rx/tx/PCS/whatever into the PHY subnodes.
Yeah, I already mentioned that in the cover letter.
Quoted 3 lines
For the USB+DP combo PHYs we have to have subnodes, however it would also be logical to move serdes register to the subnode devices, leaving only
DP_COMin the base node.
Quoted 8 lines
Quoted 5 lines
No, not at all. First, we may not even need the subnodes (the individual PHYs can be indexed), but even if we do keep them for the combo case, the register block should go in the wrapper node as the registers can be and are shared (e.g. for sc8280xp for which the current binding is completely broken).
Hmm, which register blocks are shared on the sc8280xp combo PHY? Could you please lightly describe it, if possible?
At least serdes and tx. Note that the combo PHY on sc8280xp also supports USB4, so there is likely some differences compared to the older platforms.
And while I haven't looked in detail at the older platforms for the combo PHYs yet, describing the separate register subregions there appears to be just as misguided for those (e.g. as the binding currently only describes what Linux is using) and is mostly an artefact of how the original Linux driver was implemented.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
In reply to Dmitry BaryshkovQuoted 4 lines · Dmitry Baryshkov
Quoted 4 lines
Quoted 3 lines
And yes, I think we should also upgrade
older DTs, keeping drivers backwards compatible (for some time?).
Quoted 8 lines
Quoted 4 lines
Possibly, but I'm not sure it's worth the dts churn. As I mentioned elsewhere, supporting both the old and new binding in the driver is mostly trivial, while encoding the deprecated bindings in DT schema sounds like it would be painful.
This is probably the time where Krzysztof can advise us. I'm still not sure when it is expected to encode both old and new bindings in the schema and when we can update both the schema and the DT.
I do not follow what exactly the proposal is. Are you asking whether to:
1. keep existing DTS compatible with old driver?
or
2. update existing DTS so it is working only with new driver (and not compatible with old driver thus having ABI break)?
If so, it is less question to bindings but more to the usage of DTS in other projects (like bootloaders, firmware, BSD) and generic recommendation is: do not break other users, if possible. It is however up to the platform maintainer (Bjorn) to decide on this, not on me.
Best regards,
Krzysztof
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 20 lines · Krzysztof Kozlowski
Quoted 4 lines · Dmitry Baryshkov
Quoted 4 lines
Quoted 3 lines
And yes, I think we should also upgrade
older DTs, keeping drivers backwards compatible (for some time?).Quoted 8 lines
Quoted 4 lines
Possibly, but I'm not sure it's worth the dts churn. As I mentioned elsewhere, supporting both the old and new binding in the driver is mostly trivial, while encoding the deprecated bindings in DT schema sounds like it would be painful.
This is probably the time where Krzysztof can advise us. I'm still not sure when it is expected to encode both old and new bindings in the schema and when we can update both the schema and the DT.
I do not follow what exactly the proposal is. Are you asking whether to:
1. keep existing DTS compatible with old driver?
or
2. update existing DTS so it is working only with new driver (and not compatible with old driver thus having ABI break)?
Quoted 4 lines
If so, it is less question to bindings but more to the usage of DTS in other projects (like bootloaders, firmware, BSD) and generic recommendation is: do not break other users, if possible. It is however up to the platform maintainer (Bjorn) to decide on this, not on me.
The question is whether to convert also the current bindings and DTS to the new (sc8280xp) scheme (e.g. drop the child nodes and register subregions).
The driver can support both binding schemes using the same compatible strings for a transition period (or in theory forever) by checking for the existence of a child node.
Converting the DTS to use the new bindings would obviously prevent using them with an old kernel (i.e. 2 above), but I don't think that's a problem (unlike backward compatibility during at least a transition period).
My concern was how to describe the deprecation in DT schema if we were convert them. By instead just keeping the old bindings as-is in a separate file and continuing to support them in the driver we can have a nice and clean description of the new bindings (sc8280xp) without the legacy cruft.
If we were to start introducing conditionals on existence of child nodes, and marking the old bindings as deprecated in one large schema, then that sounds like it would be very messy and hard to read and maintain. But perhaps there is some way to do this without such downsides that I'm not aware of.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 30 lines · Johan Hovold
Quoted 20 lines · Krzysztof Kozlowski
Quoted 4 lines · Dmitry Baryshkov
Quoted 4 lines
Quoted 3 lines
And yes, I think we should also upgrade
older DTs, keeping drivers backwards compatible (for some time?).Quoted 8 lines
Quoted 4 lines
Possibly, but I'm not sure it's worth the dts churn. As I mentioned elsewhere, supporting both the old and new binding in the driver is mostly trivial, while encoding the deprecated bindings in DT schema sounds like it would be painful.
This is probably the time where Krzysztof can advise us. I'm still not sure when it is expected to encode both old and new bindings in the schema and when we can update both the schema and the DT.
I do not follow what exactly the proposal is. Are you asking whether to:
1. keep existing DTS compatible with old driver?
or
2. update existing DTS so it is working only with new driver (and not compatible with old driver thus having ABI break)?Quoted 4 lines
If so, it is less question to bindings but more to the usage of DTS in other projects (like bootloaders, firmware, BSD) and generic recommendation is: do not break other users, if possible. It is however up to the platform maintainer (Bjorn) to decide on this, not on me.
The question is whether to convert also the current bindings and DTS to the new (sc8280xp) scheme (e.g. drop the child nodes and register subregions).
Quoted 8 lines
The driver can support both binding schemes using the same compatible strings for a transition period (or in theory forever) by checking for the existence of a child node.
Converting the DTS to use the new bindings would obviously prevent using them with an old kernel (i.e. 2 above), but I don't think that's a problem (unlike backward compatibility during at least a transition period).
It is still not nice towards any other users of DTS, because this will break all of them. I agree this won't be ABI type of break. It is discouraged though, unless there are clear benefits from this or one totally does not care about other DTS users...
As I said it is up to platform maintainer.
Quoted 6 lines
My concern was how to describe the deprecation in DT schema if we were convert them. By instead just keeping the old bindings as-is in a separate file and continuing to support them in the driver we can have a nice and clean description of the new bindings (sc8280xp) without the legacy cruft.
You cannot have one compatible in two schemas, so for old bindings (and DTS):
1. Don't convert them,
2. Convert with keeping old properties - as you pointed this might be full of conditionals/allOf, so difficult to maintain and read,
3. Convert dropping old stuff.
For the option 3. for sure Rob will ask why. :)
Quoted 6 lines
If we were to start introducing conditionals on existence of child nodes, and marking the old bindings as deprecated in one large schema, then that sounds like it would be very messy and hard to read and maintain. But perhaps there is some way to do this without such downsides that I'm not aware of.
Best regards,
Krzysztof
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 09/15] dt-bindings: phy: qcom,qmp-pcie: mark current bindings as legacy
Quoted 15 lines · Krzysztof Kozlowski
Quoted 4 lines · Johan Hovold
The question is whether to convert also the current bindings and DTS to the new (sc8280xp) scheme (e.g. drop the child nodes and register subregions).
Quoted 8 lines
The driver can support both binding schemes using the same compatible strings for a transition period (or in theory forever) by checking for the existence of a child node.
Converting the DTS to use the new bindings would obviously prevent using them with an old kernel (i.e. 2 above), but I don't think that's a problem (unlike backward compatibility during at least a transition period).
Quoted 6 lines
It is still not nice towards any other users of DTS, because this will break all of them. I agree this won't be ABI type of break. It is discouraged though, unless there are clear benefits from this or one totally does not care about other DTS users...
As I said it is up to platform maintainer.
Yeah. When time I spoke to Bjorn about this, we agreed to draw the line at SC8280XP.
But if it turns out converting older platforms is needed to fix bugs or add features (e.g. due to the incomplete register descriptions), we may later have to reconsider this.
Quoted 6 lines
Quoted 5 lines
My concern was how to describe the deprecation in DT schema if we were convert them. By instead just keeping the old bindings as-is in a separate file and continuing to support them in the driver we can have a nice and clean description of the new bindings (sc8280xp) without the legacy cruft.
Quoted 8 lines
You cannot have one compatible in two schemas, so for old bindings (and DTS):
1. Don't convert them,
2. Convert with keeping old properties - as you pointed this might be full of conditionals/allOf, so difficult to maintain and read,
3. Convert dropping old stuff.For the option 3. for sure Rob will ask why. :)
Thanks for confirming.
So I guess we start with keeping the old bindings as they are (1) and if later needed (or desired) we should simply drop the old bindings (3) from the schema (we can still have the driver support the old bindings during a transition period).
Quoted 5 lines
Quoted 5 lines
If we were to start introducing conditionals on existence of child nodes, and marking the old bindings as deprecated in one large schema, then that sounds like it would be very messy and hard to read and maintain. But perhaps there is some way to do this without such downsides that I'm not aware of.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 10/15 dt-bindings: phy: qcom,qmp-pcie: add sc8280xp bindings
In reply to Johan HovoldAdd bindings for the PCIe QMP PHYs found on SC8280XP.
The PCIe2 and PCIe3 controllers and PHYs on SC8280XP can be used in 4-lane mode or as separate controllers and PHYs in 2-lane mode (e.g. as PCIe2A and PCIe2B).
The configuration for a specific system can be read from a TCSR register.
--- .../bindings/phy/qcom,qmp-pcie-phy.yaml | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +163 -0
@@ -0,0 +1,163 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,qmp-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm QMP PHY controller (PCIe) + +maintainers: + - Vinod Koul <[email protected]> + +description: + QMP PHY controller supports physical layer functionality for a number of + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. + +properties: + compatible: + enum: + - qcom,sc8280xp-qmp-gen3x1-pcie-phy + - qcom,sc8280xp-qmp-gen3x2-pcie-phy + - qcom,sc8280xp-qmp-gen3x4-pcie-phy + + reg: + minItems: 1 + maxItems: 2 + + clocks: + maxItems: 6 + + clock-names: + items: + - const: aux + - const: cfg_ahb + - const: ref + - const: rchng + - const: pipe + - const: pipediv2 + + power-domains: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + items: + - const: phy + + vdda-phy-supply: true + + vdda-pll-supply: true + + qcom,4ln-config-sel: + description: 4-lane configuration as TCSR syscon phandle, register offset + and bit number + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + maxItems: 3 + + "#clock-cells": + const: 0 + + clock-output-names: + maxItems: 1 + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - power-domains + - resets + - reset-names + - vdda-phy-supply + - vdda-pll-supply + - "#clock-cells" + - clock-output-names + - "#phy-cells" + +additionalProperties: false + +allOf: + - if: + properties: + compatible: + contains: + enum: + - qcom,sc8280xp-qmp-gen3x4-pcie-phy + then: + properties: + reg: + items: + - description: port a + - description: port b + required: + - qcom,4ln-config-sel + else: + properties: + reg: + maxItems: 1 + +examples: + - | + #include <dt-bindings/clock/qcom,gcc-sc8280xp.h> + + pcie2b_phy: phy@1c18000 { + compatible = "qcom,sc8280xp-qmp-gen3x2-pcie-phy"; + reg = <0x01c18000 0x2000>; + + clocks = <&gcc GCC_PCIE_2B_AUX_CLK>, + <&gcc GCC_PCIE_2B_CFG_AHB_CLK>, + <&gcc GCC_PCIE_2A2B_CLKREF_CLK>, + <&gcc GCC_PCIE2B_PHY_RCHNG_CLK>, + <&gcc GCC_PCIE_2B_PIPE_CLK>, + <&gcc GCC_PCIE_2B_PIPEDIV2_CLK>; + clock-names = "aux", "cfg_ahb", "ref", "rchng", + "pipe", "pipediv2"; + + power-domains = <&gcc PCIE_2B_GDSC>; + + resets = <&gcc GCC_PCIE_2B_PHY_BCR>; + reset-names = "phy"; + + vdda-phy-supply = <&vreg_l6d>; + vdda-pll-supply = <&vreg_l4d>; + + #clock-cells = <0>; + clock-output-names = "pcie_2b_pipe_clk"; + + #phy-cells = <0>; + }; + + pcie2a_phy: phy@1c24000 { + compatible = "qcom,sc8280xp-qmp-gen3x4-pcie-phy"; + reg = <0x01c24000 0x2000>, <0x01c26000 0x2000>; + + clocks = <&gcc GCC_PCIE_2A_AUX_CLK>, + <&gcc GCC_PCIE_2A_CFG_AHB_CLK>, + <&gcc GCC_PCIE_2A2B_CLKREF_CLK>, + <&gcc GCC_PCIE2A_PHY_RCHNG_CLK>, + <&gcc GCC_PCIE_2A_PIPE_CLK>, + <&gcc GCC_PCIE_2A_PIPEDIV2_CLK>; + clock-names = "aux", "cfg_ahb", "ref", "rchng", + "pipe", "pipediv2"; + + power-domains = <&gcc PCIE_2A_GDSC>; + + resets = <&gcc GCC_PCIE_2A_PHY_BCR>; + reset-names = "phy"; + + vdda-phy-supply = <&vreg_l6d>; + vdda-pll-supply = <&vreg_l4d>; + + qcom,4ln-config-sel = <&tcsr 0xa044 0>; + + #clock-cells = <0>; + clock-output-names = "pcie_2a_pipe_clk"; + + #phy-cells = <0>; + };
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 10/15] dt-bindings: phy: qcom,qmp-pcie: add sc8280xp bindings
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml
Quoted 19 lines · Johan Hovold
Add bindings for the PCIe QMP PHYs found on SC8280XP.
The PCIe2 and PCIe3 controllers and PHYs on SC8280XP can be used in 4-lane mode or as separate controllers and PHYs in 2-lane mode (e.g. as PCIe2A and PCIe2B).
The configuration for a specific system can be read from a TCSR register.
Signed-off-by Johan Hovold <[email protected]>--- .../bindings/phy/qcom,qmp-pcie-phy.yaml | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yamlDocumentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +0
-0
Filename based on compatible, so for example:
qcom,sc8280xp-qmp-pcie-phy.yaml
Quoted 49 lines
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +48
-0@@ -0,0 +1,163 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,qmp-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm QMP PHY controller (PCIe) + +maintainers: + - Vinod Koul <[email protected]> + +description: + QMP PHY controller supports physical layer functionality for a number of + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. + +properties: + compatible: + enum: + - qcom,sc8280xp-qmp-gen3x1-pcie-phy + - qcom,sc8280xp-qmp-gen3x2-pcie-phy + - qcom,sc8280xp-qmp-gen3x4-pcie-phy + + reg: + minItems: 1 + maxItems: 2 + + clocks: + maxItems: 6 + + clock-names: + items: + - const: aux + - const: cfg_ahb + - const: ref + - const: rchng + - const: pipe + - const: pipediv2 + + power-domains: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + items: + - const: phy +
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml line 58
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +10
-0+ vdda-phy-supply: true + + vdda-pll-supply: true + + qcom,4ln-config-sel: + description: 4-lane configuration as TCSR syscon phandle, register offset + and bit number + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + maxItems: 3
You have only one phandle, so you need to describe the items and limit their number, like here:
This allows you to skip most of property description.
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml line 67
Quoted 9 lines
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +9
-0+ + "#clock-cells": + const: 0 + + clock-output-names: + maxItems: 1 + + "#phy-cells": + const: 0
Best regards,
Krzysztof
Re: [PATCH 10/15] dt-bindings: phy: qcom,qmp-pcie: add sc8280xp bindings
Quoted 23 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml
Quoted 19 lines · Johan Hovold
Add bindings for the PCIe QMP PHYs found on SC8280XP.
The PCIe2 and PCIe3 controllers and PHYs on SC8280XP can be used in 4-lane mode or as separate controllers and PHYs in 2-lane mode (e.g. as PCIe2A and PCIe2B).
The configuration for a specific system can be read from a TCSR register.
Signed-off-by Johan Hovold <[email protected]>--- .../bindings/phy/qcom,qmp-pcie-phy.yaml | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yamlDocumentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +0
-0Filename based on compatible, so for example:
Quoted 1 line
qcom,sc8280xp-qmp-pcie-phy.yaml
Ok, but as I mentioned in my reply to the previous patch, this file is the one that is expected to be extended with new bindings.
I can't seem to find where this naming scheme is documented now even if I'm quite sure I've seen it before. Do you have a pointer?
And does this imply that the file name should also include the gen infix of one of the original compatibles (e.g. "qcom,sc8280xp-qmp-gen3x4-pcie-phy.yaml")?
Quoted 30 lines
Quoted 19 lines
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +18
-0@@ -0,0 +1,163 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,qmp-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm QMP PHY controller (PCIe) + +maintainers: + - Vinod Koul <[email protected]> + +description: + QMP PHY controller supports physical layer functionality for a number of + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. + +properties: + compatible: + enum:Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml line 58
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +9
-0+ - qcom,sc8280xp-qmp-gen3x1-pcie-phy + - qcom,sc8280xp-qmp-gen3x2-pcie-phy + - qcom,sc8280xp-qmp-gen3x4-pcie-phy + qcom,4ln-config-sel: + description: 4-lane configuration as TCSR syscon phandle, register offset + and bit number + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + maxItems: 3
Quoted 6 lines
You have only one phandle, so you need to describe the items and limit their number, like here:
This allows you to skip most of property description.
Ah, thanks, makes perfect sense. I based this one of the in-tree bindings which had been reviewed by Rob and must have thought it was some special phandle-array notation to express the same.
Johan
Re: [PATCH 10/15] dt-bindings: phy: qcom,qmp-pcie: add sc8280xp bindings
Quoted 24 lines · Johan Hovold
Quoted 23 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml
Quoted 19 lines · Johan Hovold
Add bindings for the PCIe QMP PHYs found on SC8280XP.
The PCIe2 and PCIe3 controllers and PHYs on SC8280XP can be used in 4-lane mode or as separate controllers and PHYs in 2-lane mode (e.g. as PCIe2A and PCIe2B).
The configuration for a specific system can be read from a TCSR register.
Signed-off-by Johan Hovold <[email protected]>--- .../bindings/phy/qcom,qmp-pcie-phy.yaml | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yamlDocumentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +0
-0Filename based on compatible, so for example:
Quoted 4 lines
Quoted 1 line
qcom,sc8280xp-qmp-pcie-phy.yaml
Ok, but as I mentioned in my reply to the previous patch, this file is the one that is expected to be extended with new bindings.
I would still propose to use compatible of this series and treat it as a family name of compatible or similar devices. What other choice we have?
If new (third) PHY bindings appear, then rename older to "-legacies" and this one to "-legacy"?
Quoted 3 lines
I can't seem to find where this naming scheme is documented now even if I'm quite sure I've seen it before. Do you have a pointer?
If you need the source of authority, then:
https://lore.kernel.org/linux-devicetree/[email protected]/
If you need unofficial documentation, then slides here:
https://osseu2022.sched.com/event/15z0W
If you need something official, that's on TODO list. :)
Quoted 4 lines
And does this imply that the file name should also include the gen infix of one of the original compatibles (e.g. "qcom,sc8280xp-qmp-gen3x4-pcie-phy.yaml")?
Since you already have here three compatibles, you cannot have one filename matching exactly all of them, so we already accept something generic. Therefore I proposed the common part - matching SoC component.
Best regards,
Krzysztof
Re: [PATCH 10/15] dt-bindings: phy: qcom,qmp-pcie: add sc8280xp bindings
Quoted 12 lines · Krzysztof Kozlowski
Quoted 11 lines · Johan Hovold
Quoted 9 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml
Quoted 4 lines · Johan Hovold
Add bindings for the PCIe QMP PHYs found on SC8280XP.
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml new file +0
-0Filename based on compatible, so for example:
qcom,sc8280xp-qmp-pcie-phy.yaml
Quoted 8 lines
Quoted 2 lines
Ok, but as I mentioned in my reply to the previous patch, this file is the one that is expected to be extended with new bindings.
I would still propose to use compatible of this series and treat it as a family name of compatible or similar devices. What other choice we have?
If new (third) PHY bindings appear, then rename older to "-legacies" and this one to "-legacy"?
We could also continue using
qcom,qmp-pcie-phy.yaml
for the latest generic binding were new devices should be added and rename the "deprecated" ones after one of the compatibles to make it sound less generic.
But I get your point.
Quoted 10 lines
Quoted 2 lines
I can't seem to find where this naming scheme is documented now even if I'm quite sure I've seen it before. Do you have a pointer?
If you need the source of authority, then:
https://lore.kernel.org/linux-devicetree/[email protected]/If you need unofficial documentation, then slides here:
https://osseu2022.sched.com/event/15z0WIf you need something official, that's on TODO list. :)
Heh. Ok.
Quoted 7 lines
Quoted 3 lines
And does this imply that the file name should also include the gen infix of one of the original compatibles (e.g. "qcom,sc8280xp-qmp-gen3x4-pcie-phy.yaml")?
Since you already have here three compatibles, you cannot have one filename matching exactly all of them, so we already accept something generic. Therefore I proposed the common part - matching SoC component.
Yeah, that's what I was alluding too. As soon you add one more SoC to the same document, the common part is no longer
qcom,sc8280xp-qmp-pcie-phy
but rather
qcom,qmp-pcie-phy
Johan
PATCH 11/15 phy: qcom-qmp-pcie: restructure PHY creation
In reply to Johan HovoldIn preparation for supporting devicetree bindings which do not use a child node, move the PHY creation to probe() proper and parse the serdes resource in what is now the legacy devicetree helper.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 36 +++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +17 -19
@@ -2147,14 +2147,15 @@ static int phy_pipe_clk_register(struct qmp_pcie *qmp, struct device_node *np)return devm_add_action_or_reset (qmp->dev, phy_clk_release_provider, np); } -static int qmp_pcie_create (struct qmp_pcie *qmp,struct device_node *np) +static int qmp_pcie_parse_dt_legacy (struct qmp_pcie *qmp,struct device_node *np) { +struct platform_device *pdev =to_platform_device (qmp->dev);const struct qmp_phy_cfg *cfg = qmp->cfg;struct device *dev = qmp->dev; -struct phy *generic_phy; -int ret; - qmp->mode =PHY_MODE_PCIE_RC ; + qmp->serdes =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (qmp->serdes)) +return PTR_ERR (qmp->serdes);/* * Get memory resources for the PHY:
@@ -2209,16 +2210,6 @@ static int qmp_pcie_create(struct qmp_pcie *qmp, struct device_node *np) "failed to get pipe clock\n"); } - generic_phy =devm_phy_create (dev, np, &qmp_pcie_phy_ops); -if (IS_ERR (generic_phy)) { - ret =PTR_ERR (generic_phy); -dev_err (dev,"failed to create PHY: %d\n" , ret); -return ret; - } - - qmp->phy = generic_phy; -phy_set_drvdata (generic_phy, qmp); -return 0 ; }
@@ -2243,10 +2234,6 @@ static int qmp_pcie_probe(struct platform_device *pdev)WARN_ON_ONCE (!qmp->cfg->pwrdn_ctrl);WARN_ON_ONCE (!qmp->cfg->phy_status); - qmp->serdes =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (qmp->serdes)) -return PTR_ERR (qmp->serdes); - ret =qmp_pcie_clk_init (qmp);if (ret)return ret;
@@ -2263,7 +2250,7 @@ static int qmp_pcie_probe(struct platform_device *pdev)if (!child)return -EINVAL ; - ret =qmp_pcie_create (qmp, child); + ret =qmp_pcie_parse_dt_legacy (qmp, child);if (ret) goto err_node_put;
@@ -2271,6 +2258,17 @@ static int qmp_pcie_probe(struct platform_device *pdev)if (ret) goto err_node_put; + qmp->mode =PHY_MODE_PCIE_RC ; + + qmp->phy =devm_phy_create (dev, child, &qmp_pcie_phy_ops); +if (IS_ERR (qmp->phy)) { + ret =PTR_ERR (qmp->phy); +dev_err (dev,"failed to create PHY: %d\n" , ret); + goto err_node_put; + } + +phy_set_drvdata (qmp->phy, qmp); +of_node_put (child); phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate);
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 12/15 phy: qcom-qmp-pcie: fix initialisation reset
In reply to Johan HovoldAdd the missing delay after asserting reset. This is specifically needed for the reset to have any effect on SC8280XP.
The vendor driver uses a 1 ms delay, but that seems a bit excessive. Instead use a 200 us delay which appears to be more than enough and also matches the UFS reset delay added by commit 870b1279c7a0 ("scsi:
ufs-qcom: Add reset control support for host controller").
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +2 -0
@@ -1866,6 +1866,8 @@ static int qmp_pcie_init(struct phy *phy) goto err_disable_regulators; } +usleep_range (200 ,300 ); + ret =reset_control_bulk_deassert (cfg->num_resets, qmp->resets);if (ret) {dev_err (qmp->dev,"reset deassert failed\n" );
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 13/15 phy: qcom-qmp-pcie: add support for pipediv2 clock
In reply to Johan HovoldSome QMP PHYs have a second fixed-divider pipe clock that needs to be enabled along with the pipe clock.
Add support for an optional "pipediv2" clock.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 42 ++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +36 -6
@@ -1379,7 +1379,9 @@ struct qmp_pcie {void __iomem *rx2;struct clk *pipe_clk; +struct clk *pipediv2_clk;struct clk_bulk_data *clks; +struct reset_control_bulk_data *resets;struct regulator_bulk_data *vregs;
@@ -1902,6 +1904,36 @@ static int qmp_pcie_exit(struct phy *phy)return 0 ; } +static int pipe_clk_enable (struct qmp_pcie *qmp) +{ +int ret; + + ret =clk_prepare_enable (qmp->pipe_clk); +if (ret) { +dev_err (qmp->dev,"failed to enable pipe clock: %d\n" , ret); +return ret; + } + + ret =clk_prepare_enable (qmp->pipediv2_clk); +if (ret) { +dev_err (qmp->dev,"failed to enable pipediv2 clock: %d\n" , ret); + goto err_disable_pipe_clk; + } + +return 0 ; + +err_disable_pipe_clk: +clk_disable_unprepare (qmp->pipe_clk); + +return ret; +} + +static void pipe_clk_disable (struct qmp_pcie *qmp) +{ +clk_disable_unprepare (qmp->pipediv2_clk); +clk_disable_unprepare (qmp->pipe_clk); +} +static int qmp_pcie_power_on (struct phy *phy) {struct qmp_pcie *qmp =phy_get_drvdata (phy);
@@ -1923,11 +1955,9 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_init_registers (qmp, &cfg->tables);qmp_pcie_init_registers (qmp, mode_tables); - ret =clk_prepare_enable (qmp->pipe_clk); -if (ret) { -dev_err (qmp->dev,"pipe_clk enable failed err=%d\n" , ret); + ret =pipe_clk_enable (qmp); +if (ret)return ret; - }/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
@@ -1950,7 +1980,7 @@ static int qmp_pcie_power_on(struct phy *phy)return 0 ; err_disable_pipe_clk: -clk_disable_unprepare (qmp->pipe_clk); +pipe_clk_disable (qmp);return ret; }
@@ -1960,7 +1990,7 @@ static int qmp_pcie_power_off(struct phy *phy)struct qmp_pcie *qmp =phy_get_drvdata (phy);const struct qmp_phy_cfg *cfg = qmp->cfg; -clk_disable_unprepare (qmp->pipe_clk); +pipe_clk_disable (qmp);/* PHY reset */ qphy_setbits (qmp->pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 13/15] phy: qcom-qmp-pcie: add support for pipediv2 clock
Quoted 33 lines · Johan Hovold
Some QMP PHYs have a second fixed-divider pipe clock that needs to be enabled along with the pipe clock.
Add support for an optional "pipediv2" clock.
Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 42 ++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +7
-0@@ -1379,7 +1379,9 @@ struct qmp_pcie {void __iomem *rx2;struct clk *pipe_clk; +struct clk *pipediv2_clk;struct clk_bulk_data *clks; +struct reset_control_bulk_data *resets;struct regulator_bulk_data *vregs;@@ -1902,6 +1904,36 @@ static int qmp_pcie_exit(struct phy *phy)return 0 ; } +static int pipe_clk_enable (struct qmp_pcie *qmp) +{ +int ret; + + ret =clk_prepare_enable (qmp->pipe_clk);
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_exit(struct phy *phy) · line 1921
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +10
-0+if (ret) { +dev_err (qmp->dev,"failed to enable pipe clock: %d\n" , ret); +return ret; + } + + ret =clk_prepare_enable (qmp->pipediv2_clk); +if (ret) { +dev_err (qmp->dev,"failed to enable pipediv2 clock: %d\n" , ret); + goto err_disable_pipe_clk; + }
Do they have to be enabled in sequence? If not, I'd use a bulk clocks here for the pipe clocks. While it can look like an overkill, it would be a safe net for the possible future changes, which might include additional clocks.
Quoted 50 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +19
-6+ +return 0 ; + +err_disable_pipe_clk: +clk_disable_unprepare (qmp->pipe_clk); + +return ret; +} + +static void pipe_clk_disable (struct qmp_pcie *qmp) +{ +clk_disable_unprepare (qmp->pipediv2_clk); +clk_disable_unprepare (qmp->pipe_clk); +} +static int qmp_pcie_power_on (struct phy *phy) {struct qmp_pcie *qmp =phy_get_drvdata (phy);@@ -1923,11 +1955,9 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_init_registers (qmp, &cfg->tables);qmp_pcie_init_registers (qmp, mode_tables); - ret =clk_prepare_enable (qmp->pipe_clk); -if (ret) { -dev_err (qmp->dev,"pipe_clk enable failed err=%d\n" , ret); + ret =pipe_clk_enable (qmp); +if (ret)return ret; - }/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );@@ -1950,7 +1980,7 @@ static int qmp_pcie_power_on(struct phy *phy)return 0 ; err_disable_pipe_clk: -clk_disable_unprepare (qmp->pipe_clk); +pipe_clk_disable (qmp);return ret; }@@ -1960,7 +1990,7 @@ static int qmp_pcie_power_off(struct phy *phy)struct qmp_pcie *qmp =phy_get_drvdata (phy);const struct qmp_phy_cfg *cfg = qmp->cfg; -clk_disable_unprepare (qmp->pipe_clk); +pipe_clk_disable (qmp);/* PHY reset */ qphy_setbits (qmp->pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 13/15] phy: qcom-qmp-pcie: add support for pipediv2 clock
Quoted 41 lines · Dmitry Baryshkov
Quoted 40 lines · Johan Hovold
Some QMP PHYs have a second fixed-divider pipe clock that needs to be enabled along with the pipe clock.
Add support for an optional "pipediv2" clock.
Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 42 ++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +14
-0@@ -1379,7 +1379,9 @@ struct qmp_pcie {void __iomem *rx2;struct clk *pipe_clk; +struct clk *pipediv2_clk;struct clk_bulk_data *clks; +struct reset_control_bulk_data *resets;struct regulator_bulk_data *vregs;@@ -1902,6 +1904,36 @@ static int qmp_pcie_exit(struct phy *phy)return 0 ; } +static int pipe_clk_enable (struct qmp_pcie *qmp) +{ +int ret; + + ret =clk_prepare_enable (qmp->pipe_clk); +if (ret) { +dev_err (qmp->dev,"failed to enable pipe clock: %d\n" , ret); +return ret; + } + + ret =clk_prepare_enable (qmp->pipediv2_clk); +if (ret) {
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_exit(struct phy *phy) · line 1921
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +3
-0+dev_err (qmp->dev,"failed to enable pipediv2 clock: %d\n" , ret); + goto err_disable_pipe_clk; + }Do they have to be enabled in sequence? If not, I'd use a bulk clocks here for the pipe clocks. While it can look like an overkill, it would be a safe net for the possible future changes, which might include additional clocks.
I don't believe the bulk API is a good fit here as we need to support both the new and old bindings, and for the latter the pipe_clk is looked up by index rather than name (and that's from the child node too which limits which APIs you can use further).
The code is clear enough as it stands, and I don't think we need to take height for a hypothetical third pipe clock just yet.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 14/15 phy: qcom-qmp-pcie: add support for sc8280xp
In reply to Johan HovoldAdd support for the single and dual-lane PHYs found on SC8280XP.
Note that the SC8280XP binding does not try to describe every register subregion and instead the driver holds the corresponding offsets.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 302 +++++++++++++++++- .../phy/qualcomm/phy-qcom-qmp-pcs-pcie-v5.h | 2 + 2 files changed, 294 insertions(+), 10 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +292 -10
@@ -834,6 +834,143 @@ static const struct qmp_phy_init_tbl sc8180x_qmp_pcie_pcs_misc_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE, 0xc1), }; +static const struct qmp_phy_init_tbl sc8280xp_qmp_pcie_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_EN_CENTER ,0x00 ), +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 ,0x4c ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1 ,0x06 ), +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 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_PLL_RCTRL_MODE1 ,0x16 ), +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 ,0x42 ), +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 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_LOCK_CMP2_MODE1 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DEC_START_MODE0 ,0x82 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DEC_START_MODE1 ,0x68 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START1_MODE0 ,0x55 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START2_MODE0 ,0x55 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START3_MODE0 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START1_MODE1 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START2_MODE1 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_DIV_FRAC_START3_MODE1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_TUNE_MAP ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_TUNE1_MODE0 ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_TUNE1_MODE1 ,0xb4 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_VCO_TUNE2_MODE1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CLK_SELECT ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_HSCLK_SEL ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_CORECLK_DIV_MODE1 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0xb9 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x1e ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1 ,0x94 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL ,0x11 ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x1_pcie_rc_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_COM_SYSCLK_BUF_ENABLE ,0x07 ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x2_pcie_rc_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN ,0x14 ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x1_pcie_tx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_TX_PI_QEC_CTRL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_LANE_MODE_1 ,0x75 ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_LANE_MODE_4 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX ,0x1d ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX ,0x0c ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x1_pcie_rx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_LOW ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH2 ,0xbf ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH3 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH4 ,0xd8 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_LOW ,0xdc ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH ,0xdc ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH2 ,0x5c ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH3 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH4 ,0xa6 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_TX_ADAPT_POST_THRESH ,0xf0 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_10_HIGH3 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_VGA_CAL_CNTRL2 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_GM_CAL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_UCDR_SB2_THRESH1 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_UCDR_SB2_THRESH2 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_UCDR_PI_CONTROLS ,0xf0 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET ,0x38 ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x1_pcie_pcs_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V5_PCS_REFGEN_REQ_CONFIG1 ,0x05 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_RX_SIGDET_LVL ,0x77 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_RATE_SLEW_CNTRL1 ,0x0b ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x1_pcie_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1 ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_EQ_CONFIG2 ,0x0f ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE ,0xc1 ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x2_pcie_tx_tbl[] = { +QMP_PHY_INIT_CFG_LANE (QSERDES_V5_TX_PI_QEC_CTRL ,0x02 ,1 ), +QMP_PHY_INIT_CFG_LANE (QSERDES_V5_TX_PI_QEC_CTRL ,0x04 ,2 ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_LANE_MODE_1 ,0xd5 ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_LANE_MODE_4 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX ,0x0c ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x2_pcie_rx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_LOW ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH2 ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH3 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_00_HIGH4 ,0xd8 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_LOW ,0xdc ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH ,0xdc ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH2 ,0x5c ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH3 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_01_HIGH4 ,0xa6 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_RX_MODE_10_HIGH3 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_VGA_CAL_CNTRL2 ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_GM_CAL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_UCDR_SB2_THRESH1 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_UCDR_SB2_THRESH2 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_UCDR_PI_CONTROLS ,0xf0 ), +QMP_PHY_INIT_CFG (QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET ,0x38 ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x2_pcie_pcs_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V5_PCS_REFGEN_REQ_CONFIG1 ,0x05 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_RX_SIGDET_LVL ,0x88 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_RATE_SLEW_CNTRL1 ,0x0b ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_EQ_CONFIG3 ,0x0f ), +}; + +static const struct qmp_phy_init_tbl sc8280xp_qmp_gen3x2_pcie_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_POWER_STATE_CONFIG2 ,0x1d ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_POWER_STATE_CONFIG4 ,0x07 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE ,0xc1 ), +QMP_PHY_INIT_CFG (QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS ,0x00 ), +}; +static const struct qmp_phy_init_tbl sm8250_qmp_pcie_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V4_COM_SYSCLK_EN_SEL ,0x08 ),QMP_PHY_INIT_CFG (QSERDES_V4_COM_CLK_SELECT ,0x34 ),
@@ -1313,6 +1450,16 @@ 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_pcie_offsets { +u16 serdes; +u16 pcs; +u16 pcs_misc; +u16 tx; +u16 rx; +u16 tx2; +u16 rx2; +}; +struct qmp_phy_cfg_tables {const struct qmp_phy_init_tbl *serdes;int serdes_num;
@@ -1330,6 +1477,8 @@ struct qmp_phy_cfg_tables {struct qmp_phy_cfg {int lanes; +const struct qmp_pcie_offsets *offsets; +/* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ const struct qmp_phy_cfg_tables tables;/*
@@ -1422,6 +1571,9 @@ static const char * const msm8996_phy_clk_l[] = { "aux", "cfg_ahb", "ref", }; +static const char *const sc8280xp_pciephy_clk_l[] = { +"aux" ,"cfg_ahb" ,"ref" ,"rchng" , +};static const char *const sdm845_pciephy_clk_l[] = {"aux" ,"cfg_ahb" ,"ref" ,"refgen" ,
@@ -1441,6 +1593,16 @@ static const char * const sdm845_pciephy_reset_l[] = { "phy", }; +static const struct qmp_pcie_offsets qmp_pcie_offsets_v5 = { + .serdes =0 , + .pcs =0x0200 , + .pcs_misc =0x0600 , + .tx =0x0e00 , + .rx =0x1000 , + .tx2 =0x1600 , + .rx2 =0x1800 , +}; +static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .lanes =1 ,
@@ -1700,6 +1862,76 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .phy_status = PHYSTATUS, }; +static const struct qmp_phy_cfg sc8280xp_qmp_gen3x1_pciephy_cfg = { + .lanes =1 , + + .offsets = &qmp_pcie_offsets_v5, + + .tables = { + .serdes = sc8280xp_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sc8280xp_qmp_pcie_serdes_tbl), + .tx = sc8280xp_qmp_gen3x1_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sc8280xp_qmp_gen3x1_pcie_tx_tbl), + .rx = sc8280xp_qmp_gen3x1_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sc8280xp_qmp_gen3x1_pcie_rx_tbl), + .pcs = sc8280xp_qmp_gen3x1_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sc8280xp_qmp_gen3x1_pcie_pcs_tbl), + .pcs_misc = sc8280xp_qmp_gen3x1_pcie_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sc8280xp_qmp_gen3x1_pcie_pcs_misc_tbl), + }, + + .tables_rc = &(const struct qmp_phy_cfg_tables ) { + .serdes = sc8280xp_qmp_gen3x1_pcie_rc_serdes_tbl, + .serdes_num =ARRAY_SIZE (sc8280xp_qmp_gen3x1_pcie_rc_serdes_tbl), + }, + + .clk_list = sc8280xp_pciephy_clk_l, + .num_clks =ARRAY_SIZE (sc8280xp_pciephy_clk_l), + .reset_list = sdm845_pciephy_reset_l, + .num_resets =ARRAY_SIZE (sdm845_pciephy_reset_l), + .vreg_list = qmp_phy_vreg_l, + .num_vregs =ARRAY_SIZE (qmp_phy_vreg_l), + .regs = sm8250_pcie_regs_layout, + + .pwrdn_ctrl =SW_PWRDN |REFCLK_DRV_DSBL , + .phy_status =PHYSTATUS , +}; + +static const struct qmp_phy_cfg sc8280xp_qmp_gen3x2_pciephy_cfg = { + .lanes =2 , + + .offsets = &qmp_pcie_offsets_v5, + + .tables = { + .serdes = sc8280xp_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sc8280xp_qmp_pcie_serdes_tbl), + .tx = sc8280xp_qmp_gen3x2_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sc8280xp_qmp_gen3x2_pcie_tx_tbl), + .rx = sc8280xp_qmp_gen3x2_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sc8280xp_qmp_gen3x2_pcie_rx_tbl), + .pcs = sc8280xp_qmp_gen3x2_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sc8280xp_qmp_gen3x2_pcie_pcs_tbl), + .pcs_misc = sc8280xp_qmp_gen3x2_pcie_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sc8280xp_qmp_gen3x2_pcie_pcs_misc_tbl), + }, + + .tables_rc = &(const struct qmp_phy_cfg_tables ) { + .serdes = sc8280xp_qmp_gen3x2_pcie_rc_serdes_tbl, + .serdes_num =ARRAY_SIZE (sc8280xp_qmp_gen3x2_pcie_rc_serdes_tbl), + }, + + .clk_list = sc8280xp_pciephy_clk_l, + .num_clks =ARRAY_SIZE (sc8280xp_pciephy_clk_l), + .reset_list = sdm845_pciephy_reset_l, + .num_resets =ARRAY_SIZE (sdm845_pciephy_reset_l), + .vreg_list = qmp_phy_vreg_l, + .num_vregs =ARRAY_SIZE (qmp_phy_vreg_l), + .regs = sm8250_pcie_regs_layout, + + .pwrdn_ctrl =SW_PWRDN |REFCLK_DRV_DSBL , + .phy_status =PHYSTATUS , +}; +static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { .lanes =2 ,
@@ -2245,11 +2477,52 @@ static int qmp_pcie_parse_dt_legacy(struct qmp_pcie *qmp, struct device_node *npreturn 0 ; } +static int qmp_pcie_parse_dt (struct qmp_pcie *qmp) +{ +struct platform_device *pdev =to_platform_device (qmp->dev); +const struct qmp_phy_cfg *cfg = qmp->cfg; +const struct qmp_pcie_offsets *offs = cfg->offsets; +struct device *dev = qmp->dev; +void __iomem *base; + +if (!offs) +return -EINVAL ; + + base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (base)) +return PTR_ERR (base); + + qmp->serdes = base + offs->serdes; + qmp->pcs = base + offs->pcs; + qmp->pcs_misc = base + offs->pcs_misc; + qmp->tx = base + offs->tx; + qmp->rx = base + offs->rx; + +if (cfg->lanes >=2 ) { + qmp->tx2 = base + offs->tx2; + qmp->rx2 = base + offs->rx2; + } + + qmp->pipe_clk =devm_clk_get (dev,"pipe" ); +if (IS_ERR (qmp->pipe_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), +"failed to get pipe clock\n" ); + } + + qmp->pipediv2_clk =devm_clk_get (dev,"pipediv2" ); +if (IS_ERR (qmp->pipediv2_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipediv2_clk), +"failed to get pipediv2 clock\n" ); + } + +return 0 ; +} +static int qmp_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *child;struct phy_provider *phy_provider; +struct device_node *np;struct qmp_pcie *qmp;int ret;
@@ -2278,21 +2551,24 @@ static int qmp_pcie_probe(struct platform_device *pdev)if (ret)return ret; - child =of_get_next_available_child (dev->of_node,NULL ); -if (!child) -return -EINVAL ; - - ret =qmp_pcie_parse_dt_legacy (qmp, child); +/* Check for legacy binding with child node. */ + np =of_get_next_available_child (dev->of_node,NULL ); +if (np) { + ret =qmp_pcie_parse_dt_legacy (qmp, np); + }else { + np =of_node_get (dev->of_node); + ret =qmp_pcie_parse_dt (qmp); + }if (ret) goto err_node_put; - ret =phy_pipe_clk_register (qmp, child); + ret =phy_pipe_clk_register (qmp, np);if (ret) goto err_node_put; qmp->mode =PHY_MODE_PCIE_RC ; - qmp->phy =devm_phy_create (dev, child, &qmp_pcie_phy_ops); + qmp->phy =devm_phy_create (dev, np, &qmp_pcie_phy_ops);if (IS_ERR (qmp->phy)) { ret =PTR_ERR (qmp->phy);dev_err (dev,"failed to create PHY: %d\n" , ret);
@@ -2301,14 +2577,14 @@ static int qmp_pcie_probe(struct platform_device *pdev)phy_set_drvdata (qmp->phy, qmp); -of_node_put (child); +of_node_put (np); phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate);return PTR_ERR_OR_ZERO (phy_provider); err_node_put: -of_node_put (child); +of_node_put (np);return ret; }
@@ -2328,6 +2604,12 @@ static const struct of_device_id qmp_pcie_of_match_table[] = { }, { .compatible = "qcom,sc8180x-qmp-pcie-phy", .data = &sc8180x_pciephy_cfg, + }, { + .compatible = "qcom,sc8280xp-qmp-gen3x1-pcie-phy", + .data = &sc8280xp_qmp_gen3x1_pciephy_cfg, + }, { + .compatible = "qcom,sc8280xp-qmp-gen3x2-pcie-phy", + .data = &sc8280xp_qmp_gen3x2_pciephy_cfg, }, { .compatible = "qcom,sdm845-qhp-pcie-phy", .data = &sdm845_qhp_pciephy_cfg,
drivers/phy/qualcomm/phy-qcom-qmp-pcs-pcie-v5.h +2 -0
@@ -8,6 +8,8 @@#define QCOM_PHY_QMP_PCS_PCIE_V5_H_ /* Only for QMP V5 PHY - PCS_PCIE registers */ +#define QPHY_V5_PCS_PCIE_POWER_STATE_CONFIG2 0x0c +#define QPHY_V5_PCS_PCIE_POWER_STATE_CONFIG4 0x14#define QPHY_V5_PCS_PCIE_ENDPOINT_REFCLK_DRIVE 0x20#define QPHY_V5_PCS_PCIE_INT_AUX_CLK_CONFIG1 0x54#define QPHY_V5_PCS_PCIE_OSC_DTCT_ACTIONS 0x94
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 15/15 phy: qcom-qmp-pcie: add support for sc8280xp 4-lane PHYs
In reply to Johan HovoldThe PCIe2 and PCIe3 controllers and PHYs on SC8280XP can be used in 4-lane mode or as separate controllers and PHYs in 2-lane mode (e.g. as PCIe2A and PCIe2B).
Add support for fetching the 4-lane configuration from the TCSR and programming the lane registers of the second port when in 4-lane mode.
--- drivers/phy/qualcomm/Kconfig | 1 + drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 118 +++++++++++++++++++++++ 2 files changed, 119 insertions(+)
drivers/phy/qualcomm/Kconfig +1 -0
@@ -54,6 +54,7 @@ config PHY_QCOM_QMP tristate "Qualcomm QMP PHY Driver" depends on OF && COMMON_CLK && (ARCH_QCOM || COMPILE_TEST) select GENERIC_PHY + select MFD_SYSCON help Enable this to support the QMP PHY transceiver that is used with controllers such as PCIe, UFS, and USB on Qualcomm chips.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +118 -0
200 lines not on this page · raw message
Signature · 7 lines
2.37.3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy