Skip to contentSkip to conversation

Enable Bluetooth functionality for WCN3990

PATCH Superseded Balakrishna Godavarthi 3 participants 15 messages Aug 2, 2018

Subsystems (5)

v12 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v12 cover Enable Bluetooth functionality for WCN3990

These patches enables Bluetooth functinalties for new Qualcomm Bluetooth chip wnc3990. As this is latest chip with new features, along with some common features to old chip "qcom,qca6174-bt". we have updated names of functions that are used for both the chips to keep this generic and would help in future when we would have new BT SoC.

The below are difference between new and old chips.

*Power:
*New chip: we use voltage regulators to turn on/off the chip and we
must send a command on Tx line to turn on/off the chip completely.
*Old chip: We turn on/off by setting a GPIO.

*Note: Turning on sequence differs between two chips.

*Firmware download:
Only firmware file name differ from New and Old chip.

So we reused some functions/structure/variables which are used for old chip to New chip by generic naming (may be future chips may use same functions).

* As we have multiple changes for functions names,we have tested these patches on both chips.

v12:
* removed iteration loop in qca_init_wcn3990
* updated review comments.

v11:
* removed regulator current from dtbindings
* addressed review comments.

v10:
* update current load with actual values of WCN3990.
* added support for itterative connect with BT chip if it fails to respond to the HOST.
* Added regulator current dtbindings.
* addressed review comments.

v9:
* removed smps regs.
* hidded flow control in respective functions.
* moved qca_soc_ver to qca_setup
* addressed review comments.

v8:
* Squashed [v7 2/8] and [v7 3/8] to one patch.
* updated functions to set and get the UART speeds.
* addressed review comments.

v7:
* Renamed all the possible function of ROME to generic.
* updated with review comments for hci_qca and btqca
* fixed kbuild errors.
* created wrapper functions for re-usable blocks.

v6:
* Hooked up qca_power to qca_serdev.
* renamed all the naming inconsistency functions with qca_*
* leveraged common code of ROME for wcn3990.
* created wrapper functions for re-usable blocks.
* updated function of _*regulator_enable and _*regualtor_disable.
* removed redundant comments and functions.
* add code to derive the firmware files based on ROM Version.
* created new patch for common function of ROME and wcn3990.
* enables Qualcomm chip to operate at 3.2Mbps.
* updated names of functions that are used for both the chips to keep this generic.

v5:
* updated with review comments for hci_qca and btqca

v4:
* rebased all changes on top of bluetooth-next.
* addressed review comments.
* New patch created for firmware download.

v3:
* Rebased all changes on top of bluetooth-next.
* dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
- added dt-binding snippet for bluetooth chip wcn3990.
* Bluetooth: Add support for wcn3990 soc.
- updated BT_INFO with bt_dev_info, where ever necessary.

v2:
* Add support for wcn3990:
These changes are aligned as per serdev frame work.
We implemented these changes on top of https://patchwork.kernel.org/patch/10316093/
As this patch enable serdev for one of the Qualcomm BT chip.

The changes in the patch include.
- Adding support to voting up/down regulators for WCN3990.
- Bluetooth firmware download for wcn3990.

* Add device tree bindings for Atheros chips:
These changes are on top of https://patchwork.kernel.org/patch/10316097/.
- Description of device tree bindings.

Balakrishna Godavarthi (7):
dt-bindings: net: bluetooth: Add device tree bindings for QTI chip

    wcn3990

Bluetooth: btqca: Rename ROME specific functions to generic functions
Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
Bluetooth: hci_qca: Add wrapper functions for setting UART speed
Bluetooth: hci_qca: Enable 3.2 Mbps operating speed.
Bluetooth: btqca: Add wcn3990 firmware download support.
Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990

 .../bindings/net/qualcomm-bluetooth.txt       |  26 +-
 drivers/bluetooth/btqca.c                     | 117 +++--
 drivers/bluetooth/btqca.h                     |  22 +-
 drivers/bluetooth/hci_qca.c                   | 485 +++++++++++++++---
 4 files changed, 534 insertions(+), 116 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH v12 1/7 dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.

---
 .../bindings/net/qualcomm-bluetooth.txt       | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +24 -2
index 0ea18a53cc29..2175174415ee 100644
@@ -10,12 +10,22 @@ device the slave device is attached to.
 Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
+   * "qcom,wcn3990-bt"
+
+Optional properties for compatible string qcom,qca6174-bt:
 
-Optional properties:
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
-Example:
+Optional properties for compatible string qcom,wcn3990-bt:
+
+ - vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
+ - vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
+ - vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
+ - vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.
+ - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
+
+Examples:
 
 serial@7570000 {
 	label = "BT-UART";
@@ -28,3 +38,15 @@ serial@7570000 {
 		clocks = <&divclk4>;
 	};
 };
+
+serial@898000 {
+	bluetooth {
+		compatible = "qcom,wcn3990-bt";
+
+		vddio-supply = <&vreg_s4a_1p8>;
+		vddxo-supply = <&vreg_l7a_1p8>;
+		vddrf-supply = <&vreg_l17a_1p3>;
+		vddch0-supply = <&vreg_l25a_3p3>;
+		max-speed = <3200000>;
+	};
+};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw

Re: [PATCH v12 1/7] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990

In reply to Balakrishna Godavarthi
Quoted 22 lines · Balakrishna Godavarthi

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.

---
 .../bindings/net/qualcomm-bluetooth.txt       | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3 -1
index 0ea18a53cc29..2175174415ee 100644
@@ -10,12 +10,22 @@ device the slave device is attached to.
 Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
+   * "qcom,wcn3990-bt"
+
+Optional properties for compatible string qcom,qca6174-bt:
 
