Skip to contentSkip to conversation

Enable Bluetooth functionality for WCN3998.

PATCH Superseded Harish Bandi 4 participants 8 messages Apr 25, 2019

Subsystems (5)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover Enable Bluetooth functionality for WCN3998.

This patch series we add support for WCN3998 BT chip set. This new chip set is based from the WCN3990 with minimal power numbers. So here in this patch The major difference between wcn3990 and WCN3998 is only power numbers. where as init process and fw download is same with wcn3990.
So we add new compatible for WCN3998.
Removed the Reading of regulator values from dts.
Added new compatible for WCN3998.
Changes in V6:
Initialized rom_ver to 0 to fix compiler warning
Changed Commit text for DT patch
Changes in V6:
changed return value to false in the qca_is_wcn399x()stub Changes in V5:
changed is_qca_soc_type_wcn399x_family to
qca_is_wcn399x helper function
Moved the qca_is_wcn399x function to btqca.c
modified the DT document for wcn399x as per driver code
Changes in V4:
Added is_qca_soc_type_wcn399x_family helper function
to get the soc type is wcn399x or not.
Changes in V3:
updated to latest code base.

Harish Bandi (2):
Bluetooth: hci_qca: Added support for WCN3998
dt-bindings: net: bluetooth: Add device tree bindings for QTI chip

    WCN3998
 .../devicetree/bindings/net/qualcomm-bluetooth.txt |  5 +--
 drivers/bluetooth/btqca.c                          | 12 +++++--
 drivers/bluetooth/btqca.h                          |  8 ++++-
 drivers/bluetooth/hci_qca.c                        | 40 ++++++++++++++--------
 4 files changed, 45 insertions(+), 20 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 v7 1/2 Bluetooth: hci_qca: Added support for WCN3998

Added new compatible for WCN3998 and corresponding voltage and current values to WCN3998 compatible.
Changed driver code to support WCN3998

---
Changes in V7:
- Initialized rom_ver to 0 to fix compiler warning

---
 drivers/bluetooth/btqca.c   | 12 +++++++++---
 drivers/bluetooth/btqca.h   |  8 +++++++-
 drivers/bluetooth/hci_qca.c | 40 ++++++++++++++++++++++++++--------------
 3 files changed, 42 insertions(+), 18 deletions(-)
drivers/bluetooth/btqca.c +9 -3
index 6122685..495a52f 100644
@@ -336,7 +336,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 {
 	struct rome_config config;
 	int err;
-	u8 rom_ver;
+	u8 rom_ver = 0;
 
 	bt_dev_dbg(hdev, "QCA setup on UART");
 
@@ -344,7 +344,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		/* Firmware files to download are based on ROM version.
 		 * ROM version is derived from last two bytes of soc_ver.
 		 */
@@ -365,7 +365,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		snprintf(config.fwname, sizeof(config.fwname),
 			 "qca/crnv%02x.bin", rom_ver);
 	else
@@ -410,6 +410,12 @@ int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(qca_set_bdaddr);
 
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return ((soc_type == QCA_WCN3990) || (soc_type == QCA_WCN3998));
+}
+EXPORT_SYMBOL_GPL(qca_is_wcn399x);
+
 MODULE_AUTHOR("Ben Young Tae Kim <[email protected]>");
 MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver " VERSION);
 MODULE_VERSION(VERSION);
drivers/bluetooth/btqca.h +7 -1
index 6fdc25d..0f68c9e7 100644
@@ -132,7 +132,8 @@ enum qca_btsoc_type {
 	QCA_INVALID = -1,
 	QCA_AR3002,
 	QCA_ROME,
-	QCA_WCN3990
+	QCA_WCN3990,
+	QCA_WCN3998,
 };
 
 #if IS_ENABLED(CONFIG_BT_QCA)
@@ -142,6 +143,7 @@ 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);
 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type);
 #else
 
 static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
@@ -165,4 +167,8 @@ static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 	return -EOPNOTSUPP;
 }
 
+static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return false;
+}
 #endif
