[OpenWrt-Devel] [PATCH 1/3] mac80211: ath9k: add GPIO mask dts property

2019-12-21 Thread Michal Cieslakiewicz
This patch adds 'qca,gpio-mask=' device tree property to ath9k node.
This optional setting is a hack and should only be used in very special
(and rare) cases when a button or LED is wired to a GPIO pin normally
masked out (due to being one-way etc). Netgear WNDR4300 v2 is one such
example - it uses GPI9 for RFKILL.

See ath9k/reg.h *_GPIO_MASK constants.

Use with caution and expect to see stream of kernel warnings if wrong
mask value is provided.

Signed-off-by: Michal Cieslakiewicz 
---
 .../patches/ath/553-ath9k_of_gpio_mask.patch  | 25 +++
 1 file changed, 25 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch

diff --git a/package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch 
b/package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch
new file mode 100644
index 00..72b99050c4
--- /dev/null
+++ b/package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch
@@ -0,0 +1,25 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
 b/drivers/net/wireless/ath/ath9k/init.c
+@@ -654,6 +654,12 @@ static int ath9k_of_init(struct ath_soft
+   return 0;
+ }
+ 
++static void ath9k_of_gpio_mask(struct ath_softc *sc)
++{
++  of_property_read_u32(sc->dev->of_node, "qca,gpio-mask",
++   &sc->sc_ah->caps.gpio_mask);
++}
++
+ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
+   const struct ath_bus_ops *bus_ops)
+ {
+@@ -758,6 +764,9 @@ static int ath9k_init_softc(u16 devid, s
+   if (ret)
+   goto err_hw;
+ 
++  /* GPIO mask quirk */
++  ath9k_of_gpio_mask(sc);
++
+   ret = ath9k_init_queues(sc);
+   if (ret)
+   goto err_queues;
-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] ath79: add support for Netgear WNDR4300 v2

2019-12-21 Thread Michal Cieslakiewicz
This patch introduces support for Netgear WNDR4300v2.

Specification
=
  * Description: Netgear WNDR4300 v2
  * Loader: U-boot
  * SOC: Qualcomm Atheros QCA9563 (775 MHz)
  * RAM: 128 MiB
  * Flash: 2 MiB SPI-NOR + 128 MiB SPI-NAND
- NOR: U-boot binary: 256 KiB
- NOR: U-boot environment: 64 KiB
- NOR: ART Backup: 64 KiB
- NOR: Config: 64 KiB
- NOR: Traffic Meter: 64 KiB
- NOR: POT: 64 KiB
- NOR: Reserved: 1408 KiB
- NOR: ART: 64 KiB
- NAND: Firmware: 25600 KiB (see notes for OpenWrt)
- NAND: Language: 2048 KiB
- NAND: mtdoops Crash Dump: 128 KiB
- NAND: Reserved: 103296 KiB
  * Ethernet: 5 x 10/100/1000 (4 x LAN, 1 x WAN) (AR8337)
  * Wireless:
- 2.4 GHz b/g/n (internal)
- 5 GHz a/n (AR9580)
  * USB: yes, 1 x USB 2.0
  * Buttons:
- Reset
- WiFi (rfkill)
- WPS
  * LEDs:
- Power (amber/green)
- WAN (amber/green)
- WLAN 2G (green)
- WLAN 5G (blue)
- 4 x LAN (amber/green)
- USB (green)
- WPS (green)
  * UART: 4-pin connector JP1, 3.3V (Vcc, TX, RX, GND), 115200 8N1
  * Power supply: DC 12V 1.5A
  * MAC addresses: LAN=WLAN2G on case label, WAN +1, WLAN5G +2

Important Notes
===
0. NOR Flash (2 MiB) is not touched by OpenWrt installation.
1. NAND Flash (128 MiB) layout under OpenWrt is changed as follows:
   all space is assigned to 'firmware' partition which is divided into
   2 MiB kernel and 126 MiB UBI areas; vendor partitions (language and
   mtdoops) are removed; kernel space size can be increased if needed;
   maximum image size is set to 25600k for compatibility and can also
   be increased.
2. CPU clock is 775 MHz, not 750 MHz.
3. 5 GHz wireless radio chip is Atheros AR9580-AR1A with bogus PCI
   device ID 0xabcd. For ath9k driver to load successfully, this is
   overriden in DTS with correct value for this chip, 0x0033.
4. RFKILL button is wired to AR9580 pin 9 which is normally disabled
   by chip definition in ath9k code (0xF4FF gpio mask). Therefore
   'qca,gpio-mask=<0xf6ff>' hack must be used for button to work
   properly.
5. USB port is always on, no GPIO for 5V power control has been
   identified.

Installation

  * TFTP recovery
  * TFTP via U-boot prompt
  * sysupgrade
  * Web interface

Test build configuration

CONFIG_TARGET_ath79=y
CONFIG_TARGET_ath79_nand=y
CONFIG_TARGET_ath79_nand_DEVICE_netgear_wndr4300-v2=y
CONFIG_ALL_KMODS=y
CONFIG_DEVEL=y
CONFIG_CCACHE=y
CONFIG_COLLECT_KERNEL_DEBUG=y
CONFIG_IMAGEOPT=y

Signed-off-by: Michal Cieslakiewicz 
---
 package/boot/uboot-envtools/files/ath79   |   1 +
 .../linux/ath79/dts/qca9563_netgear_wndr.dtsi | 262 ++
 .../ath79/dts/qca9563_netgear_wndr4300-v2.dts |  19 ++
 target/linux/ath79/image/nand.mk  |  11 +
 .../ath79/nand/base-files/etc/board.d/01_leds |   3 +-
 .../nand/base-files/etc/board.d/02_network|   6 +-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|   6 +-
 7 files changed, 303 insertions(+), 5 deletions(-)
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4300-v2.dts

diff --git a/package/boot/uboot-envtools/files/ath79 
b/package/boot/uboot-envtools/files/ath79
index f956cf4ed4..85a0342a60 100644
--- a/package/boot/uboot-envtools/files/ath79
+++ b/package/boot/uboot-envtools/files/ath79
@@ -26,6 +26,7 @@ glinet,gl-ar750s-nor-nand|\
 librerouter,librerouter-v1|\
 netgear,ex6400|\
 netgear,ex7300|\
+netgear,wndr4300-v2|\
 netgear,wnr1000-v2|\
 netgear,wnr2000-v3|\
 netgear,wnr2200-8m|\
diff --git a/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi 
b/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
new file mode 100644
index 00..b9f76b1fe9
--- /dev/null
+++ b/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
@@ -0,0 +1,262 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include 
+#include 
+
+#include "qca956x.dtsi"
+
+/ {
+   chosen {
+   bootargs = "console=ttyS0,115200n8";
+   };
+
+   aliases {
+   led-boot = &led_power_amber;
+   led-failsafe = &led_power_amber;
+   led-running = &led_power_green;
+   led-upgrade = &led_power_amber;
+   label-mac-device = ð0;
+   };
+
+   keys {
+   compatible = "gpio-keys";
+
+   wps {
+   label = "wps";
+   linux,code = ;
+   gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+   };
+
+   reset {
+   label = "reset";
+   linux,code = ;
+   gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   ath9k-keys {
+   compatible = "gpio-keys-polled";
+   poll-interval = <20>;
+
+   rfkill {
+   label = 

[OpenWrt-Devel] [PATCH 0/3] ath79: add support for QCA9563-based Netgear WNDR routers

2019-12-21 Thread Michal Cieslakiewicz
This patchset introduces support for two Netgear dual-band routers
based on the same PCB (29764821) with QCA9563 SoC, AR9580 5GHz chip,
128 MiB RAM, 2 MiB SPI-NOR + 128 MiB SPI-NAND flash:
* Netgear WNDR4300 v2
* Netgear WNDR4500 v3

WNDR4300v2 has been tested successfully with this patchset applied
to master branch. Since I have no access to 4500v3, configuration
for this device is based on information provided by various websites,
including abandoned ar71xx patch https://patchwork.ozlabs.org/patch/809227/

Note: technical wikis claim device is running CPU @ 750 MHz, while on my
WNDR4300v2 both u-boot and OpenWrt report CPU clock value of 775 MHz.

MAC address printed on device label is for LAN interface (ART offset 0x0).

Patch #1 is a prerequisite and allows to unmask certain pins for
ath9k-compatible wireless chips using Device Tree definition. Parameter
is labelled "qca,gpio-mask" and accepts u32 value (see *_GPIO_MASK
constants in ath9k/reg.h file). One of main reasons for blocking access
to these pins is that they provide only one-way communication (in or out).
Here - setting new mask to 0xf6ff (default one is 0xf4ff) enables RFKILL
button wired to input pin 9.

Patch list (3):
  mac80211: ath9k: add GPIO mask dts property
  ath79: add support for Netgear WNDR4300 v2
  ath79: add support for Netgear WNDR4500 v3

 package/boot/uboot-envtools/files/ath79   |   2 +
 .../patches/ath/553-ath9k_of_gpio_mask.patch  |  25 ++
 .../linux/ath79/dts/qca9563_netgear_wndr.dtsi | 262 ++
 .../ath79/dts/qca9563_netgear_wndr4300-v2.dts |  19 ++
 .../ath79/dts/qca9563_netgear_wndr4500-v3.dts |  41 +++
 target/linux/ath79/image/nand.mk  |  22 ++
 .../ath79/nand/base-files/etc/board.d/01_leds |   4 +-
 .../nand/base-files/etc/board.d/02_network|   8 +-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|   8 +-
 9 files changed, 386 insertions(+), 5 deletions(-)
 create mode 100644 
package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4300-v2.dts
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts

-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/3] ath79: add support for Netgear WNDR4500 v3

2019-12-21 Thread Michal Cieslakiewicz
This patch introduces support for Netgear WNDR4500v3. Router
is very similar to WNDR4300v2 and is based on the same PCB.

Information gathered from various Internet sources (including
https://patchwork.ozlabs.org/patch/809227/) shows following
differences to WNDR4300v2:

 * two USB 2.0 ports with separate LEDs
 * WPS and RFKILL buttons soldered to secondary pads
 * described as N900 device with 3x3:3 MIMO for 2.4GHz radio
 * power supply requirement is DC 12V 2.5A
 * HW ID suffix differs in one digit
 * bigger case

Signed-off-by: Michal Cieslakiewicz 
---
 package/boot/uboot-envtools/files/ath79   |  1 +
 .../ath79/dts/qca9563_netgear_wndr4500-v3.dts | 41 +++
 target/linux/ath79/image/nand.mk  | 11 +
 .../ath79/nand/base-files/etc/board.d/01_leds |  3 +-
 .../nand/base-files/etc/board.d/02_network|  6 ++-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  6 ++-
 6 files changed, 63 insertions(+), 5 deletions(-)
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts

diff --git a/package/boot/uboot-envtools/files/ath79 
b/package/boot/uboot-envtools/files/ath79
index 85a0342a60..aafced98db 100644
--- a/package/boot/uboot-envtools/files/ath79
+++ b/package/boot/uboot-envtools/files/ath79
@@ -27,6 +27,7 @@ librerouter,librerouter-v1|\
 netgear,ex6400|\
 netgear,ex7300|\
 netgear,wndr4300-v2|\
+netgear,wndr4500-v3|\
 netgear,wnr1000-v2|\
 netgear,wnr2000-v3|\
 netgear,wnr2200-8m|\
diff --git a/target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts 
b/target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts
new file mode 100644
index 00..95e30ea84b
--- /dev/null
+++ b/target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9563_netgear_wndr.dtsi"
+
+/ {
+   compatible = "netgear,wndr4500-v3", "qca,qca9563";
+   model = "Netgear WNDR4500 v3";
+};
+
+&leds {
+   usb1_green {
+   label = "netgear:green:usb1";
+   gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+   trigger-sources = <&hub_port0>;
+   linux,default-trigger = "usbport";
+   };
+
+   usb2_green {
+   label = "netgear:green:usb2";
+   gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+   trigger-sources = <&hub_port1>;
+   linux,default-trigger = "usbport";
+   };
+};
+
+&usb_phy1 {
+   status = "okay";
+};
+
+&usb1 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "okay";
+
+   hub_port1: port@1 {
+   reg = <1>;
+   #trigger-source-cells = <0>;
+   };
+};
diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index a81127a962..529ae870a5 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -162,6 +162,17 @@ define Device/netgear_wndr4300-v2
 endef
 TARGET_DEVICES += netgear_wndr4300-v2
 
+define Device/netgear_wndr4500-v3
+  SOC := qca9563
+  DEVICE_MODEL := WNDR4500
+  DEVICE_VARIANT := v3
+  NETGEAR_KERNEL_MAGIC := 0x27051956
+  NETGEAR_BOARD_ID := WNDR4500series
+  NETGEAR_HW_ID := 29764821+2+128+128+3x3+3x3+5508012173
+  $(Device/netgear_ath79_nand)
+endef
+TARGET_DEVICES += netgear_wndr4500-v3
+
 define Device/zyxel_nbg6716
   SOC := qca9558
   DEVICE_VENDOR := ZyXEL
diff --git a/target/linux/ath79/nand/base-files/etc/board.d/01_leds 
b/target/linux/ath79/nand/base-files/etc/board.d/01_leds
index 0376b7cfc6..d9989ec538 100755
--- a/target/linux/ath79/nand/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/nand/base-files/etc/board.d/01_leds
@@ -14,7 +14,8 @@ glinet,gl-ar300m-nor)
;;
 netgear,wndr3700-v4|\
 netgear,wndr4300|\
-netgear,wndr4300-v2)
+netgear,wndr4300-v2|\
+netgear,wndr4500-v3)
ucidef_set_led_switch "wan-amber" "WAN (amber)" "netgear:amber:wan" 
"switch0" "0x20"
;;
 esac
diff --git a/target/linux/ath79/nand/base-files/etc/board.d/02_network 
b/target/linux/ath79/nand/base-files/etc/board.d/02_network
index 135a06d44b..bd02a4b383 100755
--- a/target/linux/ath79/nand/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/nand/base-files/etc/board.d/02_network
@@ -18,7 +18,8 @@ ath79_setup_interfaces()
;;
netgear,wndr3700-v4|\
netgear,wndr4300|\
-   netgear,wndr4300-v2)
+   netgear,wndr4300-v2|\
+   netgear,wndr4500-v3)
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
;;
@@ -39,7 +40,8 @@ ath79_setup_macs()
case "$board" in
netgear,wndr3700-v4|\
netgear,wndr4300|\
-   netgear,wndr4300-v2)
+   netgear,wndr4300-v2|\
+   netgear,wndr4500-v3)
wan_mac=$(mtd_get_mac_binary caldata 0x6)
;;
zyxel,nbg6716)
diff --git 
a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/ath79/nand/base-files/e

