Lines Matching refs:hu

135 	struct hci_uart *hu;  member
225 static void qca_power_shutdown(struct hci_uart *hu);
229 static enum qca_btsoc_type qca_soc_type(struct hci_uart *hu) in qca_soc_type() argument
233 if (hu->serdev) { in qca_soc_type()
234 struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); in qca_soc_type()
244 static const char *qca_get_firmware_name(struct hci_uart *hu) in qca_get_firmware_name() argument
246 if (hu->serdev) { in qca_get_firmware_name()
247 struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); in qca_get_firmware_name()
272 static void serial_clock_vote(unsigned long vote, struct hci_uart *hu) in serial_clock_vote() argument
274 struct qca_data *qca = hu->priv; in serial_clock_vote()
319 __serial_clock_on(hu->tty); in serial_clock_vote()
321 __serial_clock_off(hu->tty); in serial_clock_vote()
342 static int send_hci_ibs_cmd(u8 cmd, struct hci_uart *hu) in send_hci_ibs_cmd() argument
346 struct qca_data *qca = hu->priv; in send_hci_ibs_cmd()
348 BT_DBG("hu %p send hci ibs cmd 0x%x", hu, cmd); in send_hci_ibs_cmd()
368 struct hci_uart *hu = qca->hu; in qca_wq_awake_device() local
372 BT_DBG("hu %p wq awake device", hu); in qca_wq_awake_device()
375 serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_ON, hu); in qca_wq_awake_device()
380 if (send_hci_ibs_cmd(HCI_IBS_WAKE_IND, hu) < 0) in qca_wq_awake_device()
392 hci_uart_tx_wakeup(hu); in qca_wq_awake_device()
399 struct hci_uart *hu = qca->hu; in qca_wq_awake_rx() local
402 BT_DBG("hu %p wq awake rx", hu); in qca_wq_awake_rx()
404 serial_clock_vote(HCI_IBS_RX_VOTE_CLOCK_ON, hu); in qca_wq_awake_rx()
412 if (send_hci_ibs_cmd(HCI_IBS_WAKE_ACK, hu) < 0) in qca_wq_awake_rx()
420 hci_uart_tx_wakeup(hu); in qca_wq_awake_rx()
427 struct hci_uart *hu = qca->hu; in qca_wq_serial_rx_clock_vote_off() local
429 BT_DBG("hu %p rx clock vote off", hu); in qca_wq_serial_rx_clock_vote_off()
431 serial_clock_vote(HCI_IBS_RX_VOTE_CLOCK_OFF, hu); in qca_wq_serial_rx_clock_vote_off()
438 struct hci_uart *hu = qca->hu; in qca_wq_serial_tx_clock_vote_off() local
440 BT_DBG("hu %p tx clock vote off", hu); in qca_wq_serial_tx_clock_vote_off()
443 hci_uart_tx_wakeup(hu); in qca_wq_serial_tx_clock_vote_off()
448 serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_OFF, hu); in qca_wq_serial_tx_clock_vote_off()
454 struct hci_uart *hu = qca->hu; in hci_ibs_tx_idle_timeout() local
457 BT_DBG("hu %p idle timeout in %d state", hu, qca->tx_ibs_state); in hci_ibs_tx_idle_timeout()
465 if (send_hci_ibs_cmd(HCI_IBS_SLEEP_IND, hu) < 0) { in hci_ibs_tx_idle_timeout()
487 struct hci_uart *hu = qca->hu; in hci_ibs_wake_retrans_timeout() local
492 hu, qca->tx_ibs_state); in hci_ibs_wake_retrans_timeout()
507 if (send_hci_ibs_cmd(HCI_IBS_WAKE_IND, hu) < 0) { in hci_ibs_wake_retrans_timeout()
526 hci_uart_tx_wakeup(hu); in hci_ibs_wake_retrans_timeout()
534 struct hci_uart *hu = qca->hu; in qca_controller_memdump_timeout() local
543 hci_reset_dev(hu->hdev); in qca_controller_memdump_timeout()
552 static int qca_open(struct hci_uart *hu) in qca_open() argument
557 BT_DBG("hu %p qca_open", hu); in qca_open()
559 if (!hci_uart_has_flow_control(hu)) in qca_open()
587 qca->hu = hu; in qca_open()
596 hu->priv = qca; in qca_open()
598 if (hu->serdev) { in qca_open()
599 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_open()
602 hu->init_speed = qcadev->init_speed; in qca_open()
605 hu->oper_speed = qcadev->oper_speed; in qca_open()
622 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_debugfs_init() local
623 struct qca_data *qca = hu->priv; in qca_debugfs_init()
667 static int qca_flush(struct hci_uart *hu) in qca_flush() argument
669 struct qca_data *qca = hu->priv; in qca_flush()
671 BT_DBG("hu %p qca flush", hu); in qca_flush()
680 static int qca_close(struct hci_uart *hu) in qca_close() argument
682 struct qca_data *qca = hu->priv; in qca_close()
684 BT_DBG("hu %p qca close", hu); in qca_close()
686 serial_clock_vote(HCI_IBS_VOTE_STATS_UPDATE, hu); in qca_close()
694 qca->hu = NULL; in qca_close()
698 hu->priv = NULL; in qca_close()
707 static void device_want_to_wakeup(struct hci_uart *hu) in device_want_to_wakeup() argument
710 struct qca_data *qca = hu->priv; in device_want_to_wakeup()
712 BT_DBG("hu %p want to wake up", hu); in device_want_to_wakeup()
737 if (send_hci_ibs_cmd(HCI_IBS_WAKE_ACK, hu) < 0) { in device_want_to_wakeup()
754 hci_uart_tx_wakeup(hu); in device_want_to_wakeup()
759 static void device_want_to_sleep(struct hci_uart *hu) in device_want_to_sleep() argument
762 struct qca_data *qca = hu->priv; in device_want_to_sleep()
764 BT_DBG("hu %p want to sleep in %d state", hu, qca->rx_ibs_state); in device_want_to_sleep()
795 static void device_woke_up(struct hci_uart *hu) in device_woke_up() argument
798 struct qca_data *qca = hu->priv; in device_woke_up()
801 BT_DBG("hu %p woke up", hu); in device_woke_up()
842 hci_uart_tx_wakeup(hu); in device_woke_up()
848 static int qca_enqueue(struct hci_uart *hu, struct sk_buff *skb) in qca_enqueue() argument
851 struct qca_data *qca = hu->priv; in qca_enqueue()
853 BT_DBG("hu %p qca enq skb %p tx_ibs_state %d", hu, skb, in qca_enqueue()
858 bt_dev_dbg(hu->hdev, "SSR is in progress"); in qca_enqueue()
918 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_ibs_sleep_ind() local
920 BT_DBG("hu %p recv hci ibs cmd 0x%x", hu, HCI_IBS_SLEEP_IND); in qca_ibs_sleep_ind()
922 device_want_to_sleep(hu); in qca_ibs_sleep_ind()
930 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_ibs_wake_ind() local
932 BT_DBG("hu %p recv hci ibs cmd 0x%x", hu, HCI_IBS_WAKE_IND); in qca_ibs_wake_ind()
934 device_want_to_wakeup(hu); in qca_ibs_wake_ind()
942 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_ibs_wake_ack() local
944 BT_DBG("hu %p recv hci ibs cmd 0x%x", hu, HCI_IBS_WAKE_ACK); in qca_ibs_wake_ack()
946 device_woke_up(hu); in qca_ibs_wake_ack()
969 struct hci_uart *hu = qca->hu; in qca_controller_memdump() local
979 enum qca_btsoc_type soc_type = qca_soc_type(hu); in qca_controller_memdump()
1022 bt_dev_err(hu->hdev, "Rx invalid memdump size"); in qca_controller_memdump()
1028 bt_dev_info(hu->hdev, "QCA collecting dump of size:%u", in qca_controller_memdump()
1048 bt_dev_err(hu->hdev, "QCA: Discarding other packets"); in qca_controller_memdump()
1067 bt_dev_err(hu->hdev, "QCA controller missed packet:%d", in qca_controller_memdump()
1072 bt_dev_err(hu->hdev, in qca_controller_memdump()
1087 bt_dev_err(hu->hdev, in qca_controller_memdump()
1090 bt_dev_dbg(hu->hdev, in qca_controller_memdump()
1100 bt_dev_err(hu->hdev, in qca_controller_memdump()
1107 bt_dev_info(hu->hdev, in qca_controller_memdump()
1112 dev_coredumpv(&hu->serdev->dev, memdump_buf, in qca_controller_memdump()
1129 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_controller_memdump_event() local
1130 struct qca_data *qca = hu->priv; in qca_controller_memdump_event()
1141 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_recv_event() local
1142 struct qca_data *qca = hu->priv; in qca_recv_event()
1206 static int qca_recv(struct hci_uart *hu, const void *data, int count) in qca_recv() argument
1208 struct qca_data *qca = hu->priv; in qca_recv()
1210 if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) in qca_recv()
1213 qca->rx_skb = h4_recv_buf(hu->hdev, qca->rx_skb, data, count, in qca_recv()
1217 bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err); in qca_recv()
1225 static struct sk_buff *qca_dequeue(struct hci_uart *hu) in qca_dequeue() argument
1227 struct qca_data *qca = hu->priv; in qca_dequeue()
1270 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_set_baudrate() local
1271 struct qca_data *qca = hu->priv; in qca_set_baudrate()
1291 hci_uart_tx_wakeup(hu); in qca_set_baudrate()
1298 if (hu->serdev) in qca_set_baudrate()
1299 serdev_device_wait_until_sent(hu->serdev, in qca_set_baudrate()
1303 if (qca_is_wcn399x(qca_soc_type(hu))) in qca_set_baudrate()
1311 static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed) in host_set_baudrate() argument
1313 if (hu->serdev) in host_set_baudrate()
1314 serdev_device_set_baudrate(hu->serdev, speed); in host_set_baudrate()
1316 hci_uart_set_baudrate(hu, speed); in host_set_baudrate()
1319 static int qca_send_power_pulse(struct hci_uart *hu, bool on) in qca_send_power_pulse() argument
1335 bt_dev_dbg(hu->hdev, "sending power pulse %02x to controller", cmd); in qca_send_power_pulse()
1337 serdev_device_write_flush(hu->serdev); in qca_send_power_pulse()
1338 hci_uart_set_flow_control(hu, true); in qca_send_power_pulse()
1339 ret = serdev_device_write_buf(hu->serdev, &cmd, sizeof(cmd)); in qca_send_power_pulse()
1341 bt_dev_err(hu->hdev, "failed to send power pulse %02x", cmd); in qca_send_power_pulse()
1345 serdev_device_wait_until_sent(hu->serdev, timeout); in qca_send_power_pulse()
1346 hci_uart_set_flow_control(hu, false); in qca_send_power_pulse()
1357 static unsigned int qca_get_speed(struct hci_uart *hu, in qca_get_speed() argument
1363 if (hu->init_speed) in qca_get_speed()
1364 speed = hu->init_speed; in qca_get_speed()
1365 else if (hu->proto->init_speed) in qca_get_speed()
1366 speed = hu->proto->init_speed; in qca_get_speed()
1368 if (hu->oper_speed) in qca_get_speed()
1369 speed = hu->oper_speed; in qca_get_speed()
1370 else if (hu->proto->oper_speed) in qca_get_speed()
1371 speed = hu->proto->oper_speed; in qca_get_speed()
1377 static int qca_check_speeds(struct hci_uart *hu) in qca_check_speeds() argument
1379 if (qca_is_wcn399x(qca_soc_type(hu))) { in qca_check_speeds()
1380 if (!qca_get_speed(hu, QCA_INIT_SPEED) && in qca_check_speeds()
1381 !qca_get_speed(hu, QCA_OPER_SPEED)) in qca_check_speeds()
1384 if (!qca_get_speed(hu, QCA_INIT_SPEED) || in qca_check_speeds()
1385 !qca_get_speed(hu, QCA_OPER_SPEED)) in qca_check_speeds()
1392 static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) in qca_set_speed() argument
1395 struct qca_data *qca = hu->priv; in qca_set_speed()
1399 speed = qca_get_speed(hu, QCA_INIT_SPEED); in qca_set_speed()
1401 host_set_baudrate(hu, speed); in qca_set_speed()
1403 enum qca_btsoc_type soc_type = qca_soc_type(hu); in qca_set_speed()
1405 speed = qca_get_speed(hu, QCA_OPER_SPEED); in qca_set_speed()
1413 hci_uart_set_flow_control(hu, true); in qca_set_speed()
1421 bt_dev_dbg(hu->hdev, "Set UART speed to %d", speed); in qca_set_speed()
1422 ret = qca_set_baudrate(hu->hdev, qca_baudrate); in qca_set_speed()
1426 host_set_baudrate(hu, speed); in qca_set_speed()
1430 hci_uart_set_flow_control(hu, false); in qca_set_speed()
1438 bt_dev_err(hu->hdev, in qca_set_speed()
1450 static int qca_send_crashbuffer(struct hci_uart *hu) in qca_send_crashbuffer() argument
1452 struct qca_data *qca = hu->priv; in qca_send_crashbuffer()
1457 bt_dev_err(hu->hdev, "Failed to allocate memory for skb packet"); in qca_send_crashbuffer()
1468 bt_dev_info(hu->hdev, "crash the soc to collect controller dump"); in qca_send_crashbuffer()
1470 hci_uart_tx_wakeup(hu); in qca_send_crashbuffer()
1477 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_wait_for_dump_collection() local
1478 struct qca_data *qca = hu->priv; in qca_wait_for_dump_collection()
1488 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_hw_error() local
1489 struct qca_data *qca = hu->priv; in qca_hw_error()
1503 qca_send_crashbuffer(hu); in qca_hw_error()
1515 bt_dev_err(hu->hdev, "clearing allocated memory due to memdump timeout"); in qca_hw_error()
1537 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_cmd_timeout() local
1538 struct qca_data *qca = hu->priv; in qca_cmd_timeout()
1543 qca_send_crashbuffer(hu); in qca_cmd_timeout()
1560 hci_reset_dev(hu->hdev); in qca_cmd_timeout()
1566 static int qca_wcn3990_init(struct hci_uart *hu) in qca_wcn3990_init() argument
1574 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_wcn3990_init()
1576 serdev_device_close(hu->serdev); in qca_wcn3990_init()
1581 ret = serdev_device_open(hu->serdev); in qca_wcn3990_init()
1583 bt_dev_err(hu->hdev, "failed to open port"); in qca_wcn3990_init()
1589 host_set_baudrate(hu, 2400); in qca_wcn3990_init()
1590 ret = qca_send_power_pulse(hu, false); in qca_wcn3990_init()
1594 qca_set_speed(hu, QCA_INIT_SPEED); in qca_wcn3990_init()
1595 ret = qca_send_power_pulse(hu, true); in qca_wcn3990_init()
1604 serdev_device_close(hu->serdev); in qca_wcn3990_init()
1605 ret = serdev_device_open(hu->serdev); in qca_wcn3990_init()
1607 bt_dev_err(hu->hdev, "failed to open port"); in qca_wcn3990_init()
1611 hci_uart_set_flow_control(hu, false); in qca_wcn3990_init()
1618 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_power_on() local
1619 enum qca_btsoc_type soc_type = qca_soc_type(hu); in qca_power_on()
1626 if (!hu->serdev) in qca_power_on()
1630 ret = qca_wcn3990_init(hu); in qca_power_on()
1632 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_power_on()
1643 static int qca_setup(struct hci_uart *hu) in qca_setup() argument
1645 struct hci_dev *hdev = hu->hdev; in qca_setup()
1646 struct qca_data *qca = hu->priv; in qca_setup()
1649 enum qca_btsoc_type soc_type = qca_soc_type(hu); in qca_setup()
1650 const char *firmware_name = qca_get_firmware_name(hu); in qca_setup()
1654 ret = qca_check_speeds(hu); in qca_setup()
1685 qca_set_speed(hu, QCA_INIT_SPEED); in qca_setup()
1689 speed = qca_get_speed(hu, QCA_OPER_SPEED); in qca_setup()
1691 ret = qca_set_speed(hu, QCA_OPER_SPEED); in qca_setup()
1712 hu->hdev->hw_error = qca_hw_error; in qca_setup()
1713 hu->hdev->cmd_timeout = qca_cmd_timeout; in qca_setup()
1725 qca_power_shutdown(hu); in qca_setup()
1726 if (hu->serdev) { in qca_setup()
1727 serdev_device_close(hu->serdev); in qca_setup()
1728 ret = serdev_device_open(hu->serdev); in qca_setup()
1741 hu->hdev->set_bdaddr = qca_set_bdaddr_rome; in qca_setup()
1743 hu->hdev->set_bdaddr = qca_set_bdaddr; in qca_setup()
1802 static void qca_power_shutdown(struct hci_uart *hu) in qca_power_shutdown() argument
1805 struct qca_data *qca = hu->priv; in qca_power_shutdown()
1807 enum qca_btsoc_type soc_type = qca_soc_type(hu); in qca_power_shutdown()
1809 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_power_shutdown()
1817 qca_flush(hu); in qca_power_shutdown()
1823 if (!hu->serdev) in qca_power_shutdown()
1827 host_set_baudrate(hu, 2400); in qca_power_shutdown()
1828 qca_send_power_pulse(hu, false); in qca_power_shutdown()
1837 struct hci_uart *hu = hci_get_drvdata(hdev); in qca_power_off() local
1838 struct qca_data *qca = hu->priv; in qca_power_off()
1839 enum qca_btsoc_type soc_type = qca_soc_type(hu); in qca_power_off()
1841 hu->hdev->hw_error = NULL; in qca_power_off()
1842 hu->hdev->cmd_timeout = NULL; in qca_power_off()
1851 qca_power_shutdown(hu); in qca_power_off()
2078 struct hci_uart *hu = &qcadev->serdev_hu; in qca_suspend() local
2079 struct qca_data *qca = hu->priv; in qca_suspend()
2104 serdev_device_write_flush(hu->serdev); in qca_suspend()
2106 ret = serdev_device_write_buf(hu->serdev, &cmd, sizeof(cmd)); in qca_suspend()
2133 serdev_device_wait_until_sent(hu->serdev, in qca_suspend()
2135 serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_OFF, hu); in qca_suspend()
2161 struct hci_uart *hu = &qcadev->serdev_hu; in qca_resume() local
2162 struct qca_data *qca = hu->priv; in qca_resume()