Page MenuHomeFreeBSD

mccomphy: add support for YT8531
ClosedPublic

Authored by mhorne on Apr 29 2025, 4:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 23, 6:36 PM
Unknown Object (File)
Tue, Jun 17, 3:51 AM
Unknown Object (File)
Tue, Jun 17, 2:14 AM
Unknown Object (File)
Sat, Jun 14, 10:17 PM
Unknown Object (File)
Mon, Jun 9, 11:56 AM
Unknown Object (File)
Fri, Jun 6, 9:57 PM
Unknown Object (File)
Wed, Jun 4, 5:18 PM
Unknown Object (File)
Wed, Jun 4, 12:24 AM
Subscribers

Details

Summary

Attempt #2, this time with proper conditional FDT.

Co-authored-by: mhorne

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

@jsihv_gmx.com you might have seen, I merged this functionality but had to revert as it broke the build on amd64 (!FDT). Here is an updated version which addresses this.

sys/dev/mii/mcommphy.c
256–266

I attempted to simplify this delay logic, from your previous version. Notably we do not need to validate that the value is divisible by 150; the division operation will round down.

Does this look sane/correct? Maybe the values need an upper bound.

From sys/contrib/device-tree/Bindings/net/motorcomm,yt8xxx.yaml:

rx-internal-delay-ps:
  description: |
    RGMII RX Clock Delay used only when PHY operates in RGMII mode with
    internal delay (phy-mode is 'rgmii-id' or 'rgmii-rxid') in pico-seconds.
  enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650,
          1800, 1900, 1950, 2050, 2100, 2200, 2250, 2350, 2500, 2650, 2800,
          2950, 3100, 3250, 3400, 3550, 3700, 3850, 4000, 4150 ]
  default: 1950

tx-internal-delay-ps:
  description: |
    RGMII TX Clock Delay used only when PHY operates in RGMII mode with
    internal delay (phy-mode is 'rgmii-id' or 'rgmii-txid') in pico-seconds.
  enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800,
          1950, 2100, 2250 ]
  default: 1950
268–383

I split the FDT parsing code into a separate function here, which is called before the other setup logic.

sys/dev/mii/mcommphy.c
245

will drop this.

sys/dev/mii/mcommphy.c
49

For building on AMD64 also this #include of mii_fdt.h header requires to be omitted with #ifdef FDT

256–266

I confirm these changes are correct. Checking is not needed here though a sane FDT probably gives values divisible by 150.

268–383

My own solution (in case you missed it) was simply to put #ifdef FDT around functions mcommphy_yt8531_setup_delay() and mcommphy_yt8531_setup() (so that function's opening and closing brackets with closing return instructions are included but the rest of the content not). Anyway, I'm fine with this solution too.

mhorne added inline comments.
sys/dev/mii/mcommphy.c
49

Oh yes. It does not break the build on amd64 but it is clearly not needed there.

268–383

I did miss that...

I will exclude mcommphy_yt8531_setup_delay() from the !FDT case, since I am unsure what the implications of writing a delay value of zero would be. Especially when the default is listed as 1950 in the dts spec above...

mhorne marked an inline comment as done.

Add #ifdef FDT conditionals around mii_fdt.h inclusion and the call to mcommphy_yt8531_setup_delay().

This revision is now accepted and ready to land.Apr 30 2025, 7:24 PM
This revision was automatically updated to reflect the committed changes.