linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998.
@ 2019-03-07 12:16 Harish Bandi
  2019-03-07 12:16 ` [PATCH v1 1/2] Bluetooth: hci_qca: Added support to read the regulator values from DTS Harish Bandi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Harish Bandi @ 2019-03-07 12:16 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
	bgodavar, anubhavg, 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. 


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(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/2] Bluetooth: hci_qca: Added support to read the regulator values from DTS
  2019-03-07 12:16 [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Harish Bandi
@ 2019-03-07 12:16 ` Harish Bandi
  2019-03-07 12:16 ` [PATCH v1 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990 Harish Bandi
  2019-03-07 19:18 ` [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Matthias Kaehlcke
  2 siblings, 0 replies; 5+ messages in thread
From: Harish Bandi @ 2019-03-07 12:16 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
	bgodavar, anubhavg, Harish Bandi

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.

Signed-off-by: Harish Bandi <c-hbandi@codeaurora.org>
---
 drivers/bluetooth/hci_qca.c | 76 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 68 insertions(+), 8 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 237aea3..402336a7 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -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;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
  2019-03-07 12:16 [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Harish Bandi
  2019-03-07 12:16 ` [PATCH v1 1/2] Bluetooth: hci_qca: Added support to read the regulator values from DTS Harish Bandi
@ 2019-03-07 12:16 ` Harish Bandi
  2019-03-07 19:18 ` [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Matthias Kaehlcke
  2 siblings, 0 replies; 5+ messages in thread
From: Harish Bandi @ 2019-03-07 12:16 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
	bgodavar, anubhavg, Harish Bandi

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

Signed-off-by: Harish Bandi <c-hbandi@codeaurora.org>
---
 Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
index 824c0e2..6aed68e 100644
--- a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
+++ b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
@@ -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>;
 	};
 };
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998.
  2019-03-07 12:16 [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Harish Bandi
  2019-03-07 12:16 ` [PATCH v1 1/2] Bluetooth: hci_qca: Added support to read the regulator values from DTS Harish Bandi
  2019-03-07 12:16 ` [PATCH v1 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990 Harish Bandi
@ 2019-03-07 19:18 ` Matthias Kaehlcke
  2019-03-08  6:39   ` c-hbandi
  2 siblings, 1 reply; 5+ messages in thread
From: Matthias Kaehlcke @ 2019-03-07 19:18 UTC (permalink / raw)
  To: Harish Bandi
  Cc: marcel, johan.hedberg, linux-kernel, linux-bluetooth, hemantg,
	linux-arm-msm, bgodavar, anubhavg, Rob Herring, Mark Rutland,
	devicetree

+ device tree folks

On Thu, Mar 07, 2019 at 05:46:50PM +0530, Harish Bandi wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998.
  2019-03-07 19:18 ` [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Matthias Kaehlcke
@ 2019-03-08  6:39   ` c-hbandi
  0 siblings, 0 replies; 5+ messages in thread
From: c-hbandi @ 2019-03-08  6:39 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: marcel, johan.hedberg, linux-kernel, linux-bluetooth, hemantg,
	linux-arm-msm, bgodavar, anubhavg, Rob Herring, Mark Rutland,
	devicetree, linux-bluetooth-owner

Hi Mathias,

On 2019-03-08 00:48, Matthias Kaehlcke wrote:
> + device tree folks
> 
> On Thu, Mar 07, 2019 at 05:46:50PM +0530, Harish Bandi wrote:
>> 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
> 
> 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.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-08  6:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 12:16 [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Harish Bandi
2019-03-07 12:16 ` [PATCH v1 1/2] Bluetooth: hci_qca: Added support to read the regulator values from DTS Harish Bandi
2019-03-07 12:16 ` [PATCH v1 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990 Harish Bandi
2019-03-07 19:18 ` [PATCH v1 0/2] Enable Bluetooth functionality for wcn3998 Matthias Kaehlcke
2019-03-08  6:39   ` c-hbandi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).