mips: [RFC] adding support for APJET01 ref board

Oleksandr Hnatiuk dev at alexconst.sh
Sun Nov 7 12:28:53 PST 2021


From: Oleksandr Hnatiuk <dev at alexconst.sh>
Signed-off-by: Oleksandr Hnatiuk <dev at alexconst.sh>

Wrote incomplete device tree. Added new device to the build system.
---
Hi! I'm trying to add support for a new board based on QCN5502 SoC and I'm
unsure about how to proceed with my device tree. Below are the information
about hardware on the device and my current patches. Another device with
the same SoC is partially supported in this PR:
https://github.com/openwrt/openwrt/pull/4271. The patches to get the CPU
working seem trivial.

Arch: mips/ath79
SoC: QCN5502
Board: Qualcomm Atheros APJET01 reference board
Sold by ASUS under these names: RT-AC57U v2, RT-AC58U v2, RT-AC59U
Flash: 16 MiB (Winbond SPI nor flash)
RAM: 128 MiB (Winbond W971GG6SB-25)
Switch: Qualcomm Atheros QCA8337
2.4 GHz Wi-Fi: 802.11n 4T4R QCN5502 (integrated into the CPU?)
5 GHz Wi-Fi: 802.11ac 2T2R QCA9888
Other: USB 2.0
Additional info: https://wikidevi.wi-cat.ru/ASUS_RT-AC59U

Questions regarding device tree:

1. Is there anything else I should add to it or change?
2. How would I describe switch and ports on the board?
3. The clock of what chip does clock-frequency refer to?
4. Which partitions should be made read-only?

Questions regarding modifications to OpenWrt files for new device support:

5. How do I figure out which case is suitable for my device in
target/linux/ath79/generic/base-files/etc/board.d/02_network?
6. In target/linux/ath79/image/generic.mk, what does LOADER_FLASH_OFFS
variabe mean?
7. How do I know the IMAGE_SIZE for my device? Can I omit it?
8. Does the patch to target/linux/ath79/image/generic.mk look OK?

diff --git a/target/linux/ath79/dts/qcn5502_asus_rtac59u.dts b/target/linux/ath79/dts/qcn5502_asus_rtac59u.dts
new file mode 100644
index 0000000000..364bf4b502
--- /dev/null
+++ b/target/linux/ath79/dts/qcn5502_asus_rtac59u.dts
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "qca956x.dtsi"
+
+/ {
+	compatible = "asus,rt-ac59u", "qca,qcn5502", "qca,qca9560";
+	model = "ASUS RT-AC59U";
+
+	aliases {
+		serial0 = &uart;
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu at 0 {
+			device_type = "cpu";
+			compatible = "mips,mips74Kc";
+			clocks = <&pll ATH79_CLK_CPU>;
+			reg = <0>;
+		};
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x0 0x8000000>;
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		wlan {
+			label = "apjet01:green:wlan";
+			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+		};
+
+		usb {
+			label = "apjet01:green:usb",
+			gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+		};
+
+		lan at 1 {
+			label = "apjet01:green:lan";
+			gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
+		};
+
+		lan at 2 {
+			label = "apjet01:green:lan";
+			gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+		};
+
+		lan at 3 {
+			label = "apjet01:green:lan";
+			gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+		};
+
+		lan at 4 {
+			label = "apjet01:green:lan";
+			gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		button at 0 {
+			label = "wps";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+
+		button at 1 {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+};
+
+&ref {
+	// TODO
+	//clock-frequency = <25000000>;
+};
+
+&uart {
+	status = "okay";
+};
+
+&gpio {
+	status = "okay";
+};
+
+&spi {
+	status = "okay";
+
+	flash at 0 {
+		compatible = "winbond,w25q128", "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <25000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "u-boot";
+				reg = <0x000000 0x040000>;
+			};
+
+			partition at 040000 {
+				label = "nvram";
+				reg = <0x040000 0x010000>;
+			};
+
+			partition at 050000 {
+				label = "factory";
+				reg = <0x050000 0x010000>;
+			};
+
+			partition at 060000 {
+				label = "linux";
+				reg = <0x060000 0xf20000>;
+			};
+
+			partition at 19ab80 {
+				label = "rootfs";
+				reg = <0x19ab80 0xde5480>;
+			};
+
+			partition at f80000 {
+				label = "jffs2";
+				reg = <0xf80000 0x080000>;
+			};
+
+			partition at 0 {
+				label = "ALL";
+				reg = <0x000000 0x1000000>;
+				read-only;
+			};
+		};
+	};
+};
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index 9d0be2b86b..2b571a61d8 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -1963,6 +1963,30 @@ define Device/qca_ap143-16m
 endef
 TARGET_DEVICES += qca_ap143-16m
 
+define Device/qca_apjet01
+  SOC := qcn5502
+  DEVICE_VENDOR := Qualcomm Atheros
+  DEVICE_MODEL := APJET01
+  DEVICE_PACKAGES := kmod-usb2
+  SUPPORTED_DEVICES += apjet01
+  LOADER_TYPE := bin
+  KERNEL := kernel-bin | append-dtb | lzma -d20 | uImage lzma
+  COMPILE := loader-$(1).bin loader-$(1).uImage
+  COMPILE/loader-$(1).bin := loader-okli-compile
+  COMPILE/loader-$(1).uImage := append-loader-okli $(1) | pad-to 64k | lzma | \
+   uImage lzma
+endef
+
+define Device/qca_apjet01-16m
+  $(Device/qca_apjet01)
+  DEVICE_VARIANT := (16M)
+  IMAGES += factory.bin
+  IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | \
+  append-rootfs | pad-rootfs | check-size | pad-to 14528k | \
+   append-loader-okli-uimage $(1) | pad-to 64k
+endef
+TARGET_DEVICES += qca_apjet01-16m
+
 define Device/qihoo_c301
   $(Device/seama)
   SOC := ar9344
-- 
2.30.2



More information about the openwrt-devel mailing list