Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4827ec3

Browse files
committedSep 10, 2016
lantiq: switch to owl-loader for loading ath9k eeprom/calibration data
This moves the extraction of the eeprom calibration data to a hotplug firmware script. Additionally it modifies all .dts to configure ath9k directly from within the .dts. The owl-loader approach enables support on devices with exotic eeprom data locations (such as unaligned positions on the flash or data inside an UBI volume). Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> [add ath9k caldata mac address patcher] [fixes DGN3500 wifi mac] [fixes BTHOMEHUBV3A wifi mac] [set invalid mac for BTHOMEHUB2B, FRITZ3370, FRITZ7320 & FRITZ7360SL to restore previous random mac behavior] Signed-off-by: Mathias Kresin <dev@kresin.me>
1 parent ba1f1d0 commit 4827ec3

14 files changed

+303
-160
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/sh
2+
# Based on ar71xx 10-ath9k-eeprom
3+
4+
[ -e /lib/firmware/$FIRMWARE ] && exit 0
5+
6+
. /lib/functions.sh
7+
. /lib/functions/system.sh
8+
. /lib/functions/lantiq.sh
9+
. /lib/upgrade/nand.sh
10+
11+
# xor multiple hex values of the same length
12+
xor() {
13+
local ret="0x$1"
14+
15+
shift 1
16+
while [[ "$1" ]]; do
17+
local val="0x$1"
18+
ret=$((${ret:-0} ^ ${val:-0}))
19+
shift 1
20+
done
21+
22+
printf "%02x" "$ret"
23+
}
24+
25+
ath9k_eeprom_die() {
26+
echo "ath9k eeprom: " "$*"
27+
exit 1
28+
}
29+
30+
ath9k_eeprom_extract_raw() {
31+
local source=$1
32+
local offset=$2
33+
local size=4096
34+
35+
dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$size 2>/dev/null || \
36+
ath9k_eeprom_die "failed to extract from $mtd"
37+
}
38+
39+
ath9k_eeprom_extract() {
40+
local part=$1
41+
local offset=$2
42+
local mtd
43+
44+
mtd=$(find_mtd_chardev $part)
45+
[ -n "$mtd" ] || \
46+
ath9k_eeprom_die "no mtd device found for partition $part"
47+
48+
ath9k_eeprom_extract_raw $mtd $offset
49+
}
50+
51+
ath9k_ubi_eeprom_extract() {
52+
local part=$1
53+
local offset=$2
54+
local ubidev=$(nand_find_ubi $CI_UBIPART)
55+
local ubi
56+
57+
ubi=$(nand_find_volume $ubidev $part)
58+
[ -n "$ubi" ] || \
59+
ath9k_eeprom_die "no UBI volume found for $part"
60+
61+
ath9k_eeprom_extract_raw /dev/$ubi $offset
62+
}
63+
64+
ath9k_patch_firmware_mac() {
65+
local mac=$1
66+
local mac_offset=$2
67+
local swap=$3
68+
local chksum_offset=$4
69+
local xor_mac
70+
local xor_fw_mac
71+
local xor_fw_chksum
72+
73+
[ -z "$mac" -o -z "$mac_offset" ] && return
74+
75+
[ $swap -gt 0 ] && mac="${mac:3:2}:${mac:0:2}:${mac:9:2}:${mac:6:2}:${mac:15:2}:${mac:12:2}"
76+
77+
[ -n "$chksum_offset" ] && {
78+
xor_mac="${mac:0:2}${mac:3:2} ${mac:6:2}${mac:9:2} ${mac:12:2}${mac:15:2}"
79+
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/2 "%04x "' /lib/firmware/$FIRMWARE)
80+
81+
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
82+
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
83+
84+
echo -ne \\x${xor_fw_chksum:0:2}\\x${xor_fw_chksum:2:2} | \
85+
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
86+
}
87+
88+
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
89+
}
90+
91+
case "$FIRMWARE" in
92+
"ath9k-eeprom-pci-0000:00:0e.0.bin"|"ath9k-eeprom-pci-0000:01:00.0.bin"|"ath9k-eeprom-pci-0000:02:00.0.bin")
93+
local board=$(lantiq_board_name)
94+
case $board in
95+
ARV7518PW)
96+
ath9k_eeprom_extract "boardconfig" 1024
97+
;;
98+
ARV8539PW22)
99+
ath9k_eeprom_extract "art" 1024
100+
;;
101+
BTHOMEHUBV2B)
102+
ath9k_eeprom_extract "art" 0
103+
ath9k_patch_firmware_mac "00:00:00:00:00:00" 524 1 514
104+
;;
105+
BTHOMEHUBV3A)
106+
ath9k_eeprom_extract "art-copy" 0
107+
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 268 1 258
108+
;;
109+
BTHOMEHUBV5A)
110+
ath9k_eeprom_extract "caldata" 4096
111+
;;
112+
DGN3500*)
113+
ath9k_eeprom_extract "calibration" 61440
114+
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524 0 514
115+
;;
116+
FRITZ3370)
117+
ath9k_eeprom_extract "urlader" 2437
118+
ath9k_patch_firmware_mac "00:00:00:00:00:00" 2 0
119+
;;
120+
FRITZ7320|FRITZ7360SL)
121+
ath9k_eeprom_extract "urlader" 2437
122+
ath9k_patch_firmware_mac "00:00:00:00:00:00" 268 0 258
123+
;;
124+
TDW8970|TDW8980)
125+
ath9k_eeprom_extract "boardconfig" 135168
126+
;;
127+
*)
128+
ath9k_eeprom_die "board $board is not supported yet"
129+
;;
130+
esac
131+
;;
132+
esac

