Re: JH7110 dwc MAC support

From: John F Carr <jfc_at_mit.edu>
Date: Fri, 14 Jun 2024 19:11:14 UTC

> On Jun 14, 2024, at 11:40, JMT Sihvola <jsihv@gmx.com> wrote:
> 
> 
> 
>> Sent: Friday, June 14, 2024 at 6:06 PM
>> From: "John F Carr" <jfc@mit.edu>
>> To: "freebsd-riscv@freebsd.org" <freebsd-riscv@FreeBSD.org>
>> Subject: JH7110 dwc MAC support
>> 
>> Has anybody gotten the ethernet driver working on this chip?
>> It's a DesignWare MAC according to the device tree so if_dwc.c
>> should be the starting point.  The driver does not work
>> simply by changing the "compatible" string.  It can't find
>> the PHY because all the register reads come back 0.  The
>> only documentation I can find is the Linux driver source code.
>> I can try updating register offsets and command bit patterns
>> to match what the Linux driver does with "snps,dwmac-5.20".
> 
> JH7110 uses dwmac version 5.2. FreeBSD has codes for 4.x (which is
> almost similar) in sys/dev/eqos. JH7110 also uses Motorcomm's
> Ethernet-phy version 8531 which currently isn't supported.
> 
> I have updated those codes to get network working on JH7110 but
> I have not yet submitted them because there is a problem which prevents
> changing the Ethernet port on fly. It's possible that this problem is caused
> by a bug outside of these drivers. It has been difficult to track it down
> but I keep working on with the issue.
> 
> I have those updated driver codes in my personal github:
> https://github.com/jsihvola/freebsd-src/
> See the last commit (otherwise this repository is not up-to-date).
> 
> So if you can live with the port switching issue, those codes
> should make it possible to get JH7110 online. Also, eqos driver
> has some shortcomings, making network speed slower than what it could be.
> 
> JH7110 clocks required by Ethernet are available in FreeBSD repository.
> GPIO & MMC have been submitted. USB & pinctrl are being worked on.
> 
> -jari sihvola
> 
> 

Thanks.  I tried putting your driver on the main (15-CURRENT) branch.
It attaches but does not seem to put anything on the wire.
I will try building your 14-based branch next.

Is it correct to see a total of four PHYs in the dmesg output below?

eqos0: <DesignWare EQOS Gigabit Ethernet for JH7110> mem 0x16030000-0x1603ffff irq 62,63,64 on simplebus0
eqos0: DesignWare EQOS ver 0x52 (0x41)
eqos0: hw features 1a2173f7 09845904 01000000 00000000
eqos0: Ethernet address f2:00:25:43:09:d6
eqos0: TX ring @ 0x41ede000, RX ring @ 0x42fdf000
miibus0: <MII bus> on eqos0
mcommphy0: <Motorcomm YT8531 10/100/1000 PHY> PHY 0 on miibus0
mcommphy0: OUI 0xc82b5e, model 0x0011, rev. 11
mcommphy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
mcommphy1: <Motorcomm YT8531 10/100/1000 PHY> PHY 1 on miibus0
mcommphy1: OUI 0xc82b5e, model 0x0011, rev. 11
mcommphy1:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
eqos0: bpf attached
eqos0: Ethernet address: f2:00:25:43:09:d6
eqos1: <DesignWare EQOS Gigabit Ethernet for JH7110> mem 0x16040000-0x1604ffff irq 65,66,67 on simplebus0
eqos1: DesignWare EQOS ver 0x52 (0x41)
eqos1: hw features 1a2173f7 09845904 01000000 00000000
eqos1: Ethernet address f2:00:6a:9e:95:8b
eqos1: TX ring @ 0x42fe5000, RX ring @ 0x439e7000
miibus1: <MII bus> on eqos1
mcommphy2: <Motorcomm YT8531 10/100/1000 PHY> PHY 0 on miibus1
mcommphy2: OUI 0xc82b5e, model 0x0011, rev. 11
mcommphy2:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
mcommphy3: <Motorcomm YT8531 10/100/1000 PHY> PHY 1 on miibus1
mcommphy3: OUI 0xc82b5e, model 0x0011, rev. 11
mcommphy3:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
eqos1: bpf attached
eqos1: Ethernet address: f2:00:6a:9e:95:8b