-Optional properties:

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt device the slave device is attached to. · line 25

Quoted 10 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6 -1
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
-Example:
+Optional properties for compatible string qcom,wcn3990-bt:
+
+ - vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
+ - vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
+ - vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
+ - vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Are these really optional? If I understand correctly the driver expects the regulators to be there. Even if it could do with only some regulators specified the devm_regulator_bulk_get() call would fail if not all requested regulators are available.

#4 lore raw

Re: [PATCH v12 1/7] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990

Hi Matthias,

Quoted 27 lines · Matthias Kaehlcke
Quoted 26 lines · Balakrishna Godavarthi

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.

---
 .../bindings/net/qualcomm-bluetooth.txt       | 26 
+++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3 -1
index 0ea18a53cc29..2175174415ee 100644
@@ -10,12 +10,22 @@ device the slave device is attached to.
 Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
+   * "qcom,wcn3990-bt"
+
+Optional properties for compatible string qcom,qca6174-bt:
 
-Optional properties:
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
Quoted 12 lines

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt device the slave device is attached to. · line 25

Quoted 7 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6 -1
-Example:
+Optional properties for compatible string qcom,wcn3990-bt:
+
+ - vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
+ - vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
+ - vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
+ - vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Are these really optional? If I understand correctly the driver expects the regulators to be there. Even if it could do with only some regulators specified the devm_regulator_bulk_get() call would fail if not all requested regulators are available.

yes they are required along with compatible string "qcom,wcn3990-bt".
i have taken reference wrt compatible string "qcom,qca6174-bt".
In which clocks and enable-gpios are required for driver to work, but it was written as optional in doc.

below snippet from hci_qca.c for qcom,qca6174-bt.

 if (IS_ERR(qcadev->bt_en)) {
       dev_err(&serdev->dev, "failed to acquire enable gpio\n");
       return PTR_ERR(qcadev->bt_en);
    }
  qcadev->susclk = devm_clk_get(&serdev->dev, NULL);
  if (IS_ERR(qcadev->susclk)) {
      dev_err(&serdev->dev, "failed to acquire clk\n");
       return PTR_ERR(qcadev->susclk);
     }
Signature · 2 lines
Regards
Balakrishna.
#5 lore raw

Re: [PATCH v12 1/7] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990

Hi Matthias,

Quoted 55 lines · Balakrishna Godavarthi

Hi Matthias,

Quoted 27 lines · Matthias Kaehlcke
Quoted 26 lines · Balakrishna Godavarthi

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.

---
 .../bindings/net/qualcomm-bluetooth.txt       | 26 
+++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3 -1
index 0ea18a53cc29..2175174415ee 100644
@@ -10,12 +10,22 @@ device the slave device is attached to.
 Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
+   * "qcom,wcn3990-bt"
+
+Optional properties for compatible string qcom,qca6174-bt:
 
-Optional properties:
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
Quoted 12 lines

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt device the slave device is attached to. · line 25

Quoted 7 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6 -1
-Example:
+Optional properties for compatible string qcom,wcn3990-bt:
+
+ - vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
+ - vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
+ - vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
+ - vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Are these really optional? If I understand correctly the driver expects the regulators to be there. Even if it could do with only some regulators specified the devm_regulator_bulk_get() call would fail if not all requested regulators are available.

yes they are required along with compatible string "qcom,wcn3990-bt". i have taken reference wrt compatible string "qcom,qca6174-bt". In which clocks and enable-gpios are required for driver to work, but it was written as optional in doc.

below snippet from hci_qca.c for qcom,qca6174-bt.

 if (IS_ERR(qcadev->bt_en)) {
       dev_err(&serdev->dev, "failed to acquire enable gpio\n");
       return PTR_ERR(qcadev->bt_en);
    }
Quoted 5 lines
  qcadev->susclk = devm_clk_get(&serdev->dev, NULL);
  if (IS_ERR(qcadev->susclk)) {
      dev_err(&serdev->dev, "failed to acquire clk\n");
       return PTR_ERR(qcadev->susclk);
     }

technically it is not correct then i will update as below

Required properties for compatible string qcom,wcn3990-bt:

- vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
- vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
- vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
- vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Optional properties for compatible string qcom,wcn3990-bt:

- max-speed: see
Documentation/devicetree/bindings/serial/slave-device.txt

are they above ok?

Signature · 2 lines
Regards
Balakrishna.
#6 lore raw

Re: [PATCH v12 1/7] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990

Quoted 76 lines · Balakrishna Godavarthi

Hi Matthias,

Quoted 58 lines · Balakrishna Godavarthi

Hi Matthias,

Quoted 30 lines · Matthias Kaehlcke
Quoted 28 lines · Balakrishna Godavarthi

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.

---
 .../bindings/net/qualcomm-bluetooth.txt       | 26
+++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt index 0ea18a53cc29..2175174415ee 100644

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3 -1
@@ -10,12 +10,22 @@ device the slave device is attached to.
 Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
+   * "qcom,wcn3990-bt"
+
+Optional properties for compatible string qcom,qca6174-bt:
 
-Optional properties:
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
Quoted 12 lines

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt device the slave device is attached to. · line 25

Quoted 7 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6 -1
-Example:
+Optional properties for compatible string qcom,wcn3990-bt:
+
+ - vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
+ - vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
+ - vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
+ - vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Are these really optional? If I understand correctly the driver expects the regulators to be there. Even if it could do with only some regulators specified the devm_regulator_bulk_get() call would fail if not all requested regulators are available.

yes they are required along with compatible string "qcom,wcn3990-bt". i have taken reference wrt compatible string "qcom,qca6174-bt". In which clocks and enable-gpios are required for driver to work, but it was written as optional in doc.

below snippet from hci_qca.c for qcom,qca6174-bt.

 if (IS_ERR(qcadev->bt_en)) {
       dev_err(&serdev->dev, "failed to acquire enable gpio\n");
       return PTR_ERR(qcadev->bt_en);
    }
Quoted 5 lines
  qcadev->susclk = devm_clk_get(&serdev->dev, NULL);
  if (IS_ERR(qcadev->susclk)) {
      dev_err(&serdev->dev, "failed to acquire clk\n");
       return PTR_ERR(qcadev->susclk);
     }

technically it is not correct then i will update as below

Required properties for compatible string qcom,wcn3990-bt:

- vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
- vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
- vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
- vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Quoted 5 lines

Optional properties for compatible string qcom,wcn3990-bt:

- max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt

are they above ok?

Looks good to me.

Optionally you could remove the 'Bluetooth wcn3990' part in the regulator description, it is a bit redundant since it's already said that these are properties for the 'Bluetooth wcn3990' compatible string.

#7 lore raw

Re: [PATCH v12 1/7] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990

Hi Matthias,

Quoted 85 lines · Matthias Kaehlcke
Quoted 76 lines · Balakrishna Godavarthi

Hi Matthias,

Quoted 58 lines · Balakrishna Godavarthi

Hi Matthias,

Quoted 30 lines · Matthias Kaehlcke
Quoted 28 lines · Balakrishna Godavarthi

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.

---
 .../bindings/net/qualcomm-bluetooth.txt       | 26
+++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt index 0ea18a53cc29..2175174415ee 100644

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3 -1
@@ -10,12 +10,22 @@ device the slave device is attached to.
 Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
+   * "qcom,wcn3990-bt"
+
+Optional properties for compatible string qcom,qca6174-bt:
 
-Optional properties:
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
Quoted 12 lines

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt device the slave device is attached to. · line 25

Quoted 7 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6 -1
-Example:
+Optional properties for compatible string qcom,wcn3990-bt:
+
+ - vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
+ - vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
+ - vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
+ - vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Are these really optional? If I understand correctly the driver expects the regulators to be there. Even if it could do with only some regulators specified the devm_regulator_bulk_get() call would fail if not all requested regulators are available.

yes they are required along with compatible string "qcom,wcn3990-bt". i have taken reference wrt compatible string "qcom,qca6174-bt". In which clocks and enable-gpios are required for driver to work, but it was written as optional in doc.

below snippet from hci_qca.c for qcom,qca6174-bt.

 if (IS_ERR(qcadev->bt_en)) {
       dev_err(&serdev->dev, "failed to acquire enable gpio\n");
       return PTR_ERR(qcadev->bt_en);
    }
Quoted 5 lines
  qcadev->susclk = devm_clk_get(&serdev->dev, NULL);
  if (IS_ERR(qcadev->susclk)) {
      dev_err(&serdev->dev, "failed to acquire clk\n");
       return PTR_ERR(qcadev->susclk);
     }

technically it is not correct then i will update as below

Required properties for compatible string qcom,wcn3990-bt:

- vddio-supply: Bluetooth wcn3990 VDD_IO supply regulator handle.
- vddxo-supply: Bluetooth wcn3990 VDD_XO supply regulator handle.
- vddrf-supply: Bluetooth wcn3990 VDD_RF supply regulator handle.
- vddch0-supply: Bluetooth wcn3990 VDD_CH0 supply regulator handle.

Quoted 6 lines

Optional properties for compatible string qcom,wcn3990-bt:

- max-speed: see
Documentation/devicetree/bindings/serial/slave-device.txt

are they above ok?

Quoted 6 lines

Looks good to me.

Optionally you could remove the 'Bluetooth wcn3990' part in the regulator description, it is a bit redundant since it's already said that these are properties for the 'Bluetooth wcn3990' compatible string.

Ok. will update the same.

Signature · 2 lines
Regards
Balakrishna.
#8 lore raw

PATCH v12 2/7 Bluetooth: btqca: Rename ROME specific functions to generic functions

In reply to Balakrishna Godavarthi

Some of the QCA BTSoC ROME functions, are used for different versions or different make of BTSoC's. Instead of duplicating the same functions for new chip, update names of the functions that are used for both chips to keep this generic and would help in future when we would have new BT SoC. To have generic text in logs updated from ROME to QCA where ever possible. This avoids confusion to user, when using the future Qualcomm Bluetooth SoC's. Updated BT_DBG, BT_ERR and BT_INFO with bt_dev_dbg, bt_dev_err and bt_dev_info where ever applicable.

---
 drivers/bluetooth/btqca.c   | 85 ++++++++++++++++++-------------------
 drivers/bluetooth/btqca.h   | 10 ++++-
 drivers/bluetooth/hci_qca.c |  2 +-
 3 files changed, 51 insertions(+), 46 deletions(-)
drivers/bluetooth/btqca.c +42 -43
index 8219816c54a0..c5cf9cab438a 100644
@@ -27,7 +27,7 @@
 
 #define VERSION "0.1"
 
-static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
+int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
 {
 	struct sk_buff *skb;
 	struct edl_event_hdr *edl;
@@ -35,36 +35,35 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
 	char cmd;
 	int err = 0;
 
-	BT_DBG("%s: ROME Patch Version Request", hdev->name);
+	bt_dev_dbg(hdev, "QCA Version Request");
 
 	cmd = EDL_PATCH_VER_REQ_CMD;
 	skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
 				&cmd, HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
-		BT_ERR("%s: Failed to read version of ROME (%d)", hdev->name,
-		       err);
+		bt_dev_err(hdev, "Reading QCA version information failed (%d)",
+			   err);
 		return err;
 	}
 
 	if (skb->len != sizeof(*edl) + sizeof(*ver)) {
-		BT_ERR("%s: Version size mismatch len %d", hdev->name,
-		       skb->len);
+		bt_dev_err(hdev, "QCA Version size mismatch len %d", skb->len);
 		err = -EILSEQ;
 		goto out;
 	}
 
 	edl = (struct edl_event_hdr *)(skb->data);
 	if (!edl) {
-		BT_ERR("%s: TLV with no header", hdev->name);
+		bt_dev_err(hdev, "QCA TLV with no header");
 		err = -EILSEQ;
 		goto out;
 	}
 
 	if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
 	    edl->rtype != EDL_APP_VER_RES_EVT) {
-		BT_ERR("%s: Wrong packet received %d %d", hdev->name,
-		       edl->cresp, edl->rtype);
+		bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
+			   edl->rtype);
 		err = -EIO;
 		goto out;
 	}
@@ -76,11 +75,11 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
 	BT_DBG("%s: ROM    :0x%08x", hdev->name, le16_to_cpu(ver->rome_ver));
 	BT_DBG("%s: SOC    :0x%08x", hdev->name, le32_to_cpu(ver->soc_id));
 
-	/* ROME chipset version can be decided by patch and SoC
+	/* QCA chipset version can be decided by patch and SoC
 	 * version, combination with upper 2 bytes from SoC
 	 * and lower 2 bytes from patch will be used.
 	 */
-	*rome_version = (le32_to_cpu(ver->soc_id) << 16) |
+	*soc_version = (le32_to_cpu(ver->soc_id) << 16) |
 			(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
 
 out:
@@ -88,18 +87,19 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
 
 	return err;
 }
+EXPORT_SYMBOL_GPL(qca_read_soc_version);
 
-static int rome_reset(struct hci_dev *hdev)
+static int qca_send_reset(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
 	int err;
 
-	BT_DBG("%s: ROME HCI_RESET", hdev->name);
+	bt_dev_dbg(hdev, "QCA HCI_RESET");
 
 	skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
-		BT_ERR("%s: Reset failed (%d)", hdev->name, err);
+		bt_dev_err(hdev, "QCA Reset failed (%d)", err);
 		return err;
 	}
 
@@ -108,7 +108,7 @@ static int rome_reset(struct hci_dev *hdev)
 	return 0;
 }
 
-static void rome_tlv_check_data(struct rome_config *config,
+static void qca_tlv_check_data(struct rome_config *config,
 				const struct firmware *fw)
 {
 	const u8 *data;
@@ -207,7 +207,7 @@ static void rome_tlv_check_data(struct rome_config *config,
 	}
 }
 
-static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
+static int qca_tlv_send_segment(struct hci_dev *hdev, int seg_size,
 				 const u8 *data, enum rome_tlv_dnld_mode mode)
 {
 	struct sk_buff *skb;
@@ -228,19 +228,19 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
 				HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
-		BT_ERR("%s: Failed to send TLV segment (%d)", hdev->name, err);
+		bt_dev_err(hdev, "QCA Failed to send TLV segment (%d)", err);
 		return err;
 	}
 
 	if (skb->len != sizeof(*edl) + sizeof(*tlv_resp)) {
-		BT_ERR("%s: TLV response size mismatch", hdev->name);
+		bt_dev_err(hdev, "QCA TLV response size mismatch");
 		err = -EILSEQ;
 		goto out;
 	}
 
 	edl = (struct edl_event_hdr *)(skb->data);
 	if (!edl) {
-		BT_ERR("%s: TLV with no header", hdev->name);
+		bt_dev_err(hdev, "TLV with no header");
 		err = -EILSEQ;
 		goto out;
 	}
@@ -249,8 +249,8 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
 
 	if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
 	    edl->rtype != EDL_TVL_DNLD_RES_EVT || tlv_resp->result != 0x00) {
-		BT_ERR("%s: TLV with error stat 0x%x rtype 0x%x (0x%x)",
-		       hdev->name, edl->cresp, edl->rtype, tlv_resp->result);
+		bt_dev_err(hdev, "QCA TLV with error stat 0x%x rtype 0x%x (0x%x)",
+			   edl->cresp, edl->rtype, tlv_resp->result);
 		err = -EIO;
 	}
 
@@ -260,23 +260,23 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
 	return err;
 }
 
-static int rome_download_firmware(struct hci_dev *hdev,
+static int qca_download_firmware(struct hci_dev *hdev,
 				  struct rome_config *config)
 {
 	const struct firmware *fw;
 	const u8 *segment;
 	int ret, remain, i = 0;
 
-	bt_dev_info(hdev, "ROME Downloading %s", config->fwname);
+	bt_dev_info(hdev, "QCA Downloading %s", config->fwname);
 
 	ret = request_firmware(&fw, config->fwname, &hdev->dev);
 	if (ret) {
-		BT_ERR("%s: Failed to request file: %s (%d)", hdev->name,
-		       config->fwname, ret);
+		bt_dev_err(hdev, "QCA Failed to request file: %s (%d)",
+			   config->fwname, ret);
 		return ret;
 	}
 
-	rome_tlv_check_data(config, fw);
+	qca_tlv_check_data(config, fw);
 
 	segment = fw->data;
 	remain = fw->size;
@@ -290,7 +290,7 @@ static int rome_download_firmware(struct hci_dev *hdev,
 		if (!remain || segsize < MAX_SIZE_PER_TLV_SEGMENT)
 			config->dnld_mode = ROME_SKIP_EVT_NONE;
 
-		ret = rome_tlv_send_segment(hdev, segsize, segment,
+		ret = qca_tlv_send_segment(hdev, segsize, segment,
 					    config->dnld_mode);
 		if (ret)
 			break;
@@ -317,8 +317,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 				HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
-		BT_ERR("%s: Change address command failed (%d)",
-		       hdev->name, err);
+		bt_dev_err(hdev, "QCA Change address command failed (%d)", err);
 		return err;
 	}
 
@@ -328,32 +327,32 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
 
-int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)
+int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
 {
 	u32 rome_ver = 0;
 	struct rome_config config;
 	int err;
 
-	BT_DBG("%s: ROME setup on UART", hdev->name);
+	bt_dev_dbg(hdev, "QCA setup on UART");
 
 	config.user_baud_rate = baudrate;
 
-	/* Get ROME version information */
-	err = rome_patch_ver_req(hdev, &rome_ver);
+	/* Get QCA version information */
+	err = qca_read_soc_version(hdev, &rome_ver);
 	if (err < 0 || rome_ver == 0) {
-		BT_ERR("%s: Failed to get version 0x%x", hdev->name, err);
+		bt_dev_err(hdev, "QCA Failed to get version %d", err);
 		return err;
 	}
 
-	bt_dev_info(hdev, "ROME controller version 0x%08x", rome_ver);
+	bt_dev_info(hdev, "QCA controller version 0x%08x", rome_ver);
 
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
 	snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
 		 rome_ver);
-	err = rome_download_firmware(hdev, &config);
+	err = qca_download_firmware(hdev, &config);
 	if (err < 0) {
-		BT_ERR("%s: Failed to download patch (%d)", hdev->name, err);
+		bt_dev_err(hdev, "QCA Failed to download patch (%d)", err);
 		return err;
 	}
 
@@ -361,24 +360,24 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)
 	config.type = TLV_TYPE_NVM;
 	snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
 		 rome_ver);
-	err = rome_download_firmware(hdev, &config);
+	err = qca_download_firmware(hdev, &config);
 	if (err < 0) {
-		BT_ERR("%s: Failed to download NVM (%d)", hdev->name, err);
+		bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);
 		return err;
 	}
 
 	/* Perform HCI reset */
-	err = rome_reset(hdev);
+	err = qca_send_reset(hdev);
 	if (err < 0) {
-		BT_ERR("%s: Failed to run HCI_RESET (%d)", hdev->name, err);
+		bt_dev_err(hdev, "QCA Failed to run HCI_RESET (%d)", err);
 		return err;
 	}
 
-	bt_dev_info(hdev, "ROME setup on UART is completed");
+	bt_dev_info(hdev, "QCA setup on UART is completed");
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(qca_uart_setup_rome);
+EXPORT_SYMBOL_GPL(qca_uart_setup);
 
 MODULE_AUTHOR("Ben Young Tae Kim <[email protected]>");
 MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver " VERSION);
drivers/bluetooth/btqca.h +8 -2
index 13d77fd873b6..5c9851b11838 100644
@@ -127,7 +127,8 @@ struct tlv_type_hdr {
 #if IS_ENABLED(CONFIG_BT_QCA)
 
 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
-int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate);
+int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate);
+int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
 
 #else
 
@@ -136,7 +137,12 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad
 	return -EOPNOTSUPP;
 }
 
-static inline int qca_uart_setup_rome(struct hci_dev *hdev, int speed)
+static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
 {
 	return -EOPNOTSUPP;
 }
drivers/bluetooth/hci_qca.c +1 -1
index 51790dd02afb..d7b60669b656 100644
@@ -966,7 +966,7 @@ static int qca_setup(struct hci_uart *hu)
 	}
 
 	/* Setup patch / NVM configurations */
-	ret = qca_uart_setup_rome(hdev, qca_baudrate);
+	ret = qca_uart_setup(hdev, qca_baudrate);
 	if (!ret) {
 		set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
 		qca_debugfs_init(hdev);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#9 lore raw

PATCH v12 3/7 Bluetooth: btqca: Redefine qca_uart_setup() to generic function.

In reply to Balakrishna Godavarthi

Redefinition of qca_uart_setup will help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new arguments soc_type and soc_ver to the functions.

These arguments will help to decide type of firmware files to be loaded into Bluetooth chip.
soc_type holds the Bluetooth chip connected to APPS processor. soc_ver holds the Bluetooth chip version.

---
Changes in v12:
* updated soc_ver check.

Changes in v11:
* added error log in qca_read_soc_version() instead of qca_setup()

---
 drivers/bluetooth/btqca.c   | 21 ++++++++-------------
 drivers/bluetooth/btqca.h   | 13 +++++++++++--
 drivers/bluetooth/hci_qca.c | 10 +++++++++-
 3 files changed, 28 insertions(+), 16 deletions(-)
drivers/bluetooth/btqca.c +8 -13
index c5cf9cab438a..479179c54dcf 100644
@@ -81,9 +81,13 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
 	 */
 	*soc_version = (le32_to_cpu(ver->soc_id) << 16) |
 			(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
+	if (*soc_version == 0)
+		err = -EILSEQ;
 
 out:
 	kfree_skb(skb);
+	if (err)
+		bt_dev_err(hdev, "QCA Failed to get version (%d)", err);
 
 	return err;
 }
@@ -327,9 +331,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
 
-int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
+int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
+		   enum qca_btsoc_type soc_type, u32 soc_ver)
 {
-	u32 rome_ver = 0;
 	struct rome_config config;
 	int err;
 
@@ -337,19 +341,10 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
 
 	config.user_baud_rate = baudrate;
 
-	/* Get QCA version information */
-	err = qca_read_soc_version(hdev, &rome_ver);
-	if (err < 0 || rome_ver == 0) {
-		bt_dev_err(hdev, "QCA Failed to get version %d", err);
-		return err;
-	}
-
-	bt_dev_info(hdev, "QCA controller version 0x%08x", rome_ver);
-
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
 	snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
-		 rome_ver);
+		 soc_ver);
 	err = qca_download_firmware(hdev, &config);
 	if (err < 0) {
 		bt_dev_err(hdev, "QCA Failed to download patch (%d)", err);
@@ -359,7 +354,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
 	snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
-		 rome_ver);
+		 soc_ver);
 	err = qca_download_firmware(hdev, &config);
 	if (err < 0) {
 		bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);
drivers/bluetooth/btqca.h +11 -2
index 5c9851b11838..a9c2779f3e07 100644
@@ -124,10 +124,18 @@ struct tlv_type_hdr {
 	__u8   data[0];
 } __packed;
 
+enum qca_btsoc_type {
+	QCA_INVALID = -1,
+	QCA_AR3002,
+	QCA_ROME,
+	QCA_WCN3990
+};
+
 #if IS_ENABLED(CONFIG_BT_QCA)
 
 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
-int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate);
+int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
+		   enum qca_btsoc_type soc_type, u32 soc_ver);
 int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
 
 #else
@@ -137,7 +145,8 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad
 	return -EOPNOTSUPP;
 }
 
-static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
+static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
+				 enum qca_btsoc_type soc_type, u32 soc_ver)
 {
 	return -EOPNOTSUPP;
 }
drivers/bluetooth/hci_qca.c +9 -1
index d7b60669b656..5f1c0a8fd5cd 100644
@@ -929,6 +929,7 @@ static int qca_setup(struct hci_uart *hu)
 	struct qca_data *qca = hu->priv;
 	unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
 	int ret;
+	int soc_ver = 0;
 
 	bt_dev_info(hdev, "ROME setup");
 
@@ -965,8 +966,15 @@ static int qca_setup(struct hci_uart *hu)
 		host_set_baudrate(hu, speed);
 	}
 
+	/* Get QCA version information */
+	ret = qca_read_soc_version(hdev, &soc_ver);
+	if (ret)
+		return ret;
+
+	bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver);
+
 	/* Setup patch / NVM configurations */
-	ret = qca_uart_setup(hdev, qca_baudrate);
+	ret = qca_uart_setup(hdev, qca_baudrate, QCA_ROME, soc_ver);
 	if (!ret) {
 		set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
 		qca_debugfs_init(hdev);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#10 lore raw

PATCH v12 4/7 Bluetooth: hci_qca: Add wrapper functions for setting UART speed

In reply to Balakrishna Godavarthi

In function qca_setup, we set initial and operating speeds for Qualcomm Bluetooth SoC's. This block of code is common across different Qualcomm Bluetooth SoC's. Instead of duplicating the code, created a wrapper function to set the speeds. So that future coming SoC's can use these wrapper functions to set speeds.

---
 drivers/bluetooth/hci_qca.c | 93 ++++++++++++++++++++++++++++---------
 1 file changed, 70 insertions(+), 23 deletions(-)
drivers/bluetooth/hci_qca.c +70 -23
index 5f1c0a8fd5cd..5f8a74d65bec 100644
@@ -119,6 +119,11 @@ struct qca_data {
 	u64 votes_off;
 };
 
+enum qca_speed_type {
+	QCA_INIT_SPEED = 1,
+	QCA_OPER_SPEED
+};
+
 struct qca_serdev {
 	struct hci_uart	 serdev_hu;
 	struct gpio_desc *bt_en;
@@ -923,6 +928,61 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)
 		hci_uart_set_baudrate(hu, speed);
 }
 
