config-21.02.0.yml:add openwrt 21.02.0

This commit is contained in:
GL.iNet-Hongjian.Zhang 2021-09-22 16:22:28 +08:00
parent 69ab71b894
commit 7c4a5df73c
9 changed files with 3640 additions and 0 deletions

8
config-21.02.0.yml Normal file
View File

@ -0,0 +1,8 @@
repo: https://github.com/openwrt/openwrt.git
branch: v21.02.0
git_clone_dir: openwrt-21.02/openwrt-21.02.0
openwrt_root_dir: openwrt-21.02/openwrt-21.02.0
revision: b2ae4233149dfd78f2ac00bb5327695bcacdc255
patch_folders:
- patches-21.02.0/

View File

@ -0,0 +1,602 @@
From 426542a5861386b9f85ca636d7eecd7374c7b82b Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Fri, 17 Sep 2021 11:45:31 +0800
Subject: [PATCH 1/8] ath79: add support for gl xe300
---
include/image-commands.mk | 33 +++
scripts/sysupgrade-tar-compat-1806.sh | 79 +++++++
.../ath79/dts/qca9531_glinet_gl-xe300-iot.dts | 29 +++
.../dts/qca9531_glinet_gl-xe300-nor-nand.dts | 25 +++
.../ath79/dts/qca9531_glinet_gl-xe300-nor.dts | 18 ++
.../ath79/dts/qca9531_glinet_gl-xe300.dtsi | 199 ++++++++++++++++++
target/linux/ath79/dts/qca953x.dtsi | 2 +-
target/linux/ath79/image/Makefile | 2 +-
target/linux/ath79/image/nand.mk | 41 ++++
.../ath79/nand/base-files/etc/board.d/01_leds | 7 +
.../nand/base-files/etc/board.d/02_network | 5 +
.../etc/uci-defaults/04_led_migration | 4 +-
.../nand/base-files/lib/upgrade/platform.sh | 4 +
13 files changed, 444 insertions(+), 4 deletions(-)
create mode 100755 scripts/sysupgrade-tar-compat-1806.sh
create mode 100644 target/linux/ath79/dts/qca9531_glinet_gl-xe300-iot.dts
create mode 100644 target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor-nand.dts
create mode 100644 target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor.dts
create mode 100755 target/linux/ath79/dts/qca9531_glinet_gl-xe300.dtsi
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 4d54a14ba4..6908f5b5c1 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -64,6 +64,31 @@ define Build/append-metadata
}
endef
+metadata_gl_json = \
+ '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
+ "metadata_version": "1.0", \
+ "supported_devices":[$(call metadata_devices,$(1))], \
+ "version": { \
+ "release": "$(shell cat $(TOPDIR)/release)", \
+ "date": "$(shell TZ='Asia/Chongqing' date '+%Y%m%d%H%M%S')", \
+ "dist": "$(call json_quote,$(VERSION_DIST))", \
+ "version": "$(call json_quote,$(VERSION_NUMBER))", \
+ "revision": "$(call json_quote,$(REVISION))", \
+ "target": "$(call json_quote,$(TARGETID))", \
+ "board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
+ }, \
+ }'
+
+define Build/append-gl-metadata
+ $(if $(SUPPORTED_DEVICES),-echo $(call metadata_gl_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
+ [ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
+ cp "$(BUILD_KEY).ucert" "$@.ucert" ;\
+ usign -S -m "$@" -s "$(BUILD_KEY)" -x "$@.sig" ;\
+ ucert -A -c "$@.ucert" -x "$@.sig" ;\
+ fwtool -S "$@.ucert" "$@" ;\
+ }
+endef
+
define Build/append-rootfs
dd if=$(IMAGE_ROOTFS) >> $@
endef
@@ -377,6 +402,14 @@ define Build/sysupgrade-tar
$@
endef
+define Build/sysupgrade-tar-compat-1806
+ sh $(TOPDIR)/scripts/sysupgrade-tar-compat-1806.sh \
+ --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
+ --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
+ --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
+ $@
+endef
+
define Build/tplink-safeloader
-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
-B $(TPLINK_BOARD_ID) \
diff --git a/scripts/sysupgrade-tar-compat-1806.sh b/scripts/sysupgrade-tar-compat-1806.sh
new file mode 100755
index 0000000000..c479688e55
--- /dev/null
+++ b/scripts/sysupgrade-tar-compat-1806.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+board=""
+board1806=""
+kernel=""
+rootfs=""
+outfile=""
+err=""
+
+while [ "$1" ]; do
+ case "$1" in
+ "--board")
+ board="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--kernel")
+ kernel="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--rootfs")
+ rootfs="$2"
+ shift
+ shift
+ continue
+ ;;
+ *)
+ if [ ! "$outfile" ]; then
+ outfile=$1
+ shift
+ continue
+ fi
+ ;;
+ esac
+done
+
+if [ ! -n "$board" -o ! -r "$kernel" -a ! -r "$rootfs" -o ! "$outfile" ]; then
+ echo "syntax: $0 [--board boardname] [--kernel kernelimage] [--rootfs rootfs] out"
+ exit 1
+fi
+
+tmpdir="$( mktemp -d 2> /dev/null )"
+if [ -z "$tmpdir" ]; then
+ # try OSX signature
+ tmpdir="$( mktemp -t 'ubitmp' -d )"
+fi
+
+if [ -z "$tmpdir" ]; then
+ exit 1
+fi
+
+echo "$tmpdir ########################################################"
+
+board1806="$(echo "$board"|cut -d '_' -f 2|awk -F '-' '{print $1 "-" $2}')"
+mkdir -p "${tmpdir}/sysupgrade-${board}"
+echo "BOARD=${board}" > "${tmpdir}/sysupgrade-${board}/CONTROL"
+mkdir -p "${tmpdir}/sysupgrade-${board1806}"
+echo "BOARD=${board1806}" > "${tmpdir}/sysupgrade-${board1806}/CONTROL"
+[ -z "${rootfs}" ] || cp "${rootfs}" "${tmpdir}/sysupgrade-${board}/root"
+[ -z "${kernel}" ] || cp "${kernel}" "${tmpdir}/sysupgrade-${board}/kernel"
+
+mtime=""
+if [ -n "$SOURCE_DATE_EPOCH" ]; then
+ mtime="--mtime=@${SOURCE_DATE_EPOCH}"
+fi
+
+(cd "$tmpdir"; tar --sort=name --owner=0 --group=0 --numeric-owner -cvf sysupgrade.tar sysupgrade-${board} sysupgrade-${board1806} ${mtime})
+err="$?"
+if [ -e "$tmpdir/sysupgrade.tar" ]; then
+ cp "$tmpdir/sysupgrade.tar" "$outfile"
+else
+ err=2
+fi
+rm -rf "$tmpdir"
+
+exit $err
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-xe300-iot.dts b/target/linux/ath79/dts/qca9531_glinet_gl-xe300-iot.dts
new file mode 100644
index 0000000000..461ec1720a
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-xe300-iot.dts
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9531_glinet_gl-xe300.dtsi"
+
+/ {
+ compatible = "glinet,gl-xe300-iot", "qca,qca9531";
+ model = "GL.iNet GL-XE300 (NOR/NAND IOT)";
+};
+
+&nor_partitions {
+ partition@60000 {
+ label = "kernel";
+ reg = <0x060000 0x400000>;
+ };
+ parition@460000 {
+ label = "nor_reserved";
+ reg = <0x460000 0xba0000>;
+ };
+};
+
+&nand_ubi {
+ label = "ubi";
+};
+
+&bootargs {
+ bootargs="";
+};
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor-nand.dts b/target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor-nand.dts
new file mode 100644
index 0000000000..35117ad875
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor-nand.dts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9531_glinet_gl-xe300.dtsi"
+
+/ {
+ compatible = "glinet,gl-xe300-nor-nand", "qca,qca9531";
+ model = "GL.iNet GL-XE300 (NOR/NAND)";
+};
+
+&nor_partitions {
+ partition@60000 {
+ label = "kernel";
+ reg = <0x060000 0x400000>;
+ };
+ parition@460000 {
+ label = "nor_reserved";
+ reg = <0x460000 0xba0000>;
+ };
+};
+
+&nand_ubi {
+ label = "ubi";
+};
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor.dts b/target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor.dts
new file mode 100644
index 0000000000..9b67f49368
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-xe300-nor.dts
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9531_glinet_gl-xe300.dtsi"
+
+/ {
+ compatible = "glinet,gl-xe300-nor", "qca,qca9531";
+ model = "GL.iNet GL-XE300 (NOR)";
+};
+
+&nor_partitions {
+ partition@60000 {
+ compatible = "denx,uimage";
+ label = "firmware";
+ reg = <0x060000 0xfa0000>;
+ };
+};
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-xe300.dtsi b/target/linux/ath79/dts/qca9531_glinet_gl-xe300.dtsi
new file mode 100755
index 0000000000..07e4f9cd44
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-xe300.dtsi
@@ -0,0 +1,199 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "qca953x.dtsi"
+
+/ {
+ compatible = "glinet,gl-xe300", "qca,qca9531";
+ model = "GL.iNet GL-XE300";
+
+ gl_hw {
+ compatible = "gl-hw-info";
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ model = "xe300";
+ wan = "eth1";
+ lan = "eth0";
+ build-in-modem = "1-1.2";
+ reset-button = "gpio-3";
+ usb-port = "1-1.3";
+ nand;
+ factory_data {
+ device_mac = <&art 0>;
+ device_ddns = <&art 0x10>;
+ device_sn_bak = <&art 0x20>;
+ device_sn = <&art 0x30>;
+ country_code = <&art 0x88>;
+ };
+ };
+
+ keys {
+ compatible = "gpio-keys-polled";
+
+ poll-interval = <20>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&jtag_disable_pins>;
+
+ button0 {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ wan {
+ label = "gl-xe300:green:wan";
+ gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ lan {
+ label = "gl-xe300:green:lan";
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
+ };
+
+ wlan {
+ label = "gl-xe300:green:wlan";
+ gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+ linux,default-trigger = "phy0tpt";
+ };
+
+ lte {
+ label = "gl-xe300:green:lte";
+ gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-export {
+ compatible = "gpio-export";
+
+ gpio_lte_power {
+ gpio-export,name = "lte_power";
+ gpio-export,output = <1>;
+ gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+ };
+
+ gpio_sd_detect {
+ gpio-export,name = "sd_detect";
+ gpio-export,output = <0>;
+ gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ i2c: i2c {
+ compatible = "i2c-gpio";
+
+ sda-gpios = <&gpio 14 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+ scl-gpios = <&gpio 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ rtc@32 {
+ compatible = "rtc-sd2068";
+ reg = <0x32>;
+ };
+
+ };
+};
+
+&pcie0 {
+ status = "okay";
+};
+
+&uart {
+ status = "okay";
+};
+
+&usb0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ hub_port: port@1 {
+ reg = <1>;
+ #trigger-source-cells = <0>;
+ };
+};
+
+&usb_phy {
+ status = "okay";
+};
+
+&spi {
+ status = "okay";
+ num-cs = <2>;
+ cs-gpios = <0>, <0>;
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <25000000>;
+
+ nor_partitions: partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "u-boot";
+ reg = <0x000000 0x040000>;
+ read-only;
+ };
+
+ partition@40000 {
+ label = "u-boot-env";
+ reg = <0x040000 0x010000>;
+ };
+
+ art: partition@50000 {
+ label = "art";
+ reg = <0x050000 0x010000>;
+ read-only;
+ };
+ };
+ };
+
+ flash_nand: flash@1 {
+ compatible = "spi-nand";
+ reg = <1>;
+ spi-max-frequency = <25000000>;
+
+ nand_partitions: partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ nand_ubi: partition@0 {
+ label = "nand_ubi";
+ reg = <0x000000 0x8000000>;
+ };
+ };
+ };
+
+};
+
+&eth0 {
+ status = "okay";
+ mtd-mac-address = <&art 0x0>;
+ phy-handle = <&swphy4>;
+ ifname = "eth1";
+};
+
+&eth1 {
+ mtd-mac-address = <&art 0x0>;
+ mtd-mac-address-increment = <1>;
+ ifname = "eth0";
+};
+
+&wmac {
+ status = "okay";
+ mtd-cal-data = <&art 0x1000>;
+ mtd-mac-address = <&art 0x1002>;
+};
diff --git a/target/linux/ath79/dts/qca953x.dtsi b/target/linux/ath79/dts/qca953x.dtsi
index 801438be29..943e42437a 100644
--- a/target/linux/ath79/dts/qca953x.dtsi
+++ b/target/linux/ath79/dts/qca953x.dtsi
@@ -8,7 +8,7 @@
#address-cells = <1>;
#size-cells = <1>;
- chosen {
+ bootargs: chosen {
bootargs = "console=ttyS0,115200n8";
};
diff --git a/target/linux/ath79/image/Makefile b/target/linux/ath79/image/Makefile
index 3c126f479e..439d1710e5 100644
--- a/target/linux/ath79/image/Makefile
+++ b/target/linux/ath79/image/Makefile
@@ -77,7 +77,7 @@ define Device/Default
COMPILE :=
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | \
- append-rootfs | pad-rootfs | append-metadata | check-size
+ append-rootfs | pad-rootfs | append-gl-metadata | check-size
endef
include $(SUBTARGET).mk
diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index abf269a8ce..cfc07f14a3 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -107,6 +107,47 @@ define Device/glinet_gl-ar300m-nor
endef
TARGET_DEVICES += glinet_gl-ar300m-nor
+define Device/glinet_gl-xe300-common
+ SOC := qca9531
+ DEVICE_VENDOR := GL.iNet
+ DEVICE_MODEL := GL-XE300
+ DEVICE_PACKAGES := kmod-usb2 block-mount kmod-usb-serial-ch341
+ SUPPORTED_DEVICES += gl-xe300 glinet,gl-xe300
+endef
+
+define Device/glinet_gl-xe300-nor
+ $(Device/glinet_gl-xe300-common)
+ DEVICE_VARIANT := NOR
+ IMAGE_SIZE := 16000k
+endef
+TARGET_DEVICES += glinet_gl-xe300-nor
+
+define Device/glinet_gl-xe300-nor-nand
+ $(Device/glinet_gl-xe300-common)
+ DEVICE_VARIANT := NOR/NAND
+ KERNEL_SIZE := 4096k
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ VID_HDR_OFFSET := 2048
+ IMAGES := factory.img sysupgrade.tar
+ IMAGE/sysupgrade.tar := sysupgrade-tar-compat-1806 | append-gl-metadata
+ IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | append-gl-metadata
+endef
+TARGET_DEVICES += glinet_gl-xe300-nor-nand
+
+define Device/glinet_gl-xe300-iot
+ $(Device/glinet_gl-xe300-common)
+ DEVICE_VARIANT := NOR/NAND IOT
+ KERNEL_SIZE := 4096k
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ VID_HDR_OFFSET := 2048
+ IMAGES := factory.img sysupgrade.tar
+ IMAGE/sysupgrade.tar := sysupgrade-tar-compat-1806 | append-gl-metadata
+ IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | append-gl-metadata
+endef
+TARGET_DEVICES += glinet_gl-xe300-iot
+
define Device/glinet_gl-ar750s-common
SOC := qca9563
DEVICE_VENDOR := GL.iNet
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 8eda666a81..4a90c4673f 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
@@ -11,6 +11,13 @@ glinet,gl-ar300m-nand|\
glinet,gl-ar300m-nor)
ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
;;
+glinet,gl-xe300-iot|\
+glinet,gl-xe300-nor|\
+glinet,gl-xe300-nor-nand)
+ ucidef_set_led_switch "lan" "LAN" "gl-xe300:green:lan" "switch0" "0x10"
+ ucidef_set_led_netdev "wan" "WAN" "gl-xe300:green:wan" "eth1"
+ ucidef_set_led_netdev "3gnet" "LTE" "gl-xe300:green:lte" "wwan0"
+ ;;
netgear,wndr3700-v4|\
netgear,wndr4300|\
netgear,wndr4300sw|\
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 910df517aa..17348e001b 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
@@ -21,6 +21,11 @@ ath79_setup_interfaces()
ucidef_add_switch "switch0" \
"0@eth0" "2:lan:2" "3:lan:1" "1:wan"
;;
+ glinet,gl-xe300-iot|\
+ glinet,gl-xe300-nor|\
+ glinet,gl-xe300-nor-nand)
+ ucidef_set_interfaces_lan_wan "eth0" "eth1"
+ ;;
netgear,wndr3700-v4|\
netgear,wndr4300|\
netgear,wndr4300sw|\
diff --git a/target/linux/ath79/nand/base-files/etc/uci-defaults/04_led_migration b/target/linux/ath79/nand/base-files/etc/uci-defaults/04_led_migration
index 281d6ac0bc..3175ca9cb4 100644
--- a/target/linux/ath79/nand/base-files/etc/uci-defaults/04_led_migration
+++ b/target/linux/ath79/nand/base-files/etc/uci-defaults/04_led_migration
@@ -6,8 +6,8 @@ board=$(board_name)
case "$board" in
esac
-remove_devicename_leds
+#remove_devicename_leds
-migrations_apply system
+#migrations_apply system
exit 0
diff --git a/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh b/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh
index ea77345b06..c9b336898e 100644
--- a/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh
@@ -22,6 +22,10 @@ platform_do_upgrade() {
glinet,gl-ar750s-nor-nand)
nand_nor_do_upgrade "$1"
;;
+ glinet,gl-xe300-iot|\
+ glinet,gl-xe300-nor-nand)
+ nand_nor_do_upgrade "$1"
+ ;;
*)
nand_do_upgrade "$1"
;;
--
2.17.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,322 @@
From 180dac974bb796e5e9a5b5350baa7404ff5e235d Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Sat, 18 Sep 2021 14:19:35 +0800
Subject: [PATCH 3/8] add modem support
---
.../patches-5.4/701-add-modem-support.patch | 303 ++++++++++++++++++
1 file changed, 303 insertions(+)
create mode 100644 target/linux/ath79/patches-5.4/701-add-modem-support.patch
diff --git a/target/linux/ath79/patches-5.4/701-add-modem-support.patch b/target/linux/ath79/patches-5.4/701-add-modem-support.patch
new file mode 100644
index 0000000000..4c83520426
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/701-add-modem-support.patch
@@ -0,0 +1,303 @@
+Index: b/drivers/net/usb/qmi_wwan.c
+===================================================================
+--- a/drivers/net/usb/qmi_wwan.c 2021-09-18 12:18:32.582950993 +0800
++++ b/drivers/net/usb/qmi_wwan.c 2021-09-18 12:18:32.578950684 +0800
+@@ -507,6 +507,24 @@ static const u8 default_modem_addr[ETH_A
+
+ static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
+
++#if 1 //Added by Quectel
++#include <linux/etherdevice.h>
++struct sk_buff *qmi_wwan_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
++{
++ if (dev->udev->descriptor.idVendor != cpu_to_le16(0x2C7C))
++ return skb;
++ // Skip Ethernet header from message
++ if (skb_pull(skb, ETH_HLEN)) {
++ return skb;
++ } else {
++ dev_err(&dev->intf->dev, "Packet Dropped ");
++ }
++ // Filter the packet out, release it
++ dev_kfree_skb_any(skb);
++ return NULL;
++}
++#endif
++
+ /* Make up an ethernet header if the packet doesn't have one.
+ *
+ * A firmware bug common among several devices cause them to send raw
+@@ -801,6 +819,20 @@ static int qmi_wwan_bind(struct usbnet *
+ }
+ dev->net->netdev_ops = &qmi_wwan_netdev_ops;
+ dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group;
++#if 1 //Added by Quectel
++ if (dev->udev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
++ dev_info(&intf->dev, "QuectelEC25&EC21&EG91&EG95&EG06&EP06&EM06&BG96&AG35 work on RawIP mode\n");
++ dev->net->flags |= IFF_NOARP;
++ usb_control_msg(
++ interface_to_usbdev(intf),
++ usb_sndctrlpipe(interface_to_usbdev(intf), 0),
++ 0x22, //USB_CDC_REQ_SET_CONTROL_LINE_STATE
++ 0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE
++ 1, //active CDC DTR
++ intf->cur_altsetting->desc.bInterfaceNumber,
++ NULL, 0, 100);
++ }
++#endif
+ err:
+ return status;
+ }
+@@ -891,7 +923,10 @@ static const struct driver_info qmi_wwan
+ .bind = qmi_wwan_bind,
+ .unbind = qmi_wwan_unbind,
+ .manage_power = qmi_wwan_manage_power,
+- .rx_fixup = qmi_wwan_rx_fixup,
++ #if 1 //Added by Quectel
++ .tx_fixup = qmi_wwan_tx_fixup,
++ .rx_fixup = qmi_wwan_rx_fixup,
++ #endif
+ };
+
+ static const struct driver_info qmi_wwan_info_quirk_dtr = {
+@@ -938,6 +973,17 @@ static const struct driver_info qmi_wwan
+ .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr
+
+ static const struct usb_device_id products[] = {
++#if 1 //Added by Quectel
++ { QMI_FIXED_INTF(0x05C6, 0x9003, 4) }, /* Quectel UC20 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0125, 4) }, /* Quectel EC25 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0121, 4) }, /* Quectel EC21 */
++ { QMI_FIXED_INTF(0x05C6, 0x9215, 4) }, /* Quectel EC20 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0191, 4) }, /* Quectel EG91 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0195, 4) }, /* Quectel EG95 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0306, 4) }, /* Quectel EG06/EP06/EM06 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0296, 4) }, /* Quectel BG96 */
++ { QMI_FIXED_INTF(0x2C7C, 0x0435, 4) }, /* Quectel AG35 */
++#endif
+ /* 1. CDC ECM like devices match on the control interface */
+ { /* Huawei E392, E398 and possibly others sharing both device id and more... */
+ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
+@@ -1396,7 +1442,6 @@ static const struct usb_device_id produc
+ {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
+ {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
+ {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
+- {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
+ {QMI_FIXED_INTF(0x05c6, 0x9215, 4)}, /* Quectel EC20 Mini PCIe */
+ {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
+ {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
+Index: b/drivers/usb/serial/option.c
+===================================================================
+--- a/drivers/usb/serial/option.c 2021-09-18 12:18:32.582950993 +0800
++++ b/drivers/usb/serial/option.c 2021-09-18 12:20:11.062584026 +0800
+@@ -564,6 +564,23 @@ static void option_instat_callback(struc
+ #define WETELECOM_PRODUCT_WMD300 0x6803
+
+
++#define LONGSUNG_PRODUCT_U9300C 0x9b3c
++
++/* FORGE PRODUCT */
++#define FORGE_VENDOR_ID 0x05c6
++
++#define FORGE_PRODUCT_SLM750 0xf601
++
++/* NODECOM PRODUCT */
++#define NODECOM_VENDOR_ID 0x1508
++
++#define NODECOM_PRODUCT_NL660 0x1001
++
++/* NEOWAY PRODUCT */
++#define NEOWAY_VENDOR_ID 0x2949
++
++#define NEOWAY_PRODUCT_N720 0x8243
++
+ /* Device flags */
+
+ /* Highest interface number which can be used with NCTRL() and RSVD() */
+@@ -583,6 +600,29 @@ static void option_instat_callback(struc
+
+
+ static const struct usb_device_id option_ids[] = {
++#if 1 //Added by Quectel
++ { USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
++ { USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
++ { USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25 */
++ { USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
++ { USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
++ { USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
++ { USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
++ { USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
++ { USB_DEVICE(0x2C7C, 0x0700) }, /* Quectel BG95 */
++ { USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
++ { USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
++ { USB_DEVICE(0x2C7C, 0x6026) }, /* Quectel EC200t */
++#endif
++ { USB_DEVICE(0x19d2, 0x0536) },/* MZ386 */
++ { USB_DEVICE(0x19d2, 0x0117) },
++ { USB_DEVICE(0x19d2, 0x0199) },
++ { USB_DEVICE(0x19d2, 0x1476) },
++ { USB_DEVICE(LONGCHEER_VENDOR_ID, LONGSUNG_PRODUCT_U9300C) },
++ { USB_DEVICE(FORGE_VENDOR_ID, FORGE_PRODUCT_SLM750) },
++ { USB_DEVICE(NODECOM_VENDOR_ID, NODECOM_PRODUCT_NL660) },
++ { USB_DEVICE(NEOWAY_VENDOR_ID, NEOWAY_PRODUCT_N720) },
++
+ { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
+ { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
+ { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
+@@ -2114,6 +2154,9 @@ static struct usb_serial_driver option_1
+ #ifdef CONFIG_PM
+ .suspend = usb_wwan_suspend,
+ .resume = usb_wwan_resume,
++#if 1 //Added by Quectel
++ .reset_resume = usb_wwan_resume,
++#endif
+ #endif
+ };
+
+@@ -2136,6 +2179,7 @@ static int option_probe(struct usb_seria
+ {
+ struct usb_interface_descriptor *iface_desc =
+ &serial->interface->cur_altsetting->desc;
++ struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
+ unsigned long device_flags = id->driver_info;
+
+ /* Never bind to the CD-Rom emulation interface */
+@@ -2151,15 +2195,99 @@ static int option_probe(struct usb_seria
+ return -ENODEV;
+
+ /*
++ * Don't bind network interface on Samsung GT-B3730, it is handled by
++ * a separate module.
++ */
++ if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) &&
++ dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) &&
++ iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
++ return -ENODEV;
++
++ /*
+ * Allow matching on bNumEndpoints for devices whose interface numbers
+ * can change (e.g. Quectel EP06).
+ */
+ if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
+ return -ENODEV;
+
+- /* Store the device flags so we can use them during attach. */
+- usb_set_serial_data(serial, (void *)device_flags);
+-
++#if 1 //Added by Quectel
++ //Quectel UC20's interface 4 can be used as USB network device
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && \
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9003) \
++ && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
++ return -ENODEV;
++ //Quectel EC20's interface 4 can be used as USB network device
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && \
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9215) \
++ && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
++ return -ENODEV;
++ //Quectel EC25&EC21&EG91&EG95&EG06&EP06&EM06&BG96/AG35's interface 4 can be used as USB network device
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C) && \
++ serial->dev->descriptor.idProduct != cpu_to_le16(0x6026) \
++ && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
++ return -ENODEV;
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C) && \
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x6026) \
++ && serial->interface->cur_altsetting->desc.bInterfaceNumber<= 1)
++ return -ENODEV;
++#endif
++#if 1 //Added by Quectel
++ //For USB Auto Suspend
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9090)) {
++ pm_runtime_set_autosuspend_delay(&serial->dev->dev, 3000);
++ usb_enable_autosuspend(serial->dev);
++ }
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9003)) {
++ pm_runtime_set_autosuspend_delay(&serial->dev->dev, 3000);
++ usb_enable_autosuspend(serial->dev);
++ }
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9215)) {
++ pm_runtime_set_autosuspend_delay(&serial->dev->dev, 3000);
++ usb_set_serial_data(serial, (void *)device_flags);
++ usb_enable_autosuspend(serial->dev);
++ }
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
++ pm_runtime_set_autosuspend_delay(&serial->dev->dev, 3000);
++ usb_enable_autosuspend(serial->dev);
++ }
++#endif
++#if 1 //Added by Quectel
++ //For USB Remote Wakeup
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9090)) {
++ device_init_wakeup(&serial->dev->dev, 1); //usb remote wakeup
++ }
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9003)) {
++ device_init_wakeup(&serial->dev->dev, 1); //usb remote wakeup
++ }
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x9215)) {
++ device_init_wakeup(&serial->dev->dev, 1); //usb remote wakeup
++ }
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
++ device_init_wakeup(&serial->dev->dev, 1); //usb remote wakeup
++ }
++#endif
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x19d2) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x1476) &&
++ serial->interface->cur_altsetting->desc. bInterfaceNumber == 3)
++ return -ENODEV;
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x19d2) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x1476) &&
++ serial->interface->cur_altsetting->desc. bInterfaceNumber == 4)
++ return -ENODEV;
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x19d2) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x1509) &&
++ serial->interface->cur_altsetting->desc. bInterfaceNumber == 4)
++ return -ENODEV;
++ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x19d2) &&
++ serial->dev->descriptor.idProduct == cpu_to_le16(0x1509) &&
++ serial->interface->cur_altsetting->desc. bInterfaceNumber == 5)
++ return -ENODEV;
+ return 0;
+ }
+
+Index: b/drivers/usb/serial/qcserial.c
+===================================================================
+--- a/drivers/usb/serial/qcserial.c 2021-09-18 12:18:32.582950993 +0800
++++ b/drivers/usb/serial/qcserial.c 2021-09-18 12:18:32.582950993 +0800
+@@ -88,7 +88,6 @@ static const struct usb_device_id id_tab
+ {USB_DEVICE(0x03f0, 0x241d)}, /* HP Gobi 2000 QDL device (VP412) */
+ {USB_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
+ {USB_DEVICE(0x05c6, 0x9214)}, /* Acer Gobi 2000 QDL device (VP413) */
+- {USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
+ {USB_DEVICE(0x05c6, 0x9264)}, /* Asus Gobi 2000 QDL device (VR305) */
+ {USB_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
+ {USB_DEVICE(0x05c6, 0x9234)}, /* Top Global Gobi 2000 QDL device (VR306) */
+Index: b/drivers/usb/serial/usb_wwan.c
+===================================================================
+--- a/drivers/usb/serial/usb_wwan.c 2021-09-18 12:18:32.582950993 +0800
++++ b/drivers/usb/serial/usb_wwan.c 2021-09-18 12:18:32.582950993 +0800
+@@ -476,6 +476,19 @@ static struct urb *usb_wwan_setup_urb(st
+ usb_fill_bulk_urb(urb, serial->dev,
+ usb_sndbulkpipe(serial->dev, endpoint) | dir,
+ buf, len, callback, ctx);
++#if 1 //Added by Quectel for zero packet
++ if (dir == USB_DIR_OUT) {
++ struct usb_device_descriptor *desc = &serial->dev->descriptor;
++ if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))
++ urb->transfer_flags |= URB_ZERO_PACKET;
++ if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))
++ urb->transfer_flags |= URB_ZERO_PACKET;
++ if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))
++ urb->transfer_flags |= URB_ZERO_PACKET;
++ if (desc->idVendor == cpu_to_le16(0x2C7C))
++ urb->transfer_flags |= URB_ZERO_PACKET;
++ }
++#endif
+
+ if (intfdata->use_zlp && dir == USB_DIR_OUT)
+ urb->transfer_flags |= URB_ZERO_PACKET;
--
2.17.1

View File

@ -0,0 +1,102 @@
From d5bdb37fd02b420cc6a682bf9e51e7e50658c85b Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Sat, 18 Sep 2021 14:44:13 +0800
Subject: [PATCH 4/8] add RS485 support
---
.../821-fix-glinet-rs485-auto-txrx.patch | 83 +++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 target/linux/ath79/patches-5.4/821-fix-glinet-rs485-auto-txrx.patch
diff --git a/target/linux/ath79/patches-5.4/821-fix-glinet-rs485-auto-txrx.patch b/target/linux/ath79/patches-5.4/821-fix-glinet-rs485-auto-txrx.patch
new file mode 100644
index 0000000000..2030cad53d
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/821-fix-glinet-rs485-auto-txrx.patch
@@ -0,0 +1,83 @@
+Index: b/drivers/tty/serial/8250/8250.h
+===================================================================
+--- a/drivers/tty/serial/8250/8250.h 2021-08-26 20:55:22.000000000 +0800
++++ b/drivers/tty/serial/8250/8250.h 2021-09-18 14:30:46.200708724 +0800
+@@ -13,6 +13,8 @@
+
+ #include "../serial_mctrl_gpio.h"
+
++extern unsigned int rs485txen_gpio;
++
+ struct uart_8250_dma {
+ int (*tx_dma)(struct uart_8250_port *p);
+ int (*rx_dma)(struct uart_8250_port *p);
+Index: b/drivers/tty/serial/8250/8250_of.c
+===================================================================
+--- a/drivers/tty/serial/8250/8250_of.c 2021-08-26 20:55:22.000000000 +0800
++++ b/drivers/tty/serial/8250/8250_of.c 2021-09-18 14:41:02.964067786 +0800
+@@ -205,6 +205,7 @@ err_pmruntime:
+ /*
+ * Try to register a serial port
+ */
++unsigned int rs485txen_gpio = 0xff;
+ static int of_platform_serial_probe(struct platform_device *ofdev)
+ {
+ struct of_serial_info *info;
+@@ -246,6 +247,10 @@ static int of_platform_serial_probe(stru
+ &port8250.overrun_backoff_time_ms) != 0)
+ port8250.overrun_backoff_time_ms = 0;
+
++ if(!of_property_read_u32(ofdev->dev.of_node,"rs485_pin",&rs485txen_gpio)){
++ pr_info("Serial port to 485 enable,rs485txen_gpio = gpio%d \n",rs485txen_gpio);
++ }
++
+ ret = serial8250_register_8250_port(&port8250);
+ if (ret < 0)
+ goto err_dispose;
+Index: b/drivers/tty/serial/8250/8250_port.c
+===================================================================
+--- a/drivers/tty/serial/8250/8250_port.c 2021-08-26 20:55:22.000000000 +0800
++++ b/drivers/tty/serial/8250/8250_port.c 2021-09-18 14:36:49.548608917 +0800
+@@ -34,6 +34,7 @@
+ #include <linux/uaccess.h>
+ #include <linux/pm_runtime.h>
+ #include <linux/ktime.h>
++#include <linux/gpio/consumer.h>
+
+ #include <asm/io.h>
+ #include <asm/irq.h>
+@@ -1463,10 +1464,22 @@ static void __stop_tx_rs485(struct uart_
+ }
+ }
+
++static unsigned int serial8250_tx_empty(struct uart_port *port);
+ static inline void __do_stop_tx(struct uart_8250_port *p)
+ {
+- if (serial8250_clear_THRI(p))
++ if (serial8250_clear_THRI(p)){
++
+ serial8250_rpm_put_tx(p);
++
++ if(0xff != rs485txen_gpio){
++
++ while(!serial8250_tx_empty(&(p->port))){
++
++ ;
++ }
++ gpiod_set_value(gpio_to_desc(rs485txen_gpio),0);
++ }
++ }
+ }
+
+ static inline void __stop_tx(struct uart_8250_port *p)
+@@ -1510,6 +1523,10 @@ static void serial8250_stop_tx(struct ua
+
+ static inline void __start_tx(struct uart_port *port)
+ {
++ if(0xff != rs485txen_gpio){
++ gpiod_set_value(gpio_to_desc(rs485txen_gpio),1);
++ }
++
+ struct uart_8250_port *up = up_to_u8250p(port);
+
+ if (up->dma && !up->dma->tx_dma(up))
--
2.17.1

View File

@ -0,0 +1,79 @@
From 21020c2da30239e998d69c95c53bfbbc428f76a2 Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Sat, 18 Sep 2021 15:52:56 +0800
Subject: [PATCH 5/8] add spinand support
---
.../499-mtd-spinand-add-support.patch | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 target/linux/ath79/patches-5.4/499-mtd-spinand-add-support.patch
diff --git a/target/linux/ath79/patches-5.4/499-mtd-spinand-add-support.patch b/target/linux/ath79/patches-5.4/499-mtd-spinand-add-support.patch
new file mode 100644
index 0000000000..4a4b6e9bf0
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/499-mtd-spinand-add-support.patch
@@ -0,0 +1,60 @@
+Index: b/drivers/mtd/nand/spi/gigadevice.c
+===================================================================
+--- a/drivers/mtd/nand/spi/gigadevice.c 2021-09-18 14:49:34.250500716 +0800
++++ b/drivers/mtd/nand/spi/gigadevice.c 2021-09-18 14:55:06.091509000 +0800
+@@ -278,6 +278,15 @@ static const struct spinand_info gigadev
+ SPINAND_HAS_QE_BIT,
+ SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout,
+ gd5fxgq4uexxg_ecc_get_status)),
++ SPINAND_INFO("GD5F1GQ5UExxG", 0x51,
++ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
++ NAND_ECCREQ(8, 512),
++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
++ &write_cache_variants,
++ &update_cache_variants),
++ SPINAND_HAS_QE_BIT,
++ SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout,
++ gd5fxgq4uexxg_ecc_get_status)),
+ SPINAND_INFO("GD5F1GQ4UFxxG", 0xb148,
+ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+ NAND_ECCREQ(8, 512),
+Index: b/drivers/mtd/nand/spi/macronix.c
+===================================================================
+--- a/drivers/mtd/nand/spi/macronix.c 2021-08-26 20:55:22.000000000 +0800
++++ b/drivers/mtd/nand/spi/macronix.c 2021-09-18 15:06:07.031203336 +0800
+@@ -108,6 +108,15 @@ static const struct spinand_info macroni
+ SPINAND_HAS_QE_BIT,
+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
+ mx35lf1ge4ab_ecc_get_status)),
++ SPINAND_INFO("MX35LF1G24AD", 0x14,
++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
++ NAND_ECCREQ(4, 512),
++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
++ &write_cache_variants,
++ &update_cache_variants),
++ SPINAND_HAS_QE_BIT,
++ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
++ mx35lf1ge4ab_ecc_get_status)),
+ SPINAND_INFO("MX35LF2GE4AB", 0x22,
+ NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1),
+ NAND_ECCREQ(4, 512),
+Index: b/drivers/mtd/nand/spi/paragon.c
+===================================================================
+--- a/drivers/mtd/nand/spi/paragon.c 2021-08-26 20:55:22.000000000 +0800
++++ b/drivers/mtd/nand/spi/paragon.c 2021-09-18 15:01:02.476309144 +0800
+@@ -115,6 +115,15 @@ static const struct spinand_info paragon
+ 0,
+ SPINAND_ECCINFO(&pn26g0xa_ooblayout,
+ pn26g0xa_ecc_get_status)),
++ SPINAND_INFO("XT26G01xxxx", 0xf1,
++ NAND_MEMORG(1, 2048, 128, 64, 1024, 21, 1, 1, 1),
++ NAND_ECCREQ(8, 512),
++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
++ &write_cache_variants,
++ &update_cache_variants),
++ 0,
++ SPINAND_ECCINFO(&pn26g0xa_ooblayout,
++ pn26g0xa_ecc_get_status)),
+ };
+
+ static int paragon_spinand_detect(struct spinand_device *spinand)
--
2.17.1

