lantiq: use ath9k device tree bindings binding/owl-loader

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>
This commit is contained in:
Martin Blumenstingl 2016-11-26 01:01:15 +01:00 committed by Mathias Kresin
parent 448b9b67e1
commit a20616863d
14 changed files with 305 additions and 141 deletions

View file

@ -0,0 +1,140 @@
#!/bin/sh
# Based on ar71xx 10-ath9k-eeprom
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/lantiq.sh
. /lib/upgrade/nand.sh
# xor multiple hex values of the same length
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
ath9k_eeprom_die() {
echo "ath9k eeprom: $*"
exit 1
}
ath9k_eeprom_extract_raw() {
local source=$1
local offset=$2
local size=4096
dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$size 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath9k_eeprom_die "no mtd device found for partition $part"
ath9k_eeprom_extract_raw $mtd $offset
}
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath9k_eeprom_die "no UBI volume found for $part"
ath9k_eeprom_extract_raw /dev/$ubi $offset
}
ath9k_patch_firmware_mac() {
local mac=$1
local mac_offset=$2
local swap=$3
local chksum_offset=$4
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" -o -z "$mac_offset" ] && return
[ $swap -gt 0 ] && mac="${mac:3:2}:${mac:0:2}:${mac:9:2}:${mac:6:2}:${mac:15:2}:${mac:12:2}"
[ -n "$chksum_offset" ] && {
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
}
case "$FIRMWARE" in
"ath9k-eeprom-pci-0000:00:0e.0.bin" | \
"ath9k-eeprom-pci-0000:01:00.0.bin" | \
"ath9k-eeprom-pci-0000:02:00.0.bin")
board=$(lantiq_board_name)
case "$board" in
ARV7518PW)
ath9k_eeprom_extract "boardconfig" 1024
;;
ARV8539PW22)
ath9k_eeprom_extract "art" 1024
;;
BTHOMEHUBV2B)
ath9k_eeprom_extract "art" 0
ath9k_patch_firmware_mac "00:00:00:00:00:00" 524 1 514
;;
BTHOMEHUBV3A)
ath9k_eeprom_extract "art-copy" 0
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 268 1 258
;;
BTHOMEHUBV5A)
ath9k_eeprom_extract "caldata" 4096
;;
DGN3500*)
ath9k_eeprom_extract "calibration" 61440
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524 0 514
;;
FRITZ3370)
ath9k_eeprom_extract "urlader" 2437
ath9k_patch_firmware_mac "00:00:00:00:00:00" 2 0
;;
FRITZ7320|FRITZ7360SL)
ath9k_eeprom_extract "urlader" 2437
ath9k_patch_firmware_mac "00:00:00:00:00:00" 268 0 258
;;
TDW8970|TDW8980)
ath9k_eeprom_extract "boardconfig" 135168
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
;;
esac
;;
esac

View file

