Skip to contentSkip to conversation

Enable Bluetooth functionality for wcn3998.

PATCH Superseded Harish Bandi 2 participants 5 messages Mar 7, 2019 – Mar 8, 2019

Subsystems (5)

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

cover Enable Bluetooth functionality for wcn3998.

This patch series we add support for wcn3998 BT chip set. This new chipset 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 are leveraging the existing code of wcn3990 along with readiing the voltages from the dts file.

Harish Bandi (2):
Bluetooth: hci_qca: Added support to read the regulator values from
DTS
dt-bindings: net: bluetooth: Add device tree bindings for QTI chip

    wcn3990
 .../devicetree/bindings/net/qualcomm-bluetooth.txt | 12 ++++
 drivers/bluetooth/hci_qca.c                        | 76 +++++++++++++++++++---
 2 files changed, 80 insertions(+), 8 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 1/2 Bluetooth: hci_qca: Added support to read the regulator values from DTS

wcn3990 as base chip. based on wcn3990 we have multiple bt chip sets, with enhanced power numbers. So every chip set will have its own power numbers, but the functionality is same as wcn3990. With this change we read the regulator values from DTS in driver initialization time. While initializing the regulators, it will set the those current and voltage values. If no values set in DTS, it will read the default values and set those values only. This change will help in supporting multiple platforms.

---
 drivers/bluetooth/hci_qca.c | 76 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 68 insertions(+), 8 deletions(-)
drivers/bluetooth/hci_qca.c +68 -8
index 237aea3..402336a7 100644
@@ -155,7 +155,7 @@ struct qca_vreg_data {
  */
 struct qca_power {
 	struct device *dev;
-	const struct qca_vreg_data *vreg_data;
+	struct qca_vreg_data *vreg_data;
 	struct regulator_bulk_data *vreg_bulk;
 	bool vregs_on;
 };
@@ -1387,10 +1387,48 @@ static int qca_power_setup(struct hci_uart *hu, bool on)
 	return ret;
 }
 
