Skip to content

Commit

Permalink
ipq40xx: use NVMEM-on-UBI for ASUS RT-AC42U
Browse files Browse the repository at this point in the history
Instead of extracting WiFi precal as well as MAC addresses in userspace
use recently introduced NVMEM-on-UBI instead.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Feb 26, 2024
1 parent a084d6c commit 16425f3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
3 changes: 0 additions & 3 deletions target/linux/ipq40xx/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ ipq40xx_setup_macs()
8dev,habanero-dvk)
label_mac=$(mtd_get_mac_binary "ART" 0x1006)
;;
asus,rt-ac42u)
label_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
;;
avm,fritzbox-7530)
local tffsdev=$(find_mtd_chardev "nand-tffs")
wan_mac=$(/usr/bin/fritz_tffs_nand -b -d $tffsdev -n macdsl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ case "$FIRMWARE" in
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
asus,rt-ac42u)
caldata_extract_ubi "Factory" 0x9000 0x2f20
;;
avm,fritzrepeater-3000)
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
Expand Down Expand Up @@ -53,8 +50,7 @@ case "$FIRMWARE" in
;;
"ath10k/pre-cal-ahb-a000000.wifi.bin")
case "$board" in
asus,map-ac2200|\
asus,rt-ac42u)
asus,map-ac2200)
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
avm,fritzbox-4040)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ preinit_set_mac_address() {
ip link set dev eth0 address $(macaddr_add "$base_mac" 1)
ip link set dev eth1 address $(macaddr_add "$base_mac" 3)
;;
asus,rt-ac42u)
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
ip link set dev eth0 address $base_mac
ip link set dev lan1 address $base_mac
ip link set dev lan2 address $base_mac
ip link set dev lan3 address $base_mac
ip link set dev lan4 address $base_mac
ip link set dev wan address $(mtd_get_mac_binary_ubi Factory 0x9006)
;;
engenius,eap2200)
base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth1 address $(macaddr_add "$base_mac" 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
};

aliases {
label-mac-device = &gmac;
led-boot = &led_power;
led-failsafe = &led_power;
led-running = &led_power;
Expand Down Expand Up @@ -254,13 +255,44 @@
read-only;
};
partition@400000 {
label = "ubi";
compatible = "linux,ubi";
reg = <0x00400000 0x07C00000>;
label = "ubi";

volumes {
ubi_factory: ubi-volume-factory {
volname = "Factory";
};
};
};
};
};
};

&ubi_factory {
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

precal_factory_1000: precal@1000 {
reg = <0x1000 0x2f20>;
};

macaddr_factory_1006: macaddr@1006 {
reg = <0x1006 0x6>;
};

precal_factory_9000: precal@9000 {
reg = <0x9000 0x2f20>;
};

macaddr_factory_9006: macaddr@9006 {
reg = <0x9006 0x6>;
};
};
};

&usb3_ss_phy {
status = "okay";
};
Expand All @@ -271,6 +303,8 @@

&gmac {
status = "okay";
nvmem-cells = <&macaddr_factory_1006>;
nvmem-cell-names = "mac-address";
};

&switch {
Expand All @@ -295,10 +329,14 @@

&swport5 {
status = "okay";
nvmem-cells = <&macaddr_factory_9006>;
nvmem-cell-names = "mac-address";
};

&wifi0 {
status = "okay";
nvmem-cell-names = "pre-calibration";
nvmem-cells = <&precal_factory_1000>;
qcom,ath10k-calibration-variant = "ASUS-RT-AC42U";
};

Expand All @@ -317,6 +355,8 @@
wifi2: wifi@1,0 {
compatible = "qcom,ath10k";
reg = <0x00010000 0 0 0 0>;
nvmem-cell-names = "pre-calibration";
nvmem-cells = <&precal_factory_9000>;

qcom,ath10k-calibration-variant = "ASUS-RT-AC42U";
};
Expand Down

0 comments on commit 16425f3

Please sign in to comment.