bluetooth: hci_qca: Fix qca6390 enable failure after warm reboot
PATCH v2 1/1 bluetooth: hci_qca: Fix qca6390 enable failure after warm reboot
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.
--- drivers/bluetooth/hci_qca.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/bluetooth/hci_qca.c +27 -0
@@ -1975,6 +1975,32 @@ 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 res; +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 }; + +if (qcadev->btsoc_type ==QCA_QCA6390 ) { +serdev_device_write_flush (serdev); + res =serdev_device_write_buf (serdev, + ibs_wake_cmd,sizeof (ibs_wake_cmd)); +BT_DBG ("%s: send ibs_wake_cmd res = %d" , __func__, res); +serdev_device_wait_until_sent (serdev, timeout); +usleep_range (8000 ,10000 ); + +serdev_device_write_flush (serdev); + res =serdev_device_write_buf (serdev, + edl_reset_soc_cmd,sizeof (edl_reset_soc_cmd)); +BT_DBG ("%s: send edl_reset_soc_cmd res = %d" , __func__, res); +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 +2126,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, }, };
Signature · 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 17 lines · Zijun Hu
Warm reboot can not restore qca6390 controller baudrate to default due to lack of controllable
BT_ENpin or power supply, so fails to download firmware after warm reboot.Fixed by sending
EDL_SOC_RESETVSC to reset controller within added device shutdown implementation.Signed-off-by Zijun Hu <[email protected]>--- drivers/bluetooth/hci_qca.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/bluetooth/hci_qca.c +0
-0
drivers/bluetooth/hci_qca.c static void qca_serdev_remove(struct serdev_device *serdev) · line 1980
Quoted 6 lines
drivers/bluetooth/hci_qca.c +3
-0@@ -1975,6 +1975,32 @@ 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 res;
nit: 'ret' would be a more standard name
drivers/bluetooth/hci_qca.c static void qca_serdev_remove(struct serdev_device *serdev) · line 1991
Quoted 11 lines
drivers/bluetooth/hci_qca.c +11
-0+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 }; + +if (qcadev->btsoc_type ==QCA_QCA6390 ) { +serdev_device_write_flush (serdev); + res =serdev_device_write_buf (serdev, + ibs_wake_cmd,sizeof (ibs_wake_cmd)); +BT_DBG ("%s: send ibs_wake_cmd res = %d" , __func__, res);
Why use BT_DBG regardless of the result, instead of using BT_ERR/WARN only in the failure case? And does it actually make sense to continue in case of an error?
drivers/bluetooth/hci_qca.c static void qca_serdev_remove(struct serdev_device *serdev) · line 1998
Quoted 7 lines
drivers/bluetooth/hci_qca.c +7
-0+serdev_device_wait_until_sent (serdev, timeout); +usleep_range (8000 ,10000 ); + +serdev_device_write_flush (serdev); + res =serdev_device_write_buf (serdev, + edl_reset_soc_cmd,sizeof (edl_reset_soc_cmd)); +BT_DBG ("%s: send edl_reset_soc_cmd res = %d" , __func__, res);
ditto
Quoted 19 lines
drivers/bluetooth/hci_qca.c +6
-0+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 +2126,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, }, };Signature · 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project