+static unsigned int qca_get_speed(struct hci_uart *hu,
+				  enum qca_speed_type speed_type)
+{
+	unsigned int speed = 0;
+
+	if (speed_type == QCA_INIT_SPEED) {
+		if (hu->init_speed)
+			speed = hu->init_speed;
+		else if (hu->proto->init_speed)
+			speed = hu->proto->init_speed;
+	} else {
+		if (hu->oper_speed)
+			speed = hu->oper_speed;
+		else if (hu->proto->oper_speed)
+			speed = hu->proto->oper_speed;
+	}
+
+	return speed;
+}
+
+static int qca_check_speeds(struct hci_uart *hu)
+{
+	if (!qca_get_speed(hu, QCA_INIT_SPEED) ||
+	    !qca_get_speed(hu, QCA_OPER_SPEED))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
+{
+	unsigned int speed, qca_baudrate;
+	int ret;
+
+	if (speed_type == QCA_INIT_SPEED) {
+		speed = qca_get_speed(hu, QCA_INIT_SPEED);
+		if (speed)
+			host_set_baudrate(hu, speed);
+	} else {
+		speed = qca_get_speed(hu, QCA_OPER_SPEED);
+		if (!speed)
+			return 0;
+
+		qca_baudrate = qca_get_baudrate_value(speed);
+		bt_dev_info(hu->hdev, "Set UART speed to %d", speed);
+		ret = qca_set_baudrate(hu->hdev, qca_baudrate);
+		if (ret)
+			return ret;
+
+		host_set_baudrate(hu, speed);
+	}
+
+	return 0;
+}
+
 static int qca_setup(struct hci_uart *hu)
 {
 	struct hci_dev *hdev = hu->hdev;
@@ -933,37 +993,24 @@ static int qca_setup(struct hci_uart *hu)
 
 	bt_dev_info(hdev, "ROME setup");
 
+	ret = qca_check_speeds(hu);
+	if (ret)
+		return ret;
+
 	/* Patch downloading has to be done without IBS mode */
 	clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
 
 	/* Setup initial baudrate */
-	speed = 0;
-	if (hu->init_speed)
-		speed = hu->init_speed;
-	else if (hu->proto->init_speed)
-		speed = hu->proto->init_speed;
-
-	if (speed)
-		host_set_baudrate(hu, speed);
+	qca_set_speed(hu, QCA_INIT_SPEED);
 
 	/* Setup user speed if needed */
-	speed = 0;
-	if (hu->oper_speed)
-		speed = hu->oper_speed;
-	else if (hu->proto->oper_speed)
-		speed = hu->proto->oper_speed;
-
+	speed = qca_get_speed(hu, QCA_OPER_SPEED);
 	if (speed) {
-		qca_baudrate = qca_get_baudrate_value(speed);
-
-		bt_dev_info(hdev, "Set UART speed to %d", speed);
-		ret = qca_set_baudrate(hdev, qca_baudrate);
-		if (ret) {
-			bt_dev_err(hdev, "Failed to change the baud rate (%d)",
-				   ret);
+		ret = qca_set_speed(hu, QCA_OPER_SPEED);
+		if (ret)
 			return ret;
-		}
-		host_set_baudrate(hu, speed);
+
+		qca_baudrate = qca_get_baudrate_value(speed);
 	}
 
 	/* Get QCA version information */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#11 lore raw

PATCH v12 5/7 Bluetooth: hci_qca: Enable 3.2 Mbps operating speed.

In reply to Balakrishna Godavarthi

Enable Qualcomm chips to operate at 3.2Mbps.

---
 drivers/bluetooth/hci_qca.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +3 -1
index 5f8a74d65bec..a6e7d38ef931 100644
@@ -877,6 +877,8 @@ static uint8_t qca_get_baudrate_value(int speed)
 		return QCA_BAUDRATE_2000000;
 	case 3000000:
 		return QCA_BAUDRATE_3000000;
+	case 3200000:
+		return QCA_BAUDRATE_3200000;
 	case 3500000:
 		return QCA_BAUDRATE_3500000;
 	default:
@@ -891,7 +893,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	struct sk_buff *skb;
 	u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 };
 
-	if (baudrate > QCA_BAUDRATE_3000000)
+	if (baudrate > QCA_BAUDRATE_3200000)
 		return -EINVAL;
 
 	cmd[4] = baudrate;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#12 lore raw

PATCH v12 6/7 Bluetooth: btqca: Add wcn3990 firmware download support.

In reply to Balakrishna Godavarthi

This patch enables the RAM and NV patch download for wcn3990.

---
 drivers/bluetooth/btqca.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/bluetooth/btqca.c +21 -4
index 479179c54dcf..488f5e7521dd 100644
@@ -336,6 +336,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 {
 	struct rome_config config;
 	int err;
+	u8 rom_ver;
 
 	bt_dev_dbg(hdev, "QCA setup on UART");
 
@@ -343,8 +344,19 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
-	snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
-		 soc_ver);
+	if (soc_type == QCA_WCN3990) {
+		/* Firmware files to download are based on ROM version.
+		 * ROM version is derived from last two bytes of soc_ver.
+		 */
+		rom_ver = ((soc_ver & 0x00000f00) >> 0x04) |
+			    (soc_ver & 0x0000000f);
+		snprintf(config.fwname, sizeof(config.fwname),
+			 "qca/crbtfw%02x.tlv", rom_ver);
+	} else {
+		snprintf(config.fwname, sizeof(config.fwname),
+			 "qca/rampatch_%08x.bin", soc_ver);
+	}
+
 	err = qca_download_firmware(hdev, &config);
 	if (err < 0) {
 		bt_dev_err(hdev, "QCA Failed to download patch (%d)", err);
@@ -353,8 +365,13 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
-	snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
-		 soc_ver);
+	if (soc_type == QCA_WCN3990)
+		snprintf(config.fwname, sizeof(config.fwname),
+			 "qca/crnv%02x.bin", rom_ver);
+	else
+		snprintf(config.fwname, sizeof(config.fwname),
+			 "qca/nvm_%08x.bin", soc_ver);
+
 	err = qca_download_firmware(hdev, &config);
 	if (err < 0) {
 		bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#13 lore raw

PATCH v12 7/7 Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990

In reply to Balakrishna Godavarthi

Add support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.

---
Changes in v12:
* removed retrying iteration loop in qca_wcn3990_init.

Changes in v11:
* removed support to read regulator currents from dts.
* updated review comments.

Changes in v10:
* added support to read regulator currents from dts.
* added support to try to connect with chip if it fails to respond to initial commands
* updated review comments.

changes in v9:
* moved flow control to vendor and set_baudarte functions.
* removed parent regs.

changes in v8:
* closing qca buffer, if qca_power_setup fails
* chnaged ibs start timer function call location.
* updated review comments.

changes in v7:
* addressed review comments.

changes in v6:
* Hooked up qca_power to qca_serdev.
* renamed all the naming inconsistency functions with qca_*
* leveraged common code of ROME for wcn3990.
* created wrapper functions for re-usable blocks.
* updated function of _*regulator_enable and _*regualtor_disable.
* removed redundant comments and functions.
* addressed review comments.

Changes in v5:
* updated regulator vddpa min_uV to 1304000.
* addressed review comments.

Changes in v4:
* Segregated the changes of btqca from hci_qca
* rebased all changes on top of bluetooth-next.
* addressed review comments.

---
 drivers/bluetooth/btqca.h   |   3 +
 drivers/bluetooth/hci_qca.c | 404 +++++++++++++++++++++++++++++++-----
 2 files changed, 360 insertions(+), 47 deletions(-)
drivers/bluetooth/btqca.h +3 -0
index a9c2779f3e07..0c01f375fe83 100644
@@ -37,6 +37,9 @@
 #define EDL_TAG_ID_HCI			(17)
 #define EDL_TAG_ID_DEEP_SLEEP		(27)
 
+#define QCA_WCN3990_POWERON_PULSE	0xFC
+#define QCA_WCN3990_POWEROFF_PULSE	0xC0
+
 enum qca_bardrate {
 	QCA_BAUDRATE_115200 	= 0,
 	QCA_BAUDRATE_57600,
drivers/bluetooth/hci_qca.c +357 -47

554 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v12 7/7
#14 lore raw

Re: [PATCH v12 7/7] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990

Hi Balakrishna,

only two minor comments, though I hate to make you respin once more for nits. I also noticed a possible error in the DT bindings, so maybe you'd have to respin anyway ...

Quoted 99 lines · Balakrishna Godavarthi

Add support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.

---
Changes in v12:
* removed retrying iteration loop in qca_wcn3990_init.

Changes in v11:
* removed support to read regulator currents from dts.
* updated review comments.

Changes in v10:
* added support to read regulator currents from dts.
* added support to try to connect with chip if it fails to respond to initial commands
* updated review comments.

changes in v9:
* moved flow control to vendor and set_baudarte functions.
* removed parent regs.

changes in v8:
* closing qca buffer, if qca_power_setup fails
* chnaged ibs start timer function call location.
* updated review comments.

changes in v7:
* addressed review comments.

changes in v6:
* Hooked up qca_power to qca_serdev.

* renamed all the naming inconsistency functions with qca_*
* leveraged common code of ROME for wcn3990.
* created wrapper functions for re-usable blocks.
* updated function of _*regulator_enable and _*regualtor_disable.
* removed redundant comments and functions.
* addressed review comments.

Changes in v5:
* updated regulator vddpa min_uV to 1304000.
* addressed review comments.

Changes in v4:
* Segregated the changes of btqca from hci_qca
* rebased all changes on top of bluetooth-next.
* addressed review comments.

---
 drivers/bluetooth/btqca.h   |   3 +
 drivers/bluetooth/hci_qca.c | 404 +++++++++++++++++++++++++++++++-----
 2 files changed, 360 insertions(+), 47 deletions(-)
drivers/bluetooth/btqca.h +3 -0
index a9c2779f3e07..0c01f375fe83 100644
@@ -37,6 +37,9 @@
 #define EDL_TAG_ID_HCI			(17)
 #define EDL_TAG_ID_DEEP_SLEEP		(27)
 
+#define QCA_WCN3990_POWERON_PULSE	0xFC
+#define QCA_WCN3990_POWEROFF_PULSE	0xC0
+
 enum qca_bardrate {
 	QCA_BAUDRATE_115200 	= 0,
 	QCA_BAUDRATE_57600,
drivers/bluetooth/hci_qca.c +25 -0
index a6e7d38ef931..24ce42babe6d 100644
 
...
 
+static int qca_wcn3990_init(struct hci_uart *hu, u32 *soc_ver)
+{
+	struct hci_dev *hdev = hu->hdev;
+	int ret;
+
+	/* Forcefully enable wcn3990 to enter in to boot mode. */
+	host_set_baudrate(hu, 2400);
+	ret = qca_send_power_pulse(hdev, QCA_WCN3990_POWEROFF_PULSE);
+	if (ret)
+		return ret;
+
+	qca_set_speed(hu, QCA_INIT_SPEED);
+	ret = qca_send_power_pulse(hdev, QCA_WCN3990_POWERON_PULSE);
+	if (ret)
+		return ret;
+
+	/* Wait for 100 ms for SoC to boot */
+	msleep(100);
+
+	/* Now the device is in ready state to communicate with host.
+	 * To sync host with device we need to reopen port.
+	 * Without this, we will have RTS and CTS synchronization
+	 * issues.
+	 */
+	serdev_device_close(hu->serdev);

drivers/bluetooth/hci_qca.c static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) · line 1135

Quoted 10 lines
drivers/bluetooth/hci_qca.c +10 -0
+	ret = serdev_device_open(hu->serdev);
+	if (ret) {
+		bt_dev_err(hu->hdev, "failed to open port");
+		return ret;
+	}
+
+	hci_uart_set_flow_control(hu, false);
+	ret = qca_read_soc_version(hdev, soc_ver);
+
+	return ret;

return qca_read_soc_version(hdev, soc_ver);

Quoted 7 lines
drivers/bluetooth/hci_qca.c +7 -0
+static int qca_power_setup(struct hci_uart *hu, bool on)
+{
+	struct qca_vreg *vregs;
+	struct regulator_bulk_data *vreg_bulk;
+	struct qca_serdev *qcadev;
+	int i, num_vregs, ret = 0;
+

drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1288

Quoted 10 lines
drivers/bluetooth/hci_qca.c +10 -0
+	qcadev = serdev_device_get_drvdata(hu->serdev);
+	if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_data ||
+	    !qcadev->bt_power->vreg_bulk)
+		return -EINVAL;
+
+	vregs = qcadev->bt_power->vreg_data->vregs;
+	vreg_bulk = qcadev->bt_power->vreg_bulk;
+	num_vregs = qcadev->bt_power->vreg_data->num_vregs;
+	BT_DBG("on: %d", on);
+	if (on  && !qcadev->bt_power->vregs_on) {

Remove extra blank after 'on'

Other than that:

Thanks for following through!