ath79: Add wifi to WNDR3700, WNDR3700v2 and WNDR3800
authorHannu Nyman <hannu.nyman@iki.fi>
Mon, 13 Aug 2018 20:10:47 +0000 (23:10 +0300)
committerMathias Kresin <dev@kresin.me>
Tue, 14 Aug 2018 08:19:37 +0000 (10:19 +0200)
Add ath9k wifi capabilities to WNDR3700 family.

* use kmod-owl-loader to load firmware from "art"
* add wifi to DTS
* add wifi LEDs

Avoid using the same MAC for eth0 LAN and wlan0 by
toggling the eth0 MAC into a locally administered MAC.
That is currently done by in user-space by adding a
uci config item into /etc/config/network
(More elegant solution might be setting it already in
preinit phase.)

Known issues:

* wifi firmware file may not get created on the first boot
  after flashing on time to bring wifi normally up. Likely
  the overlay jffs2 is not yet ready for creating the
  firmware file. "wifi up" may still bring wifi up.
  Wifi will work normally at subsequent boots.

* phy0 and phy1 may get assigned mixed, so that phy0 may
  be the 5GHz radio instead of the normal 2.4GHz, and vice
  versa for phy1. Does not happen always, but may happen.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
[fix the wifi unit address in the dts]
Signed-off-by: Mathias Kresin <dev@kresin.me>
target/linux/ath79/base-files/etc/board.d/02_network
target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
target/linux/ath79/dts/ar7161_netgear_wndr3700.dtsi
target/linux/ath79/image/generic.mk

index 68f9523568af7d576995f6baa03c193364bb7fac..da98061d08338617f4b111d4fec6aaff6f77fe5d 100755 (executable)
@@ -160,6 +160,11 @@ ath79_setup_macs()
                lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
                wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
                ;;
+       netgear,wndr3700|\
+       netgear,wndr3700v2|\
+       netgear,wndr3800)
+               lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
+               ;;
        phicomm,k2t)
                lan_mac=$(k2t_get_mac "lan_mac")
                wan_mac=$(k2t_get_mac "wan_mac")
index 29c11bbd5fa515386b04a153566b750e89306d11..f71139c55cfdd79a6219da3ffcdc1d435b630f36 100644 (file)
@@ -146,6 +146,11 @@ case "$FIRMWARE" in
                ath9k_eeprom_extract "caldata" 4096 3768
                ath9k_patch_fw_mac_crc $(mtd_get_mac_text "caldata" 65440) 524
                ;;
+       netgear,wndr3700|\
+       netgear,wndr3700v2|\
+       netgear,wndr3800)
+               ath9k_eeprom_extract "art" 4096 3768
+               ;;
        *)
                ath9k_eeprom_die "board $board is not supported yet"
                ;;
@@ -157,6 +162,11 @@ case "$FIRMWARE" in
                ath9k_eeprom_extract "caldata" 20480 3768
                ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 65460) 1) 524
                ;;
+       netgear,wndr3700|\
+       netgear,wndr3700v2|\
+       netgear,wndr3800)
+               ath9k_eeprom_extract "art" 20480 3768
+               ;;
        *)
                ath9k_eeprom_die "board $board is not supported yet"
                ;;
index f3751d588d66cc9077ea6d2a8660e8c22a9c24d4..ef9984c86e4051953a63b45a4acc6df75ae2df14 100644 (file)
                };
        };
 
+       ath9k-leds {
+               compatible = "gpio-leds";
+               wlan2g {
+                       label = "netgear:green:wlan2g";
+                       gpios = <&ath9k0 5 GPIO_ACTIVE_LOW>;
+                       default-state = "off";
+                       linux,default-trigger = "phy0tpt";
+               };
+               wlan5g {
+                       label = "netgear:blue:wlan5g";
+                       gpios = <&ath9k1 5 GPIO_ACTIVE_LOW>;
+                       default-state = "off";
+                       linux,default-trigger = "phy1tpt";
+               };
+       };
+
        gpio-keys-polled {
                compatible = "gpio-keys-polled";
                poll-interval = <100>;
 
 &pcie0 {
        status = "okay";
+
+       ath9k0: wifi@0,11 {
+               compatible = "pci168c,0029";
+               reg = <0x8800 0 0 0 0x10000>;
+               mtd-mac-address = <&art 0x0>;
+               qca,no-eeprom;
+               #gpio-cells = <2>;
+               gpio-controller;
+       };
+
+       ath9k1: wifi@0,12 {
+               compatible = "pci168c,0029";
+               reg = <0x9000 0 0 0 0x10000>;
+               mtd-mac-address = <&art 0xc>;
+               qca,no-eeprom;
+               #gpio-cells = <2>;
+               gpio-controller;
+       };
 };
 
 &uart {
index 117198f70b5490e1ba9ee5707f8080bc78582163..01020810ccc73368b118d4d14a097db88c6f97c2 100644 (file)
@@ -141,7 +141,7 @@ define Device/netgear_wndr3x00
   IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | netgear-squashfs | append-rootfs | pad-rootfs
   IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | check-size $$$$(IMAGE_SIZE)
   IMAGE/factory.img := $$(IMAGE/default) | netgear-dni | check-size $$$$(IMAGE_SIZE)
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport kmod-leds-reset
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport kmod-leds-reset kmod-owl-loader
 endef
 
 define Device/netgear_wndr3700