From: Matthias Kaehlcke <mka@chromium.org>
To: Balakrishna Godavarthi <bgodavar@codeaurora.org>
Cc: marcel@holtmann.org, johan.hedberg@gmail.com,
linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org,
tientzu@chromium.org, seanpaul@chromium.org
Subject: Re: [PATCH v1] Bluetooth: hci_qca: Enable clocks required for BT SOC
Date: Thu, 12 Dec 2019 09:43:48 -0800 [thread overview]
Message-ID: <20191212174348.GS228856@google.com> (raw)
In-Reply-To: <20191114081430.25427-1-bgodavar@codeaurora.org>
On Thu, Nov 14, 2019 at 01:44:30PM +0530, Balakrishna Godavarthi 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: Balakrishna Godavarthi <bgodavar@codeaurora.org>
> ---
> drivers/bluetooth/hci_qca.c | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index f10bdf8e1fc5..dc95e378574b 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -164,6 +164,7 @@ struct qca_serdev {
> };
>
> static int qca_regulator_enable(struct qca_serdev *qcadev);
> +static int qca_power_on(struct qca_serdev *qcadev);
> static void qca_regulator_disable(struct qca_serdev *qcadev);
> static void qca_power_shutdown(struct hci_uart *hu);
> static int qca_power_off(struct hci_dev *hdev);
> @@ -528,7 +529,7 @@ static int qca_open(struct hci_uart *hu)
> } else {
> hu->init_speed = qcadev->init_speed;
> hu->oper_speed = qcadev->oper_speed;
> - ret = qca_regulator_enable(qcadev);
> + ret = qca_power_on(qcadev);
> if (ret) {
> destroy_workqueue(qca->workqueue);
> kfree_skb(qca->rx_skb);
> @@ -1214,7 +1215,7 @@ static int qca_wcn3990_init(struct hci_uart *hu)
> qcadev = serdev_device_get_drvdata(hu->serdev);
> if (!qcadev->bt_power->vregs_on) {
> serdev_device_close(hu->serdev);
> - ret = qca_regulator_enable(qcadev);
> + ret = qca_power_on(qcadev);
> if (ret)
> return ret;
>
> @@ -1408,6 +1409,9 @@ static void qca_power_shutdown(struct hci_uart *hu)
> host_set_baudrate(hu, 2400);
> qca_send_power_pulse(hu, false);
> qca_regulator_disable(qcadev);
> +
> + if (qcadev->susclk)
> + clk_disable_unprepare(qcadev->susclk);
> }
>
> static int qca_power_off(struct hci_dev *hdev)
> @@ -1423,6 +1427,20 @@ static int qca_power_off(struct hci_dev *hdev)
> return 0;
> }
>
> +static int qca_power_on(struct qca_serdev *qcadev)
> +{
> + int err;
> +
> + if (qcadev->susclk) {
> + err = clk_prepare_enable(qcadev->susclk);
> + if (err)
> + return err;
> + }
> +
> + qca_regulator_enable(qcadev);
> + return 0;
> +}
> +
> static int qca_regulator_enable(struct qca_serdev *qcadev)
> {
> struct qca_power *power = qcadev->bt_power;
> @@ -1523,6 +1541,15 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>
> qcadev->bt_power->vregs_on = false;
>
> + if (qcadev->btsoc_type == QCA_WCN3990 ||
> + qcadev->btsoc_type == QCA_WCN3991) {
> + 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);
> + }
This will break existing users. Use devm_clk_get_optional() and at most
raise a warning if the clock doesn't exist.
It would also be nice to add the clock to the affected devices in the tree
if possible:
arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi: compatible = "qcom,wcn3990-bt";
arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi: compatible = "qcom,wcn3990-bt";
arch/arm64/boot/dts/qcom/qcs404-evb.dtsi: compatible = "qcom,wcn3990-bt";
arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi: compatible = "qcom,wcn3990-bt";
arch/arm64/boot/dts/qcom/sdm845-db845c.dts: compatible = "qcom,wcn3990-bt";
arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts: compatible = "qcom,wcn3990-bt";
next prev parent reply other threads:[~2019-12-12 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 8:14 [PATCH v1] Bluetooth: hci_qca: Enable clocks required for BT SOC Balakrishna Godavarthi
2019-11-14 8:55 ` Marcel Holtmann
2019-11-18 6:01 ` bgodavar
2019-11-14 17:19 ` Stephen Boyd
2019-11-18 6:21 ` bgodavar
2019-12-12 17:43 ` Matthias Kaehlcke [this message]
2020-01-14 11:34 ` bgodavar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191212174348.GS228856@google.com \
--to=mka@chromium.org \
--cc=bgodavar@codeaurora.org \
--cc=hemantg@codeaurora.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=seanpaul@chromium.org \
--cc=tientzu@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.