diff mbox series

[v3,3/6] ath79: D-Link DAP-2680 A1: convert ath10k caldata to nvmem

Message ID 139c4cb3edac32de6e813618bd83442cd7cde2b3.1655542439.git.sander@svanheule.net
State Accepted
Delegated to: Sander Vanheule
Headers show
Series ath79: convert QCA955x-based D-Link DAP-2xxx to nvmem | expand

Commit Message

Sander Vanheule June 18, 2022, 8:55 a.m. UTC
Add the PCIe node for the ath10k radio to the devicetree, and refer to
the art partition for the pre-calibration data using nvmem-cells.

MAC address assignment is moved to '10_fix_wifi_mac', so the device can
then be removed from the caldata extraction script '11-ath10k-caldata'.

Cc: Sebastian Schaper <openwrt@sebastianschaper.net>
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
 .../linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts  | 14 ++++++++++++++
 .../etc/hotplug.d/firmware/11-ath10k-caldata       |  6 ------
 .../etc/hotplug.d/ieee80211/10_fix_wifi_mac        |  7 ++++++-
 3 files changed, 20 insertions(+), 7 deletions(-)

Comments

Sebastian Schaper June 18, 2022, 9:45 a.m. UTC | #1
Tested successfully on DAP-2680, both radios are available and
the MAC address assignment is correct for LAN and both radios.

Feel free to add my Tested-By to the commit message.

I also tested DAP-2660 as an example Wave-1 device from the series,
both radios and MAC assignment are working fine here as well.

Looking at other devices using pre-calibration, it seems the dts alias
used for the nvmem cell also reflects the type of calibration data,
maybe this could be used here as well, for the sake of consistency.

Best,
Sebastian


Am 18.06.22 um 10:55 schrieb Sander Vanheule:
> Add the PCIe node for the ath10k radio to the devicetree, and refer to
> the art partition for the pre-calibration data using nvmem-cells.
>
> MAC address assignment is moved to '10_fix_wifi_mac', so the device can
> then be removed from the caldata extraction script '11-ath10k-caldata'.
>
> Cc: Sebastian Schaper <openwrt@sebastianschaper.net>
> Signed-off-by: Sander Vanheule <sander@svanheule.net>
> ---
>   .../linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts  | 14 ++++++++++++++
>   .../etc/hotplug.d/firmware/11-ath10k-caldata       |  6 ------
>   .../etc/hotplug.d/ieee80211/10_fix_wifi_mac        |  7 ++++++-
>   3 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> index 0593fd29f418..a688293ce6bc 100644
> --- a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> +++ b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> @@ -79,4 +79,18 @@
>   
>   &pcie0 {
>   	status = "okay";
> +
> +	wifi@0,0 {
> +		compatible = "qcom,ath10k";
> +		reg = <0 0 0 0 0>;
> +
> +		nvmem-cells = <&cal_ath10k>;
> +		nvmem-cell-names = "pre-calibration";
> +	};
> +};
> +
> +&art {
> +	cal_ath10k: calibration@5000 {
> +		reg = <0x5000 0x2f20>;
> +	};
>   };
> diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> index cb4a5797ec31..1ce3f00c7e4f 100644
> --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> @@ -197,12 +197,6 @@ case "$FIRMWARE" in
>   			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
>   		rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
>   		;;
> -	dlink,dap-2680-a1)
> -		caldata_extract "art" 0x5000 0x2f20
> -		ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
> -		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
> -			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
> -		;;
>   	dlink,dir-842-c1|\
>   	dlink,dir-842-c2|\
>   	dlink,dir-842-c3)
> diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> index a4f82c54e271..d5a2471a99a9 100644
> --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> @@ -27,12 +27,17 @@ case "$board" in
>   		mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
>   		;;
>   	dlink,dap-2660-a1|\
> -	dlink,dap-2680-a1|\
>   	dlink,dap-2695-a1|\
>   	dlink,dap-3662-a1)
>   		[ "$PHYNBR" -eq 1 ] && \
>   			mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
>   		;;
> +	dlink,dap-2680-a1)
> +		[ "$PHYNBR" -eq 0 ] && \
> +			mtd_get_mac_ascii bdcfg "wlanmac_a" > /sys${DEVPATH}/macaddress
> +		[ "$PHYNBR" -eq 1 ] && \
> +			mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
> +		;;
>   	iodata,wn-ac1600dgr)
>   		# There is no eeprom data for 5 GHz wlan in "art" partition
>   		# which would allow to patch the macaddress
Sander Vanheule June 18, 2022, 10:08 a.m. UTC | #2
Hi Sebastian,

On Sat, 2022-06-18 at 11:45 +0200, Sebastian Schaper wrote:
> Tested successfully on DAP-2680, both radios are available and
> the MAC address assignment is correct for LAN and both radios.
> 
> Feel free to add my Tested-By to the commit message.
> 
> I also tested DAP-2660 as an example Wave-1 device from the series,
> both radios and MAC assignment are working fine here as well.

Thanks for testing!

> 
> Looking at other devices using pre-calibration, it seems the dts alias
> used for the nvmem cell also reflects the type of calibration data,
> maybe this could be used here as well, for the sake of consistency.

I've updated the node name and label for the pre-cal data, and merged the patches.

Best,
Sander

> 
> Best,
> Sebastian
> 
> 
> Am 18.06.22 um 10:55 schrieb Sander Vanheule:
> > Add the PCIe node for the ath10k radio to the devicetree, and refer to
> > the art partition for the pre-calibration data using nvmem-cells.
> > 
> > MAC address assignment is moved to '10_fix_wifi_mac', so the device can
> > then be removed from the caldata extraction script '11-ath10k-caldata'.
> > 
> > Cc: Sebastian Schaper <openwrt@sebastianschaper.net>
> > Signed-off-by: Sander Vanheule <sander@svanheule.net>
> > ---
> >   .../linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts  | 14 ++++++++++++++
> >   .../etc/hotplug.d/firmware/11-ath10k-caldata       |  6 ------
> >   .../etc/hotplug.d/ieee80211/10_fix_wifi_mac        |  7 ++++++-
> >   3 files changed, 20 insertions(+), 7 deletions(-)
> > 
> > diff --git a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> > b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> > index 0593fd29f418..a688293ce6bc 100644
> > --- a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> > +++ b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
> > @@ -79,4 +79,18 @@
> >   
> >   &pcie0 {
> >         status = "okay";
> > +
> > +       wifi@0,0 {
> > +               compatible = "qcom,ath10k";
> > +               reg = <0 0 0 0 0>;
> > +
> > +               nvmem-cells = <&cal_ath10k>;
> > +               nvmem-cell-names = "pre-calibration";
> > +       };
> > +};
> > +
> > +&art {
> > +       cal_ath10k: calibration@5000 {
> > +               reg = <0x5000 0x2f20>;
> > +       };
> >   };
> > diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> > b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> > index cb4a5797ec31..1ce3f00c7e4f 100644
> > --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> > +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> > @@ -197,12 +197,6 @@ case "$FIRMWARE" in
> >                         /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
> >                 rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
> >                 ;;
> > -       dlink,dap-2680-a1)
> > -               caldata_extract "art" 0x5000 0x2f20
> > -               ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
> > -               ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
> > -                       /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
> > -               ;;
> >         dlink,dir-842-c1|\
> >         dlink,dir-842-c2|\
> >         dlink,dir-842-c3)
> > diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> > b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> > index a4f82c54e271..d5a2471a99a9 100644
> > --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> > +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> > @@ -27,12 +27,17 @@ case "$board" in
> >                 mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
> >                 ;;
> >         dlink,dap-2660-a1|\
> > -       dlink,dap-2680-a1|\
> >         dlink,dap-2695-a1|\
> >         dlink,dap-3662-a1)
> >                 [ "$PHYNBR" -eq 1 ] && \
> >                         mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
> >                 ;;
> > +       dlink,dap-2680-a1)
> > +               [ "$PHYNBR" -eq 0 ] && \
> > +                       mtd_get_mac_ascii bdcfg "wlanmac_a" > /sys${DEVPATH}/macaddress
> > +               [ "$PHYNBR" -eq 1 ] && \
> > +                       mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
> > +               ;;
> >         iodata,wn-ac1600dgr)
> >                 # There is no eeprom data for 5 GHz wlan in "art" partition
> >                 # which would allow to patch the macaddress
diff mbox series

Patch

diff --git a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
index 0593fd29f418..a688293ce6bc 100644
--- a/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
+++ b/target/linux/ath79/dts/qca9558_dlink_dap-2680-a1.dts
@@ -79,4 +79,18 @@ 
 
 &pcie0 {
 	status = "okay";
+
+	wifi@0,0 {
+		compatible = "qcom,ath10k";
+		reg = <0 0 0 0 0>;
+
+		nvmem-cells = <&cal_ath10k>;
+		nvmem-cell-names = "pre-calibration";
+	};
+};
+
+&art {
+	cal_ath10k: calibration@5000 {
+		reg = <0x5000 0x2f20>;
+	};
 };
diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index cb4a5797ec31..1ce3f00c7e4f 100644
--- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -197,12 +197,6 @@  case "$FIRMWARE" in
 			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
 		rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
 		;;
-	dlink,dap-2680-a1)
-		caldata_extract "art" 0x5000 0x2f20
-		ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
-		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
-			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
-		;;
 	dlink,dir-842-c1|\
 	dlink,dir-842-c2|\
 	dlink,dir-842-c3)
diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
index a4f82c54e271..d5a2471a99a9 100644
--- a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
+++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -27,12 +27,17 @@  case "$board" in
 		mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
 		;;
 	dlink,dap-2660-a1|\
-	dlink,dap-2680-a1|\
 	dlink,dap-2695-a1|\
 	dlink,dap-3662-a1)
 		[ "$PHYNBR" -eq 1 ] && \
 			mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
 		;;
+	dlink,dap-2680-a1)
+		[ "$PHYNBR" -eq 0 ] && \
+			mtd_get_mac_ascii bdcfg "wlanmac_a" > /sys${DEVPATH}/macaddress
+		[ "$PHYNBR" -eq 1 ] && \
+			mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
+		;;
 	iodata,wn-ac1600dgr)
 		# There is no eeprom data for 5 GHz wlan in "art" partition
 		# which would allow to patch the macaddress