[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220426132139.26761-11-linux@fw-web.de>
Date: Tue, 26 Apr 2022 15:21:38 +0200
From: Frank Wunderlich <linux@...web.de>
To: linux-rockchip@...ts.infradead.org
Cc: Frank Wunderlich <frank-w@...lic-files.de>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Heiko Stuebner <heiko@...ech.de>,
Kishon Vijay Abraham I <kishon@...com>,
Vinod Koul <vkoul@...nel.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Krzysztof WilczyĆski <kw@...ux.com>,
Philipp Zabel <p.zabel@...gutronix.de>,
Johan Jonker <jbx6244@...il.com>,
Peter Geis <pgwipeout@...il.com>,
Michael Riesch <michael.riesch@...fvision.net>,
linux-pci@...r.kernel.org, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-phy@...ts.infradead.org
Subject: [RFC/RFT v2 10/11] PCI: rockchip: add a lane-map to rockchip pcie driver
From: Frank Wunderlich <frank-w@...lic-files.de>
Add a basic lane-map to define which PCIe lanes should be
used with this controller.
Rockchip driver uses this for bifurcation (true/false) based
on lanes should be splitted across controllers or not.
On rk3568 there are 2 PCIe Controllers which share PCIe lanes.
pcie3x1: pcie@...70000 //lane1 when using 1+1
pcie3x2: pcie@...80000 //lane0 when using 1+1
This ends up in one Controller (pcie3x1) uses lane-map = <0 1>; and
the other lane-map = <1 0>; (pcie3x2)
This means there are 2 lanes (count of numbers), one (by position)
is mapped to the first controller, the other one is used on the other
controller.
In this driver the lane-map is simply converted to the bifurcation
bool instead of direct mapping a specific lane to a controller.
Signed-off-by: Frank Wunderlich <frank-w@...lic-files.de>
---
v2:
- new patch
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 79e909df241c..21cb697a5be1 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -60,6 +60,7 @@ struct rockchip_pcie {
struct regulator *vpcie3v3;
struct irq_domain *irq_domain;
bool bifurcation;
+ u32 lane_map[2];
};
static int rockchip_pcie_readl_apb(struct rockchip_pcie *rockchip,
@@ -293,8 +294,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rockchip_pcie *rockchip;
+ unsigned int lanecnt = 0;
struct pcie_port *pp;
int ret;
+ int len;
rockchip = devm_kzalloc(dev, sizeof(*rockchip), GFP_KERNEL);
if (!rockchip)
@@ -327,8 +330,16 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
}
}
- if (device_property_read_bool(dev, "bifurcation"))
- rockchip->bifurcation = true;
+ len = of_property_read_variable_u32_array(dev->of_node, "lane-map", rockchip->lane_map,
+ 2, ARRAY_SIZE(rockchip->lane_map));
+
+ for (int i = 0; i < len; i++)
+ if (rockchip->lane_map[i])
+ lanecnt++;
+
+ rockchip->bifurcation = ((lanecnt > 0) && (lanecnt != len));
+
+ dev_info(dev, "bifurcation: %s\n", rockchip->bifurcation ? "true" : "false");
ret = rockchip_pcie_phy_init(rockchip);
if (ret)
--
2.25.1
Powered by blists - more mailing lists