[OpenWrt-Devel] [PATCH 3/3] ath79: add support for Netgear WNDR4500 v3

2019-12-21 Thread Michal Cieslakiewicz
This patch introduces support for Netgear WNDR4500v3. Router
is very similar to WNDR4300v2 and is based on the same PCB.

Information gathered from various Internet sources (including
https://patchwork.ozlabs.org/patch/809227/) shows following
differences to WNDR4300v2:

 * two USB 2.0 ports
 * WPS and RFKILL buttons soldered to secondary pads
 * described as N900 device with 3x3:3 MIMO for 2.4GHz radio
 * power supply requirement is DC 12V 2.5A
 * HW ID suffix differs in one digit
 * bigger case

Signed-off-by: Michal Cieslakiewicz 
---
 package/boot/uboot-envtools/files/ath79   |  1 +
 .../ath79/dts/qca9563_netgear_wndr4500-v3.dts | 41 +++
 target/linux/ath79/image/nand.mk  | 11 +
 .../ath79/nand/base-files/etc/board.d/01_leds |  3 +-
 .../nand/base-files/etc/board.d/02_network|  6 ++-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  6 ++-
 6 files changed, 63 insertions(+), 5 deletions(-)
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts

diff --git a/package/boot/uboot-envtools/files/ath79 
b/package/boot/uboot-envtools/files/ath79
index 85a0342a60..aafced98db 100644
--- a/package/boot/uboot-envtools/files/ath79
+++ b/package/boot/uboot-envtools/files/ath79
@@ -27,6 +27,7 @@ librerouter,librerouter-v1|\
 netgear,ex6400|\
 netgear,ex7300|\
 netgear,wndr4300-v2|\
+netgear,wndr4500-v3|\
 netgear,wnr1000-v2|\
 netgear,wnr2000-v3|\
 netgear,wnr2200-8m|\
diff --git a/target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts 
b/target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts
new file mode 100644
index 00..95e30ea84b
--- /dev/null
+++ b/target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9563_netgear_wndr.dtsi"
+
+/ {
+   compatible = "netgear,wndr4500-v3", "qca,qca9563";
+   model = "Netgear WNDR4500 v3";
+};
+
+&leds {
+   usb1_green {
+   label = "netgear:green:usb1";
+   gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+   trigger-sources = <&hub_port0>;
+   linux,default-trigger = "usbport";
+   };
+
+   usb2_green {
+   label = "netgear:green:usb2";
+   gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+   trigger-sources = <&hub_port1>;
+   linux,default-trigger = "usbport";
+   };
+};
+
+&usb_phy1 {
+   status = "okay";
+};
+
+&usb1 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "okay";
+
+   hub_port1: port@1 {
+   reg = <1>;
+   #trigger-source-cells = <0>;
+   };
+};
diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index a81127a962..529ae870a5 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -162,6 +162,17 @@ define Device/netgear_wndr4300-v2
 endef
 TARGET_DEVICES += netgear_wndr4300-v2
 
