Skip to content

Commit 5e9a5af

Browse files
John MadieuMani-Sadhasivam
authored andcommitted
PCI: rzg3s-host: Add PCIe Gen3 (8.0 GT/s) link speed support
Extend the link speed configuration to support Gen3 (8.0 GT/s) in addition to Gen2 (5.0 GT/s). This is required for RZ/G3E PCIe host support, which is Gen3 capable. Instead of relying on DT max-link-speed for configuration, read the hardware capabilities from the PCI_EXP_LNKCAP register to determine the maximum supported speed. The DT max-link-speed property is now only used as an optional limit when explicitly specified, which aligns with PCIe subsystem expectations. Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # RZ/V2N EVK Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://patch.msgid.link/20260306143423.19562-12-john.madieu.xa@bp.renesas.com
1 parent 1e75d2e commit 5e9a5af

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

drivers/pci/controller/pcie-rzg3s-host.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,9 @@ static int rzg3s_pcie_set_max_link_speed(struct rzg3s_pcie_host *host)
10041004
{
10051005
u32 remote_supported_link_speeds, max_supported_link_speeds;
10061006
u32 cs2, tmp, pcie_cap = RZG3S_PCI_CFG_PCIEC;
1007-
u32 cur_link_speed, link_speed;
1007+
u32 cur_link_speed, link_speed, hw_max_speed;
10081008
u8 ltssm_state_l0 = 0xc;
1009+
u32 lnkcap;
10091010
int ret;
10101011
u16 ls;
10111012

@@ -1025,7 +1026,22 @@ static int rzg3s_pcie_set_max_link_speed(struct rzg3s_pcie_host *host)
10251026
ls = readw_relaxed(host->pcie + pcie_cap + PCI_EXP_LNKSTA);
10261027
cs2 = readl_relaxed(host->axi + RZG3S_PCI_PCSTAT2);
10271028

1028-
switch (pcie_link_speed[host->max_link_speed]) {
1029+
/* Read hardware supported link speed from Link Capabilities Register */
1030+
lnkcap = readl_relaxed(host->pcie + pcie_cap + PCI_EXP_LNKCAP);
1031+
hw_max_speed = FIELD_GET(PCI_EXP_LNKCAP_SLS, lnkcap);
1032+
1033+
/*
1034+
* Use DT max-link-speed only as a limit. If specified and lower
1035+
* than hardware capability, cap to that value.
1036+
*/
1037+
if (host->max_link_speed > 0 && host->max_link_speed < hw_max_speed)
1038+
hw_max_speed = host->max_link_speed;
1039+
1040+
switch (pcie_link_speed[hw_max_speed]) {
1041+
case PCIE_SPEED_8_0GT:
1042+
max_supported_link_speeds = GENMASK(PCI_EXP_LNKSTA_CLS_8_0GB - 1, 0);
1043+
link_speed = PCI_EXP_LNKCTL2_TLS_8_0GT;
1044+
break;
10291045
case PCIE_SPEED_5_0GT:
10301046
max_supported_link_speeds = GENMASK(PCI_EXP_LNKSTA_CLS_5_0GB - 1, 0);
10311047
link_speed = PCI_EXP_LNKCTL2_TLS_5_0GT;
@@ -1041,10 +1057,10 @@ static int rzg3s_pcie_set_max_link_speed(struct rzg3s_pcie_host *host)
10411057
remote_supported_link_speeds &= max_supported_link_speeds;
10421058

10431059
/*
1044-
* Return if max link speed is already set or the connected device
1060+
* Return if target link speed is already set or the connected device
10451061
* doesn't support it.
10461062
*/
1047-
if (cur_link_speed == host->max_link_speed ||
1063+
if (cur_link_speed == hw_max_speed ||
10481064
remote_supported_link_speeds != max_supported_link_speeds)
10491065
return 0;
10501066

@@ -1632,8 +1648,6 @@ static int rzg3s_pcie_probe(struct platform_device *pdev)
16321648
host->pcie = host->axi + RZG3S_PCI_CFG_BASE;
16331649

16341650
host->max_link_speed = of_pci_get_max_link_speed(np);
1635-
if (host->max_link_speed < 0)
1636-
host->max_link_speed = 2;
16371651

16381652
ret = rzg3s_pcie_host_parse_port(host);
16391653
if (ret)

0 commit comments

Comments
 (0)