From 24fc5ff2136a10bf0ee9e764ae0404b2928a67ce Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Thu, 19 Dec 2024 10:46:40 +0100 Subject: [PATCH 01/22] ipq40xx-generic: EN WS-AP3915i remove BLOCKSIZE from image definition The blocksize was too high, resulting in forgetting the config on sysupgrade It is not needed for SPI-NOR. Signed-off-by: Florian Maurer Link: https://github.com/openwrt/openwrt/pull/17305 Signed-off-by: Robert Marko --- target/linux/ipq40xx/image/generic.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index d92d0824f9..21841f4bf1 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -542,7 +542,6 @@ define Device/extreme-networks_ws-ap3915i DEVICE_MODEL := WS-AP3915i IMAGE_SIZE := 30080k SOC := qcom-ipq4029 - BLOCKSIZE := 128k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata endef TARGET_DEVICES += extreme-networks_ws-ap3915i From 363f52d067e1852d46ccdc3ab4d12bc2f9d018dd Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Thu, 19 Dec 2024 11:49:13 +0100 Subject: [PATCH 02/22] ipq40xx-generic: ws-ap3915i fix macadress set macaddress correctly for board Signed-off-by: Florian Maurer Link: https://github.com/openwrt/openwrt/pull/17305 Signed-off-by: Robert Marko --- target/linux/ipq40xx/base-files/etc/board.d/02_network | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index e3a6e24228..549e1ac0c9 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -202,6 +202,9 @@ ipq40xx_setup_macs() wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) lan_mac=$(macaddr_add "$wan_mac" 1) ;; + extreme-networks,ws-ap3915i) + label_mac="$(mtd_get_mac_ascii CFG1 ethaddr)" + ;; ezviz,cs-w3-wd1200g-eup) label_mac=$(mtd_get_mac_binary "ART" 0x6) ;; From 0de59fb952b7784c8085e340367523276c97687c Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Sun, 22 Dec 2024 20:13:05 +0800 Subject: [PATCH 03/22] Revert "ipq40xx: use PHY to control USB GPIO" This reverts commit 3bd2cee9bf85f01732e05e0c8fb070fb18c74095. Based on my testing, we are unable to control USB power supply through some third-party tools (e.g. uhubctl) or sysfs in userspace. Signed-off-by: Shiji Yang Link: https://github.com/openwrt/openwrt/pull/17339 Signed-off-by: Robert Marko --- .../arch/arm/boot/dts/qcom/qcom-ipq4019-wia3300-20.dts | 7 +++++-- target/linux/ipq40xx/generic/config-default | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target/linux/ipq40xx/files-6.6/arch/arm/boot/dts/qcom/qcom-ipq4019-wia3300-20.dts b/target/linux/ipq40xx/files-6.6/arch/arm/boot/dts/qcom/qcom-ipq4019-wia3300-20.dts index 85ad382223..644329419d 100644 --- a/target/linux/ipq40xx/files-6.6/arch/arm/boot/dts/qcom/qcom-ipq4019-wia3300-20.dts +++ b/target/linux/ipq40xx/files-6.6/arch/arm/boot/dts/qcom/qcom-ipq4019-wia3300-20.dts @@ -68,6 +68,11 @@ }; }; + output-usb-power { + compatible = "regulator-output"; + vout-supply = <®_usb>; + }; + reg_usb: regulator-usb { compatible = "regulator-fixed"; @@ -414,8 +419,6 @@ &usb2_hs_phy { status = "okay"; - - phy-supply = <®_usb>; }; &watchdog { diff --git a/target/linux/ipq40xx/generic/config-default b/target/linux/ipq40xx/generic/config-default index bd9876a0b6..4999ad3622 100644 --- a/target/linux/ipq40xx/generic/config-default +++ b/target/linux/ipq40xx/generic/config-default @@ -3,4 +3,5 @@ CONFIG_MTD_UBI_BEB_LIMIT=20 CONFIG_MTD_UBI_BLOCK=y CONFIG_MTD_UBI_NVMEM=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 +CONFIG_REGULATOR_USERSPACE_CONSUMER=y CONFIG_UBIFS_FS=y From 967a6a2cf501d4dd60e790ab69c871a000d85391 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Mon, 23 Dec 2024 21:56:31 +0800 Subject: [PATCH 04/22] uboot-rockchip: increase rng-seed size Increase rng-seed size to make Linux happy and initialize rng pool instantly. Linux 5.19+ requires 32 bytes of entropy to initialize random pool, but u-boot currently provides only 8 bytes. Boot with 8 byte rng-seed (Linux 6.11): # dmesg | grep crng [ 12.089286] random: crng init done Boot with 32 byte rng-seed (Linux 6.11): # dmesg | grep crng [ 0.000000] random: crng init done Signed-off-by: Tianling Shen Link: https://github.com/openwrt/openwrt/pull/17352 Signed-off-by: Hauke Mehrtens --- ...se-rng-seed-size-to-make-it-sufficie.patch | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 package/boot/uboot-rockchip/patches/001-rockchip-board-Increase-rng-seed-size-to-make-it-sufficie.patch diff --git a/package/boot/uboot-rockchip/patches/001-rockchip-board-Increase-rng-seed-size-to-make-it-sufficie.patch b/package/boot/uboot-rockchip/patches/001-rockchip-board-Increase-rng-seed-size-to-make-it-sufficie.patch new file mode 100644 index 0000000000..0b7bf1be7d --- /dev/null +++ b/package/boot/uboot-rockchip/patches/001-rockchip-board-Increase-rng-seed-size-to-make-it-sufficie.patch @@ -0,0 +1,96 @@ +From ed4ae7386257aa66455e330234e513d098a36f84 Mon Sep 17 00:00:00 2001 +From: Alex Shumsky +Date: Wed, 16 Oct 2024 13:02:03 +0300 +Subject: [PATCH] rockchip: board: Increase rng-seed size to make it sufficient + for modern Linux + +Increase rng-seed size to make Linux happy and initialize rng pool instantly. +Linux 5.19+ requires 32 bytes of entropy to initialize random pool, but u-boot +currently provides only 8 bytes. +Linux 5.18 and probably some versions before it used to require 64 bytes. +Bump min value to 64 bytes to be on a safe side. + +Boot with 8 byte rng-seed (Linux 6.11): + # dmesg | grep crng + [ 12.089286] random: crng init done +Boot with 32 byte rng-seed (Linux 6.11): + # dmesg | grep crng + [ 0.000000] random: crng init done + +Linux source references: +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/char/random.c?h=v5.19#n551 +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/char/random.c?h=v5.18#n236 + +Signed-off-by: Alex Shumsky +Fixes: d2048bafae40 ("rockchip: board: Add board_rng_seed() for all Rockchip devices") +Reviewed-by: Dragan Simic +Reviewed-by: Marek Vasut +Reviewed-by: Quentin Schulz +Reviewed-by: Kever Yang +--- + arch/arm/mach-rockchip/board.c | 11 ++++++++++- + common/Kconfig | 3 +++ + doc/usage/environment.rst | 5 +++++ + include/fdt_support.h | 3 ++- + 4 files changed, 20 insertions(+), 2 deletions(-) + +--- a/arch/arm/mach-rockchip/board.c ++++ b/arch/arm/mach-rockchip/board.c +@@ -480,9 +480,18 @@ __weak int misc_init_r(void) + __weak int board_rng_seed(struct abuf *buf) + { + struct udevice *dev; +- size_t len = 0x8; ++ ulong len = env_get_ulong("rng_seed_size", 10, 64); + u64 *data; + ++ if (len < 64) { ++ /* ++ * rng_seed_size should be at least 32 bytes for Linux 5.19+, ++ * or 64 for older Linux kernel versions ++ */ ++ log_warning("Value for rng_seed_size (%lu) too low, Linux kernel RNG may fail to initialize early\n", ++ len); ++ } ++ + data = malloc(len); + if (!data) { + printf("Out of memory\n"); +--- a/common/Kconfig ++++ b/common/Kconfig +@@ -927,6 +927,9 @@ config BOARD_RNG_SEED + new seed for use on subsequent boots, and whether or not the + kernel should account any entropy from the given seed. + ++ Default seed size (64 bytes) can be overridden by a decimal ++ environment variable rng_seed_size. ++ + endmenu + + menu "Update support" +--- a/doc/usage/environment.rst ++++ b/doc/usage/environment.rst +@@ -323,6 +323,11 @@ netretry + Useful on scripts which control the retry operation + themselves. + ++rng_seed_size ++ Size of random value added to device-tree node /chosen/rng-seed. ++ This variable is given as a decimal number. ++ If unset, 64 bytes is used as the default. ++ + silent_linux + If set then Linux will be told to boot silently, by + adding 'console=' to its command line. If "yes" it will be +--- a/include/fdt_support.h ++++ b/include/fdt_support.h +@@ -202,7 +202,8 @@ int ft_board_setup(void *blob, struct bd + * + * This function is called if CONFIG_BOARD_RNG_SEED is set, and must + * be provided by the board. It should return, via @buf, some suitable +- * seed value to pass to the kernel. ++ * seed value to pass to the kernel. Seed size could be set in a decimal ++ * environment variable rng_seed_size and it defaults to 64 bytes. + * + * @param buf A struct abuf for returning the seed and its size. + * @return 0 if ok, negative on error. From 4e68103c4eb93d3f9b9359742c3c377ee2844943 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Mon, 23 Dec 2024 21:57:15 +0800 Subject: [PATCH 05/22] uboot-rockchip: fix build with swig 4.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following error by backporting upstream update: ``` scripts/dtc/pylibfdt/libfdt_wrap.c: In function ‘_wrap_fdt_next_node’: scripts/dtc/pylibfdt/libfdt_wrap.c:5581:17: error: too few arguments to function ‘SWIG_Python_AppendOutput’ 5581 | resultobj = SWIG_Python_AppendOutput(resultobj, val); | ^~~~~~~~~~~~~~~~~~~~~~~~ ``` Fixes: https://github.com/openwrt/openwrt/issues/17345 Signed-off-by: Tianling Shen Link: https://github.com/openwrt/openwrt/pull/17352 Signed-off-by: Hauke Mehrtens --- ...libfdt-i_shipped-Use-SWIG_AppendOutp.patch | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 package/boot/uboot-rockchip/patches/002-scripts-dtc-pylibfdt-libfdt-i_shipped-Use-SWIG_AppendOutp.patch diff --git a/package/boot/uboot-rockchip/patches/002-scripts-dtc-pylibfdt-libfdt-i_shipped-Use-SWIG_AppendOutp.patch b/package/boot/uboot-rockchip/patches/002-scripts-dtc-pylibfdt-libfdt-i_shipped-Use-SWIG_AppendOutp.patch new file mode 100644 index 0000000000..f5beca8d77 --- /dev/null +++ b/package/boot/uboot-rockchip/patches/002-scripts-dtc-pylibfdt-libfdt-i_shipped-Use-SWIG_AppendOutp.patch @@ -0,0 +1,55 @@ +From a63456b9191fae2fe49f4b121e025792022e3950 Mon Sep 17 00:00:00 2001 +From: Markus Volk +Date: Wed, 30 Oct 2024 06:07:16 +0100 +Subject: [PATCH] scripts/dtc/pylibfdt/libfdt.i_shipped: Use SWIG_AppendOutput +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Swig has changed language specific AppendOutput functions. The helper +macro SWIG_AppendOutput remains unchanged. Use that instead +of SWIG_Python_AppendOutput, which would require an extra parameter +since swig 4.3.0. + +/home/flk/poky/build-test/tmp/work/qemux86_64-poky-linux/u-boot/2024.10/git/arch/x86/cpu/u-boot-64.lds +| scripts/dtc/pylibfdt/libfdt_wrap.c: In function ‘_wrap_fdt_next_node’: +| scripts/dtc/pylibfdt/libfdt_wrap.c:5581:17: error: too few arguments to function ‘SWIG_Python_AppendOutput’ +| 5581 | resultobj = SWIG_Python_AppendOutput(resultobj, val); +| | ^~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Markus Volk +Reported-by: Rudi Heitbaum +Link: https://github.com/dgibson/dtc/pull/154 +--- + scripts/dtc/pylibfdt/libfdt.i_shipped | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/scripts/dtc/pylibfdt/libfdt.i_shipped ++++ b/scripts/dtc/pylibfdt/libfdt.i_shipped +@@ -1037,7 +1037,7 @@ typedef uint32_t fdt32_t; + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +- resultobj = SWIG_Python_AppendOutput(resultobj, buff); ++ resultobj = SWIG_AppendOutput(resultobj, buff); + } + } + +@@ -1076,7 +1076,7 @@ typedef uint32_t fdt32_t; + + %typemap(argout) int *depth { + PyObject *val = Py_BuildValue("i", *arg$argnum); +- resultobj = SWIG_Python_AppendOutput(resultobj, val); ++ resultobj = SWIG_AppendOutput(resultobj, val); + } + + %apply int *depth { int *depth }; +@@ -1092,7 +1092,7 @@ typedef uint32_t fdt32_t; + if (PyTuple_GET_SIZE(resultobj) == 0) + resultobj = val; + else +- resultobj = SWIG_Python_AppendOutput(resultobj, val); ++ resultobj = SWIG_AppendOutput(resultobj, val); + } + } + From 3c0ef48bc82cb11edd0b4fdbc4beaa3f95708967 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 Dec 2024 17:33:21 +0100 Subject: [PATCH 06/22] mbedtls: Deactivate ARIA block cipher by default The ARIA block cipher is pretty uncommon in TLS, deactivate it for now. This saves some space and reduces the possible variations and attack vectors of mbedtls. ARIA support was deactivated in OpenWrt 23.05 by default. Link: https://github.com/openwrt/openwrt/pull/17342 Signed-off-by: Hauke Mehrtens --- package/libs/mbedtls/Config.in | 4 ++++ package/libs/mbedtls/Makefile | 1 + 2 files changed, 5 insertions(+) diff --git a/package/libs/mbedtls/Config.in b/package/libs/mbedtls/Config.in index 51f8bcbbdd..0a760ed2cb 100644 --- a/package/libs/mbedtls/Config.in +++ b/package/libs/mbedtls/Config.in @@ -8,6 +8,10 @@ config MBEDTLS_AES_C bool "MBEDTLS_AES_C" default y +config MBEDTLS_ARIA_C + bool "MBEDTLS_ARIA_C" + default n + config MBEDTLS_CAMELLIA_C bool "MBEDTLS_CAMELLIA_C" default n diff --git a/package/libs/mbedtls/Makefile b/package/libs/mbedtls/Makefile index 2efdf86cd2..f5bff13324 100644 --- a/package/libs/mbedtls/Makefile +++ b/package/libs/mbedtls/Makefile @@ -37,6 +37,7 @@ MBEDTLS_BUILD_OPTS_CURVES= \ MBEDTLS_BUILD_OPTS_CIPHERS= \ CONFIG_MBEDTLS_AES_C \ + CONFIG_MBEDTLS_ARIA_C \ CONFIG_MBEDTLS_CAMELLIA_C \ CONFIG_MBEDTLS_CCM_C \ CONFIG_MBEDTLS_CMAC_C \ From 42254d3f5fa010466195c167c13f704ba85b3f54 Mon Sep 17 00:00:00 2001 From: Edward Chow Date: Tue, 10 Dec 2024 18:36:40 +0800 Subject: [PATCH 07/22] ath79: port buffalo WZR-450HP2 from ar71xx Referencing commit a1837135e04b Hardware -------- SoC: Qualcomm Atheros QCA9558 RAM: 128M DDR2 (Nanya NT5TU64M16HG-AC) FLASH: 128M SPI-NAND (Spansion S34ML01G100TFI00) WLAN: QCA9558 3T3R 802.11 bgn ETH: Qualcomm Atheros QCA8337 UART: 115200 8n1 BUTTON: Reset - WPS - "Router" switch LED: 2x system-LED, 2x wlan-LED, 1x internet-LED, 2x routing-LED LEDs besides the ethernet ports are controlled by the ethernet switch MAC Address: use address(sample 1) source label cc:e1:d5:xx:xx:ed art@macaddr_wan lan cc:e1:d5:xx:xx:ec art@macaddr_lan wan cc:e1:d5:xx:xx:ed $label WiFi4_2G cc:e1:d5:xx:xx:ec art@cal_ath9k Installation from Serial Console ------------ 1. Connect to the serial console. Power up the device and interrupt autoboot when prompted 2. Connect a TFTP server reachable at 192.168.11.10/24 to the ethernet port. Serve the OpenWrt initramfs image as "openwrt.bin" 3. Boot the initramfs image using U-Boot ath> tftpboot 0x84000000 openwrt.bin ath> bootm 0x84000000 4. Copy the OpenWrt sysupgrade image to the device using scp and install it like a normal upgrade (with no need to keeping config since no config from "previous OpenWRT installation" could be kept at all) # sysupgrade -n /path/to/openwrt/sysupgrade.bin Installation from Web Interface ------------ To flash just do a firmware upgrade from the stock firmware (Buffalo branded dd-wrt) with squashfs-factory.bin Signed-off-by: Edward Chow Link: https://github.com/openwrt/openwrt/pull/17227 Signed-off-by: Hauke Mehrtens --- package/boot/uboot-envtools/files/ath79 | 1 + .../ath79/dts/qca9558_buffalo_wzr-450hp2.dts | 179 ++++++++++++++++++ .../generic/base-files/etc/board.d/02_network | 4 + target/linux/ath79/image/generic.mk | 12 ++ 4 files changed, 196 insertions(+) create mode 100644 target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index c6d23ce73d..c989e61bd5 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -28,6 +28,7 @@ asus,rt-ac59u-v2|\ asus,zenwifi-cd6n|\ asus,zenwifi-cd6r|\ buffalo,bhr-4grv2|\ +buffalo,wzr-450hp2|\ devolo,magic-2-wifi|\ engenius,eap300-v2|\ engenius,eap350-v1|\ diff --git a/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts b/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts new file mode 100644 index 0000000000..8f19907dfe --- /dev/null +++ b/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qca955x.dtsi" + +#include +#include +#include + +/ { + compatible = "buffalo,wzr-450hp2", "qca,qca9558"; + model = "Buffalo WZR-450HP2/WZR-450HP2D"; + + aliases { + led-boot = &led_status_green; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_green; + label-mac-device = ð0; + }; + + leds { + compatible = "gpio-leds"; + + led_status_green: status_green { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&gpio 20 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + led_wlan_green: wlan_green { + function = LED_FUNCTION_WLAN; + color = ; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + led_wps_green: wps_green { + function = LED_FUNCTION_WPS; + color = ; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "Reset button"; + linux,code = ; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + rfkill { + label = "RFKILL button"; + linux,code = ; + gpios = <&gpio 21 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + reg = <0x40000 0x10000>; + label = "u-boot-env"; + }; + + partition@50000 { + compatible = "denx,uimage"; + reg = <0x50000 0xf90000>; + label = "firmware"; + }; + + partition@fe0000 { + reg = <0xfe0000 0x10000>; + label = "user_property"; + read-only; + }; + + art: partition@ff0000 { + label = "art"; + reg = <0xff0000 0x10000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_wan: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_lan: macaddr@6 { + reg = <0x6 0x6>; + }; + + cal_ath9k: cal_ath9k@1000 { + reg = <0x1000 0x440>; + }; + }; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy0: ethernet-phy@0 { + reg = <0>; + + qca,ar8327-initvals = < + 0x04 0x07600000 /* PORT0 PAD MODE CTRL: RGMII, to eth0 */ + 0x0c 0x00080080 /* PORT6 PAD MODE CTRL: SGMII, to eth1 */ + 0x10 0x81000080 /* POWER ON STRAP */ + 0x50 0xcc35cc35 /* LED_CTRL0 */ + 0x54 0xca35ca35 /* LED_CTRL1 */ + 0x58 0xc935c935 /* LED_CTRL2 */ + 0x5c 0x03ffff00 /* LED_CTRL3 */ + 0x7c 0x0000007e /* PORT0_STATUS */ + 0x94 0x0000007e /* PORT6_STATUS */ + >; + }; +}; + +ð0 { + status = "okay"; + + nvmem-cells = <&macaddr_wan>; + nvmem-cell-names = "mac-address"; + phy-handle = <&phy0>; + pll-data = <0x56000000 0x00000101 0x00001616>; + + gmac-config { + device = <&gmac>; + rgmii-enabled = <1>; + }; +}; + +ð1 { + status = "okay"; + + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; + pll-data = <0x03000101 0x00000101 0x00001616>; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&wmac { + status = "okay"; + + nvmem-cells = <&cal_ath9k>; + nvmem-cell-names = "calibration"; +}; 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 ad0365a465..0321a9ac85 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -213,6 +213,10 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0" ;; + buffalo,wzr-450hp2) + ucidef_add_switch "switch0" \ + "6@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0" + ;; buffalo,wzr-600dhp|\ buffalo,wzr-hp-ag300h|\ tplink,archer-c25-v1|\ diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 92f9bc6cdd..846a9acd20 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -759,6 +759,18 @@ define Device/buffalo_wzr-hp-g450h endef TARGET_DEVICES += buffalo_wzr-hp-g450h +define Device/buffalo_wzr-450hp2 + $(Device/buffalo_common) + SOC := qca9558 + DEVICE_MODEL := WZR-450HP2 + DEVICE_ALT0_VENDOR := Buffalo + DEVICE_ALT0_MODEL := WZR-450HP2D + BUFFALO_PRODUCT := WZR-450HP2 + IMAGE_SIZE := 15936k + SUPPORTED_DEVICES += wzr-450hp2 +endef +TARGET_DEVICES += buffalo_wzr-450hp2 + define Device/comfast_cf-e110n-v2 SOC := qca9533 DEVICE_VENDOR := COMFAST From f69fc4c413357ab2e981f11eacd6101b6a59ab34 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 Dec 2024 17:47:34 +0100 Subject: [PATCH 08/22] procd: update to Git HEAD (2024-12-22) 42d3937 jail/seccomp: add support for loongarch64 Link: https://github.com/openwrt/openwrt/pull/17335 Signed-off-by: Hauke Mehrtens --- package/system/procd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index 7a2276a46d..65cc0ad9f6 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git -PKG_MIRROR_HASH:=99139ce325d73f5b250d115703540acfac3bcdc8ee202f2d3aacf3083042bc70 -PKG_SOURCE_DATE:=2024-12-17 -PKG_SOURCE_VERSION:=fd01fb852302a2683d09ee1c2193d7c51e2b0ba8 +PKG_MIRROR_HASH:=41dbb5352eff931ecc78c4ce9a081645c26a7fb8dc57cdd6521a2f8d3a142567 +PKG_SOURCE_DATE:=2024-12-22 +PKG_SOURCE_VERSION:=42d3937654508b04da64969f9d764ac2ec411904 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 From b6b6148d7d19f7081551491192e161f46cb0bdb8 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Sun, 22 Dec 2024 18:32:54 +0800 Subject: [PATCH 09/22] config: enable SECCOMP support for loongarch64 Make USE_SECCOMP selectable for loongarch64 Signed-off-by: Weijie Gao Link: https://github.com/openwrt/openwrt/pull/17335 Signed-off-by: Hauke Mehrtens --- config/Config-build.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/Config-build.in b/config/Config-build.in index ec3a8d1f80..9b6b5f3066 100644 --- a/config/Config-build.in +++ b/config/Config-build.in @@ -426,7 +426,7 @@ menu "Global build settings" config USE_SECCOMP bool "Enable SECCOMP" select KERNEL_SECCOMP - depends on (aarch64 || arm || armeb || mips || mipsel || mips64 || mips64el || i386 || powerpc || x86_64) + depends on (aarch64 || arm || armeb || mips || mipsel || mips64 || mips64el || i386 || loongarch64 || powerpc || x86_64) depends on !TARGET_uml default y help From b3ce08e0b6fa6780bf7ee295a1f176c053b1100b Mon Sep 17 00:00:00 2001 From: Roland Reinl Date: Fri, 13 Dec 2024 18:58:26 +0100 Subject: [PATCH 10/22] mediatek: filogic: Add support for D-Link AQUILA PRO AI M60 Specification: - MT7986 CPU using 2.4GHz and 5GHz WiFi (both AX) - MT7531 switch - 512MB RAM - 128MB NAND flash (MX35LF1GE4AB-Z4I) with two UBI partitions with identical size - 1 multi color LED (red, green, blue, white) connected via GCA230718 (Same as D-Link M30 A1) - 3 buttons (WPS, reset, LED on/off) - 1x 2.5 Gbit WAN port with Maxlinear GPY211C - 4x 1 Gbit LAN ports Disassembly: - There are five screws at the bottom: 2 under the rubber feet, 3 under the label. - After removing the screws, the white plastic part can be shifted out of the blue part. - Be careful because the antennas are mounted on the side and the top of the white part. Serial Interface - The serial interface can be connected to the 4 pin holes next to/under the antenna cables. - Note that there is another set of 4 pin holes on the side of the board, it's not used. - Pins (from front to rear): - 3.3V (do not connect) - TX - RX - GND - Settings: 115200, 8N1 MAC addresses: - MAC address is stored in partition "Odm" at offset 0x81 (for example XX:XX:XX:XX:XX:52) - MAC address on the device label is ODM + 1 (for example XX:XX:XX:XX:XX:53) - WAN MAC is the one from the ODM partition (for example XX:XX:XX:XX:XX:52) - LAN MAC is the one from the ODM partition + 1 (for example XX:XX:XX:XX:XX:53) - WLAN MAC (2.4 GHz) is the one from the ODM partition + 2 (for example (XX:XX:XX:XX:XX:54) - WLAN MAC (5 GHz) is the one from the ODM partition + 5 (for example (XX:XX:XX:XX:XX:57) Flashing via OEM web interface: - Currently not supported because image crypto is not known Flashing via recovery web interface: - This is only working if the first partition is active because recovery images are always flashed to the active partition and OpenWrt can only be executed from the first partition - Use a Chromium based browser, otherwise firmware upgrade might not work - Recovery web interface is accessible via 192.168.200.1 after keeping the reset button pressed during start of the device until the LED blinks red - Upload the recovery image, this will take some time. LED will continue flashing red during the update process - The after flashing, the recovery web interface redirects to http://192.168.0.1. This can be ignored. OpenWrt is accessible via 192.168.1.1 after flashing - If the first partition isn't the active partition, OpenWrt will hang during the boot process. In this case: - Download the recovery image from https://github.com/RolandoMagico/openwrt/releases/tag/M60-Recovery-UBI-Switch (UBI switch image) - Enable recovery web interface again and load the UBI switch image. This image works on the second partition of the M60 - OpenWrt should boot now as expected. After booting, flash the normal OpenWrt sysupgrade image (for example in the OpenWrt web interface) - Flashing a sysupgrade image from the UBI switch image will make the first partition the active partition and from now on, default OpenWrt images can be used Flashing via Initramfs: - Before switching to OpenWrt, ensure that both partitions contain OEM firmware. - This can be achieved by re-flashing the same OEM firmware version again via the OEM web interface. - Flashing via OEM web interface will automatically flash the currently not active partition. - Open router, connect serial interface - Start a TFTP server at 192.168.200.2 and provide the initramfs image there - When starting the router, select "7. Load Image" in U-Boot - Settings for load address, load method can be kept as they are - Specify host and router IP address if you use different ones than the default (Router 192.168.200.1, TFTP server 192.168.200.2) - Enter the file name of the initramfs image - Confirm "Run loaded data now?" question after loading the image with "Y" - OpenWrt initramfs will start now - Before flashing OpenWrt, create a backup of the "ubi" partition. It is required when reverting back to OEM - Flash sysupgrade image to flash, during flashing the U-Boot variable sw_tryactive will be set to 0 - During next boot, U-Boot tries to boot from the ubi partition. If it fails, it will switch to the ubi1 partition Reverting back to OEM: - Boot the initramfs image as described in "Flashing via Initramfs" above - Copy the backed up ubi partition to /tmp (e.g. by using SCP) - Write the backup to the UBI partition: mtd write /tmp/OpenWrt.mtd4.ubi.bin /dev/mtd4 - Reboot the device, OEM firmware will start now Signed-off-by: Roland Reinl Link: https://github.com/openwrt/openwrt/pull/17296 Signed-off-by: Hauke Mehrtens --- .../uboot-envtools/files/mediatek_filogic | 3 +- .../mt7986a-dlink-aquila-pro-ai-m60-a1.dts | 377 ++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 3 +- .../base-files/lib/upgrade/platform.sh | 4 + target/linux/mediatek/image/filogic.mk | 14 + 5 files changed, 399 insertions(+), 2 deletions(-) create mode 100644 target/linux/mediatek/dts/mt7986a-dlink-aquila-pro-ai-m60-a1.dts diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 9d7c5a1527..bf107cc135 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -96,7 +96,8 @@ zbtlink,zbt-z8102ax|\ zbtlink,zbt-z8103ax) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; -dlink,aquila-pro-ai-m30-a1) +dlink,aquila-pro-ai-m30-a1|\ +dlink,aquila-pro-ai-m60-a1) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000" ;; gatonetworks,gdsp) diff --git a/target/linux/mediatek/dts/mt7986a-dlink-aquila-pro-ai-m60-a1.dts b/target/linux/mediatek/dts/mt7986a-dlink-aquila-pro-ai-m60-a1.dts new file mode 100644 index 0000000000..a95c069156 --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-dlink-aquila-pro-ai-m60-a1.dts @@ -0,0 +1,377 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +#include +#include +#include + +#include "mt7986a.dtsi" + +/ { + model = "D-Link AQUILA PRO AI M60 A1"; + compatible = "dlink,aquila-pro-ai-m60-a1", "mediatek,mt7986a"; + + aliases { + serial0 = &uart0; + led-boot = &led_status_white; + led-failsafe = &led_status_red; + led-running = &led_status_white; + led-upgrade = &led_status_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@40000000 { + reg = <0 0x40000000 0 0x20000000>; + }; + + gpio-keys { + compatible = "gpio-keys"; + + button-reset { + label = "reset"; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + button-wps { + label = "wps"; + gpios = <&pio 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + button-leds-on-off { + label = "leds-on-off"; + linux,code = ; + gpios = <&pio 47 GPIO_ACTIVE_LOW>; + }; + }; +}; + +ð { + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + + nvmem-cells = <&macaddr_odm 1>; + nvmem-cell-names = "mac-address"; + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + phy-mode = "2500base-x"; + phy-handle = <&phy6>; + nvmem-cells = <&macaddr_odm 0>; + nvmem-cell-names = "mac-address"; + label = "internet"; + }; + + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>; + reset-delay-us = <1500000>; + reset-post-delay-us = <1000000>; + + phy6: phy@6 { + compatible = "maxlinear,gpy211", "ethernet-phy-ieee802.3-c45"; + reg = <6>; + phy-mode = "2500base-x"; + }; + + switch@1f { + compatible = "mediatek,mt7531"; + reg = <31>; + reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&pio>; + interrupts = <66 IRQ_TYPE_LEVEL_HIGH>; + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + }; + + port@1 { + reg = <1>; + label = "lan2"; + }; + + port@2 { + reg = <2>; + label = "lan3"; + }; + + port@3 { + reg = <3>; + label = "lan4"; + }; + + port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + }; + }; +}; + +&pio { + spi_flash_pins: spi-flash-pins-33-to-38 { + mux { + function = "spi"; + groups = "spi0", "spi0_wp_hold"; + }; + conf-pu { + pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP"; + drive-strength = <8>; + mediatek,pull-up-adv = <0>; /* bias-disable */ + }; + conf-pd { + pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO"; + drive-strength = <8>; + mediatek,pull-down-adv = <0>; /* bias-disable */ + }; + }; + + wf_2g_5g_pins: wf_2g_5g-pins { + mux { + function = "wifi"; + groups = "wf_2g", "wf_5g"; + }; + conf { + pins = + "WF0_HB2", + "WF0_HB3", + "WF0_HB4", + "WF0_HB0", + "WF0_HB0_B", + "WF0_HB5", + "WF0_HB6", + "WF0_HB7", + "WF0_HB8", + "WF0_HB9", + "WF0_HB10", + "WF0_TOP_CLK", + "WF0_TOP_DATA", + "WF1_HB1", + "WF1_HB2", + "WF1_HB3", + "WF1_HB4", + "WF1_HB0", + "WF1_HB5", + "WF1_HB6", + "WF1_HB7", + "WF1_HB8", + "WF1_TOP_CLK", + "WF1_TOP_DATA"; + drive-strength = <4>; + }; + }; + + i2c_pins_3_4: i2c-pins-3-4 { + mux { + function = "i2c"; + groups = "i2c"; + }; + }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi_flash_pins>; + status = "okay"; + + flash@0 { + compatible = "spi-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + + spi-max-frequency = <20000000>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; + + mediatek,nmbm; + mediatek,bmt-max-ratio = <1>; + mediatek,bmt-max-reserved-blocks = <64>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "BL2"; + reg = <0x000000 0x100000>; + read-only; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x100000 0x80000>; + }; + + partition@180000 { + label = "Factory"; + reg = <0x180000 0x200000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + }; + }; + + partition@380000 { + label = "FIP"; + reg = <0x380000 0x200000>; + read-only; + }; + + partition@580000 { + label = "ubi"; + reg = <0x580000 0x3200000>; + }; + + partition@3780000 { + label = "ubi1"; + reg = <0x3780000 0x3200000>; + read-only; + }; + + partition@6980000 { + label = "Odm"; + reg = <0x6980000 0x40000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_odm: macaddr@81 { + compatible = "mac-base"; + reg = <0x81 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + + }; + + partition@69c0000 { + label = "Config1"; + reg = <0x69c0000 0x80000>; + read-only; + }; + + partition@6a40000 { + label = "Config2"; + reg = <0x6a40000 0x80000>; + read-only; + }; + + partition@6ac0000 { + label = "Storage"; + reg = <0x6ac0000 0xA00000>; + read-only; + }; + + }; + }; +}; + +&wifi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&wf_2g_5g_pins>; + + + nvmem-cells = <&eeprom_factory_0>; + nvmem-cell-names = "eeprom"; + + band@0 { + /* 2.4 GHz */ + reg = <0>; + nvmem-cells = <&macaddr_odm 2>; + nvmem-cell-names = "mac-address"; + }; + band@1 { + /* 5 GHz */ + reg = <1>; + nvmem-cells = <&macaddr_odm 5>; + nvmem-cell-names = "mac-address"; + }; +}; + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&i2c0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c_pins_3_4>; + + gca230718@40 { + compatible = "unknown,gca230718"; + reg = <0x40>; + + led_status_red: led@0 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <0>; + }; + + led@1 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <1>; + }; + + led_status_blue: led@2 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <2>; + }; + + led_status_white: led@3 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <3>; + }; + }; +}; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index 0d0ee52617..e9f63938b2 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -93,7 +93,8 @@ mediatek_setup_interfaces() openwrt,one) ucidef_set_interfaces_lan_wan eth1 eth0 ;; - dlink,aquila-pro-ai-m30-a1) + dlink,aquila-pro-ai-m30-a1|\ + dlink,aquila-pro-ai-m60-a1) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" internet ;; keenetic,kn-3911|\ diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index f3d5cb472e..baab9ac291 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -123,6 +123,10 @@ platform_do_upgrade() { yuncore,ax835) default_do_upgrade "$1" ;; + dlink,aquila-pro-ai-m60-a1) + fw_setenv sw_tryactive 0 + nand_do_upgrade "$1" + ;; mercusys,mr90x-v1|\ tplink,re6000xd) CI_UBIPART="ubi0" diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 235971d194..22c9151ff3 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -720,6 +720,20 @@ define Device/dlink_aquila-pro-ai-m30-a1 endef TARGET_DEVICES += dlink_aquila-pro-ai-m30-a1 +define Device/dlink_aquila-pro-ai-m60-a1 + DEVICE_VENDOR := D-Link + DEVICE_MODEL := AQUILA PRO AI M60 + DEVICE_VARIANT := A1 + DEVICE_DTS := mt7986a-dlink-aquila-pro-ai-m60-a1 + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := kmod-leds-gca230718 kmod-mt7915e kmod-mt7986-firmware mt7986-wo-firmware + IMAGES += recovery.bin + IMAGE_SIZE := 51200k + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGE/recovery.bin := sysupgrade-tar | pad-to $$(IMAGE_SIZE) | dlink-ai-recovery-header DLK6E8202001 \x30\x6C\x19\x0C \x00\x00\x2C\x00 \x00\x00\x20\x03 \x82\x6E +endef +TARGET_DEVICES += dlink_aquila-pro-ai-m60-a1 + define Device/edgecore_eap111 DEVICE_VENDOR := Edgecore DEVICE_MODEL := EAP111 From 0e2dcfc4f488ecd7acf31e01bd10624d8a273cde Mon Sep 17 00:00:00 2001 From: Joel Low Date: Sat, 14 Dec 2024 21:39:36 +0800 Subject: [PATCH 11/22] netfilter: add kmod-nfnetlink-ct{helper,timeout} Add kmod-nfnetlink-ct{helper,timeout} to allow handling firewall rules in userspace (together with conntrackd). The timeout module allows specifying custom expiration rules. Signed-off-by: Joel Low Link: https://github.com/openwrt/openwrt/pull/17267 Signed-off-by: Hauke Mehrtens --- config/Config-kernel.in | 7 +++++ package/kernel/linux/modules/netfilter.mk | 34 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 91678cf2a6..64c8c63466 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -1239,6 +1239,13 @@ config KERNEL_MPTCP_IPV6 default KERNEL_MPTCP endif +config KERNEL_NF_CONNTRACK_TIMEOUT + bool "Per-connection connection tracking timeout" + default y if !SMALL_FLASH + help + Select this option to enable support for per-connection conntrack timeouts. + Increases the (uncompressed) size of nf_conntrack.ko by ~8kB. + # # NFS related symbols # diff --git a/package/kernel/linux/modules/netfilter.mk b/package/kernel/linux/modules/netfilter.mk index cf66bd8cd8..30ff35ca6b 100644 --- a/package/kernel/linux/modules/netfilter.mk +++ b/package/kernel/linux/modules/netfilter.mk @@ -1048,6 +1048,40 @@ endef $(eval $(call KernelPackage,nfnetlink-queue)) +define KernelPackage/nfnetlink-cthelper + TITLE:=Netfilter User space conntrack helpers + FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink_cthelper.ko + KCONFIG:=CONFIG_NF_CT_NETLINK_HELPER + AUTOLOAD:=$(call AutoProbe,nfnetlink_cthelper) + $(call AddDepends/nfnetlink,+kmod-nfnetlink-queue +kmod-nf-conntrack-netlink) +endef + +define KernelPackage/nfnetlink-cthelper/description + Kernel modules support for a netlink-based connection tracking + userspace helpers interface +endef + +$(eval $(call KernelPackage,nfnetlink-cthelper)) + + +define KernelPackage/nfnetlink-cttimeout + TITLE:=Netfilter conntrack expectation timeout + FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink_cttimeout.ko + KCONFIG:=CONFIG_NF_CT_NETLINK_TIMEOUT + AUTOLOAD:=$(call AutoProbe,nfnetlink_cttimeout) + $(call AddDepends/nfnetlink,+kmod-nf-conntrack +kmod-nf-conntrack-timeout @KERNEL_NF_CONNTRACK_TIMEOUT) +endef + +define KernelPackage/nfnetlink-cttimeout/description + Kernel modules support for a netlink-based connection tracking + userspace timeout interface + + Requires CONFIG_NF_CONNTRACK_TIMEOUT (only enabled for non-small flash devices) +endef + +$(eval $(call KernelPackage,nfnetlink-cttimeout)) + + define KernelPackage/nf-conntrack-netlink TITLE:=Connection tracking netlink interface FILES:=$(LINUX_DIR)/net/netfilter/nf_conntrack_netlink.ko From 5c76e63f198610d975c40a1af33d4f41e09481f7 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 14 Dec 2024 17:07:36 -0800 Subject: [PATCH 12/22] ath79: use nvmem for wrong 3e0 cal size These three devices use AR9287 chips, which have a calibration size of 3d8. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17278 Signed-off-by: Hauke Mehrtens --- .../ath79/dts/ar7241_netgear_wnr2200-16m.dts | 8 ++++++-- .../linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts | 8 ++++++-- .../linux/ath79/dts/ar7241_netgear_wnr2200.dtsi | 1 - .../ath79/dts/ar7241_tplink_tl-wr842n-v1.dts | 15 ++++++++++++--- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 5 ----- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts index aa734966d5..9576666486 100644 --- a/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts +++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts @@ -50,6 +50,10 @@ macaddr_art_6: macaddr@6 { reg = <0x6 0x6>; }; + + cal_art_1000: calibration@1000 { + reg = <0x1000 0x3d8>; + }; }; }; }; @@ -65,6 +69,6 @@ }; &ath9k { - nvmem-cells = <&macaddr_art_0 1>; - nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_art_0 1>, <&cal_art_1000>; + nvmem-cell-names = "mac-address", "calibration"; }; diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts index 27c31c3c12..62ee49e9d0 100644 --- a/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts +++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts @@ -50,6 +50,10 @@ macaddr_art_6: macaddr@6 { reg = <0x6 0x6>; }; + + cal_art_1000: calibration@1000 { + reg = <0x1000 0x3d8>; + }; }; }; }; @@ -65,6 +69,6 @@ }; &ath9k { - nvmem-cells = <&macaddr_art_0 1>; - nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_art_0 1>, <&cal_art_1000>; + nvmem-cell-names = "mac-address", "calibration"; }; diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200.dtsi b/target/linux/ath79/dts/ar7241_netgear_wnr2200.dtsi index 2c1dd064fe..8dcb8f852c 100644 --- a/target/linux/ath79/dts/ar7241_netgear_wnr2200.dtsi +++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200.dtsi @@ -173,7 +173,6 @@ ath9k: wifi@0,0 { compatible = "pci168c,002e"; reg = <0x0000 0 0 0 0>; - qca,no-eeprom; #gpio-cells = <2>; gpio-controller; diff --git a/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts b/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts index b0edbf4d06..8369010688 100644 --- a/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts +++ b/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts @@ -128,6 +128,16 @@ reg = <0x7f0000 0x10000>; label = "art"; read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + cal_art_1000: calibration@1000 { + reg = <0x1000 0x3d8>; + }; + }; }; }; }; @@ -141,9 +151,8 @@ reg = <0x0000 0 0 0 0>; #gpio-cells = <2>; gpio-controller; - qca,no-eeprom; - nvmem-cells = <&macaddr_uboot_1fc00 0>; - nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_uboot_1fc00 0>, <&cal_art_1000>; + nvmem-cell-names = "mac-address", "calibration"; }; }; diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 675522823f..89cb3df6f2 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -83,11 +83,6 @@ case "$FIRMWARE" in meraki,mr12) caldata_extract "art" 0x11000 0xeb8 ;; - netgear,wnr2200-8m|\ - netgear,wnr2200-16m|\ - tplink,tl-wr842n-v1) - caldata_extract "art" 0x1000 0x3e0 - ;; ubnt,powerbridge-m|\ ubnt,rocket-m) caldata_extract "art" 0x1000 0x1000 From a2b0ded29f1f92663b1fd7e2a3382d61f1856b09 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 16 Dec 2024 14:15:08 -0800 Subject: [PATCH 13/22] ath79: fix calibration size for AR9287 These devices use AR9287, which uses 3d8 as the calibration size, not 440 like newer chips do. Add a compatible line to make it clear that this is the case. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17278 Signed-off-by: Hauke Mehrtens --- target/linux/ath79/dts/ar7241_ubnt_unifi-ap.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ath79/dts/ar7241_ubnt_unifi-ap.dtsi b/target/linux/ath79/dts/ar7241_ubnt_unifi-ap.dtsi index d9c7336f91..e9abd423f5 100644 --- a/target/linux/ath79/dts/ar7241_ubnt_unifi-ap.dtsi +++ b/target/linux/ath79/dts/ar7241_ubnt_unifi-ap.dtsi @@ -83,7 +83,7 @@ }; calibration_art_1000: calibration@1000 { - reg = <0x1000 0x440>; + reg = <0x1000 0x3d8>; }; }; }; @@ -92,6 +92,7 @@ }; &wifi { + compatible = "pci168c,002e"; nvmem-cells = <&calibration_art_1000>; nvmem-cell-names = "calibration"; }; From ed5f6fdd7d2e2ca1ddb6bd5369723bc3a5c53622 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 14 Dec 2024 14:32:14 -0800 Subject: [PATCH 14/22] ath79: wr2543: add compatible string for wifi Makes it clear that the calibration size is correct as most ar72xx devices use older wifi chips. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17278 Signed-off-by: Hauke Mehrtens --- target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts b/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts index 0124ddff87..744971c6f8 100644 --- a/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts +++ b/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts @@ -159,6 +159,7 @@ status = "okay"; ath9k: wifi@0,0 { + compatible = "pci168c,0030"; reg = <0x0000 0 0 0 0>; #gpio-cells = <2>; gpio-controller; From eabfe691cef15da08ad515a7724d01da1b11ae73 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 15 Dec 2024 23:54:02 -0800 Subject: [PATCH 15/22] bmips: dsl-2750b-b1: fix calibration size AR9287 uses 3d8, not 440 like newer chips. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17278 Signed-off-by: Hauke Mehrtens --- target/linux/bmips/dts/bcm6328-dlink-dsl-2750b-b1.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/bmips/dts/bcm6328-dlink-dsl-2750b-b1.dts b/target/linux/bmips/dts/bcm6328-dlink-dsl-2750b-b1.dts index e4806c0a9a..970182629d 100644 --- a/target/linux/bmips/dts/bcm6328-dlink-dsl-2750b-b1.dts +++ b/target/linux/bmips/dts/bcm6328-dlink-dsl-2750b-b1.dts @@ -180,7 +180,7 @@ #size-cells = <1>; cal_data_1000: calibration@1000 { - reg = <0x1000 0x440>; + reg = <0x1000 0x3d8>; }; }; }; From d3f8b1cf17ad0a241316f217ea2710fcf5228005 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 16 Dec 2024 15:07:50 -0800 Subject: [PATCH 16/22] lantiq: use nvmem for fritz73x0 These units use AR9287, which has a calibration size of 3d8. Also fixed compatible string to the proper one to indicate AR9287. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17278 Signed-off-by: Hauke Mehrtens --- .../arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts | 9 +++++++-- .../arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts | 9 +++++++-- .../base-files/etc/hotplug.d/firmware/12-ath9k-eeprom | 3 --- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts index 9ea6c3929c..ba6c487048 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts @@ -136,6 +136,10 @@ #address-cells = <1>; #size-cells = <1>; + cal_ath9k_cal_985: calibration@985 { + reg = <0x985 0x3d8>; + }; + macaddr_ath9k_cal_a91: macaddr@a91 { compatible = "mac-base"; reg = <0xa91 0x6>; @@ -180,8 +184,9 @@ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>; wifi@0,0 { - compatible = "pci0,0"; + compatible = "pci168c,002d"; reg = <0x7000 0 0 0 0>; - qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */ + nvmem-cells = <&cal_ath9k_cal_985>; + nvmem-cell-names = "calibration"; }; }; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts index 953a8ccbf7..c09d3879b4 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts @@ -163,6 +163,10 @@ #address-cells = <1>; #size-cells = <1>; + cal_ath9k_cal_985: calibration@985 { + reg = <0x985 0x3d8>; + }; + macaddr_ath9k_cal_a91: macaddr@a91 { compatible = "mac-base"; reg = <0xa91 0x6>; @@ -206,9 +210,10 @@ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>; wifi@0,0 { - compatible = "pci0,0"; + compatible = "pci168c,002d"; reg = <0x7000 0 0 0 0>; - qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */ + nvmem-cells = <&cal_ath9k_cal_985>; + nvmem-cell-names = "calibration"; }; }; diff --git a/target/linux/lantiq/xway/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/xway/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 98bb9af694..91eb3f1680 100644 --- a/target/linux/lantiq/xway/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/xway/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -45,9 +45,6 @@ case "$FIRMWARE" in caldata_extract "calibration" 0xf000 0x1000 ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 2) 0x20c ;; - avm,fritz7312|avm,fritz7320) - caldata_extract "urlader" 0x985 0x1000 - ;; *) caldata_die "board $board is not supported yet" ;; From e85b1afe6e49b03fad13145a3fdd4cc7e45c27f7 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 16 Dec 2024 15:42:19 -0800 Subject: [PATCH 17/22] lantiq: use nvmem for fritz 736x Two use AR9287 and one AR9381. Both have different calibration sizes. Move differences out of wifi node to make it clearer what's what. qca,no-eeprom needs to stay for 7362sl as there's no nvmem equivalent for caldata_extract_reverse Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17278 Signed-off-by: Hauke Mehrtens --- .../arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts | 4 ++-- .../arch/mips/boot/dts/lantiq/vr9_avm_fritz7360sl.dts | 10 ++++++++++ .../arch/mips/boot/dts/lantiq/vr9_avm_fritz7362sl.dts | 5 +++++ .../arch/mips/boot/dts/lantiq/vr9_avm_fritz736x.dtsi | 4 +--- .../base-files/etc/hotplug.d/firmware/12-ath9k-eeprom | 3 --- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts index cc15324b56..1b41405062 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts @@ -49,7 +49,7 @@ #size-cells = <1>; cal_urlader_985: cal@985 { - reg = <0x985 0x440>; + reg = <0x985 0x3d8>; }; macaddr_urlader_a91: macaddr@a91 { @@ -94,7 +94,7 @@ }; &wifi { - /delete-property/ qca,no-eeprom; + compatible = "pci168c,002e"; nvmem-cells = <&cal_urlader_985>; nvmem-cell-names = "calibration"; }; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360sl.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360sl.dts index cbe6c14c99..9301b049ca 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360sl.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360sl.dts @@ -49,6 +49,10 @@ #address-cells = <1>; #size-cells = <1>; + cal_urlader_985: cal@985 { + reg = <0x985 0x3d8>; + }; + macaddr_urlader_a91: macaddr@a91 { compatible = "mac-base"; reg = <0xa91 0x6>; @@ -89,3 +93,9 @@ &phy1 { reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>; }; + +&wifi { + compatible = "pci168c,002e"; + nvmem-cells = <&cal_urlader_985>; + nvmem-cell-names = "calibration"; +}; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7362sl.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7362sl.dts index 7929bde6cf..e1334fa306 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7362sl.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7362sl.dts @@ -127,3 +127,8 @@ &phy1 { reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>; }; + +&wifi { + compatible = "pci168c,0030"; + qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:01:00.0.bin */ +}; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz736x.dtsi b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz736x.dtsi index e7fc9a4f55..cc0c97da89 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz736x.dtsi +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz736x.dtsi @@ -155,10 +155,8 @@ #address-cells = <2>; device_type = "pci"; - wifi: wifi@168c,002e { - compatible = "pci168c,002e"; + wifi: wifi@0,0 { reg = <0 0 0 0 0>; - qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:01:00.0.bin */ }; }; }; diff --git a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 164e2d39ca..936181c693 100644 --- a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -19,9 +19,6 @@ case "$FIRMWARE" in avm,fritz3390) caldata_extract_reverse "urlader" 0x2546 0x440 ;; - avm,fritz7360sl) - caldata_extract "urlader" 0x985 0x1000 - ;; avm,fritz7412|\ avm,fritz7430) /usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 5120 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader") || \ From f6433c58108f7e9edf0a8de017132ac5a9d0c1de Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 6 Oct 2024 16:51:49 -0700 Subject: [PATCH 18/22] kernel: leds-gca230718: run through clang-format This file does not use a coding style consistent with the kernel. Run clang-format with the kernel's .clang-format file. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16869 Signed-off-by: Hauke Mehrtens --- .../leds-gca230718/src/leds-gca230718.c | 159 +++++++++--------- 1 file changed, 84 insertions(+), 75 deletions(-) diff --git a/package/kernel/leds-gca230718/src/leds-gca230718.c b/package/kernel/leds-gca230718/src/leds-gca230718.c index 194d149970..71c8b983b5 100644 --- a/package/kernel/leds-gca230718/src/leds-gca230718.c +++ b/package/kernel/leds-gca230718/src/leds-gca230718.c @@ -17,40 +17,39 @@ #include #include -#define GCA230718_MAX_LEDS (4u) +#define GCA230718_MAX_LEDS (4u) -#define GCA230718_OPMODE_DISABLED (0x00u) -#define GCA230718_OPMODE_NO_TOGGLE (0x01u) -#define GCA230718_OPMODE_TOGGLE_RAMP_CONTROL_DISABLED (0x02u) -#define GCA230718_OPMODE_TOGGLE_RAMP_CONTROL_ENSABLED (0x03u) +#define GCA230718_OPMODE_DISABLED (0x00u) +#define GCA230718_OPMODE_NO_TOGGLE (0x01u) +#define GCA230718_OPMODE_TOGGLE_RAMP_CONTROL_DISABLED (0x02u) +#define GCA230718_OPMODE_TOGGLE_RAMP_CONTROL_ENSABLED (0x03u) -#define GCA230718_1ST_SEQUENCE_BYTE_1 (0x02u) -#define GCA230718_2ND_SEQUENCE_BYTE_1 (0x01u) -#define GCA230718_3RD_SEQUENCE_BYTE_1 (0x03u) +#define GCA230718_1ST_SEQUENCE_BYTE_1 (0x02u) +#define GCA230718_2ND_SEQUENCE_BYTE_1 (0x01u) +#define GCA230718_3RD_SEQUENCE_BYTE_1 (0x03u) -struct gca230718_led -{ +struct gca230718_led { enum led_brightness brightness; struct i2c_client *client; struct led_classdev ledClassDev; }; -struct gca230718_private -{ +struct gca230718_private { struct mutex lock; struct gca230718_led leds[GCA230718_MAX_LEDS]; }; -static void gca230718_init_private_led_data(struct gca230718_private* data) +static void gca230718_init_private_led_data(struct gca230718_private *data) { u8 ledIndex; - for (ledIndex = 0; ledIndex < GCA230718_MAX_LEDS; ledIndex++) - { + for (ledIndex = 0; ledIndex < GCA230718_MAX_LEDS; ledIndex++) { data->leds[ledIndex].client = NULL; } } -static void gca230718_send_sequence(struct i2c_client *client, u8 byte0, struct gca230718_private* gca230718_privateData) +static void +gca230718_send_sequence(struct i2c_client *client, u8 byte0, + struct gca230718_private *gca230718_privateData) { int status = 0; u8 ledIndex; @@ -64,140 +63,150 @@ static void gca230718_send_sequence(struct i2c_client *client, u8 byte0, struct controlCommand[1] = byte0; controlCommand[2] = GCA230718_OPMODE_NO_TOGGLE; /* Byte 3-6 are set below to the brighness value of the individual LEDs */ - controlCommand[7] = 0x01; /* Frequency, doesn't care as long as GCA230718_OPMODE_NO_TOGGLE is used above */ + controlCommand[7] = + 0x01; /* Frequency, doesn't care as long as GCA230718_OPMODE_NO_TOGGLE is used above */ /* Byte 8-11 are set below to the brighness value of the individual LEDs */ controlCommand[12] = 0x87; - for (ledIndex = 0; ledIndex < GCA230718_MAX_LEDS; ledIndex++) - { - controlCommand[3 + ledIndex] = gca230718_privateData->leds[ledIndex].brightness; - controlCommand[8 + ledIndex] = gca230718_privateData->leds[ledIndex].brightness; + for (ledIndex = 0; ledIndex < GCA230718_MAX_LEDS; ledIndex++) { + controlCommand[3 + ledIndex] = + gca230718_privateData->leds[ledIndex].brightness; + controlCommand[8 + ledIndex] = + gca230718_privateData->leds[ledIndex].brightness; } mutex_lock(&(gca230718_privateData->lock)); - if ((status = i2c_smbus_write_i2c_block_data(client, resetCommandRegister, sizeof(resetCommand), resetCommand)) != 0) - { - pr_info("Error %i during call of i2c_smbus_write_i2c_block_data for reset command\n", status); - } - else if ((status = i2c_smbus_write_i2c_block_data(client, controlCommandRegister, sizeof(controlCommand), controlCommand)) != 0) - { - pr_info("Error %i during call of i2c_smbus_write_i2c_block_data for control command\n", status); + if ((status = i2c_smbus_write_i2c_block_data( + client, resetCommandRegister, sizeof(resetCommand), + resetCommand)) != 0) { + pr_info("Error %i during call of i2c_smbus_write_i2c_block_data for reset command\n", + status); + } else if ((status = i2c_smbus_write_i2c_block_data( + client, controlCommandRegister, + sizeof(controlCommand), controlCommand)) != 0) { + pr_info("Error %i during call of i2c_smbus_write_i2c_block_data for control command\n", + status); } mutex_unlock(&(gca230718_privateData->lock)); } -static int gca230718_set_brightness(struct led_classdev *led_cdev, enum led_brightness value) +static int gca230718_set_brightness(struct led_classdev *led_cdev, + enum led_brightness value) { - struct gca230718_led* led; - struct i2c_client* client; + struct gca230718_led *led; + struct i2c_client *client; led = container_of(led_cdev, struct gca230718_led, ledClassDev); client = led->client; - if (client != NULL) - { - struct gca230718_private* gca230718_privateData; + if (client != NULL) { + struct gca230718_private *gca230718_privateData; led->brightness = value; gca230718_privateData = i2c_get_clientdata(client); - gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, gca230718_privateData); + gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, + gca230718_privateData); } return 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) static int gca230718_probe(struct i2c_client *client) #else -static int gca230718_probe(struct i2c_client *client, const struct i2c_device_id *id) +static int gca230718_probe(struct i2c_client *client, + const struct i2c_device_id *id) #endif { int status = 0; - struct gca230718_private* gca230718_privateData; + struct gca230718_private *gca230718_privateData; pr_info("Enter gca230718_probe for device address %u\n", client->addr); - gca230718_privateData = devm_kzalloc(&(client->dev), sizeof(struct gca230718_private), GFP_KERNEL); + gca230718_privateData = devm_kzalloc( + &(client->dev), sizeof(struct gca230718_private), GFP_KERNEL); - if (gca230718_privateData == NULL) - { + if (gca230718_privateData == NULL) { pr_info("Error during allocating memory for private data\n"); status = -ENOMEM; - } - else - { - struct device_node* ledNode; + } else { + struct device_node *ledNode; mutex_init(&gca230718_privateData->lock); gca230718_init_private_led_data(gca230718_privateData); i2c_set_clientdata(client, gca230718_privateData); - for_each_child_of_node(client->dev.of_node, ledNode) - { + for_each_child_of_node(client->dev.of_node, ledNode) { u32 regValue = 0; - if (of_property_read_u32(ledNode, "reg", ®Value) != 0) - { - pr_info("Missing entry \"reg\" in node %s\n", ledNode->name); - } - else if (regValue >= GCA230718_MAX_LEDS) - { - pr_info("Invalid entry \"reg\" in node %s (%u)\n", ledNode->name, regValue); - } - else - { - struct led_classdev* ledClassDev = &(gca230718_privateData->leds[regValue].ledClassDev); + if (of_property_read_u32(ledNode, "reg", ®Value) != + 0) { + pr_info("Missing entry \"reg\" in node %s\n", + ledNode->name); + } else if (regValue >= GCA230718_MAX_LEDS) { + pr_info("Invalid entry \"reg\" in node %s (%u)\n", + ledNode->name, regValue); + } else { + struct led_classdev *ledClassDev = + &(gca230718_privateData->leds[regValue] + .ledClassDev); struct led_init_data init_data = {}; - gca230718_privateData->leds[regValue].client = client; + gca230718_privateData->leds[regValue].client = + client; init_data.fwnode = of_fwnode_handle(ledNode); - pr_info("Creating LED for node %s: reg=%u\n", ledNode->name, regValue); + pr_info("Creating LED for node %s: reg=%u\n", + ledNode->name, regValue); - ledClassDev->name = of_get_property(ledNode, "label", NULL); - if (ledClassDev->name == NULL) - { + ledClassDev->name = + of_get_property(ledNode, "label", NULL); + if (ledClassDev->name == NULL) { ledClassDev->name = ledNode->name; } ledClassDev->brightness = LED_OFF; ledClassDev->max_brightness = LED_FULL; - ledClassDev->brightness_set_blocking = gca230718_set_brightness; - - if (devm_led_classdev_register_ext(&(client->dev), ledClassDev, &init_data) != 0) - { + ledClassDev->brightness_set_blocking = + gca230718_set_brightness; + + if (devm_led_classdev_register_ext( + &(client->dev), ledClassDev, + &init_data) != 0) { pr_info("Error during call of devm_led_classdev_register_ext"); } } } } - if (status == 0) - { + if (status == 0) { /* Send full initialization sequence. Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values. */ - gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1, gca230718_privateData); - gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, gca230718_privateData); - gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1, gca230718_privateData); + gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1, + gca230718_privateData); + gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, + gca230718_privateData); + gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1, + gca230718_privateData); } return status; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) static void gca230718_remove(struct i2c_client *client) #else static int gca230718_remove(struct i2c_client *client) #endif { - struct gca230718_private* gca230718_privateData; + struct gca230718_private *gca230718_privateData; gca230718_privateData = i2c_get_clientdata(client); mutex_destroy(&gca230718_privateData->lock); gca230718_init_private_led_data(gca230718_privateData); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) return 0; #endif } From e2b80013ed78fef11ff5f2e1347fb9fe250f5231 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 6 Oct 2024 16:53:39 -0700 Subject: [PATCH 19/22] kernel: leds-gca230718: remove old kernel compat Not needed as all the older kernels are gone. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16869 Signed-off-by: Hauke Mehrtens --- package/kernel/leds-gca230718/src/leds-gca230718.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/package/kernel/leds-gca230718/src/leds-gca230718.c b/package/kernel/leds-gca230718/src/leds-gca230718.c index 71c8b983b5..9069fc90f7 100644 --- a/package/kernel/leds-gca230718/src/leds-gca230718.c +++ b/package/kernel/leds-gca230718/src/leds-gca230718.c @@ -114,12 +114,7 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev, return 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) static int gca230718_probe(struct i2c_client *client) -#else -static int gca230718_probe(struct i2c_client *client, - const struct i2c_device_id *id) -#endif { int status = 0; struct gca230718_private *gca230718_privateData; @@ -195,20 +190,12 @@ static int gca230718_probe(struct i2c_client *client, return status; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) static void gca230718_remove(struct i2c_client *client) -#else -static int gca230718_remove(struct i2c_client *client) -#endif { struct gca230718_private *gca230718_privateData; gca230718_privateData = i2c_get_clientdata(client); mutex_destroy(&gca230718_privateData->lock); gca230718_init_private_led_data(gca230718_privateData); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) - return 0; -#endif } static const struct i2c_device_id gca230718_i2c_ids[] = { From 980fe907116e4a15737ca3895979b59c10aff791 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 6 Oct 2024 16:56:25 -0700 Subject: [PATCH 20/22] kernel: leds-gca230718: remove status variable I have no idea why this is even here. Simplifies the code with direct returns. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16869 Signed-off-by: Hauke Mehrtens --- .../leds-gca230718/src/leds-gca230718.c | 103 ++++++++---------- 1 file changed, 47 insertions(+), 56 deletions(-) diff --git a/package/kernel/leds-gca230718/src/leds-gca230718.c b/package/kernel/leds-gca230718/src/leds-gca230718.c index 9069fc90f7..98cc732c34 100644 --- a/package/kernel/leds-gca230718/src/leds-gca230718.c +++ b/package/kernel/leds-gca230718/src/leds-gca230718.c @@ -116,78 +116,69 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev, static int gca230718_probe(struct i2c_client *client) { - int status = 0; struct gca230718_private *gca230718_privateData; pr_info("Enter gca230718_probe for device address %u\n", client->addr); gca230718_privateData = devm_kzalloc( - &(client->dev), sizeof(struct gca230718_private), GFP_KERNEL); + &client->dev, sizeof(struct gca230718_private), GFP_KERNEL); - if (gca230718_privateData == NULL) { + if (!gca230718_privateData) { pr_info("Error during allocating memory for private data\n"); - status = -ENOMEM; - } else { - struct device_node *ledNode; - mutex_init(&gca230718_privateData->lock); - gca230718_init_private_led_data(gca230718_privateData); - i2c_set_clientdata(client, gca230718_privateData); + return -ENOMEM; + } + struct device_node *ledNode; + mutex_init(&gca230718_privateData->lock); + gca230718_init_private_led_data(gca230718_privateData); + i2c_set_clientdata(client, gca230718_privateData); - for_each_child_of_node(client->dev.of_node, ledNode) { - u32 regValue = 0; - if (of_property_read_u32(ledNode, "reg", ®Value) != - 0) { - pr_info("Missing entry \"reg\" in node %s\n", - ledNode->name); - } else if (regValue >= GCA230718_MAX_LEDS) { - pr_info("Invalid entry \"reg\" in node %s (%u)\n", - ledNode->name, regValue); - } else { - struct led_classdev *ledClassDev = - &(gca230718_privateData->leds[regValue] - .ledClassDev); - struct led_init_data init_data = {}; + for_each_child_of_node(client->dev.of_node, ledNode) { + u32 regValue = 0; + if (of_property_read_u32(ledNode, "reg", ®Value)) + pr_info("Missing entry \"reg\" in node %s\n", + ledNode->name); + else if (regValue >= GCA230718_MAX_LEDS) + pr_info("Invalid entry \"reg\" in node %s (%u)\n", + ledNode->name, regValue); + else { + struct led_classdev *ledClassDev = + &(gca230718_privateData->leds[regValue] + .ledClassDev); + struct led_init_data init_data = {}; - gca230718_privateData->leds[regValue].client = - client; - init_data.fwnode = of_fwnode_handle(ledNode); + gca230718_privateData->leds[regValue].client = client; + init_data.fwnode = of_fwnode_handle(ledNode); - pr_info("Creating LED for node %s: reg=%u\n", - ledNode->name, regValue); + pr_info("Creating LED for node %s: reg=%u\n", + ledNode->name, regValue); - ledClassDev->name = - of_get_property(ledNode, "label", NULL); - if (ledClassDev->name == NULL) { - ledClassDev->name = ledNode->name; - } + ledClassDev->name = + of_get_property(ledNode, "label", NULL); + if (!ledClassDev->name) + ledClassDev->name = ledNode->name; - ledClassDev->brightness = LED_OFF; - ledClassDev->max_brightness = LED_FULL; - ledClassDev->brightness_set_blocking = - gca230718_set_brightness; + ledClassDev->brightness = LED_OFF; + ledClassDev->max_brightness = LED_FULL; + ledClassDev->brightness_set_blocking = + gca230718_set_brightness; - if (devm_led_classdev_register_ext( - &(client->dev), ledClassDev, - &init_data) != 0) { - pr_info("Error during call of devm_led_classdev_register_ext"); - } - } + if (devm_led_classdev_register_ext( + &client->dev, ledClassDev, &init_data)) + pr_info("Error during call of devm_led_classdev_register_ext"); } } - if (status == 0) { - /* - Send full initialization sequence. - Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values. - */ - gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1, - gca230718_privateData); - gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, - gca230718_privateData); - gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1, - gca230718_privateData); - } + /* + Send full initialization sequence. + Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values. + */ + gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1, + gca230718_privateData); + gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, + gca230718_privateData); + gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1, + gca230718_privateData); - return status; + return 0; } static void gca230718_remove(struct i2c_client *client) From 8a1c48301f4b37b5d00d1d825be841063aa39b5b Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 6 Oct 2024 17:02:27 -0700 Subject: [PATCH 21/22] kernel: leds-gca230718: use shorter priv variable Shorter and more consistent with other drivers. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16869 Signed-off-by: Hauke Mehrtens --- .../leds-gca230718/src/leds-gca230718.c | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/package/kernel/leds-gca230718/src/leds-gca230718.c b/package/kernel/leds-gca230718/src/leds-gca230718.c index 98cc732c34..7467e35ac6 100644 --- a/package/kernel/leds-gca230718/src/leds-gca230718.c +++ b/package/kernel/leds-gca230718/src/leds-gca230718.c @@ -47,9 +47,8 @@ static void gca230718_init_private_led_data(struct gca230718_private *data) } } -static void -gca230718_send_sequence(struct i2c_client *client, u8 byte0, - struct gca230718_private *gca230718_privateData) +static void gca230718_send_sequence(struct i2c_client *client, u8 byte0, + struct gca230718_private *priv) { int status = 0; u8 ledIndex; @@ -69,13 +68,11 @@ gca230718_send_sequence(struct i2c_client *client, u8 byte0, controlCommand[12] = 0x87; for (ledIndex = 0; ledIndex < GCA230718_MAX_LEDS; ledIndex++) { - controlCommand[3 + ledIndex] = - gca230718_privateData->leds[ledIndex].brightness; - controlCommand[8 + ledIndex] = - gca230718_privateData->leds[ledIndex].brightness; + controlCommand[3 + ledIndex] = priv->leds[ledIndex].brightness; + controlCommand[8 + ledIndex] = priv->leds[ledIndex].brightness; } - mutex_lock(&(gca230718_privateData->lock)); + mutex_lock(&(priv->lock)); if ((status = i2c_smbus_write_i2c_block_data( client, resetCommandRegister, sizeof(resetCommand), @@ -89,7 +86,7 @@ gca230718_send_sequence(struct i2c_client *client, u8 byte0, status); } - mutex_unlock(&(gca230718_privateData->lock)); + mutex_unlock(&(priv->lock)); } static int gca230718_set_brightness(struct led_classdev *led_cdev, @@ -101,14 +98,14 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev, led = container_of(led_cdev, struct gca230718_led, ledClassDev); client = led->client; - if (client != NULL) { - struct gca230718_private *gca230718_privateData; + if (client) { + struct gca230718_private *priv; led->brightness = value; - gca230718_privateData = i2c_get_clientdata(client); + priv = i2c_get_clientdata(client); gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, - gca230718_privateData); + priv); } return 0; @@ -116,20 +113,19 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev, static int gca230718_probe(struct i2c_client *client) { - struct gca230718_private *gca230718_privateData; + struct gca230718_private *priv; pr_info("Enter gca230718_probe for device address %u\n", client->addr); - gca230718_privateData = devm_kzalloc( - &client->dev, sizeof(struct gca230718_private), GFP_KERNEL); - - if (!gca230718_privateData) { + priv = devm_kzalloc(&client->dev, sizeof(struct gca230718_private), + GFP_KERNEL); + if (!priv) { pr_info("Error during allocating memory for private data\n"); return -ENOMEM; } struct device_node *ledNode; - mutex_init(&gca230718_privateData->lock); - gca230718_init_private_led_data(gca230718_privateData); - i2c_set_clientdata(client, gca230718_privateData); + mutex_init(&priv->lock); + gca230718_init_private_led_data(priv); + i2c_set_clientdata(client, priv); for_each_child_of_node(client->dev.of_node, ledNode) { u32 regValue = 0; @@ -141,11 +137,10 @@ static int gca230718_probe(struct i2c_client *client) ledNode->name, regValue); else { struct led_classdev *ledClassDev = - &(gca230718_privateData->leds[regValue] - .ledClassDev); + &(priv->leds[regValue].ledClassDev); struct led_init_data init_data = {}; - gca230718_privateData->leds[regValue].client = client; + priv->leds[regValue].client = client; init_data.fwnode = of_fwnode_handle(ledNode); pr_info("Creating LED for node %s: reg=%u\n", @@ -171,22 +166,19 @@ static int gca230718_probe(struct i2c_client *client) Send full initialization sequence. Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values. */ - gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1, - gca230718_privateData); - gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, - gca230718_privateData); - gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1, - gca230718_privateData); + gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1, priv); + gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1, priv); + gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1, priv); return 0; } static void gca230718_remove(struct i2c_client *client) { - struct gca230718_private *gca230718_privateData; - gca230718_privateData = i2c_get_clientdata(client); - mutex_destroy(&gca230718_privateData->lock); - gca230718_init_private_led_data(gca230718_privateData); + struct gca230718_private *priv; + priv = i2c_get_clientdata(client); + mutex_destroy(&priv->lock); + gca230718_init_private_led_data(priv); } static const struct i2c_device_id gca230718_i2c_ids[] = { From 4c8bb0a20f8a42b598941fec8b02db6599e3c325 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 6 Oct 2024 17:08:24 -0700 Subject: [PATCH 22/22] kernel: leds-gca230718: remove _remove Not needed. Everything can be replaced with devm. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16869 Signed-off-by: Hauke Mehrtens --- .../leds-gca230718/src/leds-gca230718.c | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/package/kernel/leds-gca230718/src/leds-gca230718.c b/package/kernel/leds-gca230718/src/leds-gca230718.c index 7467e35ac6..4cfa205203 100644 --- a/package/kernel/leds-gca230718/src/leds-gca230718.c +++ b/package/kernel/leds-gca230718/src/leds-gca230718.c @@ -39,14 +39,6 @@ struct gca230718_private { struct gca230718_led leds[GCA230718_MAX_LEDS]; }; -static void gca230718_init_private_led_data(struct gca230718_private *data) -{ - u8 ledIndex; - for (ledIndex = 0; ledIndex < GCA230718_MAX_LEDS; ledIndex++) { - data->leds[ledIndex].client = NULL; - } -} - static void gca230718_send_sequence(struct i2c_client *client, u8 byte0, struct gca230718_private *priv) { @@ -114,6 +106,7 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev, static int gca230718_probe(struct i2c_client *client) { struct gca230718_private *priv; + int err; pr_info("Enter gca230718_probe for device address %u\n", client->addr); priv = devm_kzalloc(&client->dev, sizeof(struct gca230718_private), @@ -122,11 +115,14 @@ static int gca230718_probe(struct i2c_client *client) pr_info("Error during allocating memory for private data\n"); return -ENOMEM; } - struct device_node *ledNode; - mutex_init(&priv->lock); - gca230718_init_private_led_data(priv); + + err = devm_mutex_init(&client->dev, &priv->lock); + if (err) + return err; + i2c_set_clientdata(client, priv); + struct device_node *ledNode; for_each_child_of_node(client->dev.of_node, ledNode) { u32 regValue = 0; if (of_property_read_u32(ledNode, "reg", ®Value)) @@ -173,14 +169,6 @@ static int gca230718_probe(struct i2c_client *client) return 0; } -static void gca230718_remove(struct i2c_client *client) -{ - struct gca230718_private *priv; - priv = i2c_get_clientdata(client); - mutex_destroy(&priv->lock); - gca230718_init_private_led_data(priv); -} - static const struct i2c_device_id gca230718_i2c_ids[] = { { "gca230718", 0 }, {}, @@ -195,7 +183,6 @@ MODULE_DEVICE_TABLE(of, gca230718_dt_ids); static struct i2c_driver gca230718_driver = { .probe = gca230718_probe, - .remove = gca230718_remove, .id_table = gca230718_i2c_ids, .driver = { .name = KBUILD_MODNAME,