From 3d52754eed3d842fecca4fa74026d8efa4fb0933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Can=20Elmac=C4=B1?= Date: Thu, 19 Dec 2024 17:11:44 +0300 Subject: [PATCH] lantiq: Update TP-Link TD-W89x0 flash layout and convert to nvmem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flash space is scarce on 8MB devices, this commit adds 124KB of usable space by reusing OEM user configuration and unused space. This commit also switches from userspace script to using nvmem for ath9k calibration data. Signed-off-by: Mustafa Can Elmacı --- .../boot/dts/lantiq/vr9_tplink_tdw8970.dts | 6 +++--- .../boot/dts/lantiq/vr9_tplink_tdw8980.dts | 6 +++--- .../boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi | 21 ++++++++----------- target/linux/lantiq/image/tp-link_legacy.mk | 4 ++-- .../base-files/etc/board.d/02_network | 2 +- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8970.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8970.dts index 4bd70b528ca..cf39d6dcac1 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8970.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8970.dts @@ -6,13 +6,13 @@ }; &boardconfig { - cal_boardconfig_21000: calibration@21000 { - reg = <0x21000 0x440>; + boardconfig_cal: calibration@12000 { + reg = <0x12000 0x440>; }; }; &ath9k { compatible = "pci168c,0030"; - nvmem-cells = <&macaddr_ath9k_cal_f100 2>, <&cal_boardconfig_21000>; + nvmem-cells = <&boardconfig_macaddr 2>, <&boardconfig_cal>; nvmem-cell-names = "mac-address", "calibration"; }; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980.dts index a3fd6423364..039db8ca92a 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980.dts @@ -29,13 +29,13 @@ }; &boardconfig { - cal_boardconfig_21000: calibration@21000 { - reg = <0x21000 0x3d8>; + boardconfig_cal: calibration@12000 { + reg = <0x12000 0x3d8>; }; }; &ath9k { compatible = "pci168c,002e"; - nvmem-cells = <&macaddr_ath9k_cal_f100 2>, <&cal_boardconfig_21000>; + nvmem-cells = <&boardconfig_macaddr 2>, <&boardconfig_cal>; nvmem-cell-names = "mac-address", "calibration"; }; diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi index be9c8063b45..bb1408bce9d 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi @@ -113,7 +113,7 @@ }; ð0 { - nvmem-cells = <&macaddr_ath9k_cal_f100 0>; + nvmem-cells = <&boardconfig_macaddr 0>; nvmem-cell-names = "mac-address"; }; @@ -230,18 +230,12 @@ }; partition@20000 { - reg = <0x20000 0x7a0000>; + reg = <0x20000 0x7bf000>; label = "firmware"; }; - partition@7c0000 { - reg = <0x7c0000 0x10000>; - label = "config"; - read-only; - }; - - partition@7d0000 { - reg = <0x7d0000 0x30000>; + partition@7df000 { + reg = <0x7df000 0x21000>; label = "boardconfig"; read-only; @@ -250,11 +244,14 @@ #address-cells = <1>; #size-cells = <1>; - macaddr_ath9k_cal_f100: macaddr@f100 { + /* MAC Adress */ + boardconfig_macaddr: macaddr@100 { compatible = "mac-base"; - reg = <0xf100 0x6>; + reg = <0x100 0x6>; #nvmem-cell-cells = <1>; }; + /* <0x7df200 0x8> contains WPS PIN used on OEM firmware, unused in OpenWRT */ + /* <0x7e0000 0x18> used by U-Boot to store memory settings */ }; }; }; diff --git a/target/linux/lantiq/image/tp-link_legacy.mk b/target/linux/lantiq/image/tp-link_legacy.mk index d9bcd35d10f..cdce566aa7c 100644 --- a/target/linux/lantiq/image/tp-link_legacy.mk +++ b/target/linux/lantiq/image/tp-link_legacy.mk @@ -25,7 +25,7 @@ define Device/tplink_tdw8970 TPLINK_FLASHLAYOUT := 8Mltq TPLINK_HWID := 0x89700001 TPLINK_HWREV := 1 - IMAGE_SIZE := 7680k + IMAGE_SIZE := 7804k DEVICE_PACKAGES:= kmod-ath9k wpad-basic-mbedtls kmod-usb-dwc2 kmod-usb-ledtrig-usbport SUPPORTED_DEVICES += TDW8970 endef @@ -39,7 +39,7 @@ define Device/tplink_tdw8980 TPLINK_FLASHLAYOUT := 8Mltq TPLINK_HWID := 0x89800001 TPLINK_HWREV := 14 - IMAGE_SIZE := 7680k + IMAGE_SIZE := 7804k DEVICE_PACKAGES:= kmod-ath9k kmod-owl-loader wpad-basic-mbedtls kmod-usb-dwc2 kmod-usb-ledtrig-usbport SUPPORTED_DEVICES += TDW8980 endef diff --git a/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network index 9088de86b10..bca03afbe79 100644 --- a/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network +++ b/target/linux/lantiq/xrx200_legacy/base-files/etc/board.d/02_network @@ -57,7 +57,7 @@ lantiq_setup_macs() ;; tplink,tdw8970|\ tplink,tdw8980) - wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0xf100)" 1) + wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0x100)" 1) ;; esac