‎target/linux/lantiq/dts/ARV7518PW.dts

+15-16
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,6 @@
7777
gpio-controller;
7878
lantiq,shadow = <0x0>;
7979
};
80-
81-
ath9k_eep {
82-
compatible = "ath9k,eeprom";
83-
ath,eep-flash = <&boardconfig 0x400>;
84-
ath,mac-offset = <0x16>;
85-
ath,mac-increment = <1>;
86-
ath,pci-slot = <14>;
87-
ath,eep-endian;
88-
};
8980
};
9081

9182
gpio: pinmux@E100B10 {
@@ -138,13 +129,6 @@
138129
gpios = <&gpio 14 0>;
139130
};
140131

141-
pci@E105400 {
142-
status = "okay";
143-
lantiq,external-clock;
144-
gpio-reset = <&gpio 21 0>;
145-
req-mask = <0xf>;
146-
};
147-
148132
};
149133

150134
/*
@@ -229,3 +213,18 @@
229213
};
230214
};
231215
};
216+
217+
&pci0 {
218+
status = "okay";
219+
gpio-reset = <&gpio 21 0>;
220+
lantiq,external-clock;
221+
req-mask = <0xf>;
222+
223+
ath9k@7000 {
224+
reg = <0x7000 0 0 0 0>;
225+
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
226+
mtd-mac-address = <&boardconfig 0x16>;
227+
mtd-mac-address-increment = <1>;
228+
qca,check-eeprom-endianness;
229+
};
230+
};

‎target/linux/lantiq/dts/ARV8539PW22.dts

+12-15
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@
6666
};
6767
};
6868
};
69-
70-
ath9k_eep {
71-
compatible = "ath9k,eeprom";
72-
ath,eep-flash = <&art 0x400>;
73-
ath,mac-offset = <0x16>;
74-
ath,mac-increment = <1>;
75-
ath,pci-slot = <14>;
76-
ath,eep-endian;
77-
ath,arv-ath9k-fix;
78-
};
7969
};
8070

8171
gpio: pinmux@E100B10 {
@@ -112,11 +102,6 @@
112102
mtd-mac-address = <&art 0x16>;
113103
};
114104

115-
pci@E105400 {
116-
status = "okay";
117-
gpio-reset = <&gpio 21 0>;
118-
};
119-
120105
ifxhcd@E101000 {
121106
status = "okay";
122107
gpios = <&gpio 14 0>;
@@ -176,3 +161,15 @@
176161
};
177162
};
178163

164+
&pci0 {
165+
status = "okay";
166+
gpio-reset = <&gpio 21 0>;
167+
168+
ath9k@7000 {
169+
reg = <0x7000 0 0 0 0>;
170+
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
171+
mtd-mac-address = <&art 0x16>;
172+
mtd-mac-address-increment = <1>;
173+
qca,check-eeprom-endianness;
174+
};
175+
};

‎target/linux/lantiq/dts/BTHOMEHUBV2B.dts

+14-19
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,6 @@
110110
};
111111
};
112112
};
113-
114-
115-
ath9k_eep {
116-
compatible = "ath9k,eeprom";
117-
ath,eep-flash = <&ath9k_cal 0x0000>;
118-
ath,mac-increment = <1>;
119-
ath,pci-slot = <14>;
120-
ath,eep-endian;
121-
};
122113
};
123114

124115
gpio: pinmux@E100B10 {
@@ -208,16 +199,6 @@
208199
lantiq,shadow = <0xfff>;
209200
lantiq,groups = <0x3>;
210201
};
211-
212-
pci@E105400 {
213-
status = "okay";
214-
lantiq,bus-clock = <33333333>;
215-
interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
216-
interrupt-map = <0x7000 0 0 1 &icu0 30 1>;
217-
gpio-reset = <&gpio 21 0>;
218-
req-mask = <0x1>; /* GNT1 */
219-
};
220-
221202
};
222203

223204
gpio-keys-polled {
@@ -298,3 +279,17 @@
298279
};
299280
};
300281

282+
&pci0 {
283+
status = "okay";
284+
lantiq,bus-clock = <33333333>;
285+
interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
286+
interrupt-map = <0x7000 0 0 1 &icu0 30 1>;
287+
gpio-reset = <&gpio 21 0>;
288+
req-mask = <0x1>; /* GNT1 */
289+
290+
ath9k@7000 {
291+
reg = <0x7000 0 0 0 0>;
292+
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
293+
qca,check-eeprom-endianness;
294+
};
295+
};

‎target/linux/lantiq/dts/BTHOMEHUBV3A.dts

+10-12
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@
8181
};
8282
};
8383
};
84-
85-
ath9k_eep {
86-
compatible = "ath9k,eeprom";
87-
ath,eep-flash = <&ath9k_cal 0x0000>;
88-
ath,pci-slot = <14>;
89-
ath,eep-endian;
90-
};
9184
};
9285

9386
gpio: pinmux@E100B10 {
@@ -146,11 +139,6 @@
146139
gpios = <&gpio 33 0>;
147140
};
148141

149-
pci@E105400 {
150-
status = "okay";
151-
gpio-reset = <&gpio 21 0>;
152-
};
153-
154142
};
155143

156144
gpio-keys-polled {
@@ -220,3 +208,13 @@
220208
};
221209
};
222210

211+
&pci0 {
212+
status = "okay";
213+
gpio-reset = <&gpio 21 0>;
214+
215+
ath9k@7000 {
216+
reg = <0x7000 0 0 0 0>;
217+
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
218+
qca,check-eeprom-endianness;
219+
};
220+
};

‎target/linux/lantiq/dts/BTHOMEHUBV5A.dts

+16-16
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@
116116
status = "okay";
117117
gpios = <&gpio 33 0>;
118118
};
119-
120-
pci@E105400 {
121-
status = "okay";
122-
lantiq,bus-clock = <33333333>;
123-
interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
124-
interrupt-map = <0x7000 0 0 1 &icu0 30 1>;
125-
gpio-reset = <&gpio 21 0>;
126-
};
127119
};
128120

129121
gphy-xrx200 {
@@ -133,14 +125,6 @@
133125
phys = [ 00 01 ];
134126
};
135127

136-
ath9k_eep {
137-
compatible = "ath9k,eeprom";
138-
ath,eep-flash = <&caldata 0x1000>;
139-
ath,mac-offset = <0x110c>;
140-
ath,mac-increment = <2>;
141-
ath,pci-slot = <0xe>; /* 14 */
142-
};
143-
144128
gpio-keys-polled {
145129
compatible = "gpio-keys-polled";
146130
#address-cells = <1>;
@@ -219,6 +203,22 @@
219203
};
220204
};
221205

206+
&pci0 {
207+
status = "okay";
208+
lantiq,bus-clock = <33333333>;
209+
interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
210+
interrupt-map = <0x7000 0 0 1 &icu0 30 1>;
211+
gpio-reset = <&gpio 21 0>;
212+
213+
ath9k@7000 {
214+
reg = <0x7000 0 0 0 0>;
215+
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
216+
qca,disable-5ghz;
217+
mtd-mac-address = <&caldata 0x110c>;
218+
mtd-mac-address-increment = <2>;
219+
};
220+
};
221+
222222
&eth0 {
223223
lan: interface@0 {
224224
compatible = "lantiq,xrx200-pdi";

0 commit comments

Comments
 (0)
Please sign in to comment.