Lantiq XRX200 ethernet ports configuration?

This was always actually a mystery for me. How to properly configure ethernet ports for a Lantiq board in the device tree?
I ported or tried to port OpenWrt on several Lantiq boards and this is the most confusing part. While on some boards I couldn't get all ports to work neither in U-Boot nor Linux/OpenWrt, right now I'm working on ZTE ZXHN367N (marketing name 931VII v4) on which all ports work in U-Boot, but not in Linux.

SoC is VRX288. There are four 100M ports wired directly to the SoC and one gigabit WAN port wired to PEF7071.

This is the functional configuration in U-Boot:

static const struct ltq_eth_port_config eth_port_config[] = {
	/* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
	{ 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
	/* GMAC1: unused */
	{ 1, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
	/* GMAC2: internal GPHY0 with 10/100 firmware for LAN port 1 */
	{ 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
	/* GMAC3: internal GPHY0 with 10/100 firmware for LAN port 2 */
	{ 3, 0x12, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
	/* GMAC4: internal GPHY1 with 10/100 firmware for LAN port 3 */
	{ 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
	/* GMAC5: internal GPHY1 with 10/100 firmware for LAN port 4 */
	{ 5, 0x14, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
};

All four 100M ports work fine in U-Boot (let's ignore non-working gigabit port on PEF7071 for the moment).
The same configuration in the device tree results in only ports 2 and 4 (labeled 1 and 3) being functional after booting the kernel:

&eth0 {
	lan: interface@0 {
		compatible = "lantiq,xrx200-pdi";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0>;
		lantiq,switch;

		ethernet@2 {
			compatible = "lantiq,xrx200-pdi-port";
			reg = <2>;
			phy-mode = "mii";
			phy-handle = <&phy11>;
		};
		ethernet@3 {
			compatible = "lantiq,xrx200-pdi-port";
			reg = <3>;
			phy-mode = "mii";
			phy-handle = <&phy12>;
		};
		ethernet@4 {
			compatible = "lantiq,xrx200-pdi-port";
			reg = <4>;
			phy-mode = "mii";
			phy-handle = <&phy13>;
		};
		ethernet@5 {
			compatible = "lantiq,xrx200-pdi-port";
			reg = <5>;
			phy-mode = "mii";
			phy-handle = <&phy14>;
		};
	};

	wan: interface@1 {
		compatible = "lantiq,xrx200-pdi";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <1>;
		lantiq,wan;

		ethernet@0 {
			compatible = "lantiq,xrx200-pdi-port";
			reg = <0>;
			phy-mode = "rgmii";
			phy-handle = <&phy0>;
		};
	};

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "lantiq,xrx200-mdio";

		phy0: ethernet-phy@0 {
			reg = <0x0>;
			compatible = "lantiq,phy11g", "ethernet-phy-ieee802.3-c22";
		};
		phy11: ethernet-phy@11 {
			reg = <0x11>;
			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
		};
		phy12: ethernet-phy@12 {
			reg = <0x12>;
			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
		};
		phy13: ethernet-phy@13 {
			reg = <0x13>;
			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
		};
		phy14: ethernet-phy@14 {
			reg = <0x14>;
			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
		};
	};
};

(again, let's ignore the non-functional gigabit port for now)

What am I doing wrong? What is the proper way to configure the ports on a Lantiq board?

Show me dmesg, your config from /etc/board.d/02_network [1] or send link to repoistory :slight_smile:

[1] https://github.com/openwrt/openwrt/blob/master/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network

Console output, you can see at 6.282640 that it complains about PHY at addresses 0x11 and 0x13 (and a few more mdio problems above that), although they work fine in U-Boot:

## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   MIPS OpenWrt Linux-5.4.52
   Created:      2020-07-17  11:00:00 UTC
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    5069335 Bytes = 4.8 MiB
   Load Address: 80002000
   Entry Point:  80002000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
[    0.000000] Linux version 5.4.52 (danijel@danijel) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r13881-bae4204e34)) #0 SMP Fri Jul 17 11:00:00 2020
[    0.000000] SoC: xRX200 rev 1.2
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019556 (MIPS 34Kc)
[    0.000000] MIPS: machine is zte,zxhnh367n
[    0.000000] User-defined physical RAM map overwrite
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Detected 1 available secondary CPU(s)
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003dfffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003dfffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003dfffff]
[    0.000000] percpu: Embedded 14 pages/cpu s26160 r8192 d22992 u57344
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 15732
[    0.000000] Kernel command line: console=ttyLTQ0,115200 mem=62M vpe1_load_addr=0x83e00000 vpe1_mem=2M maxvpes=1 maxtcs=1 nosmp
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    0.000000] Writing ErrCtl register=00076928
[    0.000000] Readback ErrCtl register=00076928
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 51200K/63488K available (5721K kernel code, 215K rwdata, 1504K rodata, 3808K init, 220K bss, 12288K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] NR_IRQS: 256
[    0.000000] random: get_random_bytes called from start_kernel+0x33c/0x54c with crng_init=0
[    0.000000] CPU Clock: 500MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041786 ns
[    0.000010] sched_clock: 32 bits at 250MHz, resolution 4ns, wraps every 8589934590ns
[    0.007900] Calibrating delay loop... 332.54 BogoMIPS (lpj=665088)
[    0.045980] pid_max: default: 32768 minimum: 301
[    0.050901] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.058094] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.069518] rcu: Hierarchical SRCU implementation.
[    0.075093] smp: Bringing up secondary CPUs ...
[    0.079556] smp: Brought up 1 node, 1 CPU
[    0.089819] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.099485] futex hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.106548] pinctrl core: initialized pinctrl subsystem
[    0.112993] NET: Registered protocol family 16
[    0.126768] dcdc-xrx200 1f106a00.dcdc: Core Voltage : 1016 mV
[    0.137292] pinctrl-xway 1e100b10.pinmux: Init done
[    0.143361] dma-xway 1e104100.dma: Init done - hw rev: 7, ports: 7, channels: 28
[    0.152971] pcie-xrx200 1d900000.pcie: failed to get the PCIe PHY
[    0.224244] gpio-stp-xway 1e100bb0.stp: Init done
[    0.230343] usbcore: registered new interface driver usbfs
[    0.235872] usbcore: registered new interface driver hub
[    0.241233] usbcore: registered new device driver usb
[    0.255663] clocksource: Switched to clocksource MIPS
[    0.262301] NET: Registered protocol family 2
[    0.267741] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.276084] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.283742] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.290846] TCP: Hash tables configured (established 1024 bind 1024)
[    0.297454] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.303957] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.311325] NET: Registered protocol family 1
[    0.315654] PCI: CLS 0 bytes, default 32
[    1.095451] random: fast init done
[    5.787252] gptu: totally 6 16-bit timers/counters
[    5.792182] gptu: misc_register on minor 63
[    5.796332] gptu: succeeded to request irq 126
[    5.800822] gptu: succeeded to request irq 127
[    5.805350] gptu: succeeded to request irq 128
[    5.809853] gptu: succeeded to request irq 129
[    5.814363] gptu: succeeded to request irq 130
[    5.818877] gptu: succeeded to request irq 131
[    5.826581] lantiq,vmmc 1f107000.vmmc: requested GPIO 465
[    5.831949] lantiq,vmmc 1f107000.vmmc: requested GPIO 493
[    5.837395] lantiq,vmmc 1f107000.vmmc: requested GPIO 492
[    5.842817] lantiq,vmmc 1f107000.vmmc: reserved 1MB at 0x(ptrval)
[    5.856647] workingset: timestamp_bits=14 max_order=14 bucket_order=0
[    5.872898] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    5.878647] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    5.917598] 1e100c00.serial: ttyLTQ0 at MMIO 0x1e100c00 (irq = 112, base_baud = 0) is a lantiq,asc
[    5.926540] printk: console [ttyLTQ0] enabled
[    5.926540] printk: console [ttyLTQ0] enabled
[    5.935239] printk: bootconsole [early0] disabled
[    5.935239] printk: bootconsole [early0] disabled
[    5.951979] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xf1
[    5.956986] nand: Winbond W29N01GV
[    5.960327] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    5.967906] Scanning device for bad blocks
[    6.009733] 4 fixed-partitions partitions found on MTD device 10000000.flash
[    6.015389] Creating 4 MTD partitions on "10000000.flash":
[    6.020870] 0x000000000000-0x000000040000 : "uboot"
[    6.027150] 0x000000040000-0x000000060000 : "uboot-env"
[    6.032474] 0x000000060000-0x000000360000 : "kernel"
[    6.037470] 0x000000360000-0x000008000000 : "ubi"
[    6.044854] libphy: Fixed MDIO Bus: probed
[    6.051050] leds-gpio: probe of leds failed with error -16
[    6.056869] NET: Registered protocol family 10
[    6.079999] Segment Routing with IPv6
[    6.082338] NET: Registered protocol family 17
[    6.086825] 8021q: 802.1Q VLAN Support v1.8
[    6.098480] pcie-xrx200 1d900000.pcie: failed to get the PCIe PHY
[    6.210281] libphy: lantiq,xrx200-mdio: probed
[    6.213412] mdio_bus 0: MDIO device at address 0 is missing.
[    6.244566] mdio_bus 0: MDIO device at address 18 is missing.
[    6.272959] mdio_bus 0: MDIO device at address 20 is missing.
[    6.277590] net-xrx200: invalid MAC, using random
[    6.282640] Intel XWAY PHY11G (xRX v1.2 integrated) 0:11: attached PHY driver [Intel XWAY PHY11G (xRX v1.2 integrated)] (mii_bus:phy_addr=0:11, irq=POLL)
[    6.295919] lantiq,xrx200-net 1e108000.eth eth0 (uninitialized): no PHY found
[    6.302885] xrx200-mdio: probing phy of port 3 failed
[    6.308525] Intel XWAY PHY11G (xRX v1.2 integrated) 0:13: attached PHY driver [Intel XWAY PHY11G (xRX v1.2 integrated)] (mii_bus:phy_addr=0:13, irq=POLL)
[    6.321851] lantiq,xrx200-net 1e108000.eth eth0 (uninitialized): no PHY found
[    6.328824] xrx200-mdio: probing phy of port 5 failed
[    6.335137] net-xrx200: invalid MAC, using random
[    6.338635] lantiq,xrx200-net 1e108000.eth eth1 (uninitialized): no PHY found
[    6.345708] xrx200-mdio: probing phy of port 0 failed
[    6.476084] PCI host bridge /fpi@10000000/pcie@d900000 ranges:
[    6.480774] PCI host bridge to bus 0000:00
[    6.484646] pci_bus 0000:00: root bus resource [mem 0x1c000000-0x1cffffff]
[    6.491490] pci_bus 0000:00: root bus resource [io  0x1d800000-0x1d8fffff]
[    6.498365] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    6.505150] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    6.513120] pci 0000:00:00.0: [1bef:0011] type 01 class 0x060000
[    6.519098] ifx_pcie_rc_class_early_fixup: fixed pcie host bridge to pci-pci bridge
[    6.536806] pci 0000:00:00.0: ifx_pcie_rc_class_early_fixup+0x0/0x7c took 17264 usecs
[    6.543353] pci 0000:00:00.0: PME# supported from D0 D3hot
[    6.551664] pci 0000:01:00.0: [1814:3091] type 00 class 0x028000
[    6.556350] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x0000ffff]
[    6.562725] pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
[    6.571228] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    6.576499] pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 01
[    6.583098] pci 0000:00:00.0: BAR 8: assigned [mem 0x1c000000-0x1c0fffff]
[    6.589880] pci 0000:01:00.0: BAR 0: assigned [mem 0x1c000000-0x1c00ffff]
[    6.596661] pci 0000:00:00.0: PCI bridge to [bus 01]
[    6.601614] pci 0000:00:00.0:   bridge window [mem 0x1c000000-0x1c0fffff]
[    6.608552] ifx_pcie_bios_map_irq port 0 dev 0000:00:00.0 slot 0 pin 1 
[    6.615022] ifx_pcie_bios_map_irq dev 0000:00:00.0 irq 144 assigned
[    6.621283] pcieport 0000:00:00.0: enabling device (0000 -> 0002)
[    6.630625] UBI: auto-attach mtd3
[    6.632613] ubi0: attaching mtd3
[    6.782586] ubi0: scanning is finished
[    6.798637] ubi0: attached mtd3 (name "ubi", size 124 MiB)
[    6.802778] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[    6.809619] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[    6.816299] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[    6.823079] ubi0: good PEBs: 997, bad PEBs: 0, corrupted PEBs: 0
[    6.829086] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[    6.836314] ubi0: max/mean erase counter: 12/6, WL threshold: 4096, image sequence number: 1296487795
[    6.845539] ubi0: available PEBs: 185, total reserved PEBs: 812, PEBs reserved for bad PEB handling: 20
[    6.855637] ubi0: background thread "ubi_bgt0d" started[    6.874302] Freeing unused kernel memory: 3808K
[    6.877453] This architecture does not have kernel memory protection.
[    6.883858] Run /init as init process
[    6.909534] init: Console is alive
[    6.912016] init: - watchdog -
[    6.937760] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    6.946264] gpio-keys-polled keys: unable to claim gpio 469, err=-16
[    6.951323] gpio-keys-polled: probe of keys failed with error -16
[    6.959134] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    6.968004] init: - preinit -
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   11.394828] procd: - early -
[   11.396636] procd: - watchdog -
[   11.997462] procd: - watchdog -
[   11.999966] procd: - ubus -
[   12.011349] random: ubusd: uninitialized urandom read (4 bytes read)
[   12.052119] random: ubusd: uninitialized urandom read (4 bytes read)
[   12.057824] random: ubusd: uninitialized urandom read (4 bytes read)
[   12.065776] procd: - init -
Please press Enter to activate this console.
[   12.799645] kmodloader: loading kernel modules from /etc/modules.d/*
[   12.814470] IFXOS, Version 1.5.19 (c) Copyright 2009, Lantiq Deutschland GmbH
[   12.831108] NET: Registered protocol family 8
[   12.834158] NET: Registered protocol family 20
[   12.862310] PPP generic driver version 2.4.2
[   12.925233] Lantiq (VRX) DSL CPE MEI driver, version 1.5.17.6, (c) 2007-2015 Lantiq Beteiligungs-GmbH & Co. KG
[   12.952896] 
[   12.952896] 
[   12.952896] Lantiq CPE API Driver version: DSL CPE API V4.17.18.6
[   12.970552] 
[   12.970552] Predefined debug level: 3
[   13.030268] Infineon Technologies DEU driver version 2.0.0 
[   13.055794] IFX DEU DES initialized (multiblock).
[   13.071764] IFX DEU AES initialized (multiblock).
[   13.080142] IFX DEU ARC4 initialized (multiblock).
[   13.087746] IFX DEU SHA1 initialized.
[   13.091791] IFX DEU MD5 initialized.
[   13.095746] IFX DEU SHA1_HMAC initialized.
[   13.103754] IFX DEU MD5_HMAC initialized.
[   13.127681] NET: Registered protocol family 24
[   13.162682] xt_time: kernel timezone is -0000
[   13.240124] kmodloader: done loading kernel modules from /etc/modules.d/*
[   13.350370] urngd: v1.0.2 started.
[   13.590129] random: crng init done
[   13.592163] random: 7 urandom warning(s) missed due to ratelimiting

I didn't configure anything in 02_network just yet, this is some kernel problem which happens before rootfs is initialized.

@danijeltudek
Bug is probably in other part of code that you posted :wink:
VRX268/VRX288 has 2 integrated GPHYs. Each gphy can work as a single Gigabit Ethernet PHY or as a double Fast Ethernet PHY. I see that it works as Gigabit mode (PHY11G):

[    6.282640] Intel XWAY PHY11G (xRX v1.2 integrated) 0:11: attached PHY driver [Intel XWAY PHY11G (xRX v1.2 integrated)] (mii_bus:phy_addr=0:11, irq=POLL)
[    6.295919] lantiq,xrx200-net 1e108000.eth eth0 (uninitialized): no PHY found
[    6.302885] xrx200-mdio: probing phy of port 3 failed
[    6.308525] Intel XWAY PHY11G (xRX v1.2 integrated) 0:13: attached PHY driver [Intel XWAY PHY11G (xRX v1.2 integrated)] (mii_bus:phy_addr=0:13, irq=POLL)

Add this to dts:

#include <dt-bindings/mips/lantiq_rcu_gphy.h>
...
&gphy0 {
	lantiq,gphy-mode = <GPHY_MODE_FE>;
};

&gphy1 {
	lantiq,gphy-mode = <GPHY_MODE_FE>;
};
1 Like

Thanks a lot! This explains a lot now, and it makes sense why there was a pattern to which ports worked (on this board and previous ones). Is this documented anywhere except in the driver code?

Now, what about PEF7071? How is it wired and how to get it to work? I guess it needs a functional PCI bus?

Lantiq has never published documentation for this SOC. My knowledge is based on the GPL sources.
Why PCI? PHY is connected via MDIO(management) and RGMII(data) interface.
Move this to lan section:

		ethernet@0 {
			compatible = "lantiq,xrx200-pdi-port";
			reg = <0>;
			phy-mode = "rgmii";
			phy-handle = <&phy0>;
		};

Use this [1] dts as reference.
Look at this [2]. There are plans to use DSA driver.
I have plan to convert switch, GPHY firmware and firmware loader to package and load firmware from userland instead combining it in kernel. It should save ~100kB.

[1] https://github.com/openwrt/openwrt/blob/master/target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_arcadyan_arv7519rw22.dts
[2] https://github.com/openwrt/openwrt/pull/3085

1 Like

I sorted it out. Thanks again.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.