linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Zijun Hu <zijuhu@codeaurora.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org,
	c-hbandi@codeaurora.org, hemantg@codeaurora.org,
	mka@chromium.org, rjliao@codeaurora.org
Subject: Re: [PATCH v4] bluetooth: hci_qca: Fix qca6390 enable failure after warm reboot
Date: Thu, 28 May 2020 10:19:53 +0200	[thread overview]
Message-ID: <00A6B08C-CFDB-43A1-B813-CE3DF241FF33@holtmann.org> (raw)
In-Reply-To: <1590644248-9373-1-git-send-email-zijuhu@codeaurora.org>

Hi Zijun,

> Warm reboot can not restore qca6390 controller baudrate
> to default due to lack of controllable BT_EN pin or power
> supply, so fails to download firmware after warm reboot.
> 
> Fixed by sending EDL_SOC_RESET VSC to reset controller
> within added device shutdown implementation.
> 
> Signed-off-by: Zijun Hu <zijuhu@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 e4a6823..8e03bfe 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1975,6 +1975,38 @@ static void qca_serdev_remove(struct serdev_device *serdev)
> 	hci_uart_unregister_device(&qcadev->serdev_hu);
> }
> 
> +static void qca_serdev_shutdown(struct device *dev)
> +{
> +	int ret;
> +	int timeout = msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS);
> +	struct serdev_device *serdev = to_serdev_device(dev);
> +	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
> +	const u8 ibs_wake_cmd[] = { 0xFD };
> +	const u8 edl_reset_soc_cmd[] = { 0x01, 0x00, 0xFC, 0x01, 0x05 };

struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);

> +
> +	if (qcadev->btsoc_type == QCA_QCA6390) {
> +		serdev_device_write_flush(serdev);
> +		ret = serdev_device_write_buf(serdev,
> +				ibs_wake_cmd, sizeof(ibs_wake_cmd));
> +		if (ret < 0) {
> +			BT_ERR("QCA send IBS_WAKE_IND error: %d", ret);

And then use bt_dev_err here.

> +			return;
> +		}
> +		serdev_device_wait_until_sent(serdev, timeout);
> +		usleep_range(8000, 10000);
> +
> +		serdev_device_write_flush(serdev);
> +		ret = serdev_device_write_buf(serdev,
> +				edl_reset_soc_cmd, sizeof(edl_reset_soc_cmd));
> +		if (ret < 0) {
> +			BT_ERR("QCA send EDL_RESET_REQ error: %d", ret);
> +			return;
> +		}
> +		serdev_device_wait_until_sent(serdev, timeout);
> +		usleep_range(8000, 10000);
> +	}
> +}
> +
> static int __maybe_unused qca_suspend(struct device *dev)
> {
> 	struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
> @@ -2100,6 +2132,7 @@ static struct serdev_device_driver qca_serdev_driver = {
> 		.name = "hci_uart_qca",
> 		.of_match_table = of_match_ptr(qca_bluetooth_of_match),
> 		.acpi_match_table = ACPI_PTR(qca_bluetooth_acpi_match),
> +		.shutdown = qca_serdev_shutdown,
> 		.pm = &qca_pm_ops,
> 	},
> };

Regards

Marcel


  reply	other threads:[~2020-05-28  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28  5:37 [PATCH v4] bluetooth: hci_qca: Fix qca6390 enable failure after warm reboot Zijun Hu
2020-05-28  8:19 ` Marcel Holtmann [this message]
2020-05-28  9:18   ` Zijun Hu

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=00A6B08C-CFDB-43A1-B813-CE3DF241FF33@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=bgodavar@codeaurora.org \
    --cc=c-hbandi@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=mka@chromium.org \
    --cc=rjliao@codeaurora.org \
    --cc=zijuhu@codeaurora.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).