Skip to content

Commit a8a3bdd

Browse files
author
Paolo Abeni
committed
Merge branch 'follow-up-to-rgmii-mode-clarification-am65-cpsw-fix-checkpatch'
Matthias Schiffer says: ==================== Follow-up to RGMII mode clarification: am65-cpsw fix + checkpatch Following previous discussion [1] and the documentation update by Andrew [2]: Fix up the mode to account for the fixed TX delay on the AM65 CPSW Ethernet controllers, similar to the way the icssg-prueth does it. For backwards compatibility, the "impossible" modes that claim to have a delay on the PCB are still accepted, but trigger a warning message. As Andrew suggested, I have also added a checkpatch check that requires a comment for any RGMII mode that is not "rgmii-id". No Device Trees are updated to avoid the warning for now, to give other projects syncing the Linux Device Trees some time to fix their drivers as well. I intend to submit an equivalent change for U-Boot's am65-cpsw-nuss driver as soon as the changes are accepted for Linux. [1] https://lore.kernel.org/lkml/[email protected]/ [2] https://lore.kernel.org/all/[email protected]/ commit c360eb0 ("dt-bindings: net: ethernet-controller: Add informative text about RGMII delays") v1: https://lore.kernel.org/all/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents a9b24b3 + e02adac commit a8a3bdd

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

Documentation/dev-tools/checkpatch.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,15 @@ Comments
495495

496496
See: https://lore.kernel.org/lkml/20131006222342.GT19510@leaf/
497497

498+
**UNCOMMENTED_RGMII_MODE**
499+
Historically, the RGMII PHY modes specified in Device Trees have been
500+
used inconsistently, often referring to the usage of delays on the PHY
501+
side rather than describing the board.
502+
503+
PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" modes require the clock
504+
signal to be delayed on the PCB; this unusual configuration should be
505+
described in a comment. If they are not (meaning that the delay is realized
506+
internally in the MAC or PHY), "rgmii-id" is the correct PHY mode.
498507

499508
Commit message
500509
--------------

Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ examples:
284284
ti,syscon-efuse = <&mcu_conf 0x200>;
285285
phys = <&phy_gmii_sel 1>;
286286
287-
phy-mode = "rgmii-rxid";
287+
phy-mode = "rgmii-id";
288288
phy-handle = <&phy0>;
289289
};
290290
};

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,7 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
26022602
return -ENOENT;
26032603

26042604
for_each_child_of_node(node, port_np) {
2605+
phy_interface_t phy_if;
26052606
struct am65_cpsw_port *port;
26062607
u32 port_id;
26072608

@@ -2667,14 +2668,36 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
26672668

26682669
/* get phy/link info */
26692670
port->slave.port_np = of_node_get(port_np);
2670-
ret = of_get_phy_mode(port_np, &port->slave.phy_if);
2671+
ret = of_get_phy_mode(port_np, &phy_if);
26712672
if (ret) {
26722673
dev_err(dev, "%pOF read phy-mode err %d\n",
26732674
port_np, ret);
26742675
goto of_node_put;
26752676
}
26762677

2677-
ret = phy_set_mode_ext(port->slave.ifphy, PHY_MODE_ETHERNET, port->slave.phy_if);
2678+
/* CPSW controllers supported by this driver have a fixed
2679+
* internal TX delay in RGMII mode. Fix up PHY mode to account
2680+
* for this and warn about Device Trees that claim to have a TX
2681+
* delay on the PCB.
2682+
*/
2683+
switch (phy_if) {
2684+
case PHY_INTERFACE_MODE_RGMII_ID:
2685+
phy_if = PHY_INTERFACE_MODE_RGMII_RXID;
2686+
break;
2687+
case PHY_INTERFACE_MODE_RGMII_TXID:
2688+
phy_if = PHY_INTERFACE_MODE_RGMII;
2689+
break;
2690+
case PHY_INTERFACE_MODE_RGMII:
2691+
case PHY_INTERFACE_MODE_RGMII_RXID:
2692+
dev_warn(dev,
2693+
"RGMII mode without internal TX delay unsupported; please fix your Device Tree\n");
2694+
break;
2695+
default:
2696+
break;
2697+
}
2698+
2699+
port->slave.phy_if = phy_if;
2700+
ret = phy_set_mode_ext(port->slave.ifphy, PHY_MODE_ETHERNET, phy_if);
26782701
if (ret)
26792702
goto of_node_put;
26802703

scripts/checkpatch.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,6 +3741,18 @@ sub process {
37413741
}
37423742
}
37433743

3744+
# Check for RGMII phy-mode with delay on PCB
3745+
if ($realfile =~ /\.(dts|dtsi|dtso)$/ &&
3746+
$line =~ /^\+\s*(phy-mode|phy-connection-type)\s*=\s*"/ &&
3747+
!ctx_has_comment($first_line, $linenr)) {
3748+
my $prop = $1;
3749+
my $mode = get_quoted_string($line, $rawline);
3750+
if ($mode =~ /^"rgmii(?:|-rxid|-txid)"$/) {
3751+
WARN("UNCOMMENTED_RGMII_MODE",
3752+
"$prop $mode without comment -- delays on the PCB should be described, otherwise use \"rgmii-id\"\n" . $herecurr);
3753+
}
3754+
}
3755+
37443756
# check for using SPDX license tag at beginning of files
37453757
if ($realline == $checklicenseline) {
37463758
if ($rawline =~ /^[ \+]\s*\#\!\s*\//) {

0 commit comments

Comments
 (0)