Skip to content

Commit db533a6

Browse files
nehebjonasjelonek
authored andcommitted
ipq40xx: use nvmem for cal data
Userspace handling is deprecated. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: openwrt/openwrt#22178 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
1 parent a1a3659 commit db533a6

14 files changed

Lines changed: 192 additions & 96 deletions

target/linux/ipq40xx/base-files/etc/board.d/02_network

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ ipq40xx_setup_macs()
185185
local label_mac=""
186186

187187
case "$board" in
188-
8dev,habanero-dvk|\
189-
cilab,meshpoint-one)
190-
label_mac=$(mtd_get_mac_binary "ART" 0x1006)
191-
;;
192-
asus,rt-ac42u)
193-
label_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
194-
;;
195188
avm,fritzbox-7530)
196189
local tffsdev=$(find_mtd_chardev "nand-tffs")
197190
wan_mac=$(/usr/bin/fritz_tffs_nand -b -d $tffsdev -n macdsl)
@@ -218,12 +211,6 @@ ipq40xx_setup_macs()
218211
wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
219212
lan_mac=$(macaddr_add "$wan_mac" 1)
220213
;;
221-
extreme-networks,ws-ap3915i)
222-
label_mac="$(mtd_get_mac_ascii CFG1 ethaddr)"
223-
;;
224-
ezviz,cs-w3-wd1200g-eup)
225-
label_mac=$(mtd_get_mac_binary "ART" 0x6)
226-
;;
227214
google,wifi)
228215
wan_mac=$(get_mac_label)
229216
lan_mac=$(macaddr_add "$wan_mac" 1)

target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ board=$(board_name)
99
case "$FIRMWARE" in
1010
"ath10k/pre-cal-pci-0000:01:00.0.bin")
1111
case "$board" in
12-
asus,rt-ac42u)
13-
caldata_extract_ubi "Factory" 0x9000 0x2f20
14-
;;
1512
avm,fritzrepeater-3000)
1613
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
1714
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
@@ -20,22 +17,10 @@ case "$FIRMWARE" in
2017
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
2118
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
2219
;;
23-
netgear,rbr40|\
24-
netgear,rbs40|\
25-
netgear,rbr50|\
26-
netgear,rbs50|\
27-
netgear,srr60|\
28-
netgear,srs60)
29-
caldata_extract_mmc "0:ART" 0x9000 0x2f20
30-
ath10k_patch_mac $(mmc_get_mac_binary ARTMTD 0x12)
31-
;;
3220
esac
3321
;;
3422
"ath10k/pre-cal-ahb-a000000.wifi.bin")
3523
case "$board" in
36-
asus,rt-ac42u)
37-
caldata_extract_ubi "Factory" 0x1000 0x2f20
38-
;;
3924
avm,fritzbox-4040)
4025
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
4126
;;
@@ -49,9 +34,6 @@ case "$FIRMWARE" in
4934
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
5035
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
5136
;;
52-
cellc,rtl30vw)
53-
caldata_extract "0:ART" 0x1000 0x2f20
54-
;;
5537
devolo,magic-2-wifi-next)
5638
caldata_extract "ART" 0x1000 0x2f20
5739
ath10k_patch_mac $(mtd_get_mac_ascii APPSBLENV WiFiMacAddress0)
@@ -77,10 +59,6 @@ case "$FIRMWARE" in
7759
caldata_extract "ART" 0x1000 0x2f20
7860
ath10k_patch_mac $(mtd_get_mac_ascii CFG1 RADIOADDR0)
7961
;;
80-
huawei,ap4050dn)
81-
caldata_extract "0:ART" 0x1000 0x2f20
82-
ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
83-
;;
8462
mikrotik,cap-ac|\
8563
mikrotik,hap-ac2|\
8664
mikrotik,hap-ac3|\
@@ -92,15 +70,6 @@ case "$FIRMWARE" in
9270
( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x0 0x2f20 ) || \
9371
( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_0" 0x0 0x2f20 )
9472
;;
95-
netgear,rbr40|\
96-
netgear,rbs40|\
97-
netgear,rbr50|\
98-
netgear,rbs50|\
99-
netgear,srr60|\
100-
netgear,srs60)
101-
caldata_extract_mmc "0:ART" 0x1000 0x2f20
102-
ath10k_patch_mac $(mmc_get_mac_binary ARTMTD 0x0)
103-
;;
10473
pakedge,wr-1)
10574
caldata_extract "0:ART" 0x1000 0x2f20
10675
ath10k_patch_mac $(macaddr_add $(get_mac_label) 2)
@@ -110,9 +79,6 @@ case "$FIRMWARE" in
11079
caldata_extract "0:ART" 0x1000 0x2f20
11180
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary "0:CONFIG" 0x0) 2)
11281
;;
113-
sony,ncp-hg100-cellular)
114-
caldata_extract_mmc "0:ART" 0x1000 0x2f20
115-
;;
11682
zyxel,nbg6617|\
11783
zyxel,wre6606)
11884
caldata_extract "ART" 0x1000 0x2f20
@@ -135,9 +101,6 @@ case "$FIRMWARE" in
135101
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
136102
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
137103
;;
138-
cellc,rtl30vw)
139-
caldata_extract "0:ART" 0x5000 0x2f20
140-
;;
141104
devolo,magic-2-wifi-next)
142105
caldata_extract "ART" 0x5000 0x2f20
143106
ath10k_patch_mac $(mtd_get_mac_ascii APPSBLENV WiFiMacAddress1)
@@ -163,10 +126,6 @@ case "$FIRMWARE" in
163126
caldata_extract "ART" 0x5000 0x2f20
164127
ath10k_patch_mac $(mtd_get_mac_ascii CFG1 RADIOADDR1)
165128
;;
166-
huawei,ap4050dn)
167-
caldata_extract "0:ART" 0x5000 0x2f20
168-
ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
169-
;;
170129
mikrotik,cap-ac|\
171130
mikrotik,hap-ac2|\
172131
mikrotik,hap-ac3|\
@@ -179,15 +138,6 @@ case "$FIRMWARE" in
179138
( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x8000 0x2f20 ) || \
180139
( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_2" 0x0 0x2f20 )
181140
;;
182-
netgear,rbr40|\
183-
netgear,rbs40|\
184-
netgear,rbr50|\
185-
netgear,rbs50|\
186-
netgear,srr60|\
187-
netgear,srs60)
188-
caldata_extract_mmc "0:ART" 0x5000 0x2f20
189-
ath10k_patch_mac $(mmc_get_mac_binary ARTMTD 0xc)
190-
;;
191141
pakedge,wr-1)
192142
caldata_extract "0:ART" 0x5000 0x2f20
193143
ath10k_patch_mac $(macaddr_add $(get_mac_label) 4)
@@ -197,9 +147,6 @@ case "$FIRMWARE" in
197147
caldata_extract "0:ART" 0x5000 0x2f20
198148
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary "0:CONFIG" 0x0) 3)
199149
;;
200-
sony,ncp-hg100-cellular)
201-
caldata_extract_mmc "0:ART" 0x5000 0x2f20
202-
;;
203150
zyxel,nbg6617|\
204151
zyxel,wre6606)
205152
caldata_extract "ART" 0x5000 0x2f20

