diff --git a/target/linux/ath79/dts/ar9331_teltonika_rut230-v1.dts b/target/linux/ath79/dts/ar9331_teltonika_rut230-v1.dts new file mode 100644 index 0000000000000..c394cf1cb8533 --- /dev/null +++ b/target/linux/ath79/dts/ar9331_teltonika_rut230-v1.dts @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9331.dtsi" + +#include +#include + +/ { + model = "Teltonika RUT230 v1"; + compatible = "teltonika,rut230-v1", "qca,ar9331"; + + aliases { + label-mac-device = &wmac; + led-boot = &led_ss0; + led-failsafe = &led_ss0; + led-upgrade = &led_ss0; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 22 GPIO_ACTIVE_HIGH>; + debounce-interval = <60>; + }; + + input { + label = "input"; + linux,code = ; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + sim-tray { + label = "sim-tray"; + linux,code = ; + gpios = <&gpio 20 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&switch_led_disable_pins>; + + led_ss0: signal-strength-0 { + label = "green:signal-strength-0"; + gpios = <&gpio 23 GPIO_ACTIVE_HIGH>; + }; + + signal-strength-1 { + label = "green:signal-strength-1"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + signal-strength-2 { + label = "green:signal-strength-2"; + gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + }; + + signal-strength-3 { + label = "green:signal-strength-3"; + gpios = <&gpio 26 GPIO_ACTIVE_HIGH>; + }; + + signal-strength-4 { + label = "green:signal-strength4"; + gpios = <&gpio 27 GPIO_ACTIVE_HIGH>; + }; + + 2g { + label = "green:2g"; + gpios = <&gpio 8 GPIO_ACTIVE_HIGH>; + }; + + 3g { + label = "green:3g"; + gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + }; + + lan { + label = "green:lan"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + /* GPIO 13 - ACTIVE HIGH for hwrev 0 */ + }; + + wan { + label = "green:wan"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + /* GPIO 14 - ACTIVE HIGH for hwrev 0 */ + }; + + /* 4G LED - GPIO21 ACTIVE_HIGH for RUT240 */ + }; + + reg_usb_vbus: reg_usb_vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio 19 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; +}; + +ð0 { + status = "okay"; + + mtd-mac-address = <&config 0x0>; +}; + +ð1 { + status = "okay"; + + mtd-mac-address = <&config 0x0>; + mtd-mac-address-increment = <1>; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <30000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x20000>; + read-only; + }; + + config: partition@20000 { + label = "config"; + reg = <0x20000 0x10000>; + read-only; + }; + + art: partition@30000 { + label = "art"; + reg = <0x30000 0x10000>; + read-only; + }; + + partition@40000 { + compatible = "tplink,firmware"; + label = "firmware"; + reg = <0x40000 0xf30000>; + }; + + partition@f70000 { + label = "event-log"; + reg = <0xf70000 0x90000>; + read-only; + }; + }; + }; +}; + +&usb { + dr_mode = "host"; + vbus-supply = <®_usb_vbus>; + status = "okay"; +}; + +&gpio { + modem-power { + gpio-hog; + output-low; + gpios = <18 GPIO_ACTIVE_HIGH>; + line-name = "modem-power"; + }; +}; + +&usb_phy { + status = "okay"; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; + mtd-mac-address = <&config 0x0>; + mtd-mac-address-increment = <2>; +}; 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 d8e3d65967ee2..c844c70e4623d 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -276,6 +276,10 @@ qihoo,c301) samsung,wam250) ucidef_set_led_netdev "lan" "LAN" "white:lan" "eth0" ;; +teltonika,rut230-v1) + ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1" + ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x04" + ;; tplink,archer-a7-v5|\ tplink,archer-c7-v4|\ tplink,archer-c7-v5) diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 9d0be2b86b3f4..ab875bd220650 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -142,11 +142,20 @@ define Build/teltonika-fw-fake-checksum # from begin of the firmware file) with 16 bytes stored just before # 0xdeadc0de marker. Values are only compared, MD5 sum is not verified. let \ - offs="$$(stat -c%s $@) - 20"; \ + offs="$$(stat -c%s $@) - $(1)"; \ dd if=$@ bs=1 count=16 skip=76 |\ dd of=$@ bs=1 count=16 seek=$$offs conv=notrunc endef +define Build/teltonika-v1-header + $(STAGING_DIR_HOST)/bin/mktplinkfw \ + -c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \ + -E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ + -m $(TPLINK_HEADER_VERSION) -N "$(VERSION_DIST)" -V "RUT2xx " \ + -k $@ -o $@.new $(1) + @mv $@.new $@ +endef + define Build/wrgg-pad-rootfs $(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 64 >>$@ endef @@ -2182,6 +2191,28 @@ define Device/telco_t1 endef TARGET_DEVICES += telco_t1 +define Device/teltonika_rut230-v1 + SOC := ar9331 + DEVICE_VENDOR := Teltonika + DEVICE_MODEL := RUT230 + DEVICE_VARIANT := v1 + DEVICE_PACKAGES := kmod-usb-chipidea2 kmod-usb-acm kmod-usb-net-qmi-wwan \ + uqmi -uboot-envtools + IMAGE_SIZE := 15552k + TPLINK_HWID := 0x32200002 + TPLINK_HWREV := 0x1 + TPLINK_HEADER_VERSION := 1 + KERNEL := kernel-bin | append-dtb | lzma | teltonika-v1-header + KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs |\ + pad-rootfs | pad-extra 64 | teltonika-fw-fake-checksum 54 | check-size + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) |\ + append-rootfs | pad-rootfs | append-metadata |\ + check-size +endef +TARGET_DEVICES += teltonika_rut230-v1 + define Device/teltonika_rut955 SOC := ar9344 DEVICE_VENDOR := Teltonika @@ -2196,7 +2227,7 @@ define Device/teltonika_rut955 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma IMAGES += factory.bin IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs |\ - pad-rootfs | teltonika-fw-fake-checksum | append-string master |\ + pad-rootfs | teltonika-fw-fake-checksum 20 | append-string master |\ append-md5sum-bin | check-size IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) |\ append-rootfs | pad-rootfs | append-metadata |\