From 1cc3b95efcc616fba91a7f34e9781743229cc640 Mon Sep 17 00:00:00 2001 From: Felix Matouschek Date: Thu, 15 Jul 2021 21:48:11 +0200 Subject: [PATCH] ipq40xx: Add support for Teltonika RUTX10 This patch adds support for the Teltonika RUTX10. This device is an industrial DIN-rail router with 4 ethernet ports, 2.4G/5G dualband WiFi, Bluetooth, a USB 2.0 port and two GPIOs. The RUTX series devices are very similiar so common parts of the DTS are kept in a DTSI file. They are based on the QCA AP-DK01.1-C1 dev board. See https://teltonika-networks.com/product/rutx10 for more info. Hardware: SoC: Qualcomm IPQ4018 RAM: 256MB DDR3 SPI Flash 1: XTX XT25F128B (16MB, NOR) SPI Flash 2: XTX XT26G02AWS (256MB, NAND) Ethernet: Built-in IPQ4018 (SoC, QCA8075), 4x 10/100/1000 ports WiFi 1: Qualcomm QCA4019 IEEE 802.11b/g/n Wifi 2: Qualcomm QCA4019 IEEE 802.11a/n/ac USB Hub: Genesys Logic GL852GT Bluetooth: Qualcomm CSR8510 (A10U) LED/GPIO controller: STM32F030 with custom firmware Buttons: Reset button Leds: Power (green, cannot be controlled) WiFi 2.4G activity (green) WiFi 5G activity (green) MACs Details verified with the stock firmware: eth0: Partition 0:CONFIG Offset: 0x0 eth1: = eth0 + 1 radio0 (2.4 GHz): = eth0 + 2 radio1 (5.0 GHz): = eth0 + 3 Label MAC address is from eth0. The LED/GPIO controller needs a separate kernel driver to function. The driver was extracted from the Teltonika GPL sources and can be found at following feed: https://github.com/0xFelix/teltonika-rutx-openwrt USB detection of the bluetooth interface is sometimes a bit flaky. When not detected power cycle the device. When the bluetooth interface was detected properly it can be used with bluez / bluetoothctl. Flash instructions via stock web interface (sysupgrade based): 1. Set PC to fixed ip address 192.168.1.100 2. Push reset button and power on the device 3. Open u-boot HTTP recovery at http://192.168.1.1 4. Upload latest stock firmware and wait until the device is rebooted 5. Open stock web interface at http://192.168.1.1 6. Set some password so the web interface is happy 7. Go to firmware upgrade settings 8. Choose openwrt-ipq40xx-generic-teltonika_rutx10-squashfs-nand-factory.ubi 9. Set 'Keep settings' to off 10. Click update, when warned that it is not a signed image proceed Return to stock firmware: 1. Set PC to fixed ip address 192.168.1.100 2. Push reset button and power on the device 3. Open u-boot HTTP recovery at http://192.168.1.1 4. Upload latest stock firmware and wait until the device is rebooted Note: The DTS expects OpenWrt to be running from the second rootfs partition. u-boot on these devices hot-patches the DTS so running from the first rootfs partition should also be possible. If you want to be save follow the instructions above. u-boot HTTP recovery restores the device so that when flashing OpenWrt from stock firmware it is flashed to the second rootfs partition and the DTS matches. Signed-off-by: Felix Matouschek --- package/firmware/ipq-wifi/Makefile | 4 +- .../ipq-wifi/board-teltonika_rutx.qca4019 | Bin 0 -> 24276 bytes .../ipq40xx/base-files/etc/board.d/02_network | 3 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 8 + .../base-files/lib/upgrade/platform.sh | 4 + .../arch/arm/boot/dts/qcom-ipq4018-rutx.dtsi | 251 ++++++++++++++++++ .../arch/arm/boot/dts/qcom-ipq4018-rutx10.dts | 26 ++ target/linux/ipq40xx/image/generic.mk | 27 ++ .../901-arm-boot-add-dts-files.patch | 3 +- .../901-arm-boot-add-dts-files.patch | 3 +- 10 files changed, 325 insertions(+), 4 deletions(-) create mode 100644 package/firmware/ipq-wifi/board-teltonika_rutx.qca4019 create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-rutx.dtsi create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-rutx10.dts diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index 6835363cb6df..ebaac48c24e7 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -51,7 +51,8 @@ ALLWIFIBOARDS:= \ p2w_r619ac \ plasmacloud_pa1200 \ plasmacloud_pa2200 \ - qxwlan_e2600ac + qxwlan_e2600ac \ + teltonika_rutx ALLWIFIPACKAGES:=$(foreach BOARD,$(ALLWIFIBOARDS),ipq-wifi-$(BOARD)) @@ -139,5 +140,6 @@ $(eval $(call generate-ipq-wifi-package,p2w_r619ac,P&W R619AC)) $(eval $(call generate-ipq-wifi-package,plasmacloud_pa1200,Plasma Cloud PA1200)) $(eval $(call generate-ipq-wifi-package,plasmacloud_pa2200,Plasma Cloud PA2200)) $(eval $(call generate-ipq-wifi-package,qxwlan_e2600ac,Qxwlan E2600AC)) +$(eval $(call generate-ipq-wifi-package,teltonika_rutx,Teltonika RUTX)) $(foreach PACKAGE,$(ALLWIFIPACKAGES),$(eval $(call BuildPackage,$(PACKAGE)))) diff --git a/package/firmware/ipq-wifi/board-teltonika_rutx.qca4019 b/package/firmware/ipq-wifi/board-teltonika_rutx.qca4019 new file mode 100644 index 0000000000000000000000000000000000000000..440c63af41984fc90773e9ac4b5e70b39c589d20 GIT binary patch literal 24276 zcmeHPT~HHQ7QR9LR8%?%|Dg#9fy9LXfrSWBLWoR&78q6$qU$1}k^oBt<;OTB<)R`+ zWJDPP29QEUetKP{T%A#wT^-li(v-U|^XALG&4W}~TU)-Yv$xX;BqkXXgq;9=!tHzR z>3i-u_v=p5-S;D(=VT{j?^Glw6(q=tvP*l5o_?A1+10zX0daG&$` zrny~#a5lutB1DcBeZJ0enDMlW5$F4@n;Vi1$k&{~tT5@;7RPZPxfquiiI|ynVZb&~ zSmpvNw`BeLjT_x^aL}3K!1ha+G+mR#X=4`K3|@~-b#|&%dCIKUQv)5XRmy_AEsw_s z&UQAaKF>>gJOQ;vRY~5j-$A)^PY?&*j8C2JtWoVyN?%V5oN29AVtJCsw}@`aygV^< zIN#X}ZJDG)+-C4*bm~NFnKC0U9=f)-9#G0*w;KbU(6vC!e>^pCsa2ya5hs});%xK# zNUIgfN4nVVrW|bXaNJr6C^??l^0Gc1uK6NgowPeRYjUu$BfW~ZE4<**_z`{XS$;!k zg??g>e#=>QBV+%AtEv+PHQXJ+(g!2;XELh=T$n>SQ_iq2m(M^rzUY8pyB8Kq%VEH9L(Z08W5t?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cEorQZ_w>hZ^OUQ>D5gN1wUfuzTt`~r6?k$!G1oB&}aMuen7iT5e{8DaFtf3h`|43 z7*f|Mvc-wUZ}1Uat9rLMoNyTG7sP_uUSk_xq0LZ)&FYQqc$HS72!n~}wa3Z}!~)|z zykFO#E>gsh5d<)$i^dkbOe<0_XTLNa$CXe+j1TZ@5KE~TeSLT4s-an(qX;7-z&W@h z9(buwrR2&1q)?(za)Q80I5nJ1jWVxV1n!+X@!Rdm39K;R>m9Xw(?!vd8~u;==C%ut zgjWXSemi>b!d5N!a7g)Ids>uP39&(;K6kI2sL7X!5+gz{4wrT%A7`sK6+XLFdr8{H zs|(xrykAwE9v2$|z~iCgwTc{JLS*Fqu_L|GQ-TKit|#NFo~$-*ZRozILyZ-(G#)E7 z;NkV!!wLn;31sL73Qs2=4cfh7`-5ARmoiSWYl8MXGSu!ZmdD2+-qRyZ4ciqQeo%O) zzUWM9Q)qdB;_k%nu82=X)dlUF?mK!QZ(BT<;X7_p@y!U6Y+JyCC~qu ze?Go7>`>tD+r7utMREa$?mMcl|9$b!gwzPmO}(mP+p*1u83i}S>iaX>xed&HH!o@` z<(XU-i`oBW)xqug@uHyc3thXvNL6$8(4}|A8?P2#;5UaJT(u_-HE{}o6@Y-%Pi;g* zM%mn$nHt39|Gd~w*w0$*cZ1;$jY8a_l!*8|UJU$$zqG;TMn`j^OMN`%*Ea0A?-qK! z|DvtU+sClb>(?$?3b;xW3l@!EZY_1Me*w)_k9Vu`JTk3ca)2#pU7j7 zH&6215ffLQ;L)#Z7qrPCAAa)|PBvMhj%?myD%S$NlTCbif-~>ewhk7e_F +#include + +/ { + aliases { + label-mac-device = &gmac0; + }; + + memory { + device_type = "memory"; + reg = <0x80000000 0x10000000>; + }; + + soc { + pinctrl@1000000 { + mdio_pins: mdio_pinmux { + mux_1 { + pins = "gpio53"; + function = "mdio"; + bias-pull-up; + }; + mux_2 { + pins = "gpio52"; + function = "mdc"; + bias-pull-up; + }; + }; + + i2c_0_pins: i2c_0_pinmux { + mux { + pins = "gpio58", "gpio59"; + function = "blsp_i2c0"; + bias-disable; + }; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 4 1>; + linux,code = ; + }; + }; + + gpio_export { + compatible = "gpio-export"; + #size-cells = <0>; + + gpio_out { + gpio-export,name = "gpio_out"; + gpio-export,output = <0>; + gpio-export,direction_may_change = <0>; + gpios = <&stm32_io 23 GPIO_ACTIVE_HIGH>; + }; + + gpio_in { + gpio-export,name = "gpio_in"; + gpio-export,input = <0>; + gpio-export,direction_may_change = <0>; + gpios = <&stm32_io 24 GPIO_ACTIVE_LOW>; + }; + }; + }; +}; + +&blsp1_i2c3 { + status = "okay"; + pinctrl-0 = <&i2c_0_pins>; + pinctrl-names = "default"; + clock-frequency = <400000>; + + stm32_io: stm32@74 { + compatible = "tlt,stm32v1"; + #gpio-cells = <2>; + #interrupt-cells = <2>; + gpio-controller; + interrupt-controller; + interrupt-parent = <&tlmm>; + interrupts = <5 2>; + reg = <0x74>; + }; +}; + +&blsp1_spi1 { + cs-gpios = <&tlmm 54 0>, <&tlmm 63 0>; + num-cs = <2>; + + xt25f128b@0 { + /* + * Factory U-boot looks in 0:BOOTCONFIG partition for active + * partitions settings and mangles the partition config so + * 0:QSEE/0:QSEE_1, 0:CDT/0:CDT_1 and 0:APPSBL/0:APPSBL_1 pairs + * can be swaped. It isn't a problem but we never can be sure where + * OFW put factory images. "n25q128a11" is required for proper nor + * recognition in u-boot. + */ + compatible = "jedec,spi-nor", "n25q128a11"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + spi-max-frequency = <24000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "0:MIBIB"; + reg = <0x40000 0x20000>; + read-only; + }; + + partition@60000 { + label = "0:BOOTCONFIG"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:BOOTCONFIG1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:QSEE"; + reg = <0xa0000 0x60000>; + read-only; + }; + + partition@100000 { + label = "0:QSEE_1"; + reg = <0x100000 0x60000>; + read-only; + }; + + partition@160000 { + label = "0:CDT"; + reg = <0x160000 0x10000>; + read-only; + }; + + partition@170000 { + label = "0:CDT_1"; + reg = <0x170000 0x10000>; + read-only; + }; + + partition@180000 { + label = "0:DDRPARAMS"; + reg = <0x180000 0x10000>; + read-only; + }; + + partition@190000 { + label = "0:APPSBLENV"; + reg = <0x190000 0x10000>; + read-only; + }; + + partition@1a0000 { + label = "0:APPSBL"; + reg = <0x1a0000 0xa0000>; + read-only; + }; + + partition@240000 { + label = "0:APPSBL_1"; + reg = <0x240000 0xa0000>; + read-only; + }; + + partition@2e0000 { + label = "0:ART"; + reg = <0x2e0000 0x10000>; + read-only; + }; + + config: partition@2f0000 { + label = "0:CONFIG"; + reg = <0x2f0000 0x10000>; + read-only; + }; + + partition@300000 { + label = "0:CONFIG_RW"; + reg = <0x300000 0x10000>; + read-only; + }; + + partition@310000 { + label = "0:EVENTSLOG"; + reg = <0x310000 0x90000>; + read-only; + }; + }; + }; + + xt26g02a@1 { + /* + * Factory U-boot looks in 0:BOOTCONFIG partition for active + * partitions settings and mangles the partition config so + * rootfs/rootfs_1 pairs can be swaped. + * It isn't a problem but we never can be sure where OFW put + * factory images. "spinand,mt29f" value is required for proper + * nand recognition in u-boot. + */ + compatible = "spi-nand", "spinand,mt29f"; + #address-cells = <1>; + #size-cells = <1>; + reg = <1>; + spi-max-frequency = <24000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs_1"; + reg = <0x00000000 0x08000000>; + }; + + partition@8000000 { + label = "rootfs"; + reg = <0x08000000 0x08000000>; + }; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + phy-reset-gpio = <&tlmm 62 0>; +}; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-rutx10.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-rutx10.dts new file mode 100644 index 000000000000..d1d632568c6c --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-rutx10.dts @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qcom-ipq4018-rutx.dtsi" + +/ { + model = "Teltonika RUTX10"; + compatible = "teltonika,rutx10"; + + soc { + leds { + compatible = "gpio-leds"; + + wifi2g { + label = "green:wifi2g"; + gpios = <&stm32_io 19 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0tpt"; + }; + + wifi5g { + label = "green:wifi5g"; + gpios = <&stm32_io 18 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1tpt"; + }; + }; + }; +}; diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index c24eb2852345..0d7d7a30d223 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -46,6 +46,17 @@ define Build/append-rootfshdr dd if=$@.new bs=64 count=1 >> $(IMAGE_KERNEL) endef +define Build/append-rutx-metadata + echo \ + '{ \ + "device_code": [".*"], \ + "hwver": [".*"], \ + "batch": [".*"], \ + "serial": [".*"], \ + "supported_devices":["teltonika,rutx"] \ + }' | fwtool -I - $@ +endef + define Build/mkmylofw_32m $(eval device_id=$(word 1,$(1))) $(eval revision=$(word 2,$(1))) @@ -873,6 +884,22 @@ define Device/qxwlan_e2600ac-c2 endef TARGET_DEVICES += qxwlan_e2600ac-c2 +define Device/teltonika_rutx10 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Teltonika + DEVICE_MODEL := RUTX10 + SOC := qcom-ipq4018 + DEVICE_DTS_CONFIG := config@5 + KERNEL_INSTALL := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + FILESYSTEMS := squashfs + IMAGE/nand-factory.ubi := append-ubi | qsdk-ipq-factory-nand | append-rutx-metadata + DEVICE_PACKAGES := ipq-wifi-teltonika_rutx kmod-bluetooth +endef +TARGET_DEVICES += teltonika_rutx10 + define Device/unielec_u4019-32m $(call Device/FitImage) DEVICE_VENDOR := Unielec diff --git a/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch index 69ba9e4a431f..9817e9c102cf 100644 --- a/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -902,11 +902,68 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -902,11 +902,69 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ @@ -37,6 +37,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-oap100.dtb \ + qcom-ipq4018-pa1200.dtb \ + qcom-ipq4018-rt-ac58u.dtb \ ++ qcom-ipq4018-rutx10.dtb \ + qcom-ipq4018-wac510.dtb \ + qcom-ipq4018-wre6606.dtb \ + qcom-ipq4018-wrtq-329acn.dtb \ diff --git a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch index 0846c6668c91..bda2b014a460 100644 --- a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -837,11 +837,66 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -837,11 +837,67 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ @@ -37,6 +37,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-oap100.dtb \ + qcom-ipq4018-pa1200.dtb \ + qcom-ipq4018-rt-ac58u.dtb \ ++ qcom-ipq4018-rutx10.dtb \ + qcom-ipq4018-wac510.dtb \ + qcom-ipq4018-wre6606.dtb \ + qcom-ipq4018-wrtq-329acn.dtb \ -- 2.30.2