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@xxxxxxxxxxxxxx> --- 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