+/*
+ * Read function to get the voltage and current values
+ * for regulators from DTS.
+ */
+static void qca_regulator_get_voltage_current(struct device *dev,
+				      struct qca_vreg *vregs)
+{
+	char prop_name[32]; /* 32 is max size of property name */
+
+	snprintf(prop_name, 32, "%s-current", vregs->name);
+	BT_DBG("Looking up %s from device tree\n", prop_name);
+
+	if (device_property_read_bool(dev, prop_name))
+		device_property_read_u32(dev, prop_name, &vregs->load_uA);
+
+	snprintf(prop_name, 32, "%s-min-voltage", vregs->name);
+	BT_DBG("Looking up %s from device tree\n", prop_name);
+
+	if (device_property_read_bool(dev, prop_name))
+		device_property_read_u32(dev, prop_name, &vregs->min_uV);
+
+	snprintf(prop_name, 32, "%s-max-voltage", vregs->name);
+	BT_DBG("Looking up %s from device tree\n", prop_name);
+
+	if (device_property_read_bool(dev, prop_name))
+		device_property_read_u32(dev, prop_name, &vregs->max_uV);
+
+	BT_DBG("current %duA selected for regulator %s", vregs->load_uA,
+		vregs->name);
+	BT_DBG("min voltage %duA selected for regulator %s", vregs->min_uV,
+		vregs->name);
+	BT_DBG("max voltage %duA selected for regulator %s", vregs->max_uV,
+		vregs->name);
+}
+
 static int qca_init_regulators(struct qca_power *qca,
-				const struct qca_vreg *vregs, size_t num_vregs)
+				const struct qca_vreg_data *data)
 {
-	int i;
+	int i, num_vregs;
+	int load_uA;
+
+	num_vregs = data->num_vregs;
 
 	qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs,
 				      sizeof(struct regulator_bulk_data),
@@ -1398,8 +1436,32 @@ static int qca_init_regulators(struct qca_power *qca,
 	if (!qca->vreg_bulk)
 		return -ENOMEM;
 
-	for (i = 0; i < num_vregs; i++)
-		qca->vreg_bulk[i].supply = vregs[i].name;
+	qca->vreg_data = devm_kzalloc(qca->dev, sizeof(struct qca_vreg_data),
+				      GFP_KERNEL);
+	if (!qca->vreg_data)
+		return -ENOMEM;
+
+	qca->vreg_data->num_vregs = num_vregs;
+
+	qca->vreg_data->vregs = devm_kzalloc(qca->dev, num_vregs *
+				      sizeof(struct qca_vreg_data),
+				      GFP_KERNEL);
+
+	if (!qca->vreg_data->vregs)
+		return -ENOMEM;
+
+	for (i = 0; i < num_vregs; i++) {
+		/* copy regulator name, min voltage, max voltage */
+		qca->vreg_data->vregs[i].name = data->vregs[i].name;
+		qca->vreg_data->vregs[i].min_uV = data->vregs[i].min_uV;
+		qca->vreg_data->vregs[i].max_uV = data->vregs[i].max_uV;
+		load_uA = data->vregs[i].load_uA;
+		qca->vreg_data->vregs[i].load_uA = load_uA;
+		qca_regulator_get_voltage_current(qca->dev,
+			&qca->vreg_data->vregs[i]);
+
+		qca->vreg_bulk[i].supply = qca->vreg_data->vregs[i].name;
+	}
 
 	return devm_regulator_bulk_get(qca->dev, num_vregs, qca->vreg_bulk);
 }
@@ -1426,9 +1488,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 			return -ENOMEM;
 
 		qcadev->bt_power->dev = &serdev->dev;
-		qcadev->bt_power->vreg_data = data;
-		err = qca_init_regulators(qcadev->bt_power, data->vregs,
-					  data->num_vregs);
+		err = qca_init_regulators(qcadev->bt_power, data);
 		if (err) {
 			BT_ERR("Failed to init regulators:%d", err);
 			goto out;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw

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

In reply to Harish Bandi

This patch enables regulators for the Qualcomm Bluetooth wcn3990 controller.
Added entry for regulator currents, min and max voltages

---
 Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +12 -0
index 824c0e2..6aed68e 100644
@@ -50,6 +50,18 @@ serial@898000 {
 		vddxo-supply = <&vreg_l7a_1p8>;
 		vddrf-supply = <&vreg_l17a_1p3>;
 		vddch0-supply = <&vreg_l25a_3p3>;
+		vddio-current = <15000>;
+		vddxo-current = <80000>;
+		vddrf-current = <300000>;
+		vddch0-current = <450000>;
+		vddio-min-voltage = <1800000>;
+		vddxo-min-voltage = <1800000>;
+		vddrf-min-voltage = <1300000>;
+		vddch0-min-voltage = <3300000>;
+		vddio-max-voltage = <1900000>;
+		vddxo-max-voltage = <1900000>;
+		vddrf-max-voltage = <1350000>;
+		vddch0-max-voltage = <3400000>;
 		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
In reply to Harish Bandi

+ device tree folks

Quoted 5 lines · Harish Bandi

This patch series we add support for wcn3998 BT chip set. This new chipset 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 are leveraging the existing code of wcn3990 along with readiing the voltages from the dts file.

About how many different variants are we talking?

Couldn't you just use a different compatible string for each variant and specify the voltage/current limits in the hci_qca.c driver, as currently done for the WCN3990? I understand that it requires touching the driver for each new variant, but it might be preferable to specify these static values in a single location, instead of repeating them in the DT snippets of every device that uses such a controller, with the possiblity of configuration errors.

The DT folks can probably provide guidance on what is typically done in cases like this.

Thanks

Matthias

#4 lore raw

Hi Mathias,

Quoted 10 lines · Matthias Kaehlcke

+ device tree folks

Quoted 5 lines · Harish Bandi

This patch series we add support for wcn3998 BT chip set. This new chipset 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 are leveraging the existing code of wcn3990 along with readiing the voltages from the dts file.

About how many different variants are we talking?

[Harish] As of now we are seeing 2 more variants based on wcn3990

Quoted 9 lines

Couldn't you just use a different compatible string for each variant and specify the voltage/current limits in the hci_qca.c driver, as currently done for the WCN3990? I understand that it requires touching the driver for each new variant, but it might be preferable to specify these static values in a single location, instead of repeating them in the DT snippets of every device that uses such a controller, with the possiblity of configuration errors.

[Harish] Insight of coming chip sets based on wcn3990, for now we are adding new compatible in hci_qca.c driver itself with compatible name as QCA_WCN3998.But in future if we have more variants based on same chip set wcn3990. It may be good to have it in DTS.
For now we will provide the updated patch with new compatible and let's continue to discuss with DT folks for their view on these cases.

Quoted 6 lines

The DT folks can probably provide guidance on what is typically done in cases like this.

Thanks

Matthias