* [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link
@ 2026-11-30 22:52 Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 1/3] schemas: pci: bridge: Document the REFCLK supplied to the Link Niklas Cassel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Niklas Cassel @ 2026-11-30 22:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-pci, devicetree, Bjorn Helgaas, Manivannan Sadhasivam,
Krzysztof Wilczyński, Damien Le Moal, Vincent Guittot,
Marek Vasut, Koichiro Den, Niklas Cassel
This is v2 of the ref-clk-mode proposal [1]. Hopefully this RFC v2 can be
a basis for further discussion. Anyone is welcome to take over the series.
I've personally mostly moved on from PCI stuff, but still want to help
contribute to a generic binding to describe the refclock architecture.
A generic property is still needed: S32G dropped "nxp,phy-mode" until
we agree on a generic binding [2], and a patch for R-Car Gen4 hardcodes
SRIS mode per SoC [3], although the reference clock (REFCLK)
architecture depends on the board.
Having a generic property would allow e.g. R-Car Gen4 and S32G to use
this property rather than to hardcode.
Patches 1-2 are for dt-schema, patch 3 is for the kernel.
Rob, in your review of v1 [4] you wrote:
> I think we're mixing SSC and clock sources which are mostly
> independent things to describe. SSC is configuration on top of what
> the clocking topology looks like.
Agreed. The property no longer encodes SSC, nor which end supplies the
REFCLK:
- The REFCLK that a Root Port supplies to its Link is described with
the clock binding in the Root Port node (patch 1), as you suggested
for Marek's slot clock [5], and as several R-Car DTs already do.
- SSC is configured with assigned-clock-sscs (frequency, depth and
method, not just on/off).
- The same property is used for both ends of a Link (patches 2-3).
> Let's assume we define a 'clocks' entry to represent the PCIe clock.
> We could define no clock to mean 'using the slot clock'.
I tried, but the clocks cannot reliably tell the architecture:
1) An absent clock would need a meaning ("no REFCLK supplied", "uses
the REFCLK of the host"), but in existing DTs it only means "not
described", so this would change how existing DTBs are interpreted.
2) A supplied REFCLK does not have to be used, e.g. by an FPGA card set
to its local oscillator, or by a ROCK 5B in endpoint mode. The DT of
the host is then correct, but does not tell the architecture, unless
it describes the oscillator of the card.
3) Both ends need SRIS mode if either REFCLK uses SSC, but the SSC of
the other end is unknown. Always using SRIS is not free either: DWC
based controllers do not support L0s in SRIS mode, and send SKP
Ordered Sets about ten times as often.
So v2 keeps one property, for what the clock binding cannot express:
refclk-mode = "common" | "srns" | "sris";
i.e. Common Refclk, Separate Refclk with No SSC, and Separate Refclk
with Independent SSC. It can replace vendor specific properties like
"nvidia,enable-ext-refclk", "nvidia,enable-srns" and
"rockchip,rx-common-refclk-mode", and drivers keep their default when it
is absent. It also helps discoverability: an endpoint which does not use
the REFCLK of the slot can report Slot Clock Configuration = 0, so that
the host does not enable Common Clock Configuration.
Examples:
/* Sparrow Hawk: one 9FGV0441 feeds the Root Port and the M.2 slot */
&pciec0_rp {
clocks = <&pcie_clk 1>;
refclk-mode = "common";
};
/* ROCK 5B in RC mode, connected to a ROCK 5B in EP mode */
&pcie3x4 {
refclk-mode = "srns";
};
/* ROCK 5B in EP mode, in a host whose REFCLK uses SSC */
&pcie3x4_ep {
refclk-mode = "sris";
};
/* Endpoint with an on-board REFCLK that uses SSC */
&pcie_ep {
assigned-clocks = <&refclk_gen 0>;
assigned-clock-sscs = <31500 50 CLK_SSC_DOWN_SPREAD>;
refclk-mode = "sris";
};
Open questions:
- Should refclk-mode be valid in host bridge nodes (pci-bus-common.yaml,
like num-lanes), or only in Root Port nodes (pci-pci-bridge.yaml)?
- SSC generated inside a PHY, e.g. by the RK3588 PCIe 3.0 PHY (needed
for SRIS between two ROCK 5Bs), has no clock to put
assigned-clock-sscs on. Today, PHY bindings use vendor specific
booleans for this, e.g. "rockchip,enable-ssc", "brcm,enable-ssc" and
"st,ssc-on". The PHY could instead expose its PLL output as a clock,
like the Qcom QMP PHYs do for the PIPE clock, and document that any
request within the PCIe limits selects its built-in SSC profile:
assigned-clocks = <&pcie30phy>;
assigned-clock-sscs = <31500 50 CLK_SSC_DOWN_SPREAD>;
Is that acceptable, or would you rather see a generic boolean?
Changes since v1:
- Rename ref-clk-mode to refclk-mode (Mani).
- Drop common-clk-ep and common-clk-ep-ssc, and describe the REFCLK
source and SSC with the clock binding instead (Rob).
- Add the property for Downstream Ports as well (Rob).
[1] https://lore.kernel.org/linux-pci/20250425092012.95418-2-cassel@kernel.org/
[2] https://lore.kernel.org/linux-pci/20251121164920.2008569-1-vincent.guittot@linaro.org/
[3] https://lore.kernel.org/linux-pci/20261129154135.277882-1-marek.vasut+renesas@mailbox.org/
[4] https://lore.kernel.org/linux-pci/20250519145636.GA2090206-robh@kernel.org/
[5] https://lore.kernel.org/linux-pci/20250410204845.GA1027003-robh@kernel.org/
Niklas Cassel (3):
schemas: pci: bridge: Document the REFCLK supplied to the Link
schemas: pci-bus-common: Add 'refclk-mode' property
dt-bindings: PCI: pci-ep: Add refclk-mode property
dtschema/schemas/pci/pci-bus-common.yaml | 21 +++++++++++++++++++++
dtschema/schemas/pci/pci-pci-bridge.yaml | 9 +++++++++
Documentation/devicetree/bindings/pci/pci-ep.yaml | 24 +++++++++++++++++++++++
3 files changed, 54 insertions(+)
--
2.56.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v2 1/3] schemas: pci: bridge: Document the REFCLK supplied to the Link
2026-11-30 22:52 [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
@ 2026-11-30 22:52 ` Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 2/3] schemas: pci-bus-common: Add 'refclk-mode' property Niklas Cassel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2026-11-30 22:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-pci, devicetree, Bjorn Helgaas, Manivannan Sadhasivam,
Krzysztof Wilczyński, Damien Le Moal, Vincent Guittot,
Marek Vasut, Koichiro Den, Niklas Cassel
Several boards describe the reference clock (REFCLK) that the platform
supplies to a slot, or to a device soldered down on the board, using a
clocks property in the Root Port node, e.g. the R-Car Sparrow Hawk,
Salvator-X(S), ULCB-KF and Geist boards. The Linux PCI slot power
control driver enables this clock when powering on the slot.
Document the property in the PCI-PCI bridge schema, since the REFCLK is
supplied to the Link of a Downstream Port, not to the host bridge. The
spread spectrum clocking (SSC) configuration of the REFCLK can then be
described using the standard assigned-clock-sscs property.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
dtschema/schemas/pci/pci-pci-bridge.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dtschema/schemas/pci/pci-pci-bridge.yaml b/dtschema/schemas/pci/pci-pci-bridge.yaml
index 39a53eb..38552a6 100644
--- a/dtschema/schemas/pci/pci-pci-bridge.yaml
+++ b/dtschema/schemas/pci/pci-pci-bridge.yaml
@@ -28,6 +28,15 @@ properties:
contains:
const: pciclass,0604
+ clocks:
+ description:
+ The reference clock (REFCLK) that the platform supplies to the Link of
+ this Downstream Port, e.g. the REFCLK of a slot or of a connector, or the
+ REFCLK input of a device soldered down on the board. The spread spectrum
+ clocking (SSC) configuration of this clock is described by the
+ assigned-clocks and assigned-clock-sscs properties.
+ maxItems: 1
+
port:
$ref: /schemas/graph.yaml#/properties/port
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH v2 2/3] schemas: pci-bus-common: Add 'refclk-mode' property
2026-11-30 22:52 [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 1/3] schemas: pci: bridge: Document the REFCLK supplied to the Link Niklas Cassel
@ 2026-11-30 22:52 ` Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 3/3] dt-bindings: PCI: pci-ep: Add refclk-mode property Niklas Cassel
2026-11-30 23:38 ` [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
3 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2026-11-30 22:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-pci, devicetree, Bjorn Helgaas, Manivannan Sadhasivam,
Krzysztof Wilczyński, Damien Le Moal, Vincent Guittot,
Marek Vasut, Koichiro Den, Niklas Cassel
The PCIe Base Specification defines a Common Refclk architecture, where
both ends of a Link use the same reference clock (REFCLK), and separate
REFCLK architectures with No SSC (SRNS) or with Independent SSC (SRIS).
The architecture has to be known before Link training, e.g. both ends of
the Link have to schedule SKP Ordered Sets much more frequently in SRIS
mode, and some PHYs need a different receiver configuration for separate
REFCLKs.
The architecture depends on how the REFCLK of each end of the Link is
provided, which is not discoverable, and which cannot be derived
reliably from the clocks described in DT:
- Deriving it would require an absent clock to have a meaning, e.g. "the
Root Port does not supply a REFCLK" or "the endpoint uses the REFCLK
supplied by the host". In almost all existing DTs, an absent REFCLK
only means that it is not described, so such a rule would change how
existing DTs are interpreted.
- A Root Port which supplies a REFCLK to a slot has the same clocks,
regardless of whether the device in the slot uses that REFCLK, or a
REFCLK of its own, e.g. an FPGA card set to use its local oscillator.
Describing the latter would require describing the REFCLK of a plug-in
card, or of another board, in the DT of the host.
- Both ends have to operate in SRIS mode if either REFCLK uses SSC, but
the SSC configuration of the REFCLK of the other end is not known.
Always using SRIS for separate REFCLKs is not an option either, since
SRIS is not free, e.g. DWC based controllers do not support L0s in
SRIS mode.
Add a 'refclk-mode' property, which describes the REFCLK architecture of
the Link. Who supplies the REFCLK, and its SSC configuration, are still
described using the clock binding, so the property only describes what
the clock binding cannot.
Today, this is either hardcoded in drivers, or configured using vendor
specific properties, e.g. "nvidia,enable-ext-refclk", "nvidia,enable-srns"
and "rockchip,rx-common-refclk-mode".
The same property is added to the PCI endpoint controller binding in
Linux, so that both ends of a Link are described the same way.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
dtschema/schemas/pci/pci-bus-common.yaml | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dtschema/schemas/pci/pci-bus-common.yaml b/dtschema/schemas/pci/pci-bus-common.yaml
index bfac42a..5376bed 100644
--- a/dtschema/schemas/pci/pci-bus-common.yaml
+++ b/dtschema/schemas/pci/pci-bus-common.yaml
@@ -160,6 +160,27 @@ properties:
not to advertise ASPM L1 Sub-States support if there is no CLKREQ signal.
type: boolean
+ refclk-mode:
+ description: |
+ The reference clock (REFCLK) architecture of the Link, as defined by
+ the PCIe Base Specification. It depends on how the REFCLK of each end
+ of the Link is provided, which is not discoverable, but has to be known
+ before Link training, e.g. to configure SRIS mode, or the receiver of
+ the PHY.
+
+ common: Common Refclk. Both ends of the Link use the same REFCLK.
+ srns: Separate Refclk with No SSC. Each end of the Link uses its own
+ REFCLK, and neither of them uses spread spectrum clocking (SSC).
+ sris: Separate Refclk with Independent SSC. Each end of the Link uses
+ its own REFCLK, and at least one of them uses SSC.
+
+ The SSC configuration of a REFCLK provided by the platform is described
+ by the assigned-clock-sscs property. Note that both ends of the Link
+ have to operate in SRIS mode if either REFCLK uses SSC, so the
+ architecture cannot be derived from the local SSC configuration alone.
+ $ref: /schemas/types.yaml#/definitions/string
+ enum: [ common, srns, sris ]
+
aspm-no-l0s:
description: Disables ASPM L0s capability
type: boolean
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH v2 3/3] dt-bindings: PCI: pci-ep: Add refclk-mode property
2026-11-30 22:52 [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 1/3] schemas: pci: bridge: Document the REFCLK supplied to the Link Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 2/3] schemas: pci-bus-common: Add 'refclk-mode' property Niklas Cassel
@ 2026-11-30 22:52 ` Niklas Cassel
2026-11-30 23:38 ` [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
3 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2026-11-30 22:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-pci, devicetree, Bjorn Helgaas, Manivannan Sadhasivam,
Krzysztof Wilczyński, Damien Le Moal, Vincent Guittot,
Marek Vasut, Koichiro Den, Niklas Cassel
The PCIe Base Specification defines a Common Refclk architecture, where
both ends of a Link use the same reference clock (REFCLK), and separate
REFCLK architectures with No SSC (SRNS) or with Independent SSC (SRIS).
The architecture has to be known before Link training, e.g. to configure
SRIS mode.
For an endpoint, the architecture depends on the board design: whether
the board can use the REFCLK that the host supplies through the
connector, or uses a REFCLK of its own, and whether spread spectrum
clocking (SSC) is used. This is not discoverable, and cannot be derived
reliably from the clocks of the endpoint:
- In existing DTs, an absent local REFCLK only means that it is not
described, so it cannot be taken to mean that the endpoint uses the
REFCLK supplied by the host.
- An endpoint with a separate REFCLK without SSC still has to operate in
SRIS mode if the REFCLK of the host uses SSC.
Add a 'refclk-mode' property, with the same name and values as the
property for the Downstream Port side in the dt-schema pci-bus-common
schema, so that both ends of a Link are described the same way. A REFCLK
local to the endpoint, and its SSC configuration, are described using
the clock binding.
Some endpoint controller bindings already have vendor specific
properties for this, e.g. "nvidia,enable-ext-refclk" (Common Refclk) and
"nvidia,enable-srns" (SRNS).
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
.../devicetree/bindings/pci/pci-ep.yaml | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/Documentation/devicetree/bindings/pci/pci-ep.yaml b/Documentation/devicetree/bindings/pci/pci-ep.yaml
index baeb583..626dd71 100644
--- a/Documentation/devicetree/bindings/pci/pci-ep.yaml
+++ b/Documentation/devicetree/bindings/pci/pci-ep.yaml
@@ -110,6 +110,30 @@ properties:
default: 1
maximum: 16
+ refclk-mode:
+ description: |
+ The reference clock (REFCLK) architecture of the Link, as defined by
+ the PCIe Base Specification. It depends on how the REFCLK of each end
+ of the Link is provided, which is not discoverable, but has to be known
+ before Link training, e.g. to configure SRIS mode, or the receiver of
+ the PHY.
+
+ common: Common Refclk. Both ends of the Link use the same REFCLK,
+ typically the REFCLK that the host supplies through the connector.
+ srns: Separate Refclk with No SSC. Each end of the Link uses its own
+ REFCLK, and neither of them uses spread spectrum clocking (SSC).
+ sris: Separate Refclk with Independent SSC. Each end of the Link uses
+ its own REFCLK, and at least one of them uses SSC.
+
+ A REFCLK local to the endpoint (e.g. a PLL internal to the SoC, or a
+ clock generator on the board) is described using the clock binding, as
+ defined by the device specific binding, and its SSC configuration by the
+ assigned-clock-sscs property. Note that both ends of the Link have to
+ operate in SRIS mode if either REFCLK uses SSC, so the architecture
+ cannot be derived from the local SSC configuration alone.
+ $ref: /schemas/types.yaml#/definitions/string
+ enum: [ common, srns, sris ]
+
linux,pci-domain:
description:
If present this property assigns a fixed PCI domain number to a PCI
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link
2026-11-30 22:52 [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
` (2 preceding siblings ...)
2026-11-30 22:52 ` [RFC PATCH v2 3/3] dt-bindings: PCI: pci-ep: Add refclk-mode property Niklas Cassel
@ 2026-11-30 23:38 ` Niklas Cassel
3 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2026-11-30 23:38 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-pci, devicetree, Bjorn Helgaas, Manivannan Sadhasivam,
Krzysztof Wilczyński, Damien Le Moal, Vincent Guittot,
Marek Vasut, Koichiro Den
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
On Mon, Nov 30, 2026 at 11:52:55PM +0100, Niklas Cassel wrote:
> i.e. Common Refclk, Separate Refclk with No SSC, and Separate Refclk
> with Independent SSC. It can replace vendor specific properties like
> "nvidia,enable-ext-refclk", "nvidia,enable-srns" and
> "rockchip,rx-common-refclk-mode", and drivers keep their default when it
> is absent. It also helps discoverability: an endpoint which does not use
> the REFCLK of the slot can report Slot Clock Configuration = 0, so that
> the host does not enable Common Clock Configuration.
Since Krzysztof asked for a user of this property on the RFC v1:
https://lore.kernel.org/linux-pci/51fa853a-61d6-4c8f-8636-80cce90d0a94@kernel.org/
Attaching a patch (compile tested only) that clears the Slot Clock
Configuration bit in the Link Status register for the DWC driver
(if the Link uses separate REFCLKs - i.e. SRNS or SRIS).
This is what the Tegra194 driver already does for its vendor specific
"nvidia,enable-srns" property, but this really ought to be done in
common DWC code and not in the glue drivers themselves (using the new
generic property).
I should probably have included this as a 4/4 in this series, but as
mentioned in the cover-letter, a generic binding is also needed for
R-Car Gen4 and S32G, but I guess they would send follow-up series.
Kind regards,
Niklas
[-- Attachment #2: 0001-PCI-dwc-Clear-Slot-Clock-Configuration-for-separate-.patch --]
[-- Type: text/plain, Size: 6592 bytes --]
From 4c610c4ede52abf25f8f5c3d17314b9a552c0b03 Mon Sep 17 00:00:00 2001
From: Niklas Cassel <cassel@kernel.org>
Date: Tue, 1 Dec 2026 00:08:30 +0100
Subject: [PATCH] PCI: dwc: Clear Slot Clock Configuration for separate
reference clocks
The Slot Clock Configuration bit in the Link Status register indicates
that a component uses the same physical reference clock (REFCLK) that
the platform provides on the connector. The bit is HwInit, and in the
DWC controller its value after reset is a synthesis parameter, so it can
be wrong for a given board, e.g. for an endpoint which uses a REFCLK of
its own instead of the REFCLK of the slot.
If both ends of a Link report Slot Clock Configuration, the PCI core
enables Common Clock Configuration (see
pcie_aspm_configure_common_clock()), even if the REFCLKs are separate.
Parse the generic refclk-mode property, from the controller node or
from the Root Port node, and clear Slot Clock Configuration if the Link
uses separate REFCLKs (SRNS or SRIS). For a multi-function endpoint,
clear it for all functions, since all functions have to report the same
value. Keep the value after reset if the property is absent or set to
"common". The read-modify-write masks the RW1C status bits of the Link
Status register, so that they are not cleared by accident.
This is what the Tegra194 driver already does for its vendor specific
"nvidia,enable-srns" property.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
.../pci/controller/dwc/pcie-designware-ep.c | 11 +++++
drivers/pci/controller/dwc/pcie-designware.c | 48 +++++++++++++++++++
drivers/pci/controller/dwc/pcie-designware.h | 14 ++++++
3 files changed, 73 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index e6060bb0bbbd..5dfa9ba26392 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -1251,6 +1251,7 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci)
u8 funcs = ep->epc->max_functions;
u32 func0_lnkcap, lnkcap;
u8 func_no, offset;
+ u16 lnksta;
dw_pcie_dbi_ro_wr_en(pci);
@@ -1281,6 +1282,16 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci)
&lnkcap, func0_lnkcap);
dw_pcie_ep_writel_dbi(ep, func_no,
offset + PCI_EXP_LNKCAP, lnkcap);
+
+ if (!dw_pcie_refclk_is_separate(pci))
+ continue;
+
+ lnksta = dw_pcie_ep_readw_dbi(ep, func_no,
+ offset + PCI_EXP_LNKSTA);
+ lnksta &= ~(PCI_EXP_LNKSTA_SLC | PCI_EXP_LNKSTA_LBMS |
+ PCI_EXP_LNKSTA_LABS);
+ dw_pcie_ep_writew_dbi(ep, func_no,
+ offset + PCI_EXP_LNKSTA, lnksta);
}
}
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 12f102f48d5d..985b248cb6c0 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -17,6 +17,7 @@
#include <linux/ioport.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_pci.h>
#include <linux/pcie-dwc.h>
#include <linux/platform_device.h>
#include <linux/sizes.h>
@@ -111,6 +112,38 @@ static int dw_pcie_get_resets(struct dw_pcie *pci)
return 0;
}
+static enum dw_pcie_refclk_mode dw_pcie_of_get_refclk_mode(struct device *dev,
+ struct device_node *np)
+{
+ static const char * const modes[] = { "common", "srns", "sris" };
+ const char *mode;
+ int ret;
+
+ if (of_property_read_string(np, "refclk-mode", &mode))
+ return DW_PCIE_REFCLK_MODE_UNSPECIFIED;
+
+ ret = match_string(modes, ARRAY_SIZE(modes), mode);
+ if (ret < 0) {
+ dev_warn(dev, "Invalid refclk-mode \"%s\"\n", mode);
+ return DW_PCIE_REFCLK_MODE_UNSPECIFIED;
+ }
+
+ return DW_PCIE_REFCLK_MODE_COMMON + ret;
+}
+
+static void dw_pcie_get_refclk_mode(struct dw_pcie *pci)
+{
+ struct device_node *np = dev_of_node(pci->dev);
+ struct device_node *rp;
+
+ pci->refclk_mode = dw_pcie_of_get_refclk_mode(pci->dev, np);
+
+ rp = of_pci_find_child_device(np, 0);
+ if (rp && of_property_present(rp, "refclk-mode"))
+ pci->refclk_mode = dw_pcie_of_get_refclk_mode(pci->dev, rp);
+ of_node_put(rp);
+}
+
int dw_pcie_get_resources(struct dw_pcie *pci)
{
struct platform_device *pdev = to_platform_device(pci->dev);
@@ -198,6 +231,8 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
of_property_read_u32(np, "num-lanes", &pci->num_lanes);
+ dw_pcie_get_refclk_mode(pci);
+
if (of_property_read_bool(np, "snps,enable-cdm-check"))
dw_pcie_cap_set(pci, CDM_CHECK);
@@ -1268,6 +1303,16 @@ void dw_pcie_program_t_power_on(struct dw_pcie *pci, u32 t_power_on)
dw_pcie_dbi_ro_wr_dis(pci);
}
+static void dw_pcie_clear_slot_clk_config(struct dw_pcie *pci)
+{
+ u8 offset = dw_pcie_get_pcie_cap(pci);
+ u16 val;
+
+ val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
+ val &= ~(PCI_EXP_LNKSTA_SLC | PCI_EXP_LNKSTA_LBMS | PCI_EXP_LNKSTA_LABS);
+ dw_pcie_writew_dbi(pci, offset + PCI_EXP_LNKSTA, val);
+}
+
void dw_pcie_setup(struct dw_pcie *pci)
{
u32 val;
@@ -1304,6 +1349,9 @@ void dw_pcie_setup(struct dw_pcie *pci)
dw_pcie_writel_dbi(pci, PORT_LINK_CTRL, val);
dw_pcie_link_set_max_link_width(pci, pci->num_lanes);
+
+ if (dw_pcie_refclk_is_separate(pci))
+ dw_pcie_clear_slot_clk_config(pci);
}
resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci,
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 6d788aa00011..202c68dcf8db 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -340,6 +340,13 @@ enum dw_pcie_device_mode {
DW_PCIE_RC_TYPE,
};
+enum dw_pcie_refclk_mode {
+ DW_PCIE_REFCLK_MODE_UNSPECIFIED,
+ DW_PCIE_REFCLK_MODE_COMMON,
+ DW_PCIE_REFCLK_MODE_SRNS,
+ DW_PCIE_REFCLK_MODE_SRIS,
+};
+
enum dw_pcie_app_clk {
DW_PCIE_DBI_CLK,
DW_PCIE_MSTR_CLK,
@@ -566,6 +573,7 @@ struct dw_pcie {
unsigned long caps;
int num_lanes;
int max_link_speed;
+ enum dw_pcie_refclk_mode refclk_mode;
u8 n_fts[2];
struct dw_edma_chip edma;
phys_addr_t edma_reg_phys;
@@ -660,6 +668,12 @@ static inline u16 dw_pcie_readw_dbi(struct dw_pcie *pci, u32 reg)
return dw_pcie_read_dbi(pci, reg, 0x2);
}
+static inline bool dw_pcie_refclk_is_separate(struct dw_pcie *pci)
+{
+ return pci->refclk_mode == DW_PCIE_REFCLK_MODE_SRNS ||
+ pci->refclk_mode == DW_PCIE_REFCLK_MODE_SRIS;
+}
+
static inline void dw_pcie_writeb_dbi(struct dw_pcie *pci, u32 reg, u8 val)
{
dw_pcie_write_dbi(pci, reg, 0x1, val);
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 23:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:52 [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 1/3] schemas: pci: bridge: Document the REFCLK supplied to the Link Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 2/3] schemas: pci-bus-common: Add 'refclk-mode' property Niklas Cassel
2026-11-30 22:52 ` [RFC PATCH v2 3/3] dt-bindings: PCI: pci-ep: Add refclk-mode property Niklas Cassel
2026-11-30 23:38 ` [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Niklas Cassel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox