linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: hci_qca: Add poweroff support during hci down for QCA Rome
@ 2019-12-19  4:03 Rocky Liao
  2019-12-25  6:06 ` rjliao
  0 siblings, 1 reply; 2+ messages in thread
From: Rocky Liao @ 2019-12-19  4:03 UTC (permalink / raw)
  To: marcel, johan.hedberg; +Cc: linux-kernel, linux-bluetooth, Rocky Liao

This patch enables power off support for hci down and power on support
for hci up. As QCA Rome power sources are ignited by bt_en GPIO, we will
pull it down during hci down, i.e. an complete power off of QCA Rome.
So while hci up, will pull up the bt_en GPIO again to power on the chip,
requests BT chip version and download the firmware.

Signed-off-by: Rocky Liao <rjliao@codeaurora.org>
---
 drivers/bluetooth/hci_qca.c | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index b602ed01505b..1cb706acdef6 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1257,6 +1257,7 @@ static int qca_setup(struct hci_uart *hu)
 {
 	struct hci_dev *hdev = hu->hdev;
 	struct qca_data *qca = hu->priv;
+	struct qca_serdev *qcadev;
 	unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
 	enum qca_btsoc_type soc_type = qca_soc_type(hu);
 	const char *firmware_name = qca_get_firmware_name(hu);
@@ -1293,6 +1294,17 @@ static int qca_setup(struct hci_uart *hu)
 			return ret;
 	} else {
 		bt_dev_info(hdev, "ROME setup");
+		if (hu->serdev) {
+			/* Enable NON_PERSISTENT_SETUP QUIRK to ensure to
+			 * execute setup for every hci up.
+			 */
+			set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+			qcadev = serdev_device_get_drvdata(hu->serdev);
+			hu->hdev->shutdown = qca_power_off;
+			gpiod_set_value_cansleep(qcadev->bt_en, 1);
+			/* Controller needs time to bootup. */
+			msleep(150);
+		}
 		qca_set_speed(hu, QCA_INIT_SPEED);
 	}
 
@@ -1413,13 +1425,27 @@ static void qca_power_shutdown(struct hci_uart *hu)
 static int qca_power_off(struct hci_dev *hdev)
 {
 	struct hci_uart *hu = hci_get_drvdata(hdev);
+	struct qca_serdev *qcadev;
+	enum qca_btsoc_type soc_type = qca_soc_type(hu);
 
-	/* Perform pre shutdown command */
-	qca_send_pre_shutdown_cmd(hdev);
+	if (qca_is_wcn399x(soc_type)) {
+		/* Perform pre shutdown command */
+		qca_send_pre_shutdown_cmd(hdev);
 
-	usleep_range(8000, 10000);
+		usleep_range(8000, 10000);
+
+		qca_power_shutdown(hu);
+	} else {
+		if (hu->serdev) {
+
+			qcadev = serdev_device_get_drvdata(hu->serdev);
+
+			gpiod_set_value_cansleep(qcadev->bt_en, 0);
+
+			usleep_range(8000, 10000);
+		}
+	}
 
-	qca_power_shutdown(hu);
 	return 0;
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

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

* Re: [PATCH v1] Bluetooth: hci_qca: Add poweroff support during hci down for QCA Rome
  2019-12-19  4:03 [PATCH v1] Bluetooth: hci_qca: Add poweroff support during hci down for QCA Rome Rocky Liao
@ 2019-12-25  6:06 ` rjliao
  0 siblings, 0 replies; 2+ messages in thread
From: rjliao @ 2019-12-25  6:06 UTC (permalink / raw)
  To: marcel, johan.hedberg; +Cc: linux-kernel, linux-bluetooth

Please ingnore this patch, I have just sent the new set of patches.

在 2019-12-19 12:03,Rocky Liao 写道:
> This patch enables power off support for hci down and power on support
> for hci up. As QCA Rome power sources are ignited by bt_en GPIO, we 
> will
> pull it down during hci down, i.e. an complete power off of QCA Rome.
> So while hci up, will pull up the bt_en GPIO again to power on the 
> chip,
> requests BT chip version and download the firmware.
> 
> Signed-off-by: Rocky Liao <rjliao@codeaurora.org>
> ---
>  drivers/bluetooth/hci_qca.c | 34 ++++++++++++++++++++++++++++++----
>  1 file changed, 30 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index b602ed01505b..1cb706acdef6 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1257,6 +1257,7 @@ static int qca_setup(struct hci_uart *hu)
>  {
>  	struct hci_dev *hdev = hu->hdev;
>  	struct qca_data *qca = hu->priv;
> +	struct qca_serdev *qcadev;
>  	unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
>  	enum qca_btsoc_type soc_type = qca_soc_type(hu);
>  	const char *firmware_name = qca_get_firmware_name(hu);
> @@ -1293,6 +1294,17 @@ static int qca_setup(struct hci_uart *hu)
>  			return ret;
>  	} else {
>  		bt_dev_info(hdev, "ROME setup");
> +		if (hu->serdev) {
> +			/* Enable NON_PERSISTENT_SETUP QUIRK to ensure to
> +			 * execute setup for every hci up.
> +			 */
> +			set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
> +			qcadev = serdev_device_get_drvdata(hu->serdev);
> +			hu->hdev->shutdown = qca_power_off;
> +			gpiod_set_value_cansleep(qcadev->bt_en, 1);
> +			/* Controller needs time to bootup. */
> +			msleep(150);
> +		}
>  		qca_set_speed(hu, QCA_INIT_SPEED);
>  	}
> 
> @@ -1413,13 +1425,27 @@ static void qca_power_shutdown(struct hci_uart 
> *hu)
>  static int qca_power_off(struct hci_dev *hdev)
>  {
>  	struct hci_uart *hu = hci_get_drvdata(hdev);
> +	struct qca_serdev *qcadev;
> +	enum qca_btsoc_type soc_type = qca_soc_type(hu);
> 
> -	/* Perform pre shutdown command */
> -	qca_send_pre_shutdown_cmd(hdev);
> +	if (qca_is_wcn399x(soc_type)) {
> +		/* Perform pre shutdown command */
> +		qca_send_pre_shutdown_cmd(hdev);
> 
> -	usleep_range(8000, 10000);
> +		usleep_range(8000, 10000);
> +
> +		qca_power_shutdown(hu);
> +	} else {
> +		if (hu->serdev) {
> +
> +			qcadev = serdev_device_get_drvdata(hu->serdev);
> +
> +			gpiod_set_value_cansleep(qcadev->bt_en, 0);
> +
> +			usleep_range(8000, 10000);
> +		}
> +	}
> 
> -	qca_power_shutdown(hu);
>  	return 0;
>  }

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

end of thread, other threads:[~2019-12-25  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-19  4:03 [PATCH v1] Bluetooth: hci_qca: Add poweroff support during hci down for QCA Rome Rocky Liao
2019-12-25  6:06 ` rjliao

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