target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@
22

33
preinit_set_mac_address() {
44
case $(board_name) in
5-
asus,rt-ac42u)
6-
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
7-
ip link set dev eth0 address $base_mac
8-
ip link set dev lan1 address $base_mac
9-
ip link set dev lan2 address $base_mac
10-
ip link set dev lan3 address $base_mac
11-
ip link set dev lan4 address $base_mac
12-
ip link set dev wan address $(mtd_get_mac_binary_ubi Factory 0x9006)
13-
;;
145
engenius,eap2200)
156
base_mac=$(cat /sys/class/net/eth0/address)
167
ip link set dev eth1 address $(macaddr_add "$base_mac" 1)
178
;;
18-
extreme-networks,ws-ap3915i|\
19-
extreme-networks,ws-ap391x)
20-
ip link set dev eth0 address $(mtd_get_mac_ascii CFG1 ethaddr)
21-
;;
229
teltonika,rutx50)
2310
# Vendor Bootloader removes nvmem-cells from partition,
2411
# so this needs to be done here.

target/linux/ipq40xx/dts/qcom-ipq4018-ap4050dn.dts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@
243243
#size-cells = <1>;
244244

245245
macaddr_resulta_10190: macaddr@10190 {
246+
compatible = "mac-base";
246247
reg = <0x10190 0x6>;
248+
#nvmem-cell-cells = <1>;
247249
};
248250
};
249251
};
@@ -349,11 +351,15 @@
349351
&wifi0 {
350352
status = "okay";
351353
qcom,ath10k-calibration-variant = "huawei-ap4050dn";
354+
nvmem-cells = <&macaddr_resulta_10190 1>, <&precal_art_1000>;
355+
nvmem-cell-names = "mac-address", "pre-calibration";
352356
};
353357

354358
&wifi1 {
355359
status = "okay";
356360
qcom,ath10k-calibration-variant = "huawei-ap4050dn";
361+
nvmem-cells = <&macaddr_resulta_10190 2>, <&precal_art_5000>;
362+
nvmem-cell-names = "mac-address", "pre-calibration";
357363
};
358364

359365
&cryptobam {

target/linux/ipq40xx/dts/qcom-ipq4018-cs-w3-wd1200g-eup.dts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
led-failsafe = &led_status_red;
1616
led-running = &led_status_blue;
1717
led-upgrade = &led_status_green;
18+
label-mac-device = &swport5;
1819
};
1920

2021
soc {

target/linux/ipq40xx/dts/qcom-ipq4018-jalapeno.dtsi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@
182182
reg = <0x1000 0x2f20>;
183183
};
184184

185+
macaddr_art_1006: precal@1006 {
186+
reg = <0x1006 0x6>;
187+
};
188+
185189
precal_art_5000: precal@5000 {
186190
reg = <0x5000 0x2f20>;
187191
};
@@ -247,8 +251,8 @@
247251

248252
&wifi0 {
249253
status = "okay";
250-
nvmem-cell-names = "pre-calibration";
251-
nvmem-cells = <&precal_art_1000>;
254+
nvmem-cell-names = "pre-calibration", "mac-address";
255+
nvmem-cells = <&precal_art_1000>, <&macaddr_art_1006>;
252256
qcom,ath10k-calibration-variant = "8devices-Jalapeno";
253257
};
254258

target/linux/ipq40xx/dts/qcom-ipq4018-meshpoint-one.dts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
led-failsafe = &led_status;
1717
led-running = &led_status;
1818
led-upgrade = &led_status;
19+
label-mac-device = &wifi0;
1920
};
2021

2122
soc {

target/linux/ipq40xx/dts/qcom-ipq4019-habanero-dvk.dts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
led-failsafe = &led_status;
1717
led-running = &led_status;
1818
led-upgrade = &led_upgrade;
19+
label-mac-device = &wifi0;
1920
};
2021

2122
soc {
@@ -277,6 +278,10 @@
277278
reg = <0x1000 0x2f20>;
278279
};
279280

281+
macaddr_art_1006: macaddr@1006 {
282+
reg = <0x1006 0x6>;
283+
};
284+
280285
precal_art_5000: precal@5000 {
281286
reg = <0x5000 0x2f20>;
282287
};
@@ -368,15 +373,12 @@
368373

369374
&swport5 {
370375
status = "okay";
371-
372-
nvmem-cell-names = "mac-address";
373-
nvmem-cells = <&macaddr_wan>;
374376
};
375377

376378
&wifi0 {
377379
status = "okay";
378-
nvmem-cell-names = "pre-calibration";
379-
nvmem-cells = <&precal_art_1000>;
380+
nvmem-cell-names = "pre-calibration", "mac-address";
381+
nvmem-cells = <&precal_art_1000>, <&macaddr_art_1006>;
380382
qcom,ath10k-calibration-variant = "8devices-Habanero";
381383
};
382384

target/linux/ipq40xx/dts/qcom-ipq4019-ncp-hg100-cellular.dts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,29 @@
564564
emmc@0 {
565565
compatible = "mmc-card";
566566
reg = <0>;
567+
568+
block {
569+
compatible = "block-device";
570+
partitions {
571+
block-partition-art {
572+
partname = "ART";
573+
574+
nvmem-layout {
575+
compatible = "fixed-layout";
576+
#address-cells = <1>;
577+
#size-cells = <1>;
578+
579+
precal_art_1000: pre-calibration@1000 {
580+
reg = <0x1000 0x2f20>;
581+
};
582+
583+
precal_art_5000: pre-calibration@5000 {
584+
reg = <0x5000 0x2f20>;
585+
};
586+
};
587+
};
588+
};
589+
};
567590
};
568591
};
569592

@@ -621,11 +644,15 @@
621644
&wifi0 {
622645
status = "okay";
623646
qcom,ath10k-calibration-variant = "Sony-NCP-HG100-Cellular";
647+
nvmem-cells = <&precal_art_1000>;
648+
nvmem-cell-names = "pre-calibration";
624649
};
625650

626651
&wifi1 {
627652
status = "okay";
628653
qcom,ath10k-calibration-variant = "Sony-NCP-HG100-Cellular";
654+
nvmem-cells = <&precal_art_5000>;
655+
nvmem-cell-names = "pre-calibration";
629656
};
630657

631658
&watchdog {

0 commit comments

Comments
 (0)