From d684867a865672a3065e83da2c127218a307cadc Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 23 Mar 2022 14:49:19 +0100 Subject: [PATCH 1/7] Fix for rutx --- build.sh | 4 ++++ root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-08_10.dts | 2 +- root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-09_11.dts | 2 +- root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-12.dts | 2 +- root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-R1.dts | 2 +- root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-STM32.dts | 2 +- root/target/linux/ipq40xx/image/generic.mk | 3 ++- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5d048185..93eff390 100755 --- a/build.sh +++ b/build.sh @@ -243,6 +243,10 @@ if [ "$OMR_KERNEL" != "5.4" ] && [ "$OMR_TARGET" != "x86_64" ] && [ "$OMR_TARGET echo "# CONFIG_PACKAGE_kmod-r8168 is not set" >> "$OMR_TARGET/source/.config" fi +if [ "$OMR_TARGET" = "rutx" -a "$OMR_KERNEL" = "5.4" ]; then + echo "CONFIG_PACKAGE_kmod-r2ec=y" >> "$OMR_TARGET/source/.config" +fi + if [ "$OMR_TARGET" = "bpi-r1" -a "$OMR_OPENWRT" = "master" ]; then # We disable mc in master, because it leads to unknown compilation errors on bpi-r1 target # No time to check this, now, cause i am focused on make this target work diff --git a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-08_10.dts b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-08_10.dts index 0404ede3..22984ac2 100644 --- a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-08_10.dts +++ b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-08_10.dts @@ -2,7 +2,7 @@ #include "qcom-ipq4018-rutx-shiftreg.dtsi" / { - model = "RUTX08/10"; + model = "Teltonika RUTX08/10"; soc { gpio-export { diff --git a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-09_11.dts b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-09_11.dts index 707011a4..6bf9ec40 100644 --- a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-09_11.dts +++ b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-09_11.dts @@ -2,7 +2,7 @@ #include "qcom-ipq4018-rutx-shiftreg.dtsi" / { - model = "RUTX09/11"; + model = "Teltonika RUTX09/11"; soc { gpio-export { diff --git a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-12.dts b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-12.dts index d39f64e9..8b02bf9a 100644 --- a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-12.dts +++ b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-12.dts @@ -2,7 +2,7 @@ #include "qcom-ipq4018-rutx-shiftreg.dtsi" / { - model = "RUTX12"; + model = "Teltonika RUTX12"; soc { gpio-export { diff --git a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-R1.dts b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-R1.dts index 5f30195b..3742fc27 100644 --- a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-R1.dts +++ b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-R1.dts @@ -3,7 +3,7 @@ #include "qcom-ipq4018-rutx-i2c.dtsi" // SFP / { - model = "RUTXR1"; + model = "Teltonika RUTXR1"; soc { gpio-export { diff --git a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-STM32.dts b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-STM32.dts index c6e53f02..ddb8b72c 100644 --- a/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-STM32.dts +++ b/root/target/linux/ipq40xx/dts/qcom-ipq4018-rutx-STM32.dts @@ -2,7 +2,7 @@ #include "qcom-ipq4018-rutx-i2c.dtsi" / { - model = "RUTX STM32"; + model = "Teltonika RUTX STM32"; io_expander = "stm32"; soc { diff --git a/root/target/linux/ipq40xx/image/generic.mk b/root/target/linux/ipq40xx/image/generic.mk index 42cefb88..9f3507a7 100644 --- a/root/target/linux/ipq40xx/image/generic.mk +++ b/root/target/linux/ipq40xx/image/generic.mk @@ -843,7 +843,8 @@ define Device/teltonika_rutx IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand | append-rutx-metadata IMAGES += sysupgrade.bin IMAGE/sysupgrade.bin := append-ubi | qsdk-ipq-factory-nand | append-metadata - DEVICE_PACKAGES := ipq-wifi-teltonika_rutx kmod-bluetooth kmod-r2ec + #DEVICE_PACKAGES := ipq-wifi-teltonika_rutx kmod-bluetooth kmod-r2ec + DEVICE_PACKAGES := ipq-wifi-teltonika_rutx kmod-bluetooth HW_SUPPORT := io_expander%stm32:shiftreg_1 endef TARGET_DEVICES += teltonika_rutx From 41f999557fc53c832241fe2201c0ba2e90d5fd19 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 23 Mar 2022 14:49:53 +0100 Subject: [PATCH 2/7] Add missing config in kernel 5.4 --- root/target/linux/generic/config-5.4 | 1 + 1 file changed, 1 insertion(+) diff --git a/root/target/linux/generic/config-5.4 b/root/target/linux/generic/config-5.4 index 21697d2d..c9b968d2 100644 --- a/root/target/linux/generic/config-5.4 +++ b/root/target/linux/generic/config-5.4 @@ -656,6 +656,7 @@ CONFIG_BPF_JIT=y # CONFIG_BPF_JIT_ALWAYS_ON is not set # CONFIG_BPF_STREAM_PARSER is not set CONFIG_BPF_SYSCALL=y +# CONFIG_BPF_UNPRIV_DEFAULT_OFF is not set # CONFIG_BPQETHER is not set CONFIG_BQL=y CONFIG_BRANCH_PROFILE_NONE=y From 66eed314b7b4673e06a144eecdc50291706089d9 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 23 Mar 2022 14:51:06 +0100 Subject: [PATCH 3/7] Fix several RUTX issues --- .../base-files/lib/preinit/82_modem_power | 20 + .../target/linux/ipq40xx/base-files/sbin/mctl | 120 +++ .../ipq40xx/files/drivers/net/phy/qca807x.c | 865 ++++++++++++++++++ .../085-ipq40xx-fix-sleep-clock.patch | 16 + ...d-summary-entry-when-MTD-write-fails.patch | 53 ++ ...75-report-combo-link-state-to-netdev.patch | 210 +++++ .../719-meiglink_slm750_support.patch | 35 + ...spi-qup-revert-fix-PIO-DMA-transfers.patch | 105 +++ 8 files changed, 1424 insertions(+) create mode 100644 root/target/linux/ipq40xx/base-files/lib/preinit/82_modem_power create mode 100755 root/target/linux/ipq40xx/base-files/sbin/mctl create mode 100644 root/target/linux/ipq40xx/files/drivers/net/phy/qca807x.c create mode 100644 root/target/linux/ipq40xx/patches-5.15/085-ipq40xx-fix-sleep-clock.patch create mode 100644 root/target/linux/ipq40xx/patches-5.15/500-jffs2-Dont-add-summary-entry-when-MTD-write-fails.patch create mode 100644 root/target/linux/ipq40xx/patches-5.15/714-qca8075-report-combo-link-state-to-netdev.patch create mode 100644 root/target/linux/ipq40xx/patches-5.15/719-meiglink_slm750_support.patch create mode 100644 root/target/linux/ipq40xx/patches-5.15/851-spi-qup-revert-fix-PIO-DMA-transfers.patch diff --git a/root/target/linux/ipq40xx/base-files/lib/preinit/82_modem_power b/root/target/linux/ipq40xx/base-files/lib/preinit/82_modem_power new file mode 100644 index 00000000..7db2ecf2 --- /dev/null +++ b/root/target/linux/ipq40xx/base-files/lib/preinit/82_modem_power @@ -0,0 +1,20 @@ +set_state() { + local label="$1" + local disable + + [ -e "/sys/class/gpio/${label}_power/value" ] || return + + config_get disable ${label} disable + [ "${disable}" -eq 1 ] && \ + /sbin/mctl -s -m "${label}" || \ + /sbin/mctl -p -m "${label}" +} + +do_power_modem() { + [ -z "$(uci -q get system.modem.disable)" ] && /sbin/mctl -p || { + config_load system + config_foreach set_state mctl + } +} + +boot_hook_add preinit_main do_power_modem diff --git a/root/target/linux/ipq40xx/base-files/sbin/mctl b/root/target/linux/ipq40xx/base-files/sbin/mctl new file mode 100755 index 00000000..f501cc2e --- /dev/null +++ b/root/target/linux/ipq40xx/base-files/sbin/mctl @@ -0,0 +1,120 @@ +#!/bin/sh + +. /usr/share/libubox/jshn.sh + +PS_ON=1 +PS_OFF=2 + +MPS=0 +MLBL="modem" + +modem_reset() { + local label="$1" + + [ -e "/sys/class/gpio/${label}_reset/value" ] || return + + echo 1 > "/sys/class/gpio/${label}_reset/value" + sleep 1 + echo 0 > "/sys/class/gpio/${label}_reset/value" +} + +modem_off() { + local label="$1" + + [ -e "/sys/class/gpio/${label}_reset/value" ] || return + + echo 1 > "/sys/class/gpio/${label}_reset/value" +} + +modem_power() { + local label="$1" + + [ -e "/sys/class/gpio/${label}_power/value" ] || return + + # simulate power press + echo 1 > "/sys/class/gpio/${label}_power/value" + sleep 1 + echo 0 > "/sys/class/gpio/${label}_power/value" +} + +modem_list() { + local list="modem" + local label + + [ "$(modem_fetch_primary)" -eq 0 ] && { + echo "${list}" + return + } + + for m in /sys/class/gpio/modem*_power; do + label="$(basename $m | awk -F_ '{print $1}')" + [ "${label}" != "modem" ] && list="${list},${label}" + done + + echo "${list}" +} + +modem_fetch_primary() { + local modem modems primary + + json_init + json_load_file "/etc/board.json" + + json_get_keys modems modems + json_select modems + + for modem in $modems; do + json_select "$modem" + json_get_vars primary + + [ -n "$primary" ] && { + echo 1 + return + } + + json_select .. + done + echo 0 +} + +modem_is_available() { + local label="$1" + [ -e "/sys/class/gpio/${label}_power/value" ] +} + +usage() { + cat < +Control modem power state. + +Options: + -p, --power-on power on modem + -s, --shutdown shutdown modem + -r, --reboot reboot modem + -m, --modem