+define Device/netgear_wndr4500-v3
+  SOC := qca9563
+  DEVICE_MODEL := WNDR4500
+  DEVICE_VARIANT := v3
+  NETGEAR_KERNEL_MAGIC := 0x27051956
+  NETGEAR_BOARD_ID := WNDR4500series
+  NETGEAR_HW_ID := 29764821+2+128+128+3x3+3x3+5508012173
+  $(Device/netgear_ath79_nand)
+endef
+TARGET_DEVICES += netgear_wndr4500-v3
+
 define Device/zyxel_nbg6716
   SOC := qca9558
   DEVICE_VENDOR := ZyXEL
diff --git a/target/linux/ath79/nand/base-files/etc/board.d/01_leds 
b/target/linux/ath79/nand/base-files/etc/board.d/01_leds
index 0376b7cfc6..d9989ec538 100755
--- a/target/linux/ath79/nand/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/nand/base-files/etc/board.d/01_leds
@@ -14,7 +14,8 @@ glinet,gl-ar300m-nor)
;;
 netgear,wndr3700-v4|\
 netgear,wndr4300|\
-netgear,wndr4300-v2)
+netgear,wndr4300-v2|\
+netgear,wndr4500-v3)
ucidef_set_led_switch "wan-amber" "WAN (amber)" "netgear:amber:wan" 
"switch0" "0x20"
;;
 esac
