When the controller BD address is invalid (zero or default),
set the NVMEM quirks to allow retrieving the address from a
'local-bd-address' NVMEM cell. The BD address is often stored
alongside the WiFi MAC address in big-endian format, so also
set the big-endian quirk.

Reviewed-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Loic Poulain <[email protected]>
---
 arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts | 39 ++++++++++++++++++++++
 drivers/bluetooth/btqca.c                          |  5 ++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts 
b/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts
index 
bf088fa9807f040f0c8f405f9111b01790b09377..128c7a7e76b5b089044745f5d6407d6391055fc2
 100644
--- a/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts
+++ b/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts
@@ -409,7 +409,40 @@ &sdhc_1 {
        no-sdio;
        no-sd;
 
+       #address-cells = <1>;
+       #size-cells = <0>;
+
        status = "okay";
+
+       card@0 {
+               compatible = "mmc-card";
+               reg = <0>;
+
+               partitions-boot1 {
+                       compatible = "fixed-partitions";
+
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       nvmem-layout {
+                               compatible = "fixed-layout";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               wifi_mac_addr: mac-addr@4400 {
+                                       compatible = "mac-base";
+                                       reg = <0x4400 0x6>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+
+                               bd_addr: bd-addr@5400 {
+                                       compatible = "mac-base";
+                                       reg = <0x5400 0x6>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+                       };
+               };
+       };
 };
 
 &spi5 {
@@ -512,6 +545,9 @@ bluetooth {
                vddch0-supply = <&pm4125_l22>;
                enable-gpios = <&tlmm 87 GPIO_ACTIVE_HIGH>;
                max-speed = <3000000>;
+
+               nvmem-cells = <&bd_addr 0>;
+               nvmem-cell-names = "local-bd-address";
        };
 };
 
@@ -557,6 +593,9 @@ &wifi {
        qcom,ath10k-calibration-variant = "ArduinoImola";
        firmware-name = "qcm2290";
 
+       nvmem-cells = <&wifi_mac_addr 0>;
+       nvmem-cell-names = "mac-address";
+
        status = "okay";
 };
 
diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
index 
dda76365726f0bfe0e80e05fe04859fa4f0592e1..df33eacfd29fa680f393f90215150743e6001d5b
 100644
--- a/drivers/bluetooth/btqca.c
+++ b/drivers/bluetooth/btqca.c
@@ -721,8 +721,11 @@ static int qca_check_bdaddr(struct hci_dev *hdev, const 
struct qca_fw_config *co
        }
 
        bda = (struct hci_rp_read_bd_addr *)skb->data;
-       if (!bacmp(&bda->bdaddr, &config->bdaddr))
+       if (!bacmp(&bda->bdaddr, &config->bdaddr)) {
                hci_set_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
+               hci_set_quirk(hdev, HCI_QUIRK_USE_BDADDR_NVMEM);
+               hci_set_quirk(hdev, HCI_QUIRK_BDADDR_NVMEM_BE);
+       }
 
        kfree_skb(skb);
 

-- 
2.34.1


Reply via email to