@ -79,15 +79,6 @@
gpio-controller;
lantiq,shadow = <0x0>;
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&boardconfig 0x400>;
ath,mac-offset = <0x16>;
ath,mac-increment = <1>;
ath,pci-slot = <14>;
ath,eep-endian;
};
};
gpio: pinmux@E100B10 {
@ -139,13 +130,6 @@
status = "okay";
gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
};
pci@E105400 {
status = "okay";
lantiq,external-clock;
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
req-mask = <0xf>;
};
};
/*
@ -230,3 +214,18 @@
};
};
};
&pci0 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
lantiq,external-clock;
req-mask = <0xf>;
wifi@168c,0029 {
compatible = "pci168c,0029";
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
mtd-mac-address = <&boardconfig 0x16>;
mtd-mac-address-increment = <1>;
};
};

View file

@ -66,15 +66,6 @@
};
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&art 0x400>;
ath,mac-offset = <0x16>;
ath,mac-increment = <1>;
ath,pci-slot = <14>;
ath,eep-endian;
};
};
gpio: pinmux@E100B10 {
@ -111,11 +102,6 @@
mtd-mac-address = <&art 0x16>;
};
pci@E105400 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
ifxhcd@E101000 {
status = "okay";
gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
@ -175,3 +161,15 @@
};
};
&pci0 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
wifi@168c,0029 {
compatible = "pci168c,0029";
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
mtd-mac-address = <&art 0x16>;
mtd-mac-address-increment = <1>;
};
};

View file

@ -104,14 +104,6 @@
};
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&ath9k_cal 0x0000>;
ath,mac-increment = <1>;
ath,pci-slot = <14>;
ath,eep-endian;
};
};
gpio: pinmux@E100B10 {
@ -177,11 +169,6 @@
gpios: stp@E100BB0 {
status = "okay";
};
pci@E105400 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
};
gpio-keys-polled {
@ -262,3 +249,13 @@
};
};
&pci0 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
wifi@168c,0027 {
compatible = "pci168c,0027";
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
};
};

View file

@ -75,13 +75,6 @@
};
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&ath9k_cal 0x0000>;
ath,pci-slot = <14>;
ath,eep-endian;
};
};
gpio: pinmux@E100B10 {
@ -134,11 +127,6 @@
status = "okay";
gpios = <&gpio 33 GPIO_ACTIVE_HIGH>;
};
pci@E105400 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
};
gpio-keys-polled {
@ -207,3 +195,13 @@
};
};
};
&pci0 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
ath9k@7000 {
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
};
};

View file

@ -111,11 +111,6 @@
status = "okay";
gpios = <&gpio 33 GPIO_ACTIVE_HIGH>;
};
pci@E105400 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
};
gphy-xrx200 {
@ -125,14 +120,6 @@
phys = [ 00 01 ];
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&caldata 0x1000>;
ath,mac-offset = <0x110c>;
ath,mac-increment = <2>;
ath,pci-slot = <0xe>; /* 14 */
};
gpio-keys-polled {
compatible = "gpio-keys-polled";
#address-cells = <1>;
@ -211,6 +198,20 @@
};
};
&pci0 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
wifi@168c,002d {
compatible = "pci168c,002d";
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
qca,disable-5ghz;
mtd-mac-address = <&caldata 0x110c>;
mtd-mac-address-increment = <2>;
};
};
&eth0 {
lan: interface@0 {
compatible = "lantiq,xrx200-pdi";

View file

@ -69,19 +69,6 @@
ifxhcd@E101000 {
status = "okay";
};
pci@E105400 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&ath9k_cal 0xf000>;
ath,pci-slot = <14>;
ath,eep-endian;
ath,eep-swap;
};
rtl8366rb {
@ -153,6 +140,17 @@
};
};
&pci0 {
status = "okay";
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
wifi@168c,0029 {
compatible = "pci168c,0029";
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
};
};
&spi {
pinctrl-names = "default";
pinctrl-0 = <&pins_spi_default>;

View file

@ -118,13 +118,6 @@
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&ath9k_cal 0x985>;
ath,eep-endian;
ath,eep-swap;
};
gphy-xrx200 {
compatible = "lantiq,phy-xrx200";
firmware = "lantiq/vr9_phy11g_a1x.bin";
@ -196,7 +189,7 @@
reg = <4 0>;
spi-max-frequency = <1000000>;
ath9k_cal: partition@0 {
partition@0 {
reg = <0x0 0x20000>;
label = "urlader";
read-only;
@ -275,3 +268,19 @@
};
};
};
&pcie0 {
pcie@0 {
reg = <0 0 0 0 0>;
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
device_type = "pci";
wifi@0,0 {
compatible = "pci0,0";
reg = <0 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:01:00.0.bin */
};
};
};

View file

@ -65,14 +65,6 @@
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&ath9k_cal 0x985>;
ath,device-id = /bits/ 16 <0xff1d 0x2d>;
ath,eep-endian;
ath,eep-swap;
};
gpio: pinmux@E100B10 {
pinctrl-names = "default";
pinctrl-0 = <&state_default>;
@ -103,12 +95,6 @@
ifxhcd@E101000 {
status = "okay";
};
pci@E105400 {
status = "okay";
req-mask = <0xf>;
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
};
gpio-keys-polled {
@ -158,3 +144,15 @@
};
};
};
&pci0 {
status = "okay";
req-mask = <0xf>;
gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
wifi@0,0 {
compatible = "pci0,0";
reg = <0x7000 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
};
};

