From: Josua Mayer <josua@solid-run.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: Conor Dooley <conor@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
"linux-phy@lists.infradead.org" <linux-phy@lists.infradead.org>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH phy 13/14] dt-bindings: phy: lynx-28g: add compatible strings per SerDes and instantiation
Date: Mon, 8 Sep 2025 16:04:45 +0000 [thread overview]
Message-ID: <fcfbea96-7978-49f6-88c6-f78fe52edb7c@solid-run.com> (raw)
In-Reply-To: <20250908153746.7mfobudenttdi4qd@skbuf>
Am 08.09.25 um 17:37 schrieb Vladimir Oltean:
> On Mon, Sep 08, 2025 at 02:02:35PM +0000, Josua Mayer wrote:
>>> My updated plan is to describe the schema rules for the compatible as
>>> follows. Is that ok with everyone?
>>>
>>> properties:
>>> compatible:
>>> oneOf:
>>> - const: fsl,lynx-28g
>>> deprecated: true
>>> - items:
>>> - const: fsl,lx2160a-serdes1
>>> - const: fsl,lynx-28g
>>> - enum:
missed fsl,lx2160a-serdes1
>>> - fsl,lx2160a-serdes2
>>> - fsl,lx2160a-serdes3
>>> - fsl,lx2162a-serdes1
>>> - fsl,lx2162a-serdes2
>> Weak objection, I think this is more complex than it should be.
>> Perhaps it was discussed before to keep two compatible strings ...:
>>
>> properties:
>> compatible:
>> items:
>> - enum:
>> - fsl,lx2160a-serdes2
>> - fsl,lx2160a-serdes3
>> - fsl,lx2162a-serdes1
>> - fsl,lx2162a-serdes2
>> - const: fsl,lynx-28g
>>
>> This will cause the dtbs_check to complain about anyone in the future
>> using it wrong.
My proposal requires two compatible strings always, or the schema will fail
to validate. Examples:
compatible = "fsl,lynx-28g";
// fails validation but driver can keep supporting it for backwards compatibility
compatible = "fsl,lx2160a-serdes1", "fsl,lynx-28g";
// valid per my proposal, functional with existing driver and future changes.
// this is how you will know it is SD #1
compatible = "fsl,lx2160a-serdes2", "fsl,lynx-28g";
// valid per my proposal, and driver can use it in the future to identify SD #2
The kernel looks in compatible strings for the *first match*.
> So just that we stay on track, this is what the submitted patch
> originally proposed:
>
> properties:
> compatible:
> oneOf:
> - items:
> - const: fsl,lynx-28g
> - items:
> - enum:
> - fsl,lx2160a-serdes1
> - fsl,lx2160a-serdes2
> - fsl,lx2160a-serdes3
> - fsl,lx2162a-serdes1
> - fsl,lx2162a-serdes2
> - const: fsl,lynx-28g
>
> Your proposal is different in the following ways:
- always require 2 compatible strings specified in combination,.
validation fails when fsl,lynx-28g string specified alone.
> - Just compatible = "fsl,lynx-28g" will produce a schema validation error, BUT
>
> - There is no compatible = "fsl,lx2160a-serdes1". I don't understand how
> you propose to describe that SerDes.
copy-paste failure, I intended to list them all, including sd1.
>
> I realize I've CCed you late on the patches. They are here:
> https://lore.kernel.org/lkml/20250904154402.300032-1-vladimir.oltean@nxp.com/
>
> One of Conor's objections was that keeping "fsl,lynx-28g" as a fallback
> compatible string may not make sense, and indeed I tried to highlight in
> my previous reply that it can lead to incorrect behaviour if SerDes #2
> is described in this way.
>
> Further trying to argue that SerDes #2 should have "fsl,lynx-28g" as a
> fallback without directly addressing the fact it results in incorrect
> behaviour is... strange.
>
> Also, SerDes #3 is not described at all, it's not necessary to introduce
> a fallback when it can be described precisely from the start.
>
>> The driver can still probe on fsl,lynx-28g alone for backwards compatibility,
>> and you can limit the feature-set as you see fit in such case.
>>
>> Main argument for always specifying lynx-28g is that the serdes blocks
>> do share a common programming model and register definitions.
> I think this is the sticking point. The blocks do share a common
> programming model, but that model does not give us a way to identify the
> supported protocols. You can try to enable a protocol converter that
> doesn't exist, and read back the enablement status, and you'll find the
> hardware reports it to be enabled (for example PCCC[SXGMIIA_CFG]).
Indeed.
>
> The snippet below is something you can try out and see for yourself (it
> will need adaptation depending on kernel revision).
>
> static void lynx_28g_lane_probe_supported(struct lynx_28g_lane *lane)
> {
> enum lynx_lane_mode lane_mode;
> unsigned long supported = 0;
> int err;
>
> for (lane_mode = LANE_MODE_UNKNOWN + 1; lane_mode < LANE_MODE_MAX; lane_mode++) {
> u32 orig_val, val;
>
> err = lynx_pccr_read(lane, lane_mode, &orig_val);
> if (err)
> continue;
>
> val = orig_val;
>
> switch (lane_mode) {
> case LANE_MODE_1000BASEKX:
> val |= PCC8_SGMIIa_KX;
> fallthrough;
> case LANE_MODE_1000BASEX_SGMII:
> val |= PCC8_SGMIIa_CFG;
> break;
> case LANE_MODE_10GBASER:
> case LANE_MODE_10GBASEKR:
> val |= PCCC_SXGMIIn_XFI;
> fallthrough;
> case LANE_MODE_USXGMII:
> val |= PCCC_SXGMIIn_CFG;
> break;
> case LANE_MODE_25GBASER:
> case LANE_MODE_25GBASEKR:
> val |= PCCD_E25Gn_CFG;
> break;
> case LANE_MODE_40GBASER_XLAUI:
> case LANE_MODE_40GBASEKR4:
> val |= PCCE_E40Gn_CFG;
> break;
> default:
> break;
> }
>
> err = lynx_pccr_write(lane, lane_mode, val);
> if (err)
> continue;
>
> err = lynx_pccr_read(lane, lane_mode, &val);
> if (err)
> continue;
>
> dev_info(&lane->phy->dev, "Protocol %d: PCCR was 0x%x, is 0x%x\n",
> lane_mode, orig_val, val);
>
> switch (lane_mode) {
> case LANE_MODE_1000BASEKX:
> if (val & PCC8_SGMIIa_KX)
> supported |= BIT(lane_mode);
> fallthrough;
> case LANE_MODE_1000BASEX_SGMII:
> if (val & PCC8_SGMIIa_CFG)
> supported |= BIT(lane_mode);
> break;
> case LANE_MODE_10GBASER:
> case LANE_MODE_10GBASEKR:
> if (val & PCCC_SXGMIIn_XFI)
> supported |= BIT(lane_mode);
> fallthrough;
> case LANE_MODE_USXGMII:
> if (val & PCCC_SXGMIIn_CFG)
> supported |= BIT(lane_mode);
> break;
> case LANE_MODE_25GBASER:
> case LANE_MODE_25GBASEKR:
> if (val & PCCD_E25Gn_CFG)
> supported |= BIT(lane_mode);
> break;
> case LANE_MODE_40GBASER_XLAUI:
> case LANE_MODE_40GBASEKR4:
> if (val & PCCE_E40Gn_CFG)
> supported |= BIT(lane_mode);
> break;
> default:
> break;
> }
>
> WARN_ON(lynx_pccr_write(lane, lane_mode, orig_val));
> }
>
> dev_info(&lane->phy->dev, "Lane supported modes: 0x%lx\n", supported);
> }
I did play with those in u-boot trying to derive dt dpmac node status from
protocol converter registers ... ... ...
> The fact that SerDes #2 works on the fsl-lx2162a-clearfog.dts is
> accidental and doesn't change the fact that describing it as
> "fsl,lynx-28g" is wrong.
It works because only the SGMII modes are used on that board.
You can however use this argument to drop driver support for the
lone fsl,lynx-28g compatible string.
> (of course, I stand corrected if someone finds
> a way to determine that 10GbE is unsupported on some lanes based on just
> the programming model, but I doubt it.)
>
> The only 3 ways to find the list of supported protocols, that are known
> to me to work, are:
> #1: list them all in the device tree (talking about tens, and the list
> is ever-expanding as the driver gets more development). This is by
> far the most complex and difficult to maintain solution and my least
> preferred.
> #2: hardcode them in the driver, based on SerDes compatible string (the
> current patch, or variations). This is my preferred variant for
> keeping the dt-bindings simple and the
> #3: like #2, but distinguish between two "fsl,lynx-28g" instances based
> on the "reg" value. This should work fine, as every SerDes block
> index is instatiated at a fixed physical address in every SoC (block
> #1: 0x1ea0000, #2: 0x1eb0000, #3: 0x1ec0000). It should directly
> address your objection, but:
> - it also requires dt-bindings maintainers buy-in.
> - this method can distinguish features of SerDes i from j, but not
> from SoC A vs B. There is an upcoming Lynx 10G driver where we
> need the per-SoC capabilities as well, and it would be good to
> have the same overall driver and dt-binding structure for both.
#4: by listing descriptive phy sub-nodes under the serdes blocks root node.
Presence indicates whether or not a lane is available,
while each node can specify the modes it supports.
Obviously this allows the device-tree author to describe invalid configurations.
But it avoids describing each combination in the driver.
next prev parent reply other threads:[~2025-09-08 16:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 15:43 [PATCH phy 00/14] Lynx 28G improvements part 1 Vladimir Oltean
2025-09-04 15:44 ` [PATCH phy 13/14] dt-bindings: phy: lynx-28g: add compatible strings per SerDes and instantiation Vladimir Oltean
2025-09-04 19:22 ` Conor Dooley
2025-09-05 10:49 ` Vladimir Oltean
2025-09-05 11:10 ` Josua Mayer
2025-09-05 11:37 ` Vladimir Oltean
2025-09-05 14:23 ` Josua Mayer
2025-09-05 14:44 ` Josua Mayer
2025-09-05 15:29 ` Vladimir Oltean
2025-09-05 15:50 ` Josua Mayer
2025-09-09 11:37 ` Vladimir Oltean
2025-09-05 18:58 ` Conor Dooley
2025-09-05 8:29 ` Krzysztof Kozlowski
2025-09-05 11:02 ` Vladimir Oltean
2025-09-05 15:41 ` Vladimir Oltean
2025-09-05 19:02 ` Conor Dooley
2025-09-08 9:37 ` Vladimir Oltean
2025-09-08 14:02 ` Josua Mayer
2025-09-08 15:37 ` Vladimir Oltean
2025-09-08 16:04 ` Josua Mayer [this message]
2025-09-09 11:35 ` Vladimir Oltean
2025-09-09 18:35 ` Conor Dooley
2025-09-09 18:58 ` Vladimir Oltean
2025-09-16 17:07 ` Vladimir Oltean
2025-09-17 10:47 ` Josua Mayer
2025-09-08 18:39 ` Conor Dooley
2025-09-04 15:44 ` [PATCH phy 14/14] phy: lynx-28g: probe on per-SoC and per-instance compatible strings Vladimir Oltean
2025-09-05 10:41 ` Ioana Ciornei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fcfbea96-7978-49f6-88c6-f78fe52edb7c@solid-run.com \
--to=josua@solid-run.com \
--cc=conor+dt@kernel.org \
--cc=conor@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ioana.ciornei@nxp.com \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=robh@kernel.org \
--cc=vkoul@kernel.org \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox