gl-infra-builder-FUjr/patches-21.02.2/0008-ath79-add-support-for-gl-x300b.patch
2022-03-14 11:05:18 +08:00

342 lines
8.2 KiB
Diff

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";
+ 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