PCI: dwc: Add multi-port controller support
Subsystems (19)
v2 cover PCI: dwc: Add multi-port controller support
This series adds support for multi-port PCIe controllers in the DesignWare driver. Currently, the driver only supports a single Root Port with controller-level properties, which doesn't work for multi-port controllers where each port may have different configurations.
This series introduces a per-port structure and parsing API that allows each Root Port to be configured independently via pcie@N child nodes in device tree, while maintaining backward compatibility with existing single-port bindings.
---
Changes in v2:
- Fix error code preservation in dw_pcie_resume_noirq() to return actual
error from dw_pcie_wait_for_link() instead of hardcoded -ETIMEDOUT (Mani).
- Initialize ret variable to -ENOENT in dw_pcie_parse_root_ports() (Mani).
- dw_pcie_host_init(): Remove -ENOENT error skipping to make parsing
failures fatal for now, add TODO comment about making properties
optional later (Mani).
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Sumit Kumar (2):
PCI: API changes for multi-port controller support
PCI: dwc: Add multi-port controller support
drivers/pci/controller/dwc/pci-exynos.c | 4 +- drivers/pci/controller/dwc/pci-imx6.c | 15 +- drivers/pci/controller/dwc/pci-meson.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 175 ++++++++++++++++++---- drivers/pci/controller/dwc/pcie-designware.c | 32 ++-- drivers/pci/controller/dwc/pcie-designware.h | 17 ++- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 13 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 5 +- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +- drivers/pci/controller/dwc/pcie-qcom.c | 4 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 13 +- drivers/pci/controller/dwc/pcie-spear13xx.c | 5 +- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +- drivers/pci/of.c | 6 +- drivers/pci/pci.h | 2 + 16 files changed, 232 insertions(+), 74 deletions(-)
---
base-commit: 097a6c336d0080725c626fda118ecfec448acd0f
change-id: 20251010-dt-parser-98b50ce18fc1
Best regards,
Signature · 1 line
Sumit Kumar <[email protected]>
PATCH v2 1/2 PCI: API changes for multi-port controller support
For multi-port controllers, equalization preset properties should be specified in individual Root Port nodes rather than the controller node, allowing each port to have its own configuration.
Change of_pci_get_equalization_presets() to accept a device_node pointer. This allows parsing equalization presets from any device tree node, which is needed for multi-port PCIe controllers.
--- drivers/pci/of.c | 6 ++++-- drivers/pci/pci.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/pci/of.c +4 -2
@@ -971,6 +971,7 @@ EXPORT_SYMBOL_GPL(of_pci_get_slot_power_limit);* of_pci_get_equalization_presets - Parses the "eq-presets-Ngts" property. * * @dev: Device containing the properties. +* @node: Device tree node containing the properties. * @presets: Pointer to store the parsed data. * @num_lanes: Maximum number of lanes supported. *
@@ -981,6 +982,7 @@ EXPORT_SYMBOL_GPL(of_pci_get_slot_power_limit);* errno otherwise. */ int of_pci_get_equalization_presets (struct device *dev, +struct device_node *node,struct pci_eq_presets *presets,int num_lanes) {
@@ -988,7 +990,7 @@ int of_pci_get_equalization_presets(struct device *dev,int ret; presets->eq_presets_8gts[0 ] =PCI_EQ_RESV ; - ret =of_property_read_u16_array (dev->of_node,"eq-presets-8gts" , + ret =of_property_read_u16_array (node,"eq-presets-8gts" , presets->eq_presets_8gts, num_lanes);if (ret && ret != -EINVAL ) {dev_err (dev,"Error reading eq-presets-8gts: %d\n" , ret);
@@ -998,7 +1000,7 @@ int of_pci_get_equalization_presets(struct device *dev,for (int i =0 ; i <EQ_PRESET_TYPE_MAX -1 ; i++) { presets->eq_presets_Ngts[i][0 ] =PCI_EQ_RESV ;snprintf (name,sizeof (name),"eq-presets-%dgts" ,8 << (i +1 )); - ret =of_property_read_u8_array (dev->of_node, name, + ret =of_property_read_u8_array (node, name, presets->eq_presets_Ngts[i], num_lanes);if (ret && ret != -EINVAL ) {
drivers/pci/pci.h +2 -0
@@ -965,6 +965,7 @@ void pci_release_bus_of_node(struct pci_bus *bus);int devm_of_pci_bridge_init (struct device *dev,struct pci_host_bridge *bridge);bool of_pci_supply_present (struct device_node *np);int of_pci_get_equalization_presets (struct device *dev, +struct device_node *node,struct pci_eq_presets *presets,int num_lanes);#else
@@ -1013,6 +1014,7 @@ static inline bool of_pci_supply_present(struct device_node *np) }static inline int of_pci_get_equalization_presets (struct device *dev, +struct device_node *node,struct pci_eq_presets *presets,int num_lanes) {
Signature · 1 line
2.34.1
PATCH v2 2/2 PCI: dwc: Add multi-port controller support
In reply to Sumit KumarThe current DesignWare PCIe RC implementation supports only the controller (Host Bridge) node for specifying the Root Port properties in an assumption that the underlying platform only supports a single Root Port per controller instance. This limits support for multi-port controllers where different ports may have different lane configurations and speed limits.
Introduce a separate dw_pcie_port structure to enable multi-port support. Each Root Port can have independent lane count, speed limit through pcie@N child nodes in device tree. Add dw_pcie_parse_root_ports()
API to parse these child nodes.
Equalization presets and link width detection currently use common DBI space for all the Root ports. Per-port DBI space assignment for these features will be added in future.
--- drivers/pci/controller/dwc/pci-exynos.c | 4 +- drivers/pci/controller/dwc/pci-imx6.c | 15 +- drivers/pci/controller/dwc/pci-meson.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 175 ++++++++++++++++++---- drivers/pci/controller/dwc/pcie-designware.c | 32 ++-- drivers/pci/controller/dwc/pcie-designware.h | 17 ++- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 13 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 5 +- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +- drivers/pci/controller/dwc/pcie-qcom.c | 4 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 13 +- drivers/pci/controller/dwc/pcie-spear13xx.c | 5 +- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +- 14 files changed, 226 insertions(+), 72 deletions(-)
drivers/pci/controller/dwc/pci-exynos.c +3 -1
@@ -358,6 +358,8 @@ static int exynos_pcie_resume_noirq(struct device *dev)struct exynos_pcie *ep =dev_get_drvdata (dev);struct dw_pcie *pci = &ep->pci;struct dw_pcie_rp *pp = &pci->pp; +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list);int ret; ret =regulator_bulk_enable (ARRAY_SIZE (ep->supplies), ep->supplies);
@@ -368,7 +370,7 @@ static int exynos_pcie_resume_noirq(struct device *dev)exynos_pcie_host_init (pp);dw_pcie_setup_rc (pp);exynos_pcie_start_link (pci); -return dw_pcie_wait_for_link (pci); +return dw_pcie_wait_for_link (pci, port); }static const struct dev_pm_ops exynos_pcie_pm_ops = {
drivers/pci/controller/dwc/pci-imx6.c +9 -6
@@ -939,6 +939,8 @@ static int imx_pcie_start_link(struct dw_pcie *pci)struct imx_pcie *imx_pcie =to_imx_pcie (pci);struct device *dev = pci->dev;u8 offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list);u32 tmp;int ret;
@@ -963,8 +965,8 @@ static int imx_pcie_start_link(struct dw_pcie *pci)/* Start LTSSM. */ imx_pcie_ltssm_enable (dev); -if (pci->max_link_speed >1 ) { - ret =dw_pcie_wait_for_link (pci); +if (port->max_link_speed >1 ) { + ret =dw_pcie_wait_for_link (pci, port);if (ret) goto err_reset_phy;
@@ -972,7 +974,7 @@ static int imx_pcie_start_link(struct dw_pcie *pci)dw_pcie_dbi_ro_wr_en (pci); tmp =dw_pcie_readl_dbi (pci, offset +PCI_EXP_LNKCAP ); tmp &= ~PCI_EXP_LNKCAP_SLS ; - tmp |= pci->max_link_speed; + tmp |= port->max_link_speed;dw_pcie_writel_dbi (pci, offset +PCI_EXP_LNKCAP , tmp);/*
@@ -1605,6 +1607,7 @@ static int imx_pcie_probe(struct platform_device *pdev)struct dw_pcie *pci;struct imx_pcie *imx_pcie;struct device_node *np; +struct dw_pcie_port *port;struct device_node *node = dev->of_node;int ret, domain;u16 val;
@@ -1741,9 +1744,9 @@ static int imx_pcie_probe(struct platform_device *pdev) &imx_pcie->tx_swing_low)) imx_pcie->tx_swing_low =127 ; -/* Limit link speed */ - pci->max_link_speed =1 ; -of_property_read_u32 (node,"fsl,max-link-speed" , &pci->max_link_speed); + port = list_first_entry(&pci->pp.ports, struct dw_pcie_port, list); + port->max_link_speed =1 ; +of_property_read_u32 (node,"fsl,max-link-speed" , &port->max_link_speed); imx_pcie->vpcie =devm_regulator_get_optional (&pdev->dev,"vpcie" );if (IS_ERR (imx_pcie->vpcie)) {
drivers/pci/controller/dwc/pci-meson.c +0 -1
@@ -411,7 +411,6 @@ static int meson_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = &dw_pcie_ops; pci->pp.ops = &meson_pcie_host_ops; - pci->num_lanes =1 ; mp->phy =devm_phy_get (dev,"pcie" );if (IS_ERR (mp->phy)) {
drivers/pci/controller/dwc/pcie-designware-host.c +146 -29
288 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-designware.c +16 -16
@@ -178,11 +178,6 @@ int dw_pcie_get_resources(struct dw_pcie *pci)return ret; } -if (pci->max_link_speed <1 ) - pci->max_link_speed =of_pci_get_max_link_speed (np); - -of_property_read_u32 (np,"num-lanes" , &pci->num_lanes); -if (of_property_read_bool (np,"snps,enable-cdm-check" ))dw_pcie_cap_set (pci,CDM_CHECK );
@@ -696,7 +691,7 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir, int index)dw_pcie_writel_atu (pci, dir, index,PCIE_ATU_REGION_CTRL2 ,0 ); } -int dw_pcie_wait_for_link (struct dw_pcie *pci) +int dw_pcie_wait_for_link (struct dw_pcie *pci,struct dw_pcie_port *port) {u32 offset, val;int retries;
@@ -719,7 +714,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)* speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms * after Link training completes before sending a Configuration Request. */ -if (pci->max_link_speed >2 ) +if (port && port->max_link_speed >2 )msleep (PCIE_RESET_CONFIG_WAIT_MS ); offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP );
@@ -756,10 +751,11 @@ void dw_pcie_upconfig_setup(struct dw_pcie *pci) }EXPORT_SYMBOL_GPL (dw_pcie_upconfig_setup); -static void dw_pcie_link_set_max_speed (struct dw_pcie *pci) +static void dw_pcie_link_set_max_speed (struct dw_pcie *pci,struct dw_pcie_port *port) {u32 cap, ctrl2, link_speed;u8 offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); +int max_speed = port->max_link_speed; cap =dw_pcie_readl_dbi (pci, offset +PCI_EXP_LNKCAP );
@@ -768,15 +764,16 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci)* just cache the hardware default value so that the vendor drivers can * use it to do any link specific configuration. */ -if (pci->max_link_speed <1 ) { - pci->max_link_speed =FIELD_GET (PCI_EXP_LNKCAP_SLS , cap); +if (max_speed <1 ) { + max_speed =FIELD_GET (PCI_EXP_LNKCAP_SLS , cap); + port->max_link_speed = max_speed;return ; } ctrl2 =dw_pcie_readl_dbi (pci, offset +PCI_EXP_LNKCTL2 ); ctrl2 &= ~PCI_EXP_LNKCTL2_TLS ; -switch (pcie_link_speed[pci->max_link_speed]) { +switch (pcie_link_speed[max_speed]) {case PCIE_SPEED_2_5GT : link_speed =PCI_EXP_LNKCTL2_TLS_2_5GT ;break ;
@@ -800,10 +797,10 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci) cap &= ~((u32 )PCI_EXP_LNKCAP_SLS );dw_pcie_writel_dbi (pci, offset +PCI_EXP_LNKCAP , cap | link_speed); - } -int dw_pcie_link_get_max_link_width (struct dw_pcie *pci) +/* TODO: Implement per-port max link width detection using port-specific DBI space */ +int dw_pcie_link_get_max_link_width (struct dw_pcie *pci,struct dw_pcie_port *port) {u8 cap =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP );u32 lnkcap =dw_pcie_readl_dbi (pci, cap +PCI_EXP_LNKCAP );
@@ -1141,9 +1138,14 @@ void dw_pcie_edma_remove(struct dw_pcie *pci)void dw_pcie_setup (struct dw_pcie *pci) { +struct dw_pcie_port *port;u32 val; -dw_pcie_link_set_max_speed (pci); +/* Configure per-port settings */ +list_for_each_entry (port, &pci->pp.ports, list) { +dw_pcie_link_set_max_speed (pci, port); +dw_pcie_link_set_max_link_width (pci, port->num_lanes); + }/* Configure Gen1 N_FTS */ if (pci->n_fts[0 ]) {
@@ -1173,8 +1175,6 @@ void dw_pcie_setup(struct dw_pcie *pci) val &= ~PORT_LINK_FAST_LINK_MODE ; val |=PORT_LINK_DLL_LINK_EN ;dw_pcie_writel_dbi (pci,PCIE_PORT_LINK_CONTROL , val); - -dw_pcie_link_set_max_link_width (pci, pci->num_lanes); } resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci,
drivers/pci/controller/dwc/pcie-designware.h +12 -5
@@ -18,6 +18,7 @@#include <linux/dma/edma.h> #include <linux/gpio/consumer.h> #include <linux/irq.h> +#include <linux/list.h> #include <linux/msi.h> #include <linux/pci.h> #include <linux/reset.h>
@@ -392,6 +393,14 @@ struct dw_pcie_ob_atu_cfg {u64 size; }; +struct dw_pcie_port { +struct list_head list; +struct device_node *dev_node; +u32 num_lanes; +int max_link_speed; +struct pci_eq_presets presets; +}; +struct dw_pcie_host_ops {int (*init)(struct dw_pcie_rp *pp);void (*deinit)(struct dw_pcie_rp *pp);
@@ -424,7 +433,7 @@ struct dw_pcie_rp {int msg_atu_index;struct resource *msg_res;bool use_linkup_irq; -struct pci_eq_presets presets; +struct list_head ports;/* List of dw_pcie_port structures */ };struct dw_pcie_ep_ops {
@@ -505,8 +514,6 @@ struct dw_pcie {u32 version;u32 type;unsigned long caps; -int num_lanes; -int max_link_speed;u8 n_fts[2 ];struct dw_edma_chip edma;struct clk_bulk_data app_clks[DW_PCIE_NUM_APP_CLKS ];
@@ -556,8 +563,8 @@ void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val);void dw_pcie_write_dbi2 (struct dw_pcie *pci,u32 reg,size_t size,u32 val);bool dw_pcie_link_up (struct dw_pcie *pci);void dw_pcie_upconfig_setup (struct dw_pcie *pci); -int dw_pcie_wait_for_link (struct dw_pcie *pci); -int dw_pcie_link_get_max_link_width (struct dw_pcie *pci); +int dw_pcie_wait_for_link (struct dw_pcie *pci,struct dw_pcie_port *port); +int dw_pcie_link_get_max_link_width (struct dw_pcie *pci,struct dw_pcie_port *port);int dw_pcie_prog_outbound_atu (struct dw_pcie *pci,const struct dw_pcie_ob_atu_cfg *atu); int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int type,
drivers/pci/controller/dwc/pcie-fu740.c +4 -2
@@ -179,6 +179,8 @@ static int fu740_pcie_start_link(struct dw_pcie *pci) {struct device *dev = pci->dev;struct fu740_pcie *afp =dev_get_drvdata (dev); +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list);u8 cap_exp =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP );int ret;u32 orig, tmp;
@@ -202,7 +204,7 @@ static int fu740_pcie_start_link(struct dw_pcie *pci)/* Enable LTSSM */ writel_relaxed (0x1 , afp->mgmt_base +PCIEX8MGMT_APP_LTSSM_ENABLE ); - ret =dw_pcie_wait_for_link (pci); + ret =dw_pcie_wait_for_link (pci, port);if (ret) {dev_err (dev,"error: link did not start\n" ); goto err;
@@ -220,7 +222,7 @@ static int fu740_pcie_start_link(struct dw_pcie *pci) tmp |=PORT_LOGIC_SPEED_CHANGE ;dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); - ret =dw_pcie_wait_for_link (pci); + ret =dw_pcie_wait_for_link (pci, port);if (ret) {dev_err (dev,"error: link did not start at new speed\n" ); goto err;
drivers/pci/controller/dwc/pcie-intel-gw.c +10 -3
@@ -131,7 +131,10 @@ static void intel_pcie_link_setup(struct intel_pcie *pcie)static void intel_pcie_init_n_fts (struct dw_pcie *pci) { -switch (pci->max_link_speed) { +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list); + +switch (port->max_link_speed) {case 3 : pci->n_fts[1 ] =PORT_AFR_N_FTS_GEN3 ;break ;
@@ -250,8 +253,10 @@ static int intel_pcie_wait_l2(struct intel_pcie *pcie)u32 value;int ret;struct dw_pcie *pci = &pcie->pci; +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list); -if (pci->max_link_speed <3 ) +if (port->max_link_speed <3 )return 0 ;/* Send PME_TURN_OFF message */
@@ -282,6 +287,8 @@ static int intel_pcie_host_setup(struct intel_pcie *pcie) {int ret;struct dw_pcie *pci = &pcie->pci; +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list);intel_pcie_core_rst_assert (pcie);intel_pcie_device_rst_assert (pcie);
@@ -313,7 +320,7 @@ static int intel_pcie_host_setup(struct intel_pcie *pcie)intel_pcie_device_rst_deassert (pcie);intel_pcie_ltssm_enable (pcie); - ret =dw_pcie_wait_for_link (pci); + ret =dw_pcie_wait_for_link (pci, port);if (ret) goto app_init_err;
drivers/pci/controller/dwc/pcie-qcom-common.c +4 -1
@@ -49,6 +49,8 @@ EXPORT_SYMBOL_GPL(qcom_pcie_common_set_16gt_equalization);void qcom_pcie_common_set_16gt_lane_margining (struct dw_pcie *pci) {u32 reg; +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list); reg =dw_pcie_readl_dbi (pci,GEN4_LANE_MARGINING_1_OFF ); reg &= ~(MARGINING_MAX_VOLTAGE_OFFSET |
@@ -70,7 +72,8 @@ void qcom_pcie_common_set_16gt_lane_margining(struct dw_pcie *pci)MARGINING_MAXLANES |MARGINING_SAMPLE_RATE_TIMING | MARGINING_SAMPLE_RATE_VOLTAGE); - reg |=FIELD_PREP (MARGINING_MAXLANES , pci->num_lanes) | + + reg |=FIELD_PREP (MARGINING_MAXLANES , port->num_lanes) |FIELD_PREP (MARGINING_SAMPLE_RATE_TIMING ,0x3f ) |FIELD_PREP (MARGINING_SAMPLE_RATE_VOLTAGE ,0x3f );dw_pcie_writel_dbi (pci,GEN4_LANE_MARGINING_2_OFF , reg);
drivers/pci/controller/dwc/pcie-qcom-ep.c +3 -1
@@ -389,6 +389,8 @@ static void qcom_pcie_disable_resources(struct qcom_pcie_ep *pcie_ep)static int qcom_pcie_perst_deassert (struct dw_pcie *pci) { +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list);struct qcom_pcie_ep *pcie_ep =to_pcie_ep (pci);struct device *dev = pci->dev;u32 val, offset;
@@ -511,7 +513,7 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci) goto err_disable_resources; } -if (pcie_link_speed[pci->max_link_speed] ==PCIE_SPEED_16_0GT ) { +if (pcie_link_speed[port->max_link_speed] ==PCIE_SPEED_16_0GT ) {qcom_pcie_common_set_16gt_equalization (pci);qcom_pcie_common_set_16gt_lane_margining (pci); }
drivers/pci/controller/dwc/pcie-qcom.c +3 -1
@@ -321,8 +321,10 @@ static void qcom_ep_reset_deassert(struct qcom_pcie *pcie)static int qcom_pcie_start_link (struct dw_pcie *pci) {struct qcom_pcie *pcie =to_qcom_pcie (pci); +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list); -if (pcie_link_speed[pci->max_link_speed] ==PCIE_SPEED_16_0GT ) { +if (pcie_link_speed[port->max_link_speed] ==PCIE_SPEED_16_0GT ) {qcom_pcie_common_set_16gt_equalization (pci);qcom_pcie_common_set_16gt_lane_margining (pci); }
drivers/pci/controller/dwc/pcie-rcar-gen4.c +10 -3
@@ -132,6 +132,8 @@ static int rcar_gen4_pcie_speed_change(struct dw_pcie *dw)static int rcar_gen4_pcie_start_link (struct dw_pcie *dw) {struct rcar_gen4_pcie *rcar =to_rcar_gen4_pcie (dw); +struct dw_pcie_port *port =list_first_entry (&dw->pp.ports, + struct dw_pcie_port, list);int i, changes, ret;if (rcar->drvdata->ltssm_control) {
@@ -144,7 +146,7 @@ static int rcar_gen4_pcie_start_link(struct dw_pcie *dw)* Require direct speed change with retrying here if the max_link_speed * is PCIe Gen2 or higher. */ - changes =min_not_zero (dw->max_link_speed,RCAR_MAX_LINK_SPEED ) -1 ; + changes =min_not_zero (port->max_link_speed,RCAR_MAX_LINK_SPEED ) -1 ;/* * Since dw_pcie_setup_rc() sets it once, PCIe Gen2 will be trained.
@@ -173,6 +175,8 @@ static void rcar_gen4_pcie_stop_link(struct dw_pcie *dw)static int rcar_gen4_pcie_common_init (struct rcar_gen4_pcie *rcar) {struct dw_pcie *dw = &rcar->dw; +struct dw_pcie_port *port =list_first_entry (&dw->pp.ports, + struct dw_pcie_port, list);u32 val;int ret;
@@ -195,7 +199,7 @@ static int rcar_gen4_pcie_common_init(struct rcar_gen4_pcie *rcar) goto err_unprepare; } -if (dw->num_lanes <4 ) +if (port->num_lanes <4 ) val |=BIFUR_MOD_SET_ON ;writel (val, rcar->base +PCIEMSR0 );
@@ -563,12 +567,15 @@ static int r8a779f0_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable)static void rcar_gen4_pcie_additional_common_init (struct rcar_gen4_pcie *rcar) {struct dw_pcie *dw = &rcar->dw; +struct dw_pcie_port *port =list_first_entry (&dw->pp.ports, + struct dw_pcie_port, list);u32 val; val =dw_pcie_readl_dbi (dw,PCIE_PORT_LANE_SKEW ); val &= ~PORT_LANE_SKEW_INSERT_MASK ; -if (dw->num_lanes <4 ) +if (port->num_lanes <4 ) val |=BIT (6 ); +dw_pcie_writel_dbi (dw,PCIE_PORT_LANE_SKEW , val); val =readl (rcar->base +PCIEPWRMNGCTRL );
drivers/pci/controller/dwc/pcie-spear13xx.c +3 -2
@@ -191,6 +191,7 @@ static int spear13xx_pcie_probe(struct platform_device *pdev)struct dw_pcie *pci;struct spear13xx_pcie *spear13xx_pcie;struct device_node *np = dev->of_node; +struct dw_pcie_port *port;int ret; spear13xx_pcie =devm_kzalloc (dev,sizeof (*spear13xx_pcie),GFP_KERNEL );
@@ -228,9 +229,9 @@ static int spear13xx_pcie_probe(struct platform_device *pdev)dev_err (dev,"couldn't enable clk for pcie\n" );return ret; } - + port = list_first_entry(&pci->pp.ports, struct dw_pcie_port, list);if (of_property_read_bool (np,"st,pcie-is-gen1" )) - pci->max_link_speed =1 ; + port->max_link_speed =1 ;platform_set_drvdata (pdev, spear13xx_pcie);
drivers/pci/controller/dwc/pcie-tegra194.c +3 -1
@@ -957,6 +957,8 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)static int tegra_pcie_dw_start_link (struct dw_pcie *pci) {struct tegra_pcie_dw *pcie =to_tegra_pcie (pci); +struct dw_pcie_port *port =list_first_entry (&pci->pp.ports, + struct dw_pcie_port, list);struct dw_pcie_rp *pp = &pci->pp;u32 val, offset, tmp;bool retry = true;
@@ -986,7 +988,7 @@ static int tegra_pcie_dw_start_link(struct dw_pcie *pci)msleep (100 ); -if (dw_pcie_wait_for_link (pci)) { +if (dw_pcie_wait_for_link (pci, port)) {if (!retry)return 0 ;/*
Signature · 1 line
2.34.1
Quoted 10 lines
Subject: [PATCH v2 0/2] PCI: dwc: Add multi-port controller support
This series adds support for multi-port PCIe controllers in the DesignWare driver. Currently, the driver only supports a single Root Port with controller-level properties, which doesn't work for multi-port controllers where each port may have different configurations.
This series introduces a per-port structure and parsing API that allows each Root Port to be configured independently via pcie@N child nodes in device tree, while maintaining backward compatibility with existing single-port bindings.
Hi Sumit,
Glad to see you've also added multi-root port support. A quick check shows this patch set seems somewhat similar to my recent patch set:
https://lore.kernel.org/all/[email protected]/
My patch set defines struct pci_host_port to hold common Root Port properties (currently only reset GPIO descriptor) and adds the pci_host_common_parse_ports() function to parse Root Port nodes from device tree.
The main difference is that I added the list of "ports" to struct pci_host_bridge for better maintain parsed Root Port information, while you added it to the DWC layer structure struct dw_pcie_rp. Actually multi-porting isn't a DWC controller-specific feature and therefore should be added to the generic layer. Please correct me if I'm wrong.
Best Regards
Sherry
Quoted 51 lines
Signed-off-by Sumit Kumar <[email protected]>---
Changes in v2:
- Fix error code preservation indw_pcie_resume_noirq()to return actual error fromdw_pcie_wait_for_link()instead of hardcoded-ETIMEDOUT(Mani).
- Initialize ret variable to-ENOENTindw_pcie_parse_root_ports()(Mani).
-dw_pcie_host_init(): Remove-ENOENTerror skipping to make parsing failures fatal for now, add TODO comment about making properties optional later (Mani).
- Link to v1:
https://lore.kernel/
.org%2Fr%2F20260105-dt-parser-v1-0- b11c63cb5e2c%40oss.qualcomm.com&data=05%7C02%7Csherry.sun%40nxp.co m%7C136fbdfd37184ddb530b08de7a7f5e19%7C686ea1d3bc2b4c6fa92cd99c5c 301635%7C0%7C0%7C639082884622870739%7CUnknown%7CTWFpbGZsb3d8e yJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiT WFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=wE1pMUEgAKP9W7vqgSf q7AprdJW2tJfnJ0rppFMtOIk%3D&reserved=0---
Sumit Kumar (2):
PCI: API changes for multi-port controller support
PCI: dwc: Add multi-port controller supportdrivers/pci/controller/dwc/pci-exynos.c | 4 +- drivers/pci/controller/dwc/pci-imx6.c | 15 +- drivers/pci/controller/dwc/pci-meson.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 175 ++++++++++++++++++- --- drivers/pci/controller/dwc/pcie-designware.c | 32 ++-- drivers/pci/controller/dwc/pcie-designware.h | 17 ++- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 13 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 5 +- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +- drivers/pci/controller/dwc/pcie-qcom.c | 4 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 13 +- drivers/pci/controller/dwc/pcie-spear13xx.c | 5 +- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +- drivers/pci/of.c | 6 +- drivers/pci/pci.h | 2 + 16 files changed, 232 insertions(+), 74 deletions(-)---
base-commit:097a6c336d0080725c626fda118ecfec448acd0f
change-id: 20251010-dt-parser-98b50ce18fc1Best regards,
--
Sumit Kumar <[email protected]>
Manivannan Sadhasivam
maintainerQuoted 10 lines · Sumit Kumar
This series adds support for multi-port PCIe controllers in the DesignWare driver. Currently, the driver only supports a single Root Port with controller-level properties, which doesn't work for multi-port controllers where each port may have different configurations.
This series introduces a per-port structure and parsing API that allows each Root Port to be configured independently via pcie@N child nodes in device tree, while maintaining backward compatibility with existing single-port bindings.
This patch touches multiple host controller drivers. I'd appreciate if the platform maintainers could test this series and give their tested-by tag to make sure we don't regress.
- Mani
Quoted 41 lines
Signed-off-by Sumit Kumar <[email protected]>---
Changes in v2:
- Fix error code preservation indw_pcie_resume_noirq()to return actual
error fromdw_pcie_wait_for_link()instead of hardcoded-ETIMEDOUT(Mani).
- Initialize ret variable to-ENOENTindw_pcie_parse_root_ports()(Mani).
-dw_pcie_host_init(): Remove-ENOENTerror skipping to make parsing
failures fatal for now, add TODO comment about making properties
optional later (Mani).
- Link to v1: https://lore.kernel.org/r/[email protected]---
Sumit Kumar (2):
PCI: API changes for multi-port controller support
PCI: dwc: Add multi-port controller supportdrivers/pci/controller/dwc/pci-exynos.c | 4 +- drivers/pci/controller/dwc/pci-imx6.c | 15 +- drivers/pci/controller/dwc/pci-meson.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 175 ++++++++++++++++++---- drivers/pci/controller/dwc/pcie-designware.c | 32 ++-- drivers/pci/controller/dwc/pcie-designware.h | 17 ++- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 13 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 5 +- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +- drivers/pci/controller/dwc/pcie-qcom.c | 4 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 13 +- drivers/pci/controller/dwc/pcie-spear13xx.c | 5 +- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +- drivers/pci/of.c | 6 +- drivers/pci/pci.h | 2 + 16 files changed, 232 insertions(+), 74 deletions(-)---
base-commit:097a6c336d0080725c626fda118ecfec448acd0f
change-id: 20251010-dt-parser-98b50ce18fc1Best regards,
Signature · 1 line
Sumit Kumar <[email protected]>
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Le 05/03/2026 à 07:20, Sumit Kumar a écrit :
Quoted 43 lines
This series adds support for multi-port PCIe controllers in the DesignWare driver. Currently, the driver only supports a single Root Port with controller-level properties, which doesn't work for multi-port controllers where each port may have different configurations.
This series introduces a per-port structure and parsing API that allows each Root Port to be configured independently via pcie@N child nodes in device tree, while maintaining backward compatibility with existing single-port bindings.
Signed-off-by Sumit Kumar <[email protected]>---
Changes in v2:
- Fix error code preservation indw_pcie_resume_noirq()to return actual
error fromdw_pcie_wait_for_link()instead of hardcoded-ETIMEDOUT(Mani).
- Initialize ret variable to-ENOENTindw_pcie_parse_root_ports()(Mani).
-dw_pcie_host_init(): Remove-ENOENTerror skipping to make parsing
failures fatal for now, add TODO comment about making properties
optional later (Mani).
- Link to v1: https://lore.kernel.org/r/[email protected]---
Sumit Kumar (2):
PCI: API changes for multi-port controller support
PCI: dwc: Add multi-port controller supportdrivers/pci/controller/dwc/pci-exynos.c | 4 +- drivers/pci/controller/dwc/pci-imx6.c | 15 +- drivers/pci/controller/dwc/pci-meson.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 175 ++++++++++++++++++---- drivers/pci/controller/dwc/pcie-designware.c | 32 ++-- drivers/pci/controller/dwc/pcie-designware.h | 17 ++- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 13 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 5 +- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +- drivers/pci/controller/dwc/pcie-qcom.c | 4 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 13 +- drivers/pci/controller/dwc/pcie-spear13xx.c | 5 +- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +- drivers/pci/of.c | 6 +- drivers/pci/pci.h | 2 + 16 files changed, 232 insertions(+), 74 deletions(-)
Quoted 5 lines
---
base-commit:097a6c336d0080725c626fda118ecfec448acd0f
change-id: 20251010-dt-parser-98b50ce18fc1Best regards,
Tested on meson-pci (boot log https://gitlab.com/amlogic-foss/abcd-linux-test/-/jobs/13677061036)
Thanks,
Neil