drivers/bluetooth/hci_qca.c +26 -14
index 7f75652..c53ee8d 100644
@@ -521,7 +521,7 @@ static int qca_open(struct hci_uart *hu)
 	if (hu->serdev) {
 
 		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->btsoc_type != QCA_WCN3990) {
+		if (!qca_is_wcn399x(qcadev->btsoc_type)) {
 			gpiod_set_value_cansleep(qcadev->bt_en, 1);
 			/* Controller needs time to bootup. */
 			msleep(150);
@@ -629,7 +629,7 @@ static int qca_close(struct hci_uart *hu)
 
 	if (hu->serdev) {
 		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->btsoc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(qcadev->btsoc_type))
 			qca_power_shutdown(hu);
 		else
 			gpiod_set_value_cansleep(qcadev->bt_en, 0);
@@ -1011,7 +1011,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 		      msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
 
 	/* Give the controller time to process the request */
-	if (qca_soc_type(hu) == QCA_WCN3990)
+	if (qca_is_wcn399x(qca_soc_type(hu)))
 		msleep(10);
 	else
 		msleep(300);
@@ -1087,7 +1087,7 @@ static unsigned int qca_get_speed(struct hci_uart *hu,
 
 static int qca_check_speeds(struct hci_uart *hu)
 {
-	if (qca_soc_type(hu) == QCA_WCN3990) {
+	if (qca_is_wcn399x(qca_soc_type(hu))) {
 		if (!qca_get_speed(hu, QCA_INIT_SPEED) &&
 		    !qca_get_speed(hu, QCA_OPER_SPEED))
 			return -EINVAL;
@@ -1119,7 +1119,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
 		/* Disable flow control for wcn3990 to deassert RTS while
 		 * changing the baudrate of chip and host.
 		 */
-		if (soc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(soc_type))
 			hci_uart_set_flow_control(hu, true);
 
 		qca_baudrate = qca_get_baudrate_value(speed);
@@ -1131,7 +1131,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
 		host_set_baudrate(hu, speed);
 
 error:
-		if (soc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(soc_type))
 			hci_uart_set_flow_control(hu, false);
 	}
 
@@ -1204,7 +1204,7 @@ static int qca_setup(struct hci_uart *hu)
 	/* Patch downloading has to be done without IBS mode */
 	clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
 
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		bt_dev_info(hdev, "setting up wcn3990");
 
 		/* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute
@@ -1235,7 +1235,7 @@ static int qca_setup(struct hci_uart *hu)
 		qca_baudrate = qca_get_baudrate_value(speed);
 	}
 
-	if (soc_type != QCA_WCN3990) {
+	if (!qca_is_wcn399x(soc_type)) {
 		/* Get QCA version information */
 		ret = qca_read_soc_version(hdev, &soc_ver);
 		if (ret)
@@ -1260,7 +1260,7 @@ static int qca_setup(struct hci_uart *hu)
 	}
 
 	/* Setup bdaddr */
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		hu->hdev->set_bdaddr = qca_set_bdaddr;
 	else
 		hu->hdev->set_bdaddr = qca_set_bdaddr_rome;
@@ -1283,7 +1283,7 @@ static int qca_setup(struct hci_uart *hu)
 	.dequeue	= qca_dequeue,
 };
 
-static const struct qca_vreg_data qca_soc_data = {
+static const struct qca_vreg_data qca_soc_data_wcn3990 = {
 	.soc_type = QCA_WCN3990,
 	.vregs = (struct qca_vreg []) {
 		{ "vddio",   1800000, 1900000,  15000  },
@@ -1294,6 +1294,17 @@ static int qca_setup(struct hci_uart *hu)
 	.num_vregs = 4,
 };
 
+static const struct qca_vreg_data qca_soc_data_wcn3998 = {
+	.soc_type = QCA_WCN3998,
+	.vregs = (struct qca_vreg []) {
+		{ "vddio",   1800000, 1900000,  10000  },
+		{ "vddxo",   1800000, 1900000,  80000  },
+		{ "vddrf",   1300000, 1352000,  300000 },
+		{ "vddch0",  3300000, 3300000,  450000 },
+	},
+	.num_vregs = 4,
+};
+
 static void qca_power_shutdown(struct hci_uart *hu)
 {
 	struct qca_data *qca = hu->priv;
@@ -1427,8 +1438,8 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 	qcadev->serdev_hu.serdev = serdev;
 	data = of_device_get_match_data(&serdev->dev);
 	serdev_device_set_drvdata(serdev, qcadev);
-	if (data && data->soc_type == QCA_WCN3990) {
-		qcadev->btsoc_type = QCA_WCN3990;
+	if (data && qca_is_wcn399x(data->soc_type)) {
+		qcadev->btsoc_type = data->soc_type;
 		qcadev->bt_power = devm_kzalloc(&serdev->dev,
 						sizeof(struct qca_power),
 						GFP_KERNEL);
@@ -1492,7 +1503,7 @@ static void qca_serdev_remove(struct serdev_device *serdev)
 {
 	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
 
-	if (qcadev->btsoc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(qcadev->btsoc_type))
 		qca_power_shutdown(&qcadev->serdev_hu);
 	else
 		clk_disable_unprepare(qcadev->susclk);
@@ -1502,7 +1513,8 @@ static void qca_serdev_remove(struct serdev_device *serdev)
 
 static const struct of_device_id qca_bluetooth_of_match[] = {
 	{ .compatible = "qcom,qca6174-bt" },
-	{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data},
+	{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990},
+	{ .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, qca_bluetooth_of_match);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#2 lore raw

Re: [PATCH v7 1/2] Bluetooth: hci_qca: Added support for WCN3998

Hi Harish,

Quoted 20 lines

Added new compatible for WCN3998 and corresponding voltage and current values to WCN3998 compatible.
Changed driver code to support WCN3998

---
Changes in V7:
- Initialized rom_ver to 0 to fix compiler warning
---

drivers/bluetooth/btqca.c   | 12 +++++++++---
drivers/bluetooth/btqca.h   |  8 +++++++-
drivers/bluetooth/hci_qca.c | 40 ++++++++++++++++++++++++++--------------
3 files changed, 42 insertions(+), 18 deletions(-)
drivers/bluetooth/btqca.c +0 -0
index 6122685..495a52f 100644

drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · line 339

Quoted 5 lines
drivers/bluetooth/btqca.c +1 -1
@@ -336,7 +336,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 {
 	struct rome_config config;
 	int err;
-	u8 rom_ver;
+	u8 rom_ver = 0;

what is this change for?

Quoted 21 lines
drivers/bluetooth/btqca.c +2 -2
 	bt_dev_dbg(hdev, "QCA setup on UART");
 
@@ -344,7 +344,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		/* Firmware files to download are based on ROM version.
 		 * ROM version is derived from last two bytes of soc_ver.
 		 */
@@ -365,7 +365,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		snprintf(config.fwname, sizeof(config.fwname),
 			 "qca/crnv%02x.bin", rom_ver);
 	else

drivers/bluetooth/btqca.c int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 415

Quoted 6 lines
drivers/bluetooth/btqca.c +3 -0
@@ -410,6 +410,12 @@ int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(qca_set_bdaddr);
 
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return ((soc_type == QCA_WCN3990) || (soc_type == QCA_WCN3998));

no () needed around soc_type = check.

drivers/bluetooth/btqca.c int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 418

Quoted 3 lines
drivers/bluetooth/btqca.c +3 -0
+}
+EXPORT_SYMBOL_GPL(qca_is_wcn399x);
+

Why is this exported. Make this an inline function in btqca.h.

Quoted 167 lines
drivers/bluetooth/btqca.c +0 -0
 MODULE_AUTHOR("Ben Young Tae Kim <[email protected]>");
 MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver " VERSION);
 MODULE_VERSION(VERSION);
drivers/bluetooth/btqca.h +7 -1
index 6fdc25d..0f68c9e7 100644
@@ -132,7 +132,8 @@ enum qca_btsoc_type {
 	QCA_INVALID = -1,
 	QCA_AR3002,
 	QCA_ROME,
-	QCA_WCN3990
+	QCA_WCN3990,
+	QCA_WCN3998,
 };
 
 #if IS_ENABLED(CONFIG_BT_QCA)
@@ -142,6 +143,7 @@ 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);
 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type);
 #else
 
 static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
@@ -165,4 +167,8 @@ static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 	return -EOPNOTSUPP;
 }
 
+static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return false;
+}
 #endif
drivers/bluetooth/hci_qca.c +5 -5
index 7f75652..c53ee8d 100644
@@ -521,7 +521,7 @@ static int qca_open(struct hci_uart *hu)
 	if (hu->serdev) {
 
 		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->btsoc_type != QCA_WCN3990) {
+		if (!qca_is_wcn399x(qcadev->btsoc_type)) {
 			gpiod_set_value_cansleep(qcadev->bt_en, 1);
 			/* Controller needs time to bootup. */
 			msleep(150);
@@ -629,7 +629,7 @@ static int qca_close(struct hci_uart *hu)
 
 	if (hu->serdev) {
 		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->btsoc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(qcadev->btsoc_type))
 			qca_power_shutdown(hu);
 		else
 			gpiod_set_value_cansleep(qcadev->bt_en, 0);
@@ -1011,7 +1011,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 		      msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
 
 	/* Give the controller time to process the request */
-	if (qca_soc_type(hu) == QCA_WCN3990)
+	if (qca_is_wcn399x(qca_soc_type(hu)))
 		msleep(10);
 	else
 		msleep(300);
@@ -1087,7 +1087,7 @@ static unsigned int qca_get_speed(struct hci_uart *hu,
 
 static int qca_check_speeds(struct hci_uart *hu)
 {
-	if (qca_soc_type(hu) == QCA_WCN3990) {
+	if (qca_is_wcn399x(qca_soc_type(hu))) {
 		if (!qca_get_speed(hu, QCA_INIT_SPEED) &&
 		    !qca_get_speed(hu, QCA_OPER_SPEED))
 			return -EINVAL;
@@ -1119,7 +1119,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
 		/* Disable flow control for wcn3990 to deassert RTS while
 		 * changing the baudrate of chip and host.
 		 */
-		if (soc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(soc_type))
 			hci_uart_set_flow_control(hu, true);
 
 		qca_baudrate = qca_get_baudrate_value(speed);
@@ -1131,7 +1131,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
 		host_set_baudrate(hu, speed);
 

error:

drivers/bluetooth/hci_qca.c +1 -1
-		if (soc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(soc_type))
			hci_uart_set_flow_control(hu, false);
	}
drivers/bluetooth/hci_qca.c +18 -7
@@ -1204,7 +1204,7 @@ static int qca_setup(struct hci_uart *hu)
 	/* Patch downloading has to be done without IBS mode */
 	clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
 
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		bt_dev_info(hdev, "setting up wcn3990");
 
 		/* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute
@@ -1235,7 +1235,7 @@ static int qca_setup(struct hci_uart *hu)
 		qca_baudrate = qca_get_baudrate_value(speed);
 	}
 
-	if (soc_type != QCA_WCN3990) {
+	if (!qca_is_wcn399x(soc_type)) {
 		/* Get QCA version information */
 		ret = qca_read_soc_version(hdev, &soc_ver);
 		if (ret)
@@ -1260,7 +1260,7 @@ static int qca_setup(struct hci_uart *hu)
 	}
 
 	/* Setup bdaddr */
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		hu->hdev->set_bdaddr = qca_set_bdaddr;
 	else
 		hu->hdev->set_bdaddr = qca_set_bdaddr_rome;
@@ -1283,7 +1283,7 @@ static int qca_setup(struct hci_uart *hu)
 	.dequeue	= qca_dequeue,
 };
 
-static const struct qca_vreg_data qca_soc_data = {
+static const struct qca_vreg_data qca_soc_data_wcn3990 = {
 	.soc_type = QCA_WCN3990,
 	.vregs = (struct qca_vreg []) {
 		{ "vddio",   1800000, 1900000,  15000  },
@@ -1294,6 +1294,17 @@ static int qca_setup(struct hci_uart *hu)
 	.num_vregs = 4,
 };
 
+static const struct qca_vreg_data qca_soc_data_wcn3998 = {
+	.soc_type = QCA_WCN3998,
+	.vregs = (struct qca_vreg []) {
+		{ "vddio",   1800000, 1900000,  10000  },
+		{ "vddxo",   1800000, 1900000,  80000  },
+		{ "vddrf",   1300000, 1352000,  300000 },
+		{ "vddch0",  3300000, 3300000,  450000 },
+	},
+	.num_vregs = 4,
+};
+
 static void qca_power_shutdown(struct hci_uart *hu)
 {
 	struct qca_data *qca = hu->priv;
@@ -1427,8 +1438,8 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 	qcadev->serdev_hu.serdev = serdev;
 	data = of_device_get_match_data(&serdev->dev);
 	serdev_device_set_drvdata(serdev, qcadev);
-	if (data && data->soc_type == QCA_WCN3990) {
-		qcadev->btsoc_type = QCA_WCN3990;
+	if (data && qca_is_wcn399x(data->soc_type)) {
+		qcadev->btsoc_type = data->soc_type;
 		qcadev->bt_power = devm_kzalloc(&serdev->dev,
 						sizeof(struct qca_power),
 						GFP_KERNEL);
@@ -1492,7 +1503,7 @@ static void qca_serdev_remove(struct serdev_device *serdev)
 {
 	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
 
-	if (qcadev->btsoc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(qcadev->btsoc_type))
 		qca_power_shutdown(&qcadev->serdev_hu);
 	else
 		clk_disable_unprepare(qcadev->susclk);

drivers/bluetooth/hci_qca.c static void qca_serdev_remove(struct serdev_device *serdev) · line 1520

Quoted 9 lines
drivers/bluetooth/hci_qca.c +2 -1
@@ -1502,7 +1513,8 @@ static void qca_serdev_remove(struct serdev_device *serdev)
 
 static const struct of_device_id qca_bluetooth_of_match[] = {
 	{ .compatible = "qcom,qca6174-bt" },
-	{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data},
+	{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990},
+	{ .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, qca_bluetooth_of_match);

Regards

Marcel

#3 lore raw

Re: [PATCH v7 1/2] Bluetooth: hci_qca: Added support for WCN3998

Hi Marcel,

Quoted 18 lines · Marcel Holtmann

Hi Harish,

Quoted 16 lines

Added new compatible for WCN3998 and corresponding voltage and current values to WCN3998 compatible.
Changed driver code to support WCN3998

---
Changes in V7:
- Initialized rom_ver to 0 to fix compiler warning
---

drivers/bluetooth/btqca.c   | 12 +++++++++---
drivers/bluetooth/btqca.h   |  8 +++++++-
drivers/bluetooth/hci_qca.c | 40 
++++++++++++++++++++++++++--------------
3 files changed, 42 insertions(+), 18 deletions(-)
Quoted 13 lines

drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t · line 340

Quoted 11 lines
drivers/bluetooth/btqca.c +1 -1
index 6122685..495a52f 100644
@@ -336,7 +336,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t 
 baudrate,
 {
 	struct rome_config config;
 	int err;
-	u8 rom_ver;
+	u8 rom_ver = 0;

what is this change for?

[Harish] - kbuild test robot gave compiler warning. So initialized. drivers/bluetooth/btqca.c:369:3: warning: 'rom_ver' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 28 lines
Quoted 28 lines
drivers/bluetooth/btqca.c +1 -1
 	bt_dev_dbg(hdev, "QCA setup on UART");
 
@@ -344,7 +344,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t 
 baudrate,
 
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		/* Firmware files to download are based on ROM version.
 		 * ROM version is derived from last two bytes of soc_ver.
		 */
drivers/bluetooth/btqca.c +1 -1
@@ -365,7 +365,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t 
 baudrate,
 
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		snprintf(config.fwname, sizeof(config.fwname),
 			 "qca/crnv%02x.bin", rom_ver);

else

drivers/bluetooth/btqca.c +0 -0
@@ -410,6 +410,12 @@ int qca_set_bdaddr(struct hci_dev *hdev, const 
 bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(qca_set_bdaddr);
 
Quoted 5 lines

drivers/bluetooth/btqca.c int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 415

Quoted 3 lines
drivers/bluetooth/btqca.c +3 -0
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return ((soc_type == QCA_WCN3990) || (soc_type == QCA_WCN3998));

no () needed around soc_type = check.

[Harish] - OK, will change it.

Quoted 6 lines

drivers/bluetooth/btqca.c int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 418

Quoted 4 lines
drivers/bluetooth/btqca.c +3 -0
+}
+EXPORT_SYMBOL_GPL(qca_is_wcn399x);
+

Why is this exported. Make this an inline function in btqca.h.

[Harish] - This was used in btqca.c also to check the soc_type

- if (soc_type == QCA_WCN3990) {

Quoted 193 lines
Quoted 188 lines
drivers/bluetooth/btqca.c +1 -0
+	if (qca_is_wcn399x(soc_type)) {
 

MODULE_AUTHOR("Ben Young Tae Kim <[email protected]>"); MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver " VERSION); MODULE_VERSION(VERSION);

drivers/bluetooth/btqca.h +3 -1
index 6fdc25d..0f68c9e7 100644
@@ -132,7 +132,8 @@ enum qca_btsoc_type {
 	QCA_INVALID = -1,
 	QCA_AR3002,
 	QCA_ROME,
-	QCA_WCN3990
+	QCA_WCN3990,
+	QCA_WCN3998,
 };
 
 #if IS_ENABLED(CONFIG_BT_QCA)
@@ -142,6 +143,7 @@ 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);
 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type);
 #else
 

static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)

drivers/bluetooth/btqca.h +4 -0
@@ -165,4 +167,8 @@ static inline int qca_set_bdaddr(struct hci_dev 
 *hdev, const bdaddr_t *bdaddr)
 	return -EOPNOTSUPP;
 }
 
+static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return false;
+}

#endif

drivers/bluetooth/hci_qca.c +3 -3
index 7f75652..c53ee8d 100644
@@ -521,7 +521,7 @@ static int qca_open(struct hci_uart *hu)
 	if (hu->serdev) {
 
 		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->btsoc_type != QCA_WCN3990) {
+		if (!qca_is_wcn399x(qcadev->btsoc_type)) {
 			gpiod_set_value_cansleep(qcadev->bt_en, 1);
 			/* Controller needs time to bootup. */
 			msleep(150);
@@ -629,7 +629,7 @@ static int qca_close(struct hci_uart *hu)
 
 	if (hu->serdev) {
 		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->btsoc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(qcadev->btsoc_type))
 			qca_power_shutdown(hu);
 		else
 			gpiod_set_value_cansleep(qcadev->bt_en, 0);
@@ -1011,7 +1011,7 @@ static int qca_set_baudrate(struct hci_dev 
 *hdev, uint8_t baudrate)
 		      msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
 
 	/* Give the controller time to process the request */
-	if (qca_soc_type(hu) == QCA_WCN3990)
+	if (qca_is_wcn399x(qca_soc_type(hu)))
 		msleep(10);
 	else
		msleep(300);
drivers/bluetooth/hci_qca.c +1 -1
@@ -1087,7 +1087,7 @@ static unsigned int qca_get_speed(struct 
 hci_uart *hu,
 
 static int qca_check_speeds(struct hci_uart *hu)
 {
-	if (qca_soc_type(hu) == QCA_WCN3990) {
+	if (qca_is_wcn399x(qca_soc_type(hu))) {
 		if (!qca_get_speed(hu, QCA_INIT_SPEED) &&
 		    !qca_get_speed(hu, QCA_OPER_SPEED))
			return -EINVAL;
drivers/bluetooth/hci_qca.c +1 -1
@@ -1119,7 +1119,7 @@ static int qca_set_speed(struct hci_uart *hu, 
 enum qca_speed_type speed_type)
 		/* Disable flow control for wcn3990 to deassert RTS while
 		 * changing the baudrate of chip and host.
 		 */
-		if (soc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(soc_type))
 			hci_uart_set_flow_control(hu, true);
 
		qca_baudrate = qca_get_baudrate_value(speed);
drivers/bluetooth/hci_qca.c +0 -0
@@ -1131,7 +1131,7 @@ static int qca_set_speed(struct hci_uart *hu, 
 enum qca_speed_type speed_type)
 		host_set_baudrate(hu, speed);
 

error:

drivers/bluetooth/hci_qca.c +1 -1
-		if (soc_type == QCA_WCN3990)
+		if (qca_is_wcn399x(soc_type))
			hci_uart_set_flow_control(hu, false);
	}
drivers/bluetooth/hci_qca.c +17 -6
@@ -1204,7 +1204,7 @@ static int qca_setup(struct hci_uart *hu)
 	/* Patch downloading has to be done without IBS mode */
 	clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
 
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		bt_dev_info(hdev, "setting up wcn3990");
 
 		/* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute
@@ -1235,7 +1235,7 @@ static int qca_setup(struct hci_uart *hu)
 		qca_baudrate = qca_get_baudrate_value(speed);
 	}
 
-	if (soc_type != QCA_WCN3990) {
+	if (!qca_is_wcn399x(soc_type)) {
 		/* Get QCA version information */
 		ret = qca_read_soc_version(hdev, &soc_ver);
 		if (ret)
@@ -1260,7 +1260,7 @@ static int qca_setup(struct hci_uart *hu)
 	}
 
 	/* Setup bdaddr */
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		hu->hdev->set_bdaddr = qca_set_bdaddr;
 	else
 		hu->hdev->set_bdaddr = qca_set_bdaddr_rome;
@@ -1283,7 +1283,7 @@ static int qca_setup(struct hci_uart *hu)
 	.dequeue	= qca_dequeue,
 };
 
-static const struct qca_vreg_data qca_soc_data = {
+static const struct qca_vreg_data qca_soc_data_wcn3990 = {
 	.soc_type = QCA_WCN3990,
 	.vregs = (struct qca_vreg []) {
 		{ "vddio",   1800000, 1900000,  15000  },
@@ -1294,6 +1294,17 @@ static int qca_setup(struct hci_uart *hu)
 	.num_vregs = 4,
 };
 
+static const struct qca_vreg_data qca_soc_data_wcn3998 = {
+	.soc_type = QCA_WCN3998,
+	.vregs = (struct qca_vreg []) {
+		{ "vddio",   1800000, 1900000,  10000  },
+		{ "vddxo",   1800000, 1900000,  80000  },
+		{ "vddrf",   1300000, 1352000,  300000 },
+		{ "vddch0",  3300000, 3300000,  450000 },
+	},
+	.num_vregs = 4,
+};
+
 static void qca_power_shutdown(struct hci_uart *hu)
 {
 	struct qca_data *qca = hu->priv;
@@ -1427,8 +1438,8 @@ static int qca_serdev_probe(struct serdev_device 
 *serdev)
 	qcadev->serdev_hu.serdev = serdev;
 	data = of_device_get_match_data(&serdev->dev);
 	serdev_device_set_drvdata(serdev, qcadev);
-	if (data && data->soc_type == QCA_WCN3990) {
-		qcadev->btsoc_type = QCA_WCN3990;
+	if (data && qca_is_wcn399x(data->soc_type)) {
+		qcadev->btsoc_type = data->soc_type;
 		qcadev->bt_power = devm_kzalloc(&serdev->dev,
 						sizeof(struct qca_power),
						GFP_KERNEL);
drivers/bluetooth/hci_qca.c +1 -1
@@ -1492,7 +1503,7 @@ static void qca_serdev_remove(struct 
 serdev_device *serdev)
 {
 	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
 
-	if (qcadev->btsoc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(qcadev->btsoc_type))
 		qca_power_shutdown(&qcadev->serdev_hu);
 	else
		clk_disable_unprepare(qcadev->susclk);
drivers/bluetooth/hci_qca.c +2 -1
@@ -1502,7 +1513,8 @@ static void qca_serdev_remove(struct 
 serdev_device *serdev)
 
 static const struct of_device_id qca_bluetooth_of_match[] = {
 	{ .compatible = "qcom,qca6174-bt" },
-	{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data},
+	{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990},
+	{ .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998},
 	{ /* sentinel */ }
 };
Quoted 1 line

MODULE_DEVICE_TABLE(of, qca_bluetooth_of_match);

Regards

Marcel

#4 lore raw

Re: [PATCH v7 1/2] Bluetooth: hci_qca: Added support for WCN3998

Quoted 72 lines · Harish Bandi

Hi Marcel,

Quoted 18 lines · Marcel Holtmann

Hi Harish,

Quoted 16 lines

Added new compatible for WCN3998 and corresponding voltage and current values to WCN3998 compatible.
Changed driver code to support WCN3998

---
Changes in V7:
- Initialized rom_ver to 0 to fix compiler warning
---

drivers/bluetooth/btqca.c   | 12 +++++++++---
drivers/bluetooth/btqca.h   |  8 +++++++-
drivers/bluetooth/hci_qca.c | 40
++++++++++++++++++++++++++--------------
3 files changed, 42 insertions(+), 18 deletions(-)
Quoted 13 lines

drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t · line 340

Quoted 11 lines
drivers/bluetooth/btqca.c +1 -1
index 6122685..495a52f 100644
@@ -336,7 +336,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t
 baudrate,
 {
 	struct rome_config config;
 	int err;
-	u8 rom_ver;
+	u8 rom_ver = 0;

what is this change for?

[Harish] - kbuild test robot gave compiler warning. So initialized. drivers/bluetooth/btqca.c:369:3: warning: 'rom_ver' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 28 lines
Quoted 28 lines
drivers/bluetooth/btqca.c +1 -1
 	bt_dev_dbg(hdev, "QCA setup on UART");
 
@@ -344,7 +344,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t
 baudrate,
 
 	/* Download rampatch file */
 	config.type = TLV_TYPE_PATCH;
-	if (soc_type == QCA_WCN3990) {
+	if (qca_is_wcn399x(soc_type)) {
 		/* Firmware files to download are based on ROM version.
 		 * ROM version is derived from last two bytes of soc_ver.
		 */
drivers/bluetooth/btqca.c +1 -1
@@ -365,7 +365,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t
 baudrate,
 
 	/* Download NVM configuration */
 	config.type = TLV_TYPE_NVM;
-	if (soc_type == QCA_WCN3990)
+	if (qca_is_wcn399x(soc_type))
 		snprintf(config.fwname, sizeof(config.fwname),
 			 "qca/crnv%02x.bin", rom_ver);

else

drivers/bluetooth/btqca.c +0 -0
@@ -410,6 +410,12 @@ int qca_set_bdaddr(struct hci_dev *hdev, const
 bdaddr_t *bdaddr)
 }
 EXPORT_SYMBOL_GPL(qca_set_bdaddr);
 
Quoted 5 lines

drivers/bluetooth/btqca.c int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 415

Quoted 3 lines
drivers/bluetooth/btqca.c +3 -0
+bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
+{
+	return ((soc_type == QCA_WCN3990) || (soc_type == QCA_WCN3998));

no () needed around soc_type = check.

Quoted 8 lines

[Harish] - OK, will change it.

Quoted 6 lines

drivers/bluetooth/btqca.c int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 418

Quoted 4 lines
drivers/bluetooth/btqca.c +3 -0
+}
+EXPORT_SYMBOL_GPL(qca_is_wcn399x);
+

Why is this exported. Make this an inline function in btqca.h.

[Harish] - This was used in btqca.c also to check the soc_type

true, but this is still possible with an inline function in btqca.h.

#5 lore raw

PATCH v7 2/2 dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3998

In reply to Harish Bandi

Add compatible string for the Qualcomm WCN3998 Bluetooth controller

---
Changes in V6:
- Changed Commit text

---
 Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3 -2
index 824c0e2..7ef6118 100644
@@ -11,20 +11,21 @@ Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
    * "qcom,wcn3990-bt"
+   * "qcom,wcn3998-bt"
 
 Optional properties for compatible string qcom,qca6174-bt:
 
  - enable-gpios: gpio specifier used to enable chip
  - clocks: clock provided to the controller (SUSCLK_32KHZ)
 
-Required properties for compatible string qcom,wcn3990-bt:
+Required properties for compatible string qcom,wcn399x-bt:
 
  - vddio-supply: VDD_IO supply regulator handle.
  - vddxo-supply: VDD_XO supply regulator handle.
  - vddrf-supply: VDD_RF supply regulator handle.
  - vddch0-supply: VDD_CH0 supply regulator handle.
 
-Optional properties for compatible string qcom,wcn3990-bt:
+Optional properties for compatible string qcom,wcn399x-bt:
 
  - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#6 lore raw

Re: [PATCH v7 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3998

Hi Harish,

Quoted 25 lines

Add compatible string for the Qualcomm WCN3998 Bluetooth controller

---
Changes in V6:
- Changed Commit text
---
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +1 -0
index 824c0e2..7ef6118 100644
@@ -11,20 +11,21 @@ Required properties:
 - compatible: should contain one of the following:
   * "qcom,qca6174-bt"
   * "qcom,wcn3990-bt"
+   * "qcom,wcn3998-bt"
 

Optional properties for compatible string qcom,qca6174-bt:

- enable-gpios: gpio specifier used to enable chip
- clocks: clock provided to the controller (SUSCLK_32KHZ)

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt Required properties: · line 28

Quoted 10 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +2 -2
-Required properties for compatible string qcom,wcn3990-bt:
+Required properties for compatible string qcom,wcn399x-bt:
 
 - vddio-supply: VDD_IO supply regulator handle.
 - vddxo-supply: VDD_XO supply regulator handle.
 - vddrf-supply: VDD_RF supply regulator handle.
 - vddch0-supply: VDD_CH0 supply regulator handle.
 
-Optional properties for compatible string qcom,wcn3990-bt:
+Optional properties for compatible string qcom,wcn399x-bt:

wasn’t the conclusion to _not_ use x things in compatible strings? I would personally prefer you list these two compatible strings separately. However I let Rob comment and Ack this if this is fine for him.

Regards

Marcel

maintainer Reviewed-by
#7 lore raw

Re: [PATCH v7 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3998

Quoted 35 lines · Marcel Holtmann

Hi Harish,

Quoted 33 lines

Add compatible string for the Qualcomm WCN3998 Bluetooth controller

---
Changes in V6:
- Changed Commit text
---
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +1 -0
index 824c0e2..7ef6118 100644
@@ -11,20 +11,21 @@ Required properties:
 - compatible: should contain one of the following:
   * "qcom,qca6174-bt"
   * "qcom,wcn3990-bt"
+   * "qcom,wcn3998-bt"
 

Optional properties for compatible string qcom,qca6174-bt:

- enable-gpios: gpio specifier used to enable chip
- clocks: clock provided to the controller (SUSCLK_32KHZ)

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

Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt Required properties: · line 28

Quoted 2 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +1 -1
-Optional properties for compatible string qcom,wcn3990-bt:
+Optional properties for compatible string qcom,wcn399x-bt:

wasn’t the conclusion to _not_ use x things in compatible strings? I would personally prefer you list these two compatible strings separately. However I let Rob comment and Ack this if this is fine for him.

It's fine for me as it isn't the actual string used.

Rob