View file

@ -96,14 +96,6 @@
};
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&urlader 0x985>;
ath,eep-endian;
ath,eep-swap;
ath,pci-slot = <0>;
};
gphy-xrx200 {
compatible = "lantiq,phy-xrx200";
firmware = "lantiq/vr9_phy11g_a2x.bin";
@ -217,3 +209,19 @@
};
};
};
&pcie0 {
pcie@0 {
reg = <0 0 0 0 0>;
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
device_type = "pci";
wifi@168c,002e {
compatible = "pci168c,002e";
reg = <0 0 0 0 0>;
qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:01:00.0.bin */
};
};
};

View file

@ -25,10 +25,6 @@
};
};
ath9k_eep {
ath,pci-slot = <0>;
};
gpio-leds {
wifi2 {
label = "tdw8980:green:wlan5ghz";

View file

@ -14,6 +14,7 @@
led-dsl = &dsl;
led-internet = &internet;
led-wifi = &wifi;
led-usb = &usb0;
led-usb2 = &usb2;
};
@ -83,16 +84,6 @@
phys = [ 00 01 ];
};
ath9k_eep {
compatible = "ath9k,eeprom";
ath,eep-flash = <&ath9k_cal 0x21000>;
ath,mac-offset = <0xf100>;
ath,mac-increment = <2>;
ath,led-pin = <0>;
ath,disable-5ghz;
ath,led-active-high;
};
gpio-keys-polled {
compatible = "gpio-keys-polled";
#address-cells = <1>;
@ -144,6 +135,15 @@
gpios = <&gpio 37 GPIO_ACTIVE_HIGH>;
};
};
wifi-leds {
compatible = "gpio-leds";
wifi: wifi {
label = "tdw89x0:green:wifi";
gpios = <&ath9k 0 GPIO_ACTIVE_HIGH>;
};
};
};
&spi {
@ -249,3 +249,24 @@
};
};
};
&pcie0 {
pcie@0 {
reg = <0 0 0 0 0>;
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
device_type = "pci";
ath9k: wifi@168c,002e {
compatible = "pci168c,002e";
reg = <0 0 0 0 0>;
#gpio-cells = <2>;
gpio-controller;
qca,no-eeprom;
qca,disable-5ghz;
mtd-mac-address = <&ath9k_cal 0xf100>;
mtd-mac-address-increment = <2>;
};
};
};

View file

@ -176,7 +176,7 @@ define Device/BTHOMEHUBV2B
kmod-ltq-adsl-danube-fw-a kmod-ltq-atm-danube \
kmod-ltq-deu-danube \
ltq-adsl-app ppp-mod-pppoa \
kmod-ath9k wpad-mini
kmod-ath9k kmod-owl-loader wpad-mini
endef
TARGET_DEVICES += BTHOMEHUBV2B
@ -258,7 +258,7 @@ define Device/ARV7518PW
kmod-ltq-adsl-danube-mei kmod-ltq-adsl-danube \
kmod-ltq-adsl-danube-fw-a kmod-ltq-atm-danube \
ltq-adsl-app ppp-mod-pppoa \
kmod-ath9k wpad-mini
kmod-ath9k kmod-owl-loader wpad-mini
endef
TARGET_DEVICES += ARV7518PW
@ -304,7 +304,7 @@ define Device/ARV8539PW22
kmod-ltq-adsl-danube-mei kmod-ltq-adsl-danube \
kmod-ltq-adsl-danube-fw-b kmod-ltq-atm-danube \
ltq-adsl-app ppp-mod-pppoa \
kmod-ath9k wpad-mini
kmod-ath9k kmod-owl-loader wpad-mini
endef
TARGET_DEVICES += ARV8539PW22
@ -330,7 +330,8 @@ define Device/BTHOMEHUBV3A
kmod-ltq-adsl-ar9-fw-a kmod-ltq-atm-ar9 \
kmod-ltq-deu-ar9 \
ltq-adsl-app ppp-mod-pppoa \
kmod-ath9k wpad-mini uboot-envtools
kmod-ath9k kmod-owl-loader wpad-mini \
uboot-envtools
endef
TARGET_DEVICES += BTHOMEHUBV3A
@ -357,7 +358,7 @@ define Device/DGN3500
check-size 16320k | pad-to 16384k
DEVICE_TITLE := Netgear DGN3500
DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport \
kmod-ath9k wpad-mini \
kmod-ath9k kmod-owl-loader wpad-mini \
kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
kmod-ltq-adsl-ar9-fw-a kmod-ltq-atm-ar9 \
ltq-adsl-app ppp-mod-pppoa \
@ -377,7 +378,7 @@ define Device/DGN3500B
check-size 16320k | pad-to 16384k
DEVICE_TITLE := Netgear DGN3500B
DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport \
kmod-ath9k wpad-mini \
kmod-ath9k kmod-owl-loader wpad-mini \
kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \
ltq-adsl-app ppp-mod-pppoa \
@ -393,7 +394,7 @@ define Device/WBMRA
kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
kmod-ltq-adsl-ar9-fw-a kmod-ltq-atm-ar9 \
ltq-adsl-app ppp-mod-pppoa \
kmod-ath9k wpad-mini
kmod-ath9k kmod-owl-loader wpad-mini
endef
TARGET_DEVICES += WBMRA
@ -405,7 +406,7 @@ define Device/WBMRB
kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \
ltq-adsl-app ppp-mod-pppoa \
kmod-ath9k wpad-mini
kmod-ath9k kmod-owl-loader wpad-mini
endef
TARGET_DEVICES += WBMRB
@ -413,12 +414,11 @@ define Device/FRITZ7320
$(Device/AVM)
IMAGE_SIZE := 15744k
DEVICE_TITLE := 1&1 HomeServer - FRITZ7320
DEVICE_PACKAGES := kmod-ath9k wpad-mini \
DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-mini \
kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \
ltq-adsl-app ppp-mod-pppoa \
kmod-ltq-deu-ar9 kmod-usb-dwc2 \
kmod-ath9k wpad-mini -swconfig
kmod-ltq-deu-ar9 kmod-usb-dwc2 -swconfig
endef
TARGET_DEVICES += FRITZ7320
@ -477,7 +477,8 @@ TARGET_DEVICES += ARV7519RW22
define Device/BTHOMEHUBV5A
$(Device/NAND)
DEVICE_TITLE := BT Home Hub 5A
DEVICE_PACKAGES := kmod-ath9k kmod-ath10k ath10k-firmware-qca988x wpad-mini kmod-usb-dwc2
DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader \
kmod-ath10k ath10k-firmware-qca988x wpad-mini kmod-usb-dwc2
endef
TARGET_DEVICES += BTHOMEHUBV5A
@ -485,14 +486,14 @@ define Device/EASY80920NAND
$(Device/lantiqFullImage)
IMAGE_SIZE := 64512k
DEVICE_TITLE := Lantiq VR9 - EASY80920NAND
DEVICE_PACKAGES := kmod-ath9k wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += EASY80920NAND
define Device/EASY80920NOR
IMAGE_SIZE := 7936k
DEVICE_TITLE := Lantiq VR9 - EASY80920NOR
DEVICE_PACKAGES := kmod-ath9k wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += EASY80920NOR
@ -508,7 +509,7 @@ define Device/FRITZ7360SL
$(Device/AVM)
IMAGE_SIZE := 15744k
DEVICE_TITLE := 1&1 HomeServer - FRITZ7360SL
DEVICE_PACKAGES := kmod-ath9k wpad-mini kmod-usb-dwc2
DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-mini kmod-usb-dwc2
endef
TARGET_DEVICES += FRITZ7360SL

View file

@ -33,7 +33,7 @@ define Device/TDW8980
BOARD_ID := TD-W8980v1
IMAGE_SIZE := 7680k
DEVICE_TITLE := TP-LINK TD-W8980
DEVICE_PACKAGES:= kmod-ath9k wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
DEVICE_PACKAGES:= kmod-ath9k kmod-owl-loader wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
endef
define Device/VR200v