View File

@ -0,0 +1,59 @@
From aa487fa14318de14da3281023b8f45e7b6e7b0ff Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Sat, 18 Sep 2021 16:40:41 +0800
Subject: [PATCH 6/8] led netdev trigger by wwanx
---
target/linux/ath79/dts/qca953x.dtsi | 2 +-
.../931-fix-led-netdev-trigger-by-wwanx.patch | 26 +++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 target/linux/ath79/patches-5.4/931-fix-led-netdev-trigger-by-wwanx.patch
diff --git a/target/linux/ath79/dts/qca953x.dtsi b/target/linux/ath79/dts/qca953x.dtsi
index 943e42437a..7774d073e7 100644
--- a/target/linux/ath79/dts/qca953x.dtsi
+++ b/target/linux/ath79/dts/qca953x.dtsi
@@ -240,7 +240,7 @@
builtin-switch;
builtin_switch: switch0@1f {
- compatible = "qca,ar8229";
+ compatible = "qca,ar8229-builtin";
reg = <0x1f>;
resets = <&rst 8>;
diff --git a/target/linux/ath79/patches-5.4/931-fix-led-netdev-trigger-by-wwanx.patch b/target/linux/ath79/patches-5.4/931-fix-led-netdev-trigger-by-wwanx.patch
new file mode 100644
index 0000000000..e4b5950faf
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/931-fix-led-netdev-trigger-by-wwanx.patch
@@ -0,0 +1,26 @@
+Index: b/drivers/leds/trigger/ledtrig-netdev.c
+===================================================================
+--- a/drivers/leds/trigger/ledtrig-netdev.c 2021-08-26 20:55:22.000000000 +0800
++++ b/drivers/leds/trigger/ledtrig-netdev.c 2021-09-18 16:00:16.427666394 +0800
+@@ -109,6 +109,7 @@ static ssize_t device_name_store(struct
+ size_t size)
+ {
+ struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
++ unsigned int flags;
+
+ if (size >= IFNAMSIZ)
+ return -EINVAL;
+@@ -132,9 +133,11 @@ static ssize_t device_name_store(struct
+ dev_get_by_name(&init_net, trigger_data->device_name);
+
+ clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode);
+- if (trigger_data->net_dev != NULL)
+- if (netif_carrier_ok(trigger_data->net_dev))
++ if (trigger_data->net_dev != NULL){
++ flags = dev_get_flags(trigger_data->net_dev);
++ if (flags & IFF_LOWER_UP)
+ set_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode);
++ }
+
+ trigger_data->last_activity = 0;
+
--
2.17.1

View File

@ -0,0 +1,240 @@
From 35dfe90cd27e4070eb0dba1ee1d33618e2e8f4cb Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Sat, 18 Sep 2021 18:14:38 +0800
Subject: [PATCH 7/8] ath79: add support for gl ar300m
---
.../ath79/dts/qca9531_glinet_gl-ar300m.dtsi | 42 +++++++++++++++----
.../generic/base-files/etc/board.d/01_leds | 2 -
.../generic/base-files/etc/board.d/02_network | 1 -
target/linux/ath79/image/generic.mk | 21 ----------
target/linux/ath79/image/nand.mk | 26 ++++++------
.../ath79/nand/base-files/etc/board.d/01_leds | 2 +-
.../nand/base-files/etc/board.d/02_network | 2 +
7 files changed, 49 insertions(+), 47 deletions(-)
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi
index d0b0d88c48..2f747e5a30 100644
--- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi
@@ -12,6 +12,26 @@
label-mac-device = &eth0;
};
+ gl_hw {
+ compatible = "gl-hw-info";
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ model = "ar300m";
+ wan = "eth0";
+ lan = "eth1";
+ switch-button = "gpio-0";
+ reset-button = "gpio-3";
+ usb-port = "1-1";
+ factory_data {
+ device_mac = <&art 0>;
+ device_ddns = <&art 0x10>;
+ device_sn_bak = <&art 0x20>;
+ device_sn = <&art 0x30>;
+ country_code = <&art 0x88>;
+ };
+ };
+
keys {
compatible = "gpio-keys";
@@ -43,28 +63,31 @@
// Colors for non-Lite versions
led_status: status {
- label = "green:status";
+ label = "gl-ar300m:green:status";
gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
};
lan {
- label = "green:lan";
+ label = "gl-ar300m:green:lan";
gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
};
led_wlan: wlan {
- label = "red:wlan";
+ label = "gl-ar300m:green:wlan";
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};
};
+ gpio-export {
+ compatible = "gpio-export";
- i2c: i2c {
- compatible = "i2c-gpio";
-
- sda-gpios = <&gpio 17 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
- scl-gpios = <&gpio 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+ gpio_usb_power {
+ gpio-export,name = "usb_power";
+ gpio-export,output = <1>;
+ gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+ };
};
+
};
&pcie0 {
@@ -147,14 +170,17 @@
phy-handle = <&swphy4>;
mtd-mac-address = <&art 0x0>;
+ ifname = "eth0";
};
&eth1 {
mtd-mac-address = <&art 0x0>;
mtd-mac-address-increment = <1>;
+ ifname = "eth1";
};
&wmac {
status = "okay";
mtd-cal-data = <&art 0x1000>;
+ mtd-mac-address = <&art 0x1002>;
};
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
index 985adfc6a7..f3690897ee 100755
--- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
@@ -16,8 +16,6 @@ alfa-network,ap121fe|\
avm,fritz450e|\
glinet,6408|\
glinet,6416|\
-glinet,gl-ar300m-lite|\
-glinet,gl-ar300m16|\
pcs,cap324|\
tplink,cpe610-v1|\
tplink,cpe610-v2)
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network
index c4d9d76941..f446ba28c2 100755
--- a/target/linux/ath79/generic/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network
@@ -38,7 +38,6 @@ ath79_setup_interfaces()
engenius,ecb1750|\
engenius,ecb600|\
enterasys,ws-ap3705i|\
- glinet,gl-ar300m-lite|\
glinet,gl-usb150|\
hak5,wifi-pineapple-nano|\
meraki,mr16|\
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index 05ed698401..9fba9155df 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -1167,27 +1167,6 @@ define Device/glinet_gl-ar150
endef
TARGET_DEVICES += glinet_gl-ar150
-define Device/glinet_gl-ar300m-common-nor
- SOC := qca9531
- DEVICE_VENDOR := GL.iNet
- DEVICE_PACKAGES := kmod-usb2
- IMAGE_SIZE := 16000k
- SUPPORTED_DEVICES += gl-ar300m
-endef
-
-define Device/glinet_gl-ar300m-lite
- $(Device/glinet_gl-ar300m-common-nor)
- DEVICE_MODEL := GL-AR300M
- DEVICE_VARIANT := Lite
-endef
-TARGET_DEVICES += glinet_gl-ar300m-lite
-
-define Device/glinet_gl-ar300m16
- $(Device/glinet_gl-ar300m-common-nor)
- DEVICE_MODEL := GL-AR300M16
-endef
-TARGET_DEVICES += glinet_gl-ar300m16
-
define Device/glinet_gl-ar750
SOC := qca9531
DEVICE_VENDOR := GL.iNet
diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index 0c6dd699f5..8f5c27d0fd 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -77,33 +77,31 @@ define Device/domywifi_dw33d
endef
TARGET_DEVICES += domywifi_dw33d
-define Device/glinet_gl-ar300m-common-nand
+define Device/glinet_gl-ar300m-common
SOC := qca9531
DEVICE_VENDOR := GL.iNet
DEVICE_MODEL := GL-AR300M
- DEVICE_PACKAGES := kmod-usb2
- KERNEL_SIZE := 4096k
- IMAGE_SIZE := 16000k
- PAGESIZE := 2048
- VID_HDR_OFFSET := 2048
+ DEVICE_PACKAGES := kmod-usb-core kmod-usb2 block-mount kmod-usb-storage kmod-usb-ledtrig-usbport
+ SUPPORTED_DEVICES += gl-ar300m glinet,gl-ar300m
endef
define Device/glinet_gl-ar300m-nand
- $(Device/glinet_gl-ar300m-common-nand)
+ $(Device/glinet_gl-ar300m-common)
DEVICE_VARIANT := NAND
+ KERNEL_SIZE := 4096k
BLOCKSIZE := 128k
- IMAGES += factory.img
- IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
- IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
- SUPPORTED_DEVICES += glinet,gl-ar300m-nor
+ PAGESIZE := 2048
+ VID_HDR_OFFSET := 2048
+ IMAGES := factory.img sysupgrade.tar
+ IMAGE/sysupgrade.tar := sysupgrade-tar-compat-1806 | append-gl-metadata
+ IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | append-gl-metadata
endef
TARGET_DEVICES += glinet_gl-ar300m-nand
define Device/glinet_gl-ar300m-nor
- $(Device/glinet_gl-ar300m-common-nand)
+ $(Device/glinet_gl-ar300m-common)
DEVICE_VARIANT := NOR
- BLOCKSIZE := 64k
- SUPPORTED_DEVICES += glinet,gl-ar300m-nand gl-ar300m
+ IMAGE_SIZE := 16000k
endef
TARGET_DEVICES += glinet_gl-ar300m-nor
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 16545083fb..eb9e5817e6 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
@@ -9,7 +9,7 @@ board=$(board_name)
case "$board" in
glinet,gl-ar300m-nand|\
glinet,gl-ar300m-nor)
- ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+ ucidef_set_led_netdev "lan" "LAN" "gl-ar300m:green:lan" "eth1"
;;
glinet,gl-mifi)
ucidef_set_led_wlan "wlan" "WLAN" "gl-mifi:green:wlan" "phy0tpt"
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 73e23e5eb9..bee36cac1b 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
@@ -21,6 +21,8 @@ ath79_setup_interfaces()
ucidef_add_switch "switch0" \
"0@eth0" "2:lan:2" "3:lan:1" "1:wan"
;;
+ glinet,gl-ar300m-nor|\
+ glinet,gl-ar300m-nand|\
glinet,gl-mifi)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
--
2.17.1

