* [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable
@ 2024-07-17 21:27 Pawel Dembicki
2024-07-17 21:27 ` [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps Pawel Dembicki
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Pawel Dembicki @ 2024-07-17 21:27 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
devicetree, linux-kernel
This patch switches hardcoded RGMII transmit/receive delay to
a configurable value. Delay values are taken from the properties of
the CPU port: 'tx-internal-delay-ps' and 'rx-internal-delay-ps'.
The default value is configured to 2.0 ns to maintain backward
compatibility with existing code.
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v2:
- return -EINVAL when value is wrong
- info about default value are silenced
---
drivers/net/dsa/vitesse-vsc73xx-core.c | 70 ++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index d9d3e30fd47a..07b704a1557e 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -684,6 +684,67 @@ vsc73xx_update_vlan_table(struct vsc73xx *vsc, int port, u16 vid, bool set)
return vsc73xx_write_vlan_table_entry(vsc, vid, portmap);
}
+static int vsc73xx_configure_rgmii_port_delay(struct dsa_switch *ds)
+{
+ /* Keep 2.0 ns delay for backward complatibility */
+ u32 tx_delay = VSC73XX_GMIIDELAY_GMII0_GTXDELAY_2_0_NS;
+ u32 rx_delay = VSC73XX_GMIIDELAY_GMII0_RXDELAY_2_0_NS;
+ struct dsa_port *dp = dsa_to_port(ds, CPU_PORT);
+ struct device_node *port_dn = dp->dn;
+ struct vsc73xx *vsc = ds->priv;
+ u32 delay;
+
+ if (!of_property_read_u32(port_dn, "tx-internal-delay-ps", &delay)) {
+ switch (delay) {
+ case 0:
+ tx_delay = VSC73XX_GMIIDELAY_GMII0_GTXDELAY_NONE;
+ break;
+ case 1400:
+ tx_delay = VSC73XX_GMIIDELAY_GMII0_GTXDELAY_1_4_NS;
+ break;
+ case 1700:
+ tx_delay = VSC73XX_GMIIDELAY_GMII0_GTXDELAY_1_7_NS;
+ break;
+ case 2000:
+ break;
+ default:
+ dev_err(vsc->dev,
+ "Unsupported RGMII Transmit Clock Delay\n");
+ return -EINVAL;
+ }
+ } else {
+ dev_dbg(vsc->dev,
+ "RGMII Transmit Clock Delay isn't configured, set to 2.0 ns\n");
+ }
+
+ if (!of_property_read_u32(port_dn, "rx-internal-delay-ps", &delay)) {
+ switch (delay) {
+ case 0:
+ rx_delay = VSC73XX_GMIIDELAY_GMII0_RXDELAY_NONE;
+ break;
+ case 1400:
+ rx_delay = VSC73XX_GMIIDELAY_GMII0_RXDELAY_1_4_NS;
+ break;
+ case 1700:
+ rx_delay = VSC73XX_GMIIDELAY_GMII0_RXDELAY_1_7_NS;
+ break;
+ case 2000:
+ break;
+ default:
+ dev_err(vsc->dev,
+ "Unsupported RGMII Receive Clock Delay value\n");
+ return -EINVAL;
+ }
+ } else {
+ dev_dbg(vsc->dev,
+ "RGMII Receive Clock Delay isn't configured, set to 2.0 ns\n");
+ }
+
+ /* MII delay, set both GTX and RX delay */
+ return vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GMIIDELAY,
+ tx_delay | rx_delay);
+}
+
static int vsc73xx_setup(struct dsa_switch *ds)
{
struct vsc73xx *vsc = ds->priv;
@@ -746,10 +807,11 @@ static int vsc73xx_setup(struct dsa_switch *ds)
VSC73XX_MAC_CFG, VSC73XX_MAC_CFG_RESET);
}
- /* MII delay, set both GTX and RX delay to 2 ns */
- vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GMIIDELAY,
- VSC73XX_GMIIDELAY_GMII0_GTXDELAY_2_0_NS |
- VSC73XX_GMIIDELAY_GMII0_RXDELAY_2_0_NS);
+ /* Configure RGMII delay */
+ ret = vsc73xx_configure_rgmii_port_delay(ds);
+ if (ret)
+ return ret;
+
/* Ingess VLAN reception mask (table 145) */
vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANMASK,
0xff);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps
2024-07-17 21:27 [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Pawel Dembicki
@ 2024-07-17 21:27 ` Pawel Dembicki
2024-07-18 1:36 ` Andrew Lunn
2024-07-23 2:47 ` Rob Herring
2024-07-18 1:35 ` [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Andrew Lunn
2024-07-18 9:01 ` Paolo Abeni
2 siblings, 2 replies; 6+ messages in thread
From: Pawel Dembicki @ 2024-07-17 21:27 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
devicetree, linux-kernel
Add a schema validator to vitesse,vsc73xx.yaml for MAC-level RGMII delays
in the CPU port. Additionally, valid values for VSC73XX were defined,
and a common definition for the RX and TX valid range was created.
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v2:
- added info about default value when the rx/tx delay property
is missing
---
.../bindings/net/dsa/vitesse,vsc73xx.yaml | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml
index b99d7a694b70..7022a6afde5c 100644
--- a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml
@@ -52,6 +52,25 @@ properties:
allOf:
- $ref: dsa.yaml#/$defs/ethernet-ports
+patternProperties:
+ "^(ethernet-)?ports$":
+ additionalProperties: true
+ patternProperties:
+ "^(ethernet-)?port@6$":
+ allOf:
+ - if:
+ properties:
+ phy-mode:
+ contains:
+ enum:
+ - rgmii
+ then:
+ properties:
+ rx-internal-delay-ps:
+ $ref: "#/$defs/internal-delay-ps"
+ tx-internal-delay-ps:
+ $ref: "#/$defs/internal-delay-ps"
+
# This checks if reg is a chipselect so the device is on an SPI
# bus, the if-clause will fail if reg is a tuple such as for a
# platform device.
@@ -67,6 +86,16 @@ required:
- compatible
- reg
+$defs:
+ internal-delay-ps:
+ description:
+ Disable tunable delay lines using 0 ps, or enable them and select
+ the phase between 1400 ps and 2000 ps in increments of 300 ps.
+ When the property is missing, the delay value is set to 2000 ps
+ by default.
+ enum:
+ [0, 1400, 1700, 2000]
+
unevaluatedProperties: false
examples:
@@ -108,6 +137,8 @@ examples:
reg = <6>;
ethernet = <&gmac1>;
phy-mode = "rgmii";
+ rx-internal-delay-ps = <0>;
+ tx-internal-delay-ps = <0>;
fixed-link {
speed = <1000>;
full-duplex;
@@ -150,6 +181,8 @@ examples:
ethernet-port@6 {
reg = <6>;
ethernet = <&enet0>;
+ rx-internal-delay-ps = <0>;
+ tx-internal-delay-ps = <0>;
phy-mode = "rgmii";
fixed-link {
speed = <1000>;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps
2024-07-17 21:27 ` [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps Pawel Dembicki
@ 2024-07-18 1:36 ` Andrew Lunn
2024-07-23 2:47 ` Rob Herring
1 sibling, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-07-18 1:36 UTC (permalink / raw)
To: Pawel Dembicki
Cc: netdev, Florian Fainelli, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Linus Walleij, devicetree,
linux-kernel
On Wed, Jul 17, 2024 at 11:27:33PM +0200, Pawel Dembicki wrote:
> Add a schema validator to vitesse,vsc73xx.yaml for MAC-level RGMII delays
> in the CPU port. Additionally, valid values for VSC73XX were defined,
> and a common definition for the RX and TX valid range was created.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps
2024-07-17 21:27 ` [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps Pawel Dembicki
2024-07-18 1:36 ` Andrew Lunn
@ 2024-07-23 2:47 ` Rob Herring
1 sibling, 0 replies; 6+ messages in thread
From: Rob Herring @ 2024-07-23 2:47 UTC (permalink / raw)
To: Pawel Dembicki
Cc: netdev, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Krzysztof Kozlowski, Conor Dooley, Linus Walleij, devicetree,
linux-kernel
On Wed, Jul 17, 2024 at 11:27:33PM +0200, Pawel Dembicki wrote:
> Add a schema validator to vitesse,vsc73xx.yaml for MAC-level RGMII delays
> in the CPU port. Additionally, valid values for VSC73XX were defined,
> and a common definition for the RX and TX valid range was created.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
>
> ---
> v2:
> - added info about default value when the rx/tx delay property
> is missing
> ---
> .../bindings/net/dsa/vitesse,vsc73xx.yaml | 33 +++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml
> index b99d7a694b70..7022a6afde5c 100644
> --- a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.yaml
> @@ -52,6 +52,25 @@ properties:
> allOf:
> - $ref: dsa.yaml#/$defs/ethernet-ports
>
> +patternProperties:
> + "^(ethernet-)?ports$":
> + additionalProperties: true
> + patternProperties:
> + "^(ethernet-)?port@6$":
> + allOf:
> + - if:
> + properties:
> + phy-mode:
> + contains:
> + enum:
> + - rgmii
> + then:
> + properties:
> + rx-internal-delay-ps:
> + $ref: "#/$defs/internal-delay-ps"
> + tx-internal-delay-ps:
> + $ref: "#/$defs/internal-delay-ps"
> +
> # This checks if reg is a chipselect so the device is on an SPI
> # bus, the if-clause will fail if reg is a tuple such as for a
> # platform device.
> @@ -67,6 +86,16 @@ required:
> - compatible
> - reg
>
> +$defs:
> + internal-delay-ps:
> + description:
> + Disable tunable delay lines using 0 ps, or enable them and select
> + the phase between 1400 ps and 2000 ps in increments of 300 ps.
> + When the property is missing, the delay value is set to 2000 ps
> + by default.
default: 2000
Not freeform text.
> + enum:
> + [0, 1400, 1700, 2000]
> +
> unevaluatedProperties: false
>
> examples:
> @@ -108,6 +137,8 @@ examples:
> reg = <6>;
> ethernet = <&gmac1>;
> phy-mode = "rgmii";
> + rx-internal-delay-ps = <0>;
> + tx-internal-delay-ps = <0>;
> fixed-link {
> speed = <1000>;
> full-duplex;
> @@ -150,6 +181,8 @@ examples:
> ethernet-port@6 {
> reg = <6>;
> ethernet = <&enet0>;
> + rx-internal-delay-ps = <0>;
> + tx-internal-delay-ps = <0>;
> phy-mode = "rgmii";
> fixed-link {
> speed = <1000>;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable
2024-07-17 21:27 [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Pawel Dembicki
2024-07-17 21:27 ` [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps Pawel Dembicki
@ 2024-07-18 1:35 ` Andrew Lunn
2024-07-18 9:01 ` Paolo Abeni
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-07-18 1:35 UTC (permalink / raw)
To: Pawel Dembicki
Cc: netdev, Florian Fainelli, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Linus Walleij, devicetree,
linux-kernel
On Wed, Jul 17, 2024 at 11:27:31PM +0200, Pawel Dembicki wrote:
> This patch switches hardcoded RGMII transmit/receive delay to
> a configurable value. Delay values are taken from the properties of
> the CPU port: 'tx-internal-delay-ps' and 'rx-internal-delay-ps'.
>
> The default value is configured to 2.0 ns to maintain backward
> compatibility with existing code.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable
2024-07-17 21:27 [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Pawel Dembicki
2024-07-17 21:27 ` [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps Pawel Dembicki
2024-07-18 1:35 ` [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Andrew Lunn
@ 2024-07-18 9:01 ` Paolo Abeni
2 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2024-07-18 9:01 UTC (permalink / raw)
To: Pawel Dembicki, netdev
Cc: Andrew Lunn, Florian Fainelli, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Linus Walleij, devicetree, linux-kernel
On 7/17/24 23:27, Pawel Dembicki wrote:
> This patch switches hardcoded RGMII transmit/receive delay to
> a configurable value. Delay values are taken from the properties of
> the CPU port: 'tx-internal-delay-ps' and 'rx-internal-delay-ps'.
>
> The default value is configured to 2.0 ns to maintain backward
> compatibility with existing code.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
## Form letter - net-next-closed
The merge window for v6.11 and therefore net-next is closed for new
drivers, features, code refactoring and optimizations. We are currently
accepting bug fixes only.
Please repost when net-next reopens after July 29th.
RFC patches sent for review only are obviously welcome at any time.
See:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-23 2:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17 21:27 [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Pawel Dembicki
2024-07-17 21:27 ` [PATCH net-next v2 2/2] dt-bindings: net: dsa: vsc73xx: add {rx,tx}-internal-delay-ps Pawel Dembicki
2024-07-18 1:36 ` Andrew Lunn
2024-07-23 2:47 ` Rob Herring
2024-07-18 1:35 ` [PATCH net-next v2 1/2] net: dsa: vsc73xx: make RGMII delays configurable Andrew Lunn
2024-07-18 9:01 ` Paolo Abeni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).