diff --git a/target/linux/ath79/nand/base-files/etc/board.d/02_network 
b/target/linux/ath79/nand/base-files/etc/board.d/02_network
index 135a06d44b..bd02a4b383 100755
--- a/target/linux/ath79/nand/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/nand/base-files/etc/board.d/02_network
@@ -18,7 +18,8 @@ ath79_setup_interfaces()
;;
netgear,wndr3700-v4|\
netgear,wndr4300|\
-   netgear,wndr4300-v2)
+   netgear,wndr4300-v2|\
+   netgear,wndr4500-v3)
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
;;
@@ -39,7 +40,8 @@ ath79_setup_macs()
case "$board" in
netgear,wndr3700-v4|\
netgear,wndr4300|\
-   netgear,wndr4300-v2)
+   netgear,wndr4300-v2|\
+   netgear,wndr4500-v3)
wan_mac=$(mtd_get_mac_binary caldata 0x6)
;;
zyxel,nbg6716)
diff --git 
a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmwa

[OpenWrt-Devel] [PATCH 1/3] mac80211: ath9k: add GPIO mask dts property

2019-12-21 Thread Michal Cieslakiewicz
This patch adds 'qca,gpio-mask=' device tree property to ath9k node.
This optional setting is a hack and should only be used in very special
(and rare) cases when a button or LED is wired to a GPIO pin normally
masked out (due to being one-way etc). Netgear WNDR4300 v2 is one such
example - it uses GPI9 for RFKILL.