View File

@ -0,0 +1,341 @@
From f13cf41ee822127c8a42eb05a896f38724e0844f Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Wed, 22 Sep 2021 11:53:08 +0800
Subject: [PATCH 8/8] ath79: add support for gl x300b
---
.../dts/qca9531_glinet_gl-x300b-nor-nand.dts | 25 +++
.../ath79/dts/qca9531_glinet_gl-x300b-nor.dts | 18 ++
.../ath79/dts/qca9531_glinet_gl-x300b.dtsi | 191 ++++++++++++++++++
target/linux/ath79/image/nand.mk | 28 +++
.../ath79/nand/base-files/etc/board.d/01_leds | 6 +
.../nand/base-files/etc/board.d/02_network | 2 +
6 files changed, 270 insertions(+)
create mode 100644 target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor-nand.dts
create mode 100644 target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor.dts
create mode 100755 target/linux/ath79/dts/qca9531_glinet_gl-x300b.dtsi
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor-nand.dts b/target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor-nand.dts
new file mode 100644
index 0000000000..b50ed14f26
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor-nand.dts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9531_glinet_gl-x300b.dtsi"
+
+/ {
+ compatible = "glinet,gl-x300b-nor-nand", "qca,qca9531";
+ model = "GL.iNet GL-X300B (NOR/NAND)";
+};
+
+&nor_partitions {
+ partition@60000 {
+ label = "kernel";
+ reg = <0x060000 0x200000>;
+ };
+ parition@260000 {
+ label = "nor_reserved";
+ reg = <0x260000 0xbc0000>;
+ };
+};
+
+&nand_ubi {
+ label = "ubi";
+};
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor.dts b/target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor.dts
new file mode 100644
index 0000000000..566df3c238
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-x300b-nor.dts
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "qca9531_glinet_gl-x300b.dtsi"
+
+/ {
+ compatible = "glinet,gl-x300b-nor", "qca,qca9531";
+ model = "GL.iNet GL-X300B (NOR)";
+};
+
+&nor_partitions {
+ partition@60000 {
+ compatible = "denx,uimage";
+ label = "firmware";
+ reg = <0x060000 0xfa0000>;
+ };
+};
diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-x300b.dtsi b/target/linux/ath79/dts/qca9531_glinet_gl-x300b.dtsi
new file mode 100755
index 0000000000..728b40dceb
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_glinet_gl-x300b.dtsi
@@ -0,0 +1,191 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "qca953x.dtsi"
+
+/ {
+ compatible = "glinet,gl-x300b", "qca,qca9531";
+ model = "GL.iNet GL-X300B";
+
+ gl_hw {
+ compatible = "gl-hw-info";
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ model = "x300b";
+ wan = "eth0";
+ lan = "eth1";
+ build-in-modem = "1-1";
+ reset-button = "gpio-3";
+ factory_data {
+ device_mac = <&art 0>;
+ device_ddns = <&art 0x10>;
+ device_sn_bak = <&art 0x20>;
+ device_sn = <&art 0x30>;
+ country_code = <&art 0x88>;
+ };
+ };
+
+ keys {
+ compatible = "gpio-keys-polled";
+
+ poll-interval = <20>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&jtag_disable_pins>;
+
+ button0 {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ wlan2g {
+ label = "gl-x300b:green:wlan2g";
+ gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+ linux,default-trigger = "phy0tpt";
+ };
+
+ wan {
+ label = "gl-x300b:green:wan";
+ gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+ };
+
+ lte {
+ label = "gl-x300b:green:lte";
+ gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+ };
+ };
+ gpio-export {
+ compatible = "gpio-export";
+
+ gpio_lte_power {
+ gpio-export,name = "gpio0";
+ gpio-export,output = <0>;
+ gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+ };
+
+ gpio_rs485tx_en {
+ gpio-export,name = "gpio1";
+ gpio-export,output = <0>;
+ gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
+ };
+
+ gpio_ble_rst {
+ gpio-export,name = "gpio16";
+ gpio-export,output = <0>;
+ gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
+ };
+
+ };
+ watchdog {
+ compatible = "hw_wdt";
+ dog_en_gpio= <12>;
+ feed_dog_gpio=<2>;
+ feed_dog_interval=<100000000>;
+ };
+
+};
+
+
+&uart {
+ status = "okay";
+ rs485_pin=<1>;
+};
+
+&usb0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ hub_port: port@1 {
+ reg = <1>;
+ #trigger-source-cells = <0>;
+ };
+};
+
+&usb_phy {
+ status = "okay";
+};
+
+&spi {
+ status = "okay";
+ num-cs = <2>;
+ cs-gpios = <0>, <0>;
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <25000000>;
+
+ nor_partitions: partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "u-boot";
+ reg = <0x000000 0x040000>;
+ read-only;
+ };
+
+ partition@40000 {
+ label = "u-boot-env";
+ reg = <0x040000 0x010000>;
+ };
+
+ art: partition@50000 {
+ label = "art";
+ reg = <0x050000 0x010000>;
+ read-only;
+ };
+ };
+ };
+
+ flash_nand: flash@1 {
+ compatible = "spi-nand";
+ reg = <1>;
+ spi-max-frequency = <25000000>;
+
+ nand_partitions: partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ nand_ubi: partition@0 {
+ label = "nand_ubi";
+ reg = <0x000000 0x8000000>;
+ };
+ };
+ };
+
+};
+/*
+&bootargs {
+ bootargs="";
+};*/
+
+&eth0 {
+ status = "okay";
+ mtd-mac-address = <&art 0x0>;
+ phy-handle = <&swphy4>;
+ ifname = "eth0";
+};
+
+&eth1 {
+ mtd-mac-address = <&art 0x0>;
+ mtd-mac-address-increment = <1>;
+ ifname = "eth1";
+};
+
+&wmac {
+ status = "okay";
+ mtd-cal-data = <&art 0x1000>;
+ mtd-mac-address = <&art 0x1002>;
+};
diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index 8f5c27d0fd..32d8fb612f 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -77,6 +77,34 @@ define Device/domywifi_dw33d
endef
TARGET_DEVICES += domywifi_dw33d
+define Device/glinet_gl-x300b-common
+ SOC := qca9531
+ DEVICE_VENDOR := GL.iNet
+ DEVICE_MODEL := GL-X300B
+ DEVICE_PACKAGES := kmod-usb2 block-mount
+ SUPPORTED_DEVICES += gl-x300b glinet,gl-x300b
+endef
+
+define Device/glinet_gl-x300b-nor
+ $(Device/glinet_gl-x300b-common)
+ DEVICE_VARIANT := NOR
+ IMAGE_SIZE := 16000k
+endef
+TARGET_DEVICES += glinet_gl-x300b-nor
+
+define Device/glinet_gl-x300b-nor-nand
+ $(Device/glinet_gl-x300b-common)
+ DEVICE_VARIANT := NOR/NAND
+ KERNEL_SIZE := 4096k
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ VID_HDR_OFFSET := 2048
+ IMAGES := factory.img sysupgrade.tar
+ IMAGE/sysupgrade.tar := sysupgrade-tar-compat-1806 | append-gl-metadata
+ IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | append-gl-metadata
+endef
+TARGET_DEVICES += glinet_gl-x300b-nor-nand
+
define Device/glinet_gl-ar300m-common
SOC := qca9531
DEVICE_VENDOR := GL.iNet
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 eb9e5817e6..51cfe6562f 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
@@ -17,6 +17,12 @@ glinet,gl-mifi)
ucidef_set_led_switch "lan" "LAN" "gl-mifi:green:lan" "switch0" "0x2"
ucidef_set_led_netdev "3gnet" "3GNET" "gl-mifi:green:net" "3g-wan"
;;
+glinet,gl-x300b-nor|\
+glinet,gl-x300b-nor-nand)
+ ucidef_set_led_netdev "wlan2g" "WLAN2G" "gl-x300b:green:wlan2g" "wlan0"
+ ucidef_set_led_netdev "wan" "WAN" "gl-x300b:green:wan" "eth0"
+ ucidef_set_led_netdev "3gnet" "3GNET" "gl-x300b:green:lte" "3g-wan"
+ ;;
glinet,gl-xe300-iot|\
glinet,gl-xe300-nor|\
glinet,gl-xe300-nor-nand)
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 bee36cac1b..37fafafb0d 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
@@ -23,6 +23,8 @@ ath79_setup_interfaces()
;;
glinet,gl-ar300m-nor|\
glinet,gl-ar300m-nand|\
+ glinet,gl-x300b-nor|\
+ glinet,gl-x300b-nor-nand|\
glinet,gl-mifi)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
--
2.17.1