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
Subject: Re: [PATCH v2 1/1] Bluetooth: hci_qca: Add poweroff support during hci down for wcn3990
Date: Wed, 19 Sep 2018 10:21:37 -0700 [thread overview]
Message-ID: <20180919172137.GQ22824@google.com> (raw)
In-Reply-To: <20180919152113.7611-2-bgodavar@codeaurora.org>
On Wed, Sep 19, 2018 at 08:51:13PM +0530, Balakrishna Godavarthi wrote:
> This patch enables power off support for hci down and power on support
> for hci up. As wcn3990 power sources are ignited by regulators, we will
> turn off them during hci down, i.e. an complete power off of wcn3990.
> So while hci up, we will call vendor specific open/close and setup which
> will turn on the regulators, requests BT chip version and download the
> firmware.
>
> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
> ---
> drivers/bluetooth/hci_qca.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 74f5fede0274..c3038afa42af 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -168,6 +168,7 @@ struct qca_serdev {
>
> static int qca_power_setup(struct hci_uart *hu, bool on);
> static void qca_power_shutdown(struct hci_uart *hu);
> +static int qca_power_off(struct hci_dev *hdev);
>
> static void __serial_clock_on(struct tty_struct *tty)
> {
> @@ -1099,8 +1100,26 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
> static int qca_wcn3990_init(struct hci_uart *hu)
> {
> struct hci_dev *hdev = hu->hdev;
> + struct qca_serdev *qcadev;
> int ret;
>
> + /* Check for vregs status, may be hci0 down has turned
> + * off the vregs.
> + */
nit: it's not necessarily 'hci0', there may be systems with more than
one Bluetooth controller. You could say hciN instead, you might also
want to put quotes around 'hciN down' to make clearer this is
referring to a command.
> + qcadev = serdev_device_get_drvdata(hu->serdev);
> + if (qcadev->bt_power->vregs_on == false) {
nit:
if (!qcadev->bt_power->vregs_on) {
is more common and easier to read IMO
> + serdev_device_close(hu->serdev);
> + ret = qca_power_setup(hu, true);
> + if (ret)
> + return ret;
> +
> + ret = serdev_device_open(hu->serdev);
> + if (ret) {
> + bt_dev_err(hu->hdev, "failed to open port");
switch the regulators off again?
> + return ret;
> + }
> + }
> +
> /* Forcefully enable wcn3990 to enter in to boot mode. */
> host_set_baudrate(hu, 2400);
> ret = qca_send_power_pulse(hdev, QCA_WCN3990_POWEROFF_PULSE);
> @@ -1152,6 +1171,12 @@ static int qca_setup(struct hci_uart *hu)
>
> if (qcadev->btsoc_type == QCA_WCN3990) {
> bt_dev_info(hdev, "setting up wcn3990");
> +
> + /* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute
> + * setup for every hci0 up.
nit: 'hciN up'?
> + */
> + set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
> + hu->hdev->shutdown = qca_power_off;
> ret = qca_wcn3990_init(hu);
> if (ret)
> return ret;
> @@ -1242,6 +1267,14 @@ static void qca_power_shutdown(struct hci_uart *hu)
> qca_power_setup(hu, false);
> }
>
> +static int qca_power_off(struct hci_dev *hdev)
> +{
> + struct hci_uart *hu = hci_get_drvdata(hdev);
> +
> + qca_power_shutdown(hu);
Would it make sense to add a return value qca_power_shutdown() now
that it is called by a non-void function? Might not be worth the
hassle though, hci_dev_do_close() - the only caller of
hdev->shutdown() - doesn't check the return value either.
Cheers
Matthias
next prev parent reply other threads:[~2018-09-19 17:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 15:21 [PATCH v2 0/1] Cold on & off support for Qualcomm BT chip wcn3990 Balakrishna Godavarthi
2018-09-19 15:21 ` [PATCH v2 1/1] Bluetooth: hci_qca: Add poweroff support during hci down for wcn3990 Balakrishna Godavarthi
2018-09-19 17:21 ` Matthias Kaehlcke [this message]
2018-09-20 13:48 ` Balakrishna Godavarthi
2018-09-19 17:26 ` [PATCH v2 0/1] Cold on & off support for Qualcomm BT chip wcn3990 Matthias Kaehlcke
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=20180919172137.GQ22824@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 \
/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 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).