Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC
@ 2020-01-31  7:38 Venkata Lakshmi Narayana Gubba
  2020-01-31  7:38 ` [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991 Venkata Lakshmi Narayana Gubba
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Venkata Lakshmi Narayana Gubba @ 2020-01-31  7:38 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, robh, hemantg, linux-arm-msm,
	bgodavar, tientzu, seanpaul, rjliao, yshavit,
	Venkata Lakshmi Narayana Gubba

Instead of relying on other subsytem to turn ON clocks
required for BT SoC to operate, voting them from the driver.

Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
---
v2:
   * addressed forward declarations
   * updated with devm_clk_get_optional()
 
---
 drivers/bluetooth/hci_qca.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index d6e0c99..73706f3 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1738,6 +1738,15 @@ static int qca_power_off(struct hci_dev *hdev)
 	return 0;
 }
 
+static int qca_setup_clock(struct clk *clk, bool enable)
+{
+	if (enable)
+		return clk_prepare_enable(clk);
+
+	clk_disable_unprepare(clk);
+	return 0;
+}
+
 static int qca_regulator_enable(struct qca_serdev *qcadev)
 {
 	struct qca_power *power = qcadev->bt_power;
@@ -1755,6 +1764,13 @@ static int qca_regulator_enable(struct qca_serdev *qcadev)
 
 	power->vregs_on = true;
 
+	ret = qca_setup_clock(qcadev->susclk, true);
+	if (ret) {
+		/* Turn off regulators to overcome power leakage */
+		qca_regulator_disable(qcadev);
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -1773,6 +1789,9 @@ static void qca_regulator_disable(struct qca_serdev *qcadev)
 
 	regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
 	power->vregs_on = false;
+
+	if (qcadev->susclk)
+		qca_setup_clock(qcadev->susclk, false);
 }
 
 static int qca_init_regulators(struct qca_power *qca,
@@ -1839,6 +1858,12 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 
 		qcadev->bt_power->vregs_on = false;
 
+		qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
+		if (IS_ERR(qcadev->susclk)) {
+			dev_err(&serdev->dev, "failed to acquire clk\n");
+			return PTR_ERR(qcadev->susclk);
+		}
+
 		device_property_read_u32(&serdev->dev, "max-speed",
 					 &qcadev->oper_speed);
 		if (!qcadev->oper_speed)
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


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

* [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991
  2020-01-31  7:38 [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Venkata Lakshmi Narayana Gubba
@ 2020-01-31  7:38 ` Venkata Lakshmi Narayana Gubba
  2020-01-31 22:36   ` Matthias Kaehlcke
  2020-01-31 19:51 ` [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Marcel Holtmann
  2020-02-03 19:56 ` Bjorn Andersson
  2 siblings, 1 reply; 9+ messages in thread
From: Venkata Lakshmi Narayana Gubba @ 2020-01-31  7:38 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, robh, hemantg, linux-arm-msm,
	bgodavar, tientzu, seanpaul, rjliao, yshavit,
	Venkata Lakshmi Narayana Gubba

Add compatible string for the Qualcomm WCN3991 Bluetooth controller

Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
---
 Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
index 68b67d9..e72045d 100644
--- a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
+++ b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
@@ -11,6 +11,7 @@ Required properties:
  - compatible: should contain one of the following:
    * "qcom,qca6174-bt"
    * "qcom,wcn3990-bt"
+   * "qcom,wcn3991-bt"
    * "qcom,wcn3998-bt"
 
 Optional properties for compatible string qcom,qca6174-bt:
@@ -30,6 +31,7 @@ Optional properties for compatible string qcom,wcn399x-bt:
 
  - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
  - firmware-name: specify the name of nvm firmware to load
+ - clocks: clock provided to the controller
 
 Examples:
 
@@ -56,5 +58,6 @@ serial@898000 {
 		vddch0-supply = <&vreg_l25a_3p3>;
 		max-speed = <3200000>;
 		firmware-name = "crnv21.bin";
+		clocks = <&rpmhcc>;
 	};
 };
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


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

* Re: [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC
  2020-01-31  7:38 [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Venkata Lakshmi Narayana Gubba
  2020-01-31  7:38 ` [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991 Venkata Lakshmi Narayana Gubba
@ 2020-01-31 19:51 ` Marcel Holtmann
  2020-02-03  7:27   ` gubbaven
  2020-02-03 19:56 ` Bjorn Andersson
  2 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2020-01-31 19:51 UTC (permalink / raw)
  To: Venkata Lakshmi Narayana Gubba
  Cc: Johan Hedberg, Matthias Kaehlcke, linux-kernel, linux-bluetooth,
	robh, hemantg, linux-arm-msm, bgodavar, tientzu, seanpaul,
	rjliao, yshavit

Hi Venkata,

> Instead of relying on other subsytem to turn ON clocks
> required for BT SoC to operate, voting them from the driver.
> 
> Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
> ---
> v2:
>   * addressed forward declarations
>   * updated with devm_clk_get_optional()
> 
> ---
> drivers/bluetooth/hci_qca.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index d6e0c99..73706f3 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1738,6 +1738,15 @@ static int qca_power_off(struct hci_dev *hdev)
> 	return 0;
> }
> 
> +static int qca_setup_clock(struct clk *clk, bool enable)
> +{
> +	if (enable)
> +		return clk_prepare_enable(clk);
> +
> +	clk_disable_unprepare(clk);
> +	return 0;
> +}
> +

this function is pointless and it just complicated the code.

> static int qca_regulator_enable(struct qca_serdev *qcadev)
> {
> 	struct qca_power *power = qcadev->bt_power;
> @@ -1755,6 +1764,13 @@ static int qca_regulator_enable(struct qca_serdev *qcadev)
> 
> 	power->vregs_on = true;
> 
> +	ret = qca_setup_clock(qcadev->susclk, true);

	ret = clk_prepare_enable(qcadev->susclk);

> +	if (ret) {
> +		/* Turn off regulators to overcome power leakage */
> +		qca_regulator_disable(qcadev);
> +		return ret;
> +	}
> +
> 	return 0;
> }
> 
> @@ -1773,6 +1789,9 @@ static void qca_regulator_disable(struct qca_serdev *qcadev)
> 
> 	regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
> 	power->vregs_on = false;
> +
> +	if (qcadev->susclk)
> +		qca_setup_clock(qcadev->susclk, false);

		clk_disable_unprepare(qcadev->susclk);

> }
> 
> static int qca_init_regulators(struct qca_power *qca,
> @@ -1839,6 +1858,12 @@ static int qca_serdev_probe(struct serdev_device *serdev)
> 
> 		qcadev->bt_power->vregs_on = false;
> 
> +		qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
> +		if (IS_ERR(qcadev->susclk)) {
> +			dev_err(&serdev->dev, "failed to acquire clk\n");
> +			return PTR_ERR(qcadev->susclk);
> +		}
> +
> 		device_property_read_u32(&serdev->dev, "max-speed",
> 					 &qcadev->oper_speed);
> 		if (!qcadev->oper_speed)

Regards

Marcel


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

* Re: [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991
  2020-01-31  7:38 ` [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991 Venkata Lakshmi Narayana Gubba
@ 2020-01-31 22:36   ` Matthias Kaehlcke
  2020-02-03  8:23     ` gubbaven
  0 siblings, 1 reply; 9+ messages in thread
From: Matthias Kaehlcke @ 2020-01-31 22:36 UTC (permalink / raw)
  To: Venkata Lakshmi Narayana Gubba
  Cc: marcel, johan.hedberg, linux-kernel, linux-bluetooth, robh,
	hemantg, linux-arm-msm, bgodavar, tientzu, seanpaul, rjliao,
	yshavit, Rob Herring, Frank Rowand, devicetree

+ DT folks

On Fri, Jan 31, 2020 at 01:08:55PM +0530, Venkata Lakshmi Narayana Gubba wrote:
> Add compatible string for the Qualcomm WCN3991 Bluetooth controller
> 
> Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
> ---
>  Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
> index 68b67d9..e72045d 100644
> --- a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
> +++ b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
> @@ -11,6 +11,7 @@ Required properties:
>   - compatible: should contain one of the following:
>     * "qcom,qca6174-bt"
>     * "qcom,wcn3990-bt"
> +   * "qcom,wcn3991-bt"
>     * "qcom,wcn3998-bt"
>  
>  Optional properties for compatible string qcom,qca6174-bt:
> @@ -30,6 +31,7 @@ Optional properties for compatible string qcom,wcn399x-bt:
>  
>   - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
>   - firmware-name: specify the name of nvm firmware to load
> + - clocks: clock provided to the controller
>  
>  Examples:
>  
> @@ -56,5 +58,6 @@ serial@898000 {
>  		vddch0-supply = <&vreg_l25a_3p3>;
>  		max-speed = <3200000>;
>  		firmware-name = "crnv21.bin";
> +		clocks = <&rpmhcc>;

That specifies a clock controller, not a clock.

For a device with the SC7180 SoC we use this:

		clocks = <&rpmhcc RPMH_RF_CLK2>;

>  	};
>  };

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

* Re: [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC
  2020-01-31 19:51 ` [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Marcel Holtmann
@ 2020-02-03  7:27   ` gubbaven
  0 siblings, 0 replies; 9+ messages in thread
From: gubbaven @ 2020-02-03  7:27 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Johan Hedberg, Matthias Kaehlcke, linux-kernel, linux-bluetooth,
	robh, hemantg, linux-arm-msm, bgodavar, tientzu, seanpaul,
	rjliao, yshavit

Hi Marcel,

On 2020-02-01 01:21, Marcel Holtmann wrote:
> Hi Venkata,
> 
>> Instead of relying on other subsytem to turn ON clocks
>> required for BT SoC to operate, voting them from the driver.
>> 
>> Signed-off-by: Venkata Lakshmi Narayana Gubba 
>> <gubbaven@codeaurora.org>
>> ---
>> v2:
>>   * addressed forward declarations
>>   * updated with devm_clk_get_optional()
>> 
>> ---
>> drivers/bluetooth/hci_qca.c | 25 +++++++++++++++++++++++++
>> 1 file changed, 25 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> index d6e0c99..73706f3 100644
>> --- a/drivers/bluetooth/hci_qca.c
>> +++ b/drivers/bluetooth/hci_qca.c
>> @@ -1738,6 +1738,15 @@ static int qca_power_off(struct hci_dev *hdev)
>> 	return 0;
>> }
>> 
>> +static int qca_setup_clock(struct clk *clk, bool enable)
>> +{
>> +	if (enable)
>> +		return clk_prepare_enable(clk);
>> +
>> +	clk_disable_unprepare(clk);
>> +	return 0;
>> +}
>> +
> 
> this function is pointless and it just complicated the code.

[Venkata] : Sure we will remove the function and will update in next 
patch set.
> 
>> static int qca_regulator_enable(struct qca_serdev *qcadev)
>> {
>> 	struct qca_power *power = qcadev->bt_power;
>> @@ -1755,6 +1764,13 @@ static int qca_regulator_enable(struct 
>> qca_serdev *qcadev)
>> 
>> 	power->vregs_on = true;
>> 
>> +	ret = qca_setup_clock(qcadev->susclk, true);
> 
> 	ret = clk_prepare_enable(qcadev->susclk);

[Venkata] : Sure.We will update in next patch set.

> 
>> +	if (ret) {
>> +		/* Turn off regulators to overcome power leakage */
>> +		qca_regulator_disable(qcadev);
>> +		return ret;
>> +	}
>> +
>> 	return 0;
>> }
>> 
>> @@ -1773,6 +1789,9 @@ static void qca_regulator_disable(struct 
>> qca_serdev *qcadev)
>> 
>> 	regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
>> 	power->vregs_on = false;
>> +
>> +	if (qcadev->susclk)
>> +		qca_setup_clock(qcadev->susclk, false);
> 
> 		clk_disable_unprepare(qcadev->susclk);

[Venkata] : Sure.We will update in next patch set.
> 
>> }
>> 
>> static int qca_init_regulators(struct qca_power *qca,
>> @@ -1839,6 +1858,12 @@ static int qca_serdev_probe(struct 
>> serdev_device *serdev)
>> 
>> 		qcadev->bt_power->vregs_on = false;
>> 
>> +		qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
>> +		if (IS_ERR(qcadev->susclk)) {
>> +			dev_err(&serdev->dev, "failed to acquire clk\n");
>> +			return PTR_ERR(qcadev->susclk);
>> +		}
>> +
>> 		device_property_read_u32(&serdev->dev, "max-speed",
>> 					 &qcadev->oper_speed);
>> 		if (!qcadev->oper_speed)
> 
> Regards
> 
> Marcel

Regards,
Venkata.

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

* Re: [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991
  2020-01-31 22:36   ` Matthias Kaehlcke
@ 2020-02-03  8:23     ` gubbaven
  0 siblings, 0 replies; 9+ messages in thread
From: gubbaven @ 2020-02-03  8:23 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: marcel, johan.hedberg, linux-kernel, linux-bluetooth, robh,
	hemantg, linux-arm-msm, bgodavar, tientzu, seanpaul, rjliao,
	yshavit, Rob Herring, Frank Rowand, devicetree

Hi Matthias,

On 2020-02-01 04:06, Matthias Kaehlcke wrote:
> + DT folks
> 
> On Fri, Jan 31, 2020 at 01:08:55PM +0530, Venkata Lakshmi Narayana 
> Gubba wrote:
>> Add compatible string for the Qualcomm WCN3991 Bluetooth controller
>> 
>> Signed-off-by: Venkata Lakshmi Narayana Gubba 
>> <gubbaven@codeaurora.org>
>> ---
>>  Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git 
>> a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt 
>> b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
>> index 68b67d9..e72045d 100644
>> --- a/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
>> +++ b/Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt
>> @@ -11,6 +11,7 @@ Required properties:
>>   - compatible: should contain one of the following:
>>     * "qcom,qca6174-bt"
>>     * "qcom,wcn3990-bt"
>> +   * "qcom,wcn3991-bt"
>>     * "qcom,wcn3998-bt"
>> 
>>  Optional properties for compatible string qcom,qca6174-bt:
>> @@ -30,6 +31,7 @@ Optional properties for compatible string 
>> qcom,wcn399x-bt:
>> 
>>   - max-speed: see 
>> Documentation/devicetree/bindings/serial/slave-device.txt
>>   - firmware-name: specify the name of nvm firmware to load
>> + - clocks: clock provided to the controller
>> 
>>  Examples:
>> 
>> @@ -56,5 +58,6 @@ serial@898000 {
>>  		vddch0-supply = <&vreg_l25a_3p3>;
>>  		max-speed = <3200000>;
>>  		firmware-name = "crnv21.bin";
>> +		clocks = <&rpmhcc>;
> 
> That specifies a clock controller, not a clock.
> 
> For a device with the SC7180 SoC we use this:
> 
> 		clocks = <&rpmhcc RPMH_RF_CLK2>;

[Venkata] :

Sure, we will update in next patch set.
> 
>>  	};
>>  };

Regards,
Venkata.

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

* Re: [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC
  2020-01-31  7:38 [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Venkata Lakshmi Narayana Gubba
  2020-01-31  7:38 ` [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991 Venkata Lakshmi Narayana Gubba
  2020-01-31 19:51 ` [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Marcel Holtmann
@ 2020-02-03 19:56 ` Bjorn Andersson
  2020-02-04  9:04   ` Marcel Holtmann
  2 siblings, 1 reply; 9+ messages in thread
From: Bjorn Andersson @ 2020-02-03 19:56 UTC (permalink / raw)
  To: Venkata Lakshmi Narayana Gubba
  Cc: marcel, johan.hedberg, mka, linux-kernel, linux-bluetooth, robh,
	hemantg, linux-arm-msm, bgodavar, tientzu, seanpaul, rjliao,
	yshavit

On Thu 30 Jan 23:38 PST 2020, Venkata Lakshmi Narayana Gubba wrote:

> Instead of relying on other subsytem to turn ON clocks
> required for BT SoC to operate, voting them from the driver.
> 
> Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
> ---
> v2:
>    * addressed forward declarations
>    * updated with devm_clk_get_optional()
>  
> ---
>  drivers/bluetooth/hci_qca.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index d6e0c99..73706f3 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1738,6 +1738,15 @@ static int qca_power_off(struct hci_dev *hdev)
>  	return 0;
>  }
>  
> +static int qca_setup_clock(struct clk *clk, bool enable)
> +{
> +	if (enable)
> +		return clk_prepare_enable(clk);
> +
> +	clk_disable_unprepare(clk);
> +	return 0;
> +}

As Marcel requested, inline these.

> +
>  static int qca_regulator_enable(struct qca_serdev *qcadev)
>  {
>  	struct qca_power *power = qcadev->bt_power;
> @@ -1755,6 +1764,13 @@ static int qca_regulator_enable(struct qca_serdev *qcadev)
>  
>  	power->vregs_on = true;
>  
> +	ret = qca_setup_clock(qcadev->susclk, true);
> +	if (ret) {
> +		/* Turn off regulators to overcome power leakage */

You can omit this comment as well, as the name of the function you call
is aptly named.

> +		qca_regulator_disable(qcadev);
> +		return ret;

Just return ret below instead.

> +	}
> +
>  	return 0;
>  }
>  
> @@ -1773,6 +1789,9 @@ static void qca_regulator_disable(struct qca_serdev *qcadev)
>  
>  	regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
>  	power->vregs_on = false;
> +
> +	if (qcadev->susclk)

In the enable path you (correctly) rely on passing NULL to the clock
code, so do the same here.

Regards,
Bjorn

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

* Re: [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC
  2020-02-03 19:56 ` Bjorn Andersson
@ 2020-02-04  9:04   ` Marcel Holtmann
  2020-02-05 10:37     ` gubbaven
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2020-02-04  9:04 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Venkata Lakshmi Narayana Gubba, Johan Hedberg, mka, linux-kernel,
	linux-bluetooth, robh, hemantg, linux-arm-msm, bgodavar, tientzu,
	seanpaul, rjliao, yshavit

Hi Bjorn,

>> Instead of relying on other subsytem to turn ON clocks
>> required for BT SoC to operate, voting them from the driver.
>> 
>> Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
>> ---
>> v2:
>>   * addressed forward declarations
>>   * updated with devm_clk_get_optional()
>> 
>> ---
>> drivers/bluetooth/hci_qca.c | 25 +++++++++++++++++++++++++
>> 1 file changed, 25 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> index d6e0c99..73706f3 100644
>> --- a/drivers/bluetooth/hci_qca.c
>> +++ b/drivers/bluetooth/hci_qca.c
>> @@ -1738,6 +1738,15 @@ static int qca_power_off(struct hci_dev *hdev)
>> 	return 0;
>> }
>> 
>> +static int qca_setup_clock(struct clk *clk, bool enable)
>> +{
>> +	if (enable)
>> +		return clk_prepare_enable(clk);
>> +
>> +	clk_disable_unprepare(clk);
>> +	return 0;
>> +}
> 
> As Marcel requested, inline these.
> 
>> +
>> static int qca_regulator_enable(struct qca_serdev *qcadev)
>> {
>> 	struct qca_power *power = qcadev->bt_power;
>> @@ -1755,6 +1764,13 @@ static int qca_regulator_enable(struct qca_serdev *qcadev)
>> 
>> 	power->vregs_on = true;
>> 
>> +	ret = qca_setup_clock(qcadev->susclk, true);
>> +	if (ret) {
>> +		/* Turn off regulators to overcome power leakage */
> 
> You can omit this comment as well, as the name of the function you call
> is aptly named.
> 
>> +		qca_regulator_disable(qcadev);
>> +		return ret;
> 
> Just return ret below instead.
> 
>> +	}
>> +
>> 	return 0;
>> }
>> 
>> @@ -1773,6 +1789,9 @@ static void qca_regulator_disable(struct qca_serdev *qcadev)
>> 
>> 	regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
>> 	power->vregs_on = false;
>> +
>> +	if (qcadev->susclk)
> 
> In the enable path you (correctly) rely on passing NULL to the clock
> code, so do the same here.

I already pushed the patch, but I am happy to accept a cleanup patch.

Regards

Marcel


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

* Re: [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC
  2020-02-04  9:04   ` Marcel Holtmann
@ 2020-02-05 10:37     ` gubbaven
  0 siblings, 0 replies; 9+ messages in thread
From: gubbaven @ 2020-02-05 10:37 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Bjorn Andersson, Johan Hedberg, mka, linux-kernel,
	linux-bluetooth, robh, hemantg, linux-arm-msm, bgodavar, tientzu,
	seanpaul, rjliao, yshavit

Hi Bjorn,

On 2020-02-04 14:34, Marcel Holtmann wrote:
> Hi Bjorn,
> 
>>> Instead of relying on other subsytem to turn ON clocks
>>> required for BT SoC to operate, voting them from the driver.
>>> 
>>> Signed-off-by: Venkata Lakshmi Narayana Gubba 
>>> <gubbaven@codeaurora.org>
>>> ---
>>> v2:
>>>   * addressed forward declarations
>>>   * updated with devm_clk_get_optional()
>>> 
>>> ---
>>> drivers/bluetooth/hci_qca.c | 25 +++++++++++++++++++++++++
>>> 1 file changed, 25 insertions(+)
>>> 
>>> diff --git a/drivers/bluetooth/hci_qca.c 
>>> b/drivers/bluetooth/hci_qca.c
>>> index d6e0c99..73706f3 100644
>>> --- a/drivers/bluetooth/hci_qca.c
>>> +++ b/drivers/bluetooth/hci_qca.c
>>> @@ -1738,6 +1738,15 @@ static int qca_power_off(struct hci_dev *hdev)
>>> 	return 0;
>>> }
>>> 
>>> +static int qca_setup_clock(struct clk *clk, bool enable)
>>> +{
>>> +	if (enable)
>>> +		return clk_prepare_enable(clk);
>>> +
>>> +	clk_disable_unprepare(clk);
>>> +	return 0;
>>> +}
>> 
>> As Marcel requested, inline these.
>> 
>>> +
>>> static int qca_regulator_enable(struct qca_serdev *qcadev)
>>> {
>>> 	struct qca_power *power = qcadev->bt_power;
>>> @@ -1755,6 +1764,13 @@ static int qca_regulator_enable(struct 
>>> qca_serdev *qcadev)
>>> 
>>> 	power->vregs_on = true;
>>> 
>>> +	ret = qca_setup_clock(qcadev->susclk, true);
>>> +	if (ret) {
>>> +		/* Turn off regulators to overcome power leakage */
>> 
>> You can omit this comment as well, as the name of the function you 
>> call
>> is aptly named.
[Venkata] :
We will update in next patch set.
>> 
>>> +		qca_regulator_disable(qcadev);
>>> +		return ret;
>> 
>> Just return ret below instead.
[Venkata] :
We will update in next patch set
>> 
>>> +	}
>>> +
>>> 	return 0;
>>> }
>>> 
>>> @@ -1773,6 +1789,9 @@ static void qca_regulator_disable(struct 
>>> qca_serdev *qcadev)
>>> 
>>> 	regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
>>> 	power->vregs_on = false;
>>> +
>>> +	if (qcadev->susclk)
>> 
>> In the enable path you (correctly) rely on passing NULL to the clock
>> code, so do the same here.
[Venkata] :
We will update in next patch set.
> 
> I already pushed the patch, but I am happy to accept a cleanup patch.
> 
> Regards
> 
> Marcel

Regards,
Venkata.

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

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31  7:38 [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Venkata Lakshmi Narayana Gubba
2020-01-31  7:38 ` [PATCH v2 2/2] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip WCN3991 Venkata Lakshmi Narayana Gubba
2020-01-31 22:36   ` Matthias Kaehlcke
2020-02-03  8:23     ` gubbaven
2020-01-31 19:51 ` [PATCH v2 1/2] Bluetooth: hci_qca: Enable clocks required for BT SOC Marcel Holtmann
2020-02-03  7:27   ` gubbaven
2020-02-03 19:56 ` Bjorn Andersson
2020-02-04  9:04   ` Marcel Holtmann
2020-02-05 10:37     ` gubbaven

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git