See ath9k/reg.h *_GPIO_MASK constants.

Use with caution and expect to see stream of kernel warnings if wrong
mask value is provided.

Signed-off-by: Michal Cieslakiewicz 
---
 .../patches/ath/553-ath9k_of_gpio_mask.patch  | 25 +++
 1 file changed, 25 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch

diff --git a/package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch 
b/package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch
new file mode 100644
index 00..72b99050c4
--- /dev/null
+++ b/package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch
@@ -0,0 +1,25 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
 b/drivers/net/wireless/ath/ath9k/init.c
+@@ -654,6 +654,12 @@ static int ath9k_of_init(struct ath_soft
+   return 0;
+ }
+ 
++static void ath9k_of_gpio_mask(struct ath_softc *sc)
++{
++  of_property_read_u32(sc->dev->of_node, "qca,gpio-mask",
++   &sc->sc_ah->caps.gpio_mask);
++}
++
+ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
+   const struct ath_bus_ops *bus_ops)
+ {
+@@ -758,6 +764,9 @@ static int ath9k_init_softc(u16 devid, s
+   if (ret)
+   goto err_hw;
+ 
++  /* GPIO mask quirk */
++  ath9k_of_gpio_mask(sc);
++
+   ret = ath9k_init_queues(sc);
+   if (ret)
+   goto err_queues;
-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] ath79: add support for Netgear WNDR4300 v2

2019-12-21 Thread Michal Cieslakiewicz
This patch introduces support for Netgear WNDR4300v2.

Specification
=
  * Description: Netgear WNDR4300 v2
  * Loader: U-boot
  * SOC: Qualcomm Atheros QCA9563 (775 MHz)
  * RAM: 128 MiB
  * Flash: 2 MiB SPI-NOR + 128 MiB SPI-NAND
- NOR: U-boot binary: 256 KiB
- NOR: U-boot environment: 64 KiB
- NOR: ART Backup: 64 KiB
- NOR: Config: 64 KiB
- NOR: Traffic Meter: 64 KiB
- NOR: POT: 64 KiB
- NOR: Reserved: 1408 KiB
- NOR: ART: 64 KiB
- NAND: Firmware: 25600 KiB (see notes for OpenWrt)
- NAND: Language: 2048 KiB
- NAND: mtdoops Crash Dump: 128 KiB
- NAND: Reserved: 103296 KiB
  * Ethernet: 5 x 10/100/1000 (4 x LAN, 1 x WAN) (AR8337)
  * Wireless:
- 2.4 GHz b/g/n (internal)
- 5 GHz a/n (AR9580)
  * USB: yes, 1 x USB 2.0
  * Buttons:
- Reset
- WiFi (rfkill)
- WPS
  * LEDs:
- Power (amber/green)
- WAN (amber/green)
- WLAN 2G (green)
- WLAN 5G (blue)
- 4 x LAN (amber/green)
- USB (green)
- WPS (green)
  * UART: 4-pin connector JP1, 3.3V (Vcc, TX, RX, GND), 115200 8N1
  * Power supply: DC 12V 1.5A
  * MAC addresses: LAN=WLAN2G on case label, WAN +1, WLAN5G +2

Important Notes
===
0. NOR Flash (2 MiB) is not touched by OpenWrt installation.
1. NAND Flash (128 MiB) layout under OpenWrt is changed as follows:
   all space is assigned to 'firmware' partition which is divided into
   2 MiB kernel and 126 MiB UBI areas; vendor partitions (language and
   mtdoops) are removed; kernel space size can be increased if needed;
   maximum image size is set to 25600k for compatibility and can also
   be increased.
2. 5 GHz wireless radio chip is Atheros AR9580-AR1A with bogus PCI
   device ID 0xabcd. For ath9k driver to load successfully, this is
   overriden in DTS with correct value for this chip, 0x0033.
3. RFKILL button is wired to AR9580 pin 9 which is normally disabled
   by chip definition in ath9k code (0xF4FF gpio mask). Therefore
   'qca,gpio-mask=<0xf6ff>' hack must be used for button to work
   properly.
4. USB port is always on, no GPIO for 5V power control has been
   identified.

Installation

  * TFTP recovery
  * TFTP via U-boot prompt
  * sysupgrade
  * Web interface

Test build configuration

CONFIG_TARGET_ath79=y
CONFIG_TARGET_ath79_nand=y
CONFIG_TARGET_ath79_nand_DEVICE_netgear_wndr4300-v2=y
CONFIG_ALL_KMODS=y
CONFIG_DEVEL=y
CONFIG_CCACHE=y
CONFIG_COLLECT_KERNEL_DEBUG=y
CONFIG_IMAGEOPT=y

Signed-off-by: Michal Cieslakiewicz 
---
 package/boot/uboot-envtools/files/ath79   |   1 +
 .../linux/ath79/dts/qca9563_netgear_wndr.dtsi | 262 ++
 .../ath79/dts/qca9563_netgear_wndr4300-v2.dts |  19 ++
 target/linux/ath79/image/nand.mk  |  11 +
 .../ath79/nand/base-files/etc/board.d/01_leds |   3 +-
 .../nand/base-files/etc/board.d/02_network|   6 +-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|   6 +-
 7 files changed, 303 insertions(+), 5 deletions(-)
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4300-v2.dts

diff --git a/package/boot/uboot-envtools/files/ath79 
b/package/boot/uboot-envtools/files/ath79
index f956cf4ed4..85a0342a60 100644
--- a/package/boot/uboot-envtools/files/ath79
+++ b/package/boot/uboot-envtools/files/ath79
@@ -26,6 +26,7 @@ glinet,gl-ar750s-nor-nand|\
 librerouter,librerouter-v1|\
 netgear,ex6400|\
 netgear,ex7300|\
+netgear,wndr4300-v2|\
 netgear,wnr1000-v2|\
 netgear,wnr2000-v3|\
 netgear,wnr2200-8m|\
diff --git a/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi 
b/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
new file mode 100644
index 00..b9f76b1fe9
--- /dev/null
+++ b/target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
@@ -0,0 +1,262 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include 
+#include 
+
+#include "qca956x.dtsi"
+
+/ {
+   chosen {
+   bootargs = "console=ttyS0,115200n8";
+   };
+
+   aliases {
+   led-boot = &led_power_amber;
+   led-failsafe = &led_power_amber;
+   led-running = &led_power_green;
+   led-upgrade = &led_power_amber;
+   label-mac-device = ð0;
+   };
+
+   keys {
+   compatible = "gpio-keys";
+
+   wps {
+   label = "wps";
+   linux,code = ;
+   gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+   };
+
+   reset {
+   label = "reset";
+   linux,code = ;
+   gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   ath9k-keys {
+   compatible = "gpio-keys-polled";
+   poll-interval = <20>;
+
+   rfkill {
+   label = "rfkill";
+   linu

[OpenWrt-Devel] [PATCH 0/3] ath79: add support for QCA9563-based Netgear WNDR routers

2019-12-21 Thread Michal Cieslakiewicz


(resent due to me being lazy and using reply-to, apologies and pls
ignore previous thread)

This patchset introduces support for two Netgear dual-band routers
based on the same PCB (29764821) with QCA9563 SoC, AR9580 5GHz chip,
128 MiB RAM, 2 MiB SPI-NOR + 128 MiB SPI-NAND flash:
* Netgear WNDR4300 v2
* Netgear WNDR4500 v3

WNDR4300v2 has been tested successfully with this patchset applied
to master branch. Since I have no access to 4500v3, configuration
for this device is based on information provided by various websites,
including abandoned ar71xx patch https://patchwork.ozlabs.org/patch/809227/

Note: technical wikis claim device is running CPU @ 750 MHz, while on my
WNDR4300v2 both u-boot and OpenWrt report CPU clock value of 775 MHz.

MAC address printed on device label is for LAN interface (ART offset 0x0).

Patch #1 is a prerequisite and allows to unmask certain pins for
ath9k-compatible wireless chips using Device Tree definition. Parameter
is labelled "qca,gpio-mask" and accepts u32 value (see *_GPIO_MASK
constants in ath9k/reg.h file). One of main reasons for blocking access
to these pins is that they provide only one-way communication (in or out).
Here - setting new mask to 0xf6ff (default one is 0xf4ff) enables RFKILL
button wired to input pin 9.

Patch list (3):
  mac80211: ath9k: add GPIO mask dts property
  ath79: add support for Netgear WNDR4300 v2
  ath79: add support for Netgear WNDR4500 v3

 package/boot/uboot-envtools/files/ath79   |   2 +
 .../patches/ath/553-ath9k_of_gpio_mask.patch  |  25 ++
 .../linux/ath79/dts/qca9563_netgear_wndr.dtsi | 262 ++
 .../ath79/dts/qca9563_netgear_wndr4300-v2.dts |  19 ++
 .../ath79/dts/qca9563_netgear_wndr4500-v3.dts |  41 +++
 target/linux/ath79/image/nand.mk  |  22 ++
 .../ath79/nand/base-files/etc/board.d/01_leds |   4 +-
 .../nand/base-files/etc/board.d/02_network|   8 +-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|   8 +-
 9 files changed, 386 insertions(+), 5 deletions(-)
 create mode 100644 
package/kernel/mac80211/patches/ath/553-ath9k_of_gpio_mask.patch
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr.dtsi
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4300-v2.dts
 create mode 100644 target/linux/ath79/dts/qca9563_netgear_wndr4500-v3.dts

-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/3] ath79: add support for Netgear WNDR4300 v2

2019-12-21 Thread David Bauer
Hello Michal,

On 12/21/19 2:54 PM, Michal Cieslakiewicz wrote:
> 1. NAND Flash (128 MiB) layout under OpenWrt is changed as follows:
>all space is assigned to 'firmware' partition which is divided into
>2 MiB kernel and 126 MiB UBI areas; vendor partitions (language and
>mtdoops) are removed; kernel space size can be increased if needed;
>maximum image size is set to 25600k for compatibility and can also
>be increased.

Do you know if there is a hard limit to the kernel size? OpenWrt does not 
support
relocation of UBI as doing so would interfere with wear leveling.
This means the kernel size is more or less fixed if we want to be able to use 
sysupgrade.

I personally would prefer to allocate 4 (or even 8) megabytes to the kernel 
partition.
This would give us a lot more flexibility (ath79 kernel is already at ~1.8MB 
the last time
I've checked.

> + flash@1 {
> + compatible = "spi-nand";
> + reg = <1>;
> + spi-max-frequency = <2500>;
> +
> + partitions {
> + compatible = "fixed-partitions";
> + #address-cells = <1>;
> + #size-cells = <1>;
> +
> + partition@0 {
> + label = "firmware";
> + reg = <0x0 0x800>;
> + compatible = "netgear,uimage";
> + };
> +
> + kernel@0 {
> + label = "kernel";
> + reg = <0x0 0x20>;
> + };
> +
> + ubi@20 {
> + label = "ubi";
> + reg = <0x20 0x7e0>;
> + };
> + };
> + };

The firmware node can be dropped, as kernel and UBI partitions are fixed.

Best wishes
David

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/3] ath79: add support for Netgear WNDR4300 v2

2019-12-21 Thread Michal Cieslakiewicz
Hello David!

> 
> Do you know if there is a hard limit to the kernel size? OpenWrt does
> not support relocation of UBI as doing so would interfere with wear
> leveling. This means the kernel size is more or less fixed if we want
> to be able to use sysupgrade.
> 

AFAIK there is no problem with increasing kernel size here.
Unfortunately I couldn't find proper u-boot source for this router, so
my claim is not based on actual code analysis. However there was
a similar question for WNDR4300(v1) and u-boot definitely allowed
kernels > 2 MiB then.

>
> I personally would prefer to allocate 4 (or even 8) megabytes to the
> kernel partition. This would give us a lot more flexibility (ath79
> kernel is already at ~1.8MB the last time I've checked.
>

That's reasonable, it's better to reserve space for future developments
than issue a patch every time kernel size grows over a certain
boundary. So in v2 I will assign 4 MiBs here - and prepare similar patch
for WNDR4300(v1) to keep them compatible.
 
> 
> The firmware node can be dropped, as kernel and UBI partitions are
> fixed.
> 

OK then, I just wasn't sure if "netgear,uimage" compatibility string is
not used somwehere in the install/config/sysupgrade process. If not,
then indeed it's redundant.

Best regards
Michal

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] perf: Add libunwind only if selected

2019-12-21 Thread Rosen Penev
The depends are totally wrong. libunwind does not work with powerpc and
i386 as it needs glibc.

Instead of duplicating the platforms, just change the dependency.

Signed-off-by: Rosen Penev 
---
 package/devel/perf/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/devel/perf/Makefile b/package/devel/perf/Makefile
index 6f31c826e5..aa5fb16f60 100644
--- a/package/devel/perf/Makefile
+++ b/package/devel/perf/Makefile
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=perf
 PKG_VERSION:=$(LINUX_VERSION)
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_USE_MIPS16:=0
 PKG_BUILD_PARALLEL:=1
@@ -26,7 +26,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/perf
   SECTION:=devel
   CATEGORY:=Development
-  DEPENDS:= +libelf +libdw 
+(mips||mipsel||powerpc||i386||x86_64||arm||aarch64):libunwind +libpthread 
+librt +objdump @!IN_SDK @!TARGET_arc770 @KERNEL_PERF_EVENTS
+  DEPENDS:= +libelf +libdw +PACKAGE_libunwind:libunwind +libpthread +librt 
+objdump @!IN_SDK @!TARGET_arc770 @KERNEL_PERF_EVENTS
   TITLE:=Linux performance monitoring tool
   VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
   URL:=http://www.kernel.org
-- 
2.24.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] OpenWrt 19.07 status

2019-12-21 Thread Luiz Angelo Daros de Luca
Hello,

19.07 page has a Roadmap without dates:
https://openwrt.org/releases/19.07/start#roadmap

It should have some real info with dates, something to make clear that it
does not have a real schedule ("It's ready when it is ready") or simply get
removed.

Regards,
---
 Luiz Angelo Daros de Luca
luizl...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel