Porting guide ar71xx to ath79?


#769

actually, wouldn't it still error on probe without the syscon compatible property, instead of panicking on unaligned access? so i think syscon needs to remain in the compatible property. perhaps it should be moved to the eth0/eth1 nodes in ar7100.dtsi instead?


#770
compatible = "qca,ar7100-eth", "syscon";

Oh, thanks so much.
I missed that compatible property is overriden in ar7100.dtsi from "qca,ath79-eth" . :persevere:
It's very confusing...

wouldn't it still error on probe without the syscon compatible property

Yes. After applying my patch, mdiobus probing fails with -22 (-ENODEV).

I'll try your suggestion later.


#771

The PCI IRQ & ethX mode handling related fixes for ar7100 from @Pilot6 and @981213 were merged today. At the first glance, WNDR3800 seems to operate pretty ok after those fixes. Thanks.

root@OpenWrt:~# cat /proc/interrupts
           CPU0
  3:          0      MIPS   3  ehci_hcd:usb1
  4:     515550      MIPS   4  19000000.eth
  5:     694719      MIPS   5  1a000000.eth
  7:    2122035      MIPS   7  timer
  8:         12      MISC   3  ttyS0
 12:          0      MISC   6  ohci_hcd:usb2
 13:     199525      MISC   0  ath9k
 14:     525020      MISC   1  ath9k
ERR:        132

#772

That's what I was trying to say, your patch looks correct. Sorry for any misunderstanding.

I was able to get my wan port up and running with this change.

Works nicely for me, those fixes (or some other changes in master?) got my connection speed up from 260 to 400 mbit/s.


#773

I'm still having trouble with getting the network driver to load the correct Mac address from the eeprom.
The ar71xx code is here: https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c;hb=HEAD#l159

It loads each Mac from a KSEG1ADDR eeprom address, which does not seem to relate to the mtd partitions (at least I couldn't figure out how). What would I have to set in the device tree to mimic this behavior, or at least get the same result?


#774

There was a openwrt doc that describes KSEGADDR, but i don't find it a the moment.

For me it looks like your eeprom1 data starts at spi nor flash address 0x51000 and eeprom2 starts at 0x55000. Mac1 has the offset 0x5120c and mac2 0x5520c.

Depending on your defined partition layout you have to substract the begining of the related mtd partition from this offsets...

According to you partition layout the data should be in the art (begins at 0x50000) partition.

Eeprom1 = 0x1000; mac1 = 0x120c
Eeprom2 = 0x5000; mac2 = 0x520c


#775

You can look into the art partition and see where the macs are.


#776

@juppin We don't need offsets from eeprom1 and 2. We need offsets from the beginning of art.
The format should be hex and it can be set in dts without any trouble.


#777

I've added this only for completeness as the mach file adds also the 0x20c mac offset to the eeprom offset.


#778

Its '&art 0x120c' and '&art 0x520c'.


#779

So properites are

eth0:

mtd-mac-address = <&art 0x120c>;

eth1:
mtd-mac-address = <&art 0x520c>;
mtd-mac-address-increment = <1>;


#780

That's in fact what I tried, but got the same error. I will try again. @drvlabo I saw that you have the same settings in your DTS file, does it work for you?


#781

Then give the art dump to see what's there. But if wifi gets the macs correctly they should be there.


#782

Ethernet worked properly with the following code on my WZR-HP-AG300H:

&mdio0 {
	status = "okay";

	phy-mask = <0x1>;

	phy4: ethernet-phy@4 {
		reg = <4>;
		phy-mode = "rgmii";
	};
};

&eth0 {
	compatible = "qca,ar7100-eth", "syscon";
	status = "okay";

	mtd-mac-address = <&art 0x120c>;

	fixed-link {
		speed = <1000>;
		full-duplex;
	};
};

&eth1 {
	compatible = "qca,ar7100-eth", "syscon";
	status = "okay";

	mtd-mac-address = <&art 0x520c>;

	phy-handle = <&phy4>;
};

dmesg:

[    0.637809] libphy: Fixed MDIO Bus: probed
[    0.980974] libphy: ag71xx_mdio: probed
[    1.004694] switch0: Atheros AR8316 rev. 1 switch registered on mdio-bus.0
[    1.030799] ag71xx 19000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[    1.040353] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode:RGMII
[    1.380430] ar8316: Using port 4 as PHY
[    2.451381] ag71xx 1a000000.eth: connected to PHY at mdio-bus.0:04 [uid=004dd041, driver=Atheros AR8216/AR8236/AR8316]
[    2.462625] eth1: Atheros AG71xx at 0xba000000, irq 5, mode:RGMII

#783

does it work for you?

Yes, it works at me.
Just same as @musashino.


#784

I suggest to add

mtd-mac-address-increment = <1>;

for eth1 to match the factory address.


#785

Oh, indeed. I missed the offset in ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 1); in mach-wzr-hp-ag300h.c.
Thank you!


#786

i opened a PR to add syscon to ar7100.dtsi here: https://github.com/openwrt/openwrt/pull/1340

i still think the driver should be fixed to not panic, so i would suggest opening a PR for that as well, but i'll leave that to you since it's your code :wink:

edit: per drvlabo the patch has been added as a second commit in the same PR


#787

I figured out why the mac address is not loaded correctly:

  • ... because the art partition is not found
  • ... because the virtual mtd-concat flash device is not loaded yet
  • ... because its probe got defered when it first ran (by returning -EPROBE_DEFER when one of the child devices cannot be found)
  • ... because the spi flash devices were not registered yet
  • ... because the virtual flash driver is loaded in the kernel before the spi drivers and thus gets matched to its platform device first

Reordering the virtualflash into the &spi node, as @juppin and I pondered before, unfortunately does not work either, because then it will get probed as a spi device, not a platform device.
Additionally, the probe order of platform devices defined in the tree does not seem to be dependent on the position defined in the tree, but on the order in which the platform device module drivers got registered. This is why moving the mtd-concat driver to after the spi-nor directory in the Makefile prevents this issue from happening.

I believe the best solution might be after all to move the driver to the end of the mtd Makefile. Perhaps contained in a "composite" directory? In any case a comment should mark why it is there at the very end.

Does anyone have a better idea how to solve this nicely?


#788

Hey guys, I am seeing these errors in dmesg. No idea if they're critical. Running on a WNDR3700 v1. Latest master.

root@OpenWrt:~# dmesg -l err
[    0.601917] ar7100-usb-phy 18030000.usb-phy: phy reset is missing
[    0.735469] rtl8366s rtl8366s: cannot find mdio node phandle