So, I got an answer to the question.
Is it possible to use a PHY port (port1) as a cpu port with the
mv88e6xxx driver?
The Answer is:
Yes. There are a few boards in mainline that does this. The original assumption was that the switch PHY defaults to auto-neg, and so gets link as soon as the SoC PHY is configured up. No PHY driver controls the switch PHY. This works for the older mv88e6xxx devices, like the 6352.
I changed the devicetree to this.
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9331.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
model = "8devices Carambola2";
compatible = "8dev,carambola2", "qca,ar9331";
aliases {
mdio-gpio0 = &mdio_gpio;
label-mac-device = &wmac;
};
mdio_gpio: mdio-gpio {
compatible = "virtual,mdio-gpio";
gpios = <&gpio 19 GPIO_ACTIVE_HIGH>,
<&gpio 21 GPIO_ACTIVE_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
switch@1 {
compatible = "marvell,mv88e6085";
reg = <0>;
dsa,member = <0 0>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan0";
};
port@1 {
reg = <1>;
label = "cpu";
ethernet = <ð0>;
};
port@2 {
reg = <2>;
label = "lan2";
};
port@3 {
reg = <3>;
label = "lan3";
};
port@4 {
reg = <4>;
label = "lan4";
};
};
};
};
leds {
compatible = "gpio-leds";
wlan {
label = "green:wlan";
gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};
eth0 {
label = "orange:eth0";
gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
};
eth1 {
label = "orange:eth1";
gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
};
};
keys {
compatible = "gpio-keys";
wps {
label = "wps";
linux,code = <KEY_WPS_BUTTON>;
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
};
};
};
&ref {
clock-frequency = <40000000>;
};
&usb {
dr_mode = "host";
status = "okay";
};
&usb_phy {
status = "okay";
};
&spi {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
spi-max-frequency = <50000000>;
reg = <0>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
uboot: partition@0 {
label = "u-boot";
reg = <0x000000 0x040000>;
read-only;
};
partition@40000 {
label = "u-boot-env";
reg = <0x040000 0x010000>;
read-only;
};
partition@50000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x50000 0xfa0000>;
};
art: partition@ff0000 {
label = "art";
reg = <0xff0000 0x010000>;
read-only;
};
};
};
};
&mdio0 {
status = "okay";
};
ð0 {
status = "okay";
mtd-mac-address = <&art 0x0>;
gmac-config {
device = <&gmac>;
switch-phy-addr-swap = <1>;
switch-phy-swap = <1>;
};
};
ð1 {
status = "okay";
mtd-mac-address = <&art 0x6>;
};
&wmac {
status = "okay";
mtd-cal-data = <&art 0x1000>;
};
Bootlog:
[ 0.000000] printk: bootconsole [early0] enabled
[ 0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[ 0.000000] MIPS: machine is 8devices Carambola2
[ 0.000000] SoC: Atheros AR9330 rev 1
[ 0.000000] Initrd not found or empty - disabling initrd
[ 0.000000] Primary instruction cache 64kB, 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-0x0000000003ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000000000-0x0000000003ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[ 0.000000] On node 0 totalpages: 16384
[ 0.000000] Normal zone: 144 pages used for memmap
[ 0.000000] Normal zone: 0 pages reserved
[ 0.000000] Normal zone: 16384 pages, LIFO batch:3
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16240
[ 0.000000] Kernel command line: console=ttyATH0,115200 rootfstype=squashfs,jffs2
[ 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=00000000
[ 0.000000] Readback ErrCtl register=00000000
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 56964K/65536K available (5087K kernel code, 193K rwdata, 1180K rodata, 1212K init, 196K bss, 8572K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 51
[ 0.000000] random: get_random_bytes called from start_kernel+0x32c/0x520 with crng_init=0
[ 0.000000] CPU clock: 400.000 MHz
[ 0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302233 ns
[ 0.000013] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
[ 0.007893] Calibrating delay loop... 265.98 BogoMIPS (lpj=531968)
[ 0.048607] pid_max: default: 32768 minimum: 301
[ 0.053473] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.060531] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.074763] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.083128] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[ 0.090020] pinctrl core: initialized pinctrl subsystem
[ 0.096528] NET: Registered protocol family 16
[ 0.142211] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[ 0.155396] clocksource: Switched to clocksource MIPS
[ 0.160872] NET: Registered protocol family 2
[ 0.165027] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.172235] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.179788] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.186813] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.193366] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.199719] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.207025] NET: Registered protocol family 1
[ 0.211002] PCI: CLS 0 bytes, default 32
[ 0.220376] workingset: timestamp_bits=14 max_order=14 bucket_order=0
[ 0.236615] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.241059] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 0.271711] pinctrl-single 18040028.pinmux: 64 pins, size 8
[ 0.277268] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[ 0.283493] 18020000.uart: ttyATH0 at MMIO 0x18020000 (irq = 9, base_baud = 2500000) is a AR933X UART
[ 0.292073] printk: console [ttyATH0] enabled
[ 0.300061] printk: bootconsole [early0] disabled
[ 0.327776] spi-nor spi0.0: w25q128 (16384 Kbytes)
[ 0.331176] 4 fixed-partitions partitions found on MTD device spi0.0
[ 0.337482] Creating 4 MTD partitions on "spi0.0":
[ 0.342254] 0x000000000000-0x000000040000 : "u-boot"
[ 0.348691] 0x000000040000-0x000000050000 : "u-boot-env"
[ 0.354007] 0x000000050000-0x000000ff0000 : "firmware"
[ 0.362875] 2 uimage-fw partitions found on MTD device firmware
[ 0.367430] Creating 2 MTD partitions on "firmware":
[ 0.372317] 0x000000000000-0x000000210000 : "kernel"
[ 0.378605] 0x000000210000-0x000000fa0000 : "rootfs"
[ 0.383705] mtd: device 4 (rootfs) set to be root filesystem
[ 0.390385] 1 squashfs-split partitions found on MTD device rootfs
[ 0.395220] 0x0000004c0000-0x000000fa0000 : "rootfs_data"
[ 0.401979] 0x000000ff0000-0x000001000000 : "art"
[ 0.408255] libphy: GPIO Bitbanged MDIO: probed
[ 0.413506] libphy: Fixed MDIO Bus: probed
[ 0.420599] mv88e6085 gpio-0:00: switch 0x3520 detected: Marvell 88E6352, revision 1
[ 0.627134] libphy: mv88e6xxx SMI: probed
[ 0.883384] random: fast init done
[ 0.953589] libphy: ag71xx_mdio: probed
[ 0.956179] ag71xx 19000000.eth: Could not connect to PHY device. Deferring probe.
[ 1.595893] libphy: ag71xx_mdio: probed
[ 1.599262] libphy: ar8xxx-mdio: probed
[ 1.605418] switch0: Atheros AR724X/AR933X built-in rev. 2 switch registered on mdio.1
[ 1.645589] ag71xx 1a000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[ 1.654151] eth0: Atheros AG71xx at 0xba000000, irq 5, mode: gmii
[ 1.659776] i2c /dev entries driver
[ 1.665874] NET: Registered protocol family 10
[ 1.676339] Segment Routing with IPv6
[ 1.678711] NET: Registered protocol family 17
[ 1.683633] 8021q: 802.1Q VLAN Support v1.8
[ 1.689368] mv88e6085 gpio-0:00: switch 0x3520 detected: Marvell 88E6352, revision 1
[ 1.877661] libphy: mv88e6xxx SMI: probed
[ 2.205024] ag71xx 19000000.eth: connected to PHY at mdio.1:1f:04 [uid=004dd041, driver=Generic PHY]
[ 2.214126] eth1: Atheros AG71xx at 0xb9000000, irq 4, mode: mii
[ 2.219290] mv88e6085 gpio-0:00: switch 0x3520 detected: Marvell 88E6352, revision 1
[ 2.400623] libphy: mv88e6xxx SMI: probed
[ 2.679660] mv88e6085 gpio-0:00 lan0 (uninitialized): PHY [mv88e6xxx-2:00] driver [Marvell 88E1540]
[ 2.698447] mv88e6085 gpio-0:00 lan2 (uninitialized): PHY [mv88e6xxx-2:02] driver [Marvell 88E1540]
[ 2.711375] mv88e6085 gpio-0:00 lan3 (uninitialized): PHY [mv88e6xxx-2:03] driver [Marvell 88E1540]
[ 2.729265] mv88e6085 gpio-0:00 lan4 (uninitialized): PHY [mv88e6xxx-2:04] driver [Marvell 88E1540]
[ 2.741964] DSA: tree 0 setup
[ 2.751229] VFS: Mounted root (squashfs filesystem) readonly on device 31:4.
[ 2.766394] Freeing unused kernel memory: 1212K
[ 2.769502] This architecture does not have kernel memory protection.
[ 2.775896] Run /sbin/init as init process
[ 3.545724] init: Console is alive
[ 3.548196] init: - watchdog -
[ 4.945745] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[ 5.173449] usbcore: registered new interface driver usbfs
[ 5.177677] usbcore: registered new interface driver hub
[ 5.182947] usbcore: registered new device driver usb
[ 5.202693] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 5.220181] chipidea-usb2 1b000000.usb: 1b000000.usb supply vbus not found, using dummy regulator
[ 5.230799] ci_hdrc ci_hdrc.0: EHCI Host Controller
[ 5.234333] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[ 5.255748] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[ 5.261004] hub 1-0:1.0: USB hub found
[ 5.264119] hub 1-0:1.0: 1 port detected
[ 5.269649] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 5.286151] init: - preinit -
[ 5.869482] usb 1-1: new full-speed USB device number 2 using ci_hdrc
[ 6.322134] usb 1-1: device descriptor read/64, error -71
[ 6.719460] usb 1-1: device descriptor read/64, error -71
[ 6.852308] random: jshn: uninitialized urandom read (4 bytes read)
[ 7.019503] usb 1-1: new full-speed USB device number 3 using ci_hdrc
[ 7.317020] random: jshn: uninitialized urandom read (4 bytes read)
[ 7.399461] usb 1-1: device descriptor read/64, error -71
[ 7.415018] random: jshn: uninitialized urandom read (4 bytes read)
[ 7.735463] usb 1-1: device descriptor read/64, error -71
[ 7.794769] eth0: link up (1000Mbps/Full duplex)
[ 7.803669] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 7.847598] usb usb1-port1: attempt power cycle
[ 8.503410] usb 1-1: new full-speed USB device number 4 using ci_hdrc
[ 8.987418] usb 1-1: device not accepting address 4, error -71
[ 9.119402] usb 1-1: new full-speed USB device number 5 using ci_hdrc
[ 9.603708] usb 1-1: device not accepting address 5, error -71
[ 9.608161] usb usb1-port1: unable to enumerate USB device
[ 12.200781] mount_root: jffs2 not ready yet, using temporary tmpfs overlay
[ 12.212578] urandom-seed: Seed file not found (/etc/urandom.seed)
[ 12.465293] eth0: link down
[ 12.486258] procd: - early -
[ 12.487943] procd: - watchdog -
[ 13.173167] procd: - watchdog -
[ 13.332687] procd: - ubus -
[ 13.480857] urandom_read: 4 callbacks suppressed
[ 13.480869] random: ubusd: uninitialized urandom read (4 bytes read)
[ 13.541322] random: ubusd: uninitialized urandom read (4 bytes read)
[ 13.547372] random: ubusd: uninitialized urandom read (4 bytes read)
[ 13.557164] procd: - init -
[ 15.063996] kmodloader: loading kernel modules from /etc/modules.d/*
[ 15.435450] Loading modules backported from Linux version v5.10.16-0-gde53befa79cf
[ 15.441604] Backport generated by backports.git v5.10.16-1-0-g21d2a1d2
[ 15.526867] xt_time: kernel timezone is -0000
[ 15.730907] PPP generic driver version 2.4.2
[ 15.744837] NET: Registered protocol family 24
[ 15.915959] ath: EEPROM regdomain sanitized
[ 15.915977] ath: EEPROM regdomain: 0x64
[ 15.915982] ath: EEPROM indicates we should expect a direct regpair map
[ 15.916010] ath: Country alpha2 being used: 00
[ 15.916015] ath: Regpair used: 0x64
[ 15.929619] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[ 15.932941] ieee80211 phy0: Atheros AR9330 Rev:1 mem=0xb8100000, irq=2
[ 16.055713] urngd: v1.0.2 started.
[ 16.064969] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 16.624120] random: crng init done
[ 79.107606] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[ 79.127553] jffs2_build_filesystem(): unlocking the mtd device...
[ 79.127625] done.
[ 79.134264] jffs2_build_filesystem(): erasing all blocks after the end marker...
[ 86.146136] eth0: link up (1000Mbps/Full duplex)
[ 86.165028] br-lan: port 1(eth0) entered blocking state
[ 86.168893] br-lan: port 1(eth0) entered disabled state
[ 86.174553] device eth0 entered promiscuous mode
[ 86.222124] br-lan: port 1(eth0) entered blocking state
[ 86.225944] br-lan: port 1(eth0) entered forwarding state
[ 87.167455] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[ 122.488044] done.
[ 122.488563] jffs2: notice: (1686) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[ 122.670852] overlayfs: upper fs does not support tmpfile.
ip link:
root@OpenWrt:/# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UP qlen 1000
link/ether c4:93:00:20:bd:a3 brd ff:ff:ff:ff:ff:ff
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1508 qdisc fq_codel state DOWN qlen 1000
link/ether c4:93:00:20:bd:a2 brd ff:ff:ff:ff:ff:ff
4: lan0@eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether c4:93:00:20:bd:a2 brd ff:ff:ff:ff:ff:ff
5: lan2@eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether c4:93:00:20:bd:a2 brd ff:ff:ff:ff:ff:ff
6: lan3@eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether c4:93:00:20:bd:a2 brd ff:ff:ff:ff:ff:ff
7: lan4@eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether c4:93:00:20:bd:a2 brd ff:ff:ff:ff:ff:ff
8: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether c4:93:00:20:bd:a4 brd ff:ff:ff:ff:ff:ff
9: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether c4:93:00:20:bd:a3 brd ff:ff:ff:ff:ff:ff
The driver is probing now. So got a step further.
Now i'm curious about these lines.
[ 2.679660] mv88e6085 gpio-0:00 lan0 (uninitialized): PHY [mv88e6xxx-2:00] driver [Marvell 88E1540]
[ 2.698447] mv88e6085 gpio-0:00 lan2 (uninitialized): PHY [mv88e6xxx-2:02] driver [Marvell 88E1540]
[ 2.711375] mv88e6085 gpio-0:00 lan3 (uninitialized): PHY [mv88e6xxx-2:03] driver [Marvell 88E1540]
[ 2.729265] mv88e6085 gpio-0:00 lan4 (uninitialized): PHY [mv88e6xxx-2:04] driver [Marvell 88E1540]
Already tried with a fixed link speed but with the same result.