[RFC PATCH v1] Bluetooth: hci_qca: Add new hci_uart proto callback to power off voltage sources

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change adds a new hci_uart proto callback entry i.e., power off.
This poweroff Callback is exposed to the drivers and called during BT OFF
immediately after port close. This will ensure that Voltages sources are
powered off after sending all the data before port close. Previously as
part of hdev shutdown callback, voltages sources are powered off. But we
have seen cases where post shutdown sequence completion some packets which
are already queued are sent to UART. As controller is powered off, UART
can’t send the data out or it is sending partial data due RTS line high.

Signed-off-by: saluvala <saluvala@xxxxxxxxxxxxxx>
---
 drivers/bluetooth/hci_qca.c    | 26 +++++++++++++++++++-------
 drivers/bluetooth/hci_serdev.c |  3 +++
 drivers/bluetooth/hci_uart.h   |  1 +
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index dd768a8..e1dee75 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -231,6 +231,7 @@ static int qca_regulator_enable(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);
+static int qca_power_off_reg(struct hci_uart *hu);
 static void qca_controller_memdump(struct work_struct *work);
 
 static enum qca_btsoc_type qca_soc_type(struct hci_uart *hu)
@@ -554,7 +555,6 @@ static void qca_controller_memdump_timeout(struct work_struct *work)
 	mutex_unlock(&qca->hci_memdump_lock);
 }
 
-
 /* Initialize protocol */
 static int qca_open(struct hci_uart *hu)
 {
@@ -1815,6 +1815,7 @@ static const struct hci_uart_proto qca_proto = {
 	.flush		= qca_flush,
 	.setup		= qca_setup,
 	.recv		= qca_recv,
+	.poweroff	= qca_power_off_reg,
 	.enqueue	= qca_enqueue,
 	.dequeue	= qca_dequeue,
 };
@@ -1881,7 +1882,6 @@ static void qca_power_shutdown(struct hci_uart *hu)
 	struct qca_data *qca = hu->priv;
 	unsigned long flags;
 	enum qca_btsoc_type soc_type = qca_soc_type(hu);
-	bool sw_ctrl_state;
 
 	/* From this point we go into power off state. But serial port is
 	 * still open, stop queueing the IBS data and flush all the buffered
@@ -1904,7 +1904,22 @@ static void qca_power_shutdown(struct hci_uart *hu)
 		host_set_baudrate(hu, 2400);
 		qca_send_power_pulse(hu, false);
 		qca_regulator_disable(qcadev);
-	} else if (soc_type == QCA_WCN6750) {
+	} else if (qcadev->bt_en) {
+		gpiod_set_value_cansleep(qcadev->bt_en, 0);
+	}
+
+	set_bit(QCA_BT_OFF, &qca->flags);
+}
+
+static int qca_power_off_reg(struct hci_uart *hu)
+{
+	struct qca_serdev *qcadev;
+	enum qca_btsoc_type soc_type = qca_soc_type(hu);
+	bool sw_ctrl_state;
+
+	qcadev = serdev_device_get_drvdata(hu->serdev);
+
+	if (soc_type == QCA_WCN6750) {
 		gpiod_set_value_cansleep(qcadev->bt_en, 0);
 		msleep(100);
 		qca_regulator_disable(qcadev);
@@ -1912,11 +1927,8 @@ static void qca_power_shutdown(struct hci_uart *hu)
 			sw_ctrl_state = gpiod_get_value_cansleep(qcadev->sw_ctrl);
 			bt_dev_dbg(hu->hdev, "SW_CTRL is %d", sw_ctrl_state);
 		}
-	} else if (qcadev->bt_en) {
-		gpiod_set_value_cansleep(qcadev->bt_en, 0);
 	}
-
-	set_bit(QCA_BT_OFF, &qca->flags);
+	return 0;
 }
 
 static int qca_power_off(struct hci_dev *hdev)
diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
index 3b00d82..b3fec15 100644
--- a/drivers/bluetooth/hci_serdev.c
+++ b/drivers/bluetooth/hci_serdev.c
@@ -157,6 +157,9 @@ static int hci_uart_close(struct hci_dev *hdev)
 		serdev_device_close(hu->serdev);
 	}
 
+	if (hu->proto->poweroff)
+		hu->proto->poweroff(hu);
+
 	return 0;
 }
 
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index fb4a2d0..fc3cd77f 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -59,6 +59,7 @@ struct hci_uart_proto {
 	int (*recv)(struct hci_uart *hu, const void *data, int len);
 	int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb);
 	struct sk_buff *(*dequeue)(struct hci_uart *hu);
+	int (*poweroff)(struct hci_uart *hu);
 };
 
 struct hci_uart {
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux