[OpenWrt-Devel,v3,2/5] ath79: WNR612v2: improve device support
diff mbox series

Message ID 20190811224252.3641e63f@kosmio.komorska
State Superseded
Headers show
Series
  • ath79: add support for some Netgear WNR routers
Related show

Commit Message

Michal Cieslakiewicz Aug. 11, 2019, 8:42 p.m. UTC
This patch improves ath79 support for Netgear WNR612v2.
Router functionality becomes identical to ar71xx version.

Changes include:
* software control over LAN LEDs via sysfs
* correct MAC addresses for network interfaces
* correct image size in device definition
* formatting adjustments to source DT files

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
---
 .../ath79/dts/ar7240_netgear_wnr612-v2.dts    |  2 +-
 .../ath79/dts/ar7240_netgear_wnr612-v2.dtsi   | 20 +++++++++++++------
 target/linux/ath79/dts/ar7240_on_n150r.dts    |  2 +-
 target/linux/ath79/image/tiny-netgear.mk      |  2 +-
 4 files changed, 17 insertions(+), 9 deletions(-)

Comments

Adrian Schmutzler Aug. 12, 2019, 12:16 p.m. UTC | #1
Hi,

just two annotations below.

> -			uboot: partition@0 {
> +			partition@0 {

You could also just keep it. But that's just a matter of taste.

>  &pcie {
> @@ -116,6 +122,8 @@
>  	ath9k: wifi@0,0 {
>  		compatible = "pci168c,002b";
>  		reg = <0x0000 0 0 0 0>;
> +		mtd-mac-address = <&art 0x0>;
> +		mtd-mac-address-increment = <1>;

Calibration data is read here:
https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom#L184

Does this device get a MAC address from calibration data? If yes, I would prefer that one to a calculated address and remove the entries in DTS.
If not, I wonder whether your setup here will persist or being overwritten by some "wrong" address during calibration anyway. (Then one would have to use ath9k_patch_fw_mac in the linked file.

Best

Adrian
Michal Cieslakiewicz Aug. 12, 2019, 2:24 p.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Mon, 12 Aug 2019 14:16:18 +0200
"Adrian Schmutzler" <mail@adrianschmutzler.de> wrote:

> Hi,
> 
> just two annotations below.
> 
> > -			uboot: partition@0 {
> > +			partition@0 {  
> 
> You could also just keep it. But that's just a matter of taste.
> 

Hello Adrian,

This 'uboot' label was used only for MAC address extraction from
u-boot partition (kinda strange, I couldn't find a clue why it was
expected there), so I decided to remove it.

> >  &pcie {
> > @@ -116,6 +122,8 @@
> >  	ath9k: wifi@0,0 {
> >  		compatible = "pci168c,002b";
> >  		reg = <0x0000 0 0 0 0>;
> > +		mtd-mac-address = <&art 0x0>;
> > +		mtd-mac-address-increment = <1>;  
> 
> Calibration data is read here:
> https://github.com/openwrt/openwrt/blob/master/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom#L184
> 
> Does this device get a MAC address from calibration data? If yes, I
> would prefer that one to a calculated address and remove the entries
> in DTS.

Nope, it should be calculated. In theory, according to Netgear uboot
sources, it should be in ART region at 0x108c but in all devices I
could inspect that area was empty (0xff). ar71xx target also derives
wlan0 MAC from ethX MACs.

> If not, I wonder whether your setup here will persist or
> being overwritten by some "wrong" address during calibration anyway.
> (Then one would have to use ath9k_patch_fw_mac in the linked file.
> 

MAC addresses for all interfaces are correctly assigned with this
patchset in place (tested), so apparently nothing interferes here.

Cheers
Michal
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEi7ylFMzTSbpOuOZIHU8//LdGKWsFAl1RdpYACgkQHU8//LdG
KWteAg/+NDDlrQ8C3iG2Fl1MsUOumMv0SI1Z8RZ9y2wVYaBJxJiREJiL7aKc2G6y
5kIMKyjKtpE9hgegJrkJ7Dr22eo8tPjjbKNEAK6nYR3R4wAuefLkA5j3o17T4+Ih
NGYoqdEIbfvpj/K8JHOBQbWnQiotZ9EQBW2lJI3oUDBHGutlzMloygoZJdh7jfba
gCnZ8SLU2FzfwJcp+c4VGmqnfS0VpSQsmVe47fUwevvsxyheB9DmqqsizjV+CPrw
+rZvn91iSjt/Wb87vEGqhfKBu3lYfI8zXAXDzSAQIf8r5fYCavxiH+F5FCEzR52a
1dgFFi4SAzv5SQfwL7tcC4xdCmKm09QBiC7GZACbwInKAdF2S7UJ/9QjNc9qmDwx
ICYUb3qDMEhessnTSWDOvUcEIh/SP4wxLa0GMP+ZiNCMlNT8Ik37/85+S+HMZNwR
y0i9OduFUFTh+yjpMRuc30iI8GQOFMiyVumWJyuciKpWV89i4byx19txHy4Z5+jy
6Aol8rVM/f1UQv4gWg0704J8oRrDARZbDU9FfC+67BJzeo2ceIRDiI5J4+Q52/O0
2ZSGYOZbL4owQ797FRroorSxyu523UHWrZ7OQEks5y0a2OO/pLvu7wfADG1+kLv+
46B6KlfggNdxGuScu/IYcLbbOroyFWDneIQSDS92g9Y0CEy8ZJA=
=DopH
-----END PGP SIGNATURE-----
Adrian Schmutzler Aug. 12, 2019, 5:24 p.m. UTC | #3
> Hello Adrian, 
> This 'uboot' label was used only for MAC address extraction from 
> u-boot partition (kinda strange, I couldn't find a clue why it was 
> expected there), so I decided to remove it. 

Just out of curiosity:

Did you check what's in the relevant uboot locations?

So, are the addresses there, too (there are known cases of having the same addresses multiple times), or are they missing, so you are proposing a "fix" here?

Best

Adrian
Michal Cieslakiewicz Aug. 12, 2019, 6:48 p.m. UTC | #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Mon, 12 Aug 2019 19:24:47 +0200
<mail@adrianschmutzler.de> wrote:

> > Hello Adrian, 
> > This 'uboot' label was used only for MAC address extraction from 
> > u-boot partition (kinda strange, I couldn't find a clue why it was 
> > expected there), so I decided to remove it.   
> 
> Just out of curiosity:
> 
> Did you check what's in the relevant uboot locations?
> 
> So, are the addresses there, too (there are known cases of having the
> same addresses multiple times), or are they missing, so you are
> proposing a "fix" here?
> 
> Best
> 
> Adrian 

Before even starting to change anything in *wnr612v2*.dts* I've built
and flashed an openwrt master ath79 image for that router (I own a few).
MAC addresses set by original DT file were definitely bogus. Netgear's
u-boot source also points to 'pre-art' area not u-boot binary. I guess
location was inherited from other 7240-based router but definitely it
does not play well for any WNR model.

Maybe product called On Networks N150 (rebranded WNR612v2) had this
sort of setup... Personally I doubt they (ON) cared to recompile their
own u-boot and OS but I do not have such device to verify that claim.

Cheers
Michal
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEi7ylFMzTSbpOuOZIHU8//LdGKWsFAl1RtHEACgkQHU8//LdG
KWtkxBAArK1IYjkgCfXSG1B4cE3WH4xshdA88S7jLKOxN8+gIl2J91abNPvxipFe
Dpwn+xC3D7irqguEgW95f8RI8L2GofJljuuBgTxBqCNCReWBDKsjaNv2mDeAeNwI
8uTbnSlRvq2M8Qt9b9as0/sj/0uNZ7TZrvAw8TWT7nIrgwudeejuYB6jnVJxLFGL
ek5LY/ZNSklRiAtZZEHqlLHiVmBLcIsIhZkVnREil10Pt+qX6toc58wMPiiXvvxf
dZJZTiFi7Nctjek+EyEV1WHMDpE+QN+FzgapPFRHzEPoWm930GTREfkbIT9afnxf
v8yqhWFcVvV0ye/dyntot30xpYE9gesqYJDlS8c2SRpov+NPPntAoEXn2UN9U6kw
bixjCTOvcHOyb4s/HJ9tgFJjXQtSLfvki2Bn57FwC2s9olP2EwcPpTR3r1+OmxEW
B95HTk1OH0YWTPhziSPsP4naDiC2XJsNnz7Q3RNd4ayxaDGYjkggzy4AuNj78xc1
YVr0pZU6p2rBjIWB9APmyt22HM9sAiSYZyDeC4g4bvkrHplFymtCkKHemO11Vq7e
JXaEv8vs4LjnE8ZBndUsq5Tezx69TXVo5Tj2DtyP0zTaVZLQ/NSvR8kaVOod9hk/
i/Sh7TcwmIamGme4P13Pb08JvyMhHHljcwzVtrXhZmzrE2JwxsM=
=mtF8
-----END PGP SIGNATURE-----

Patch
diff mbox series

diff --git a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dts b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dts
index b3ceecf932..e6e3e8b6da 100644
--- a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dts
+++ b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dts
@@ -4,7 +4,7 @@ 
 #include "ar7240_netgear_wnr612-v2.dtsi"
 
 / {
-	model = "Netgear WNR612 v2";
 	compatible = "netgear,wnr612-v2", "qca,ar7240";
+	model = "Netgear WNR612 v2";
 };
 
diff --git a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
index 8e934429a3..ec4d5d710f 100644
--- a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
+++ b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
@@ -28,6 +28,10 @@ 
 
 	leds {
 		compatible = "gpio-leds";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&jtag_disable_pins &switch_led_disable_pins &clks_disable_pins>;
+
 		power: power {
 			label = "netgear:green:power";
 			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
@@ -47,6 +51,10 @@ 
 			label = "netgear:green:wan";
 			gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
 		};
+	};
+
+	ath9k-leds {
+		compatible = "gpio-leds";
 
 		wlan: wlan {
 			label = "netgear:green:wlan";
@@ -70,7 +78,7 @@ 
 			#address-cells = <1>;
 			#size-cells = <1>;
 
-			uboot: partition@0 {
+			partition@0 {
 				reg = <0x0 0x40000>;
 				label = "u-boot";
 				read-only;
@@ -87,7 +95,7 @@ 
 				label = "firmware";
 			};
 
-			partition@3f0000 {
+			art: partition@3f0000 {
 				reg = <0x3f0000 0x10000>;
 				label = "art";
 				read-only;
@@ -99,15 +107,13 @@ 
 &eth0 {
 	status = "okay";
 
-	mtd-mac-address = <&uboot 0x1fc00>;
-	mtd-mac-address-increment = <(-1)>;
+	mtd-mac-address = <&art 0x0>;
 };
 
 &eth1 {
 	status = "okay";
 
-	mtd-mac-address = <&uboot 0x1fc00>;
-	mtd-mac-address-increment = <1>;
+	mtd-mac-address = <&art 0x6>;
 };
 
 &pcie {
@@ -116,6 +122,8 @@ 
 	ath9k: wifi@0,0 {
 		compatible = "pci168c,002b";
 		reg = <0x0000 0 0 0 0>;
+		mtd-mac-address = <&art 0x0>;
+		mtd-mac-address-increment = <1>;
 		qca,no-eeprom;
 		#gpio-cells = <2>;
 		gpio-controller;
diff --git a/target/linux/ath79/dts/ar7240_on_n150r.dts b/target/linux/ath79/dts/ar7240_on_n150r.dts
index a318846a83..886ac6dad5 100644
--- a/target/linux/ath79/dts/ar7240_on_n150r.dts
+++ b/target/linux/ath79/dts/ar7240_on_n150r.dts
@@ -4,7 +4,7 @@ 
 #include "ar7240_netgear_wnr612-v2.dtsi"
 
 / {
-	model = "ON Network N150R";
 	compatible = "on,n150r", "qca,ar7240";
+	model = "ON Network N150R";
 };
 
diff --git a/target/linux/ath79/image/tiny-netgear.mk b/target/linux/ath79/image/tiny-netgear.mk
index 67ef28c9cc..2f17d79757 100644
--- a/target/linux/ath79/image/tiny-netgear.mk
+++ b/target/linux/ath79/image/tiny-netgear.mk
@@ -4,7 +4,7 @@  define Device/netgear_ar7240
   ATH_SOC := ar7240
   NETGEAR_KERNEL_MAGIC := 0x32303631
   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma -d20 | netgear-uImage lzma
-  IMAGE_SIZE := 3904k
+  IMAGE_SIZE := 3712k
   IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | netgear-squashfs | append-rootfs | pad-rootfs
   $(Device/netgear_ath79)
 endef