Lines Matching +full:88 +full:w8987 +full:- +full:bt

1 // SPDX-License-Identifier: GPL-2.0-or-later
261 /* UART register addresses of BT chip */
321 struct ps_data *psdata = &nxpdev->psdata; in nxp_drv_send_cmd()
327 psdata->driver_sent_cmd = true; in nxp_drv_send_cmd()
329 psdata->driver_sent_cmd = false; in nxp_drv_send_cmd()
336 if (schedule_work(&nxpdev->tx_work)) in btnxpuart_tx_wakeup()
337 set_bit(BTNXPUART_TX_STATE_ACTIVE, &nxpdev->tx_state); in btnxpuart_tx_wakeup()
343 struct ps_data *psdata = &nxpdev->psdata; in ps_start_timer()
348 if (psdata->cur_psmode == PS_MODE_ENABLE) in ps_start_timer()
349 mod_timer(&psdata->ps_timer, jiffies + msecs_to_jiffies(psdata->h2c_ps_interval)); in ps_start_timer()
351 if (psdata->ps_state == PS_STATE_AWAKE && psdata->ps_cmd == PS_CMD_ENTER_PS) in ps_start_timer()
352 cancel_work_sync(&psdata->work); in ps_start_timer()
357 struct ps_data *psdata = &nxpdev->psdata; in ps_cancel_timer()
359 flush_work(&psdata->work); in ps_cancel_timer()
360 timer_shutdown_sync(&psdata->ps_timer); in ps_cancel_timer()
366 struct ps_data *psdata = &nxpdev->psdata; in ps_control()
369 if (psdata->ps_state == ps_state || in ps_control()
370 !test_bit(BTNXPUART_SERDEV_OPEN, &nxpdev->tx_state)) in ps_control()
373 mutex_lock(&psdata->ps_lock); in ps_control()
374 switch (psdata->cur_h2c_wakeupmode) { in ps_control()
377 status = serdev_device_set_tiocm(nxpdev->serdev, TIOCM_DTR, 0); in ps_control()
379 status = serdev_device_set_tiocm(nxpdev->serdev, 0, TIOCM_DTR); in ps_control()
384 status = serdev_device_break_ctl(nxpdev->serdev, 0); in ps_control()
386 status = serdev_device_break_ctl(nxpdev->serdev, -1); in ps_control()
387 msleep(20); /* Allow chip to detect UART-break and enter sleep */ in ps_control()
393 psdata->ps_state = ps_state; in ps_control()
394 mutex_unlock(&psdata->ps_lock); in ps_control()
404 if (data->ps_cmd == PS_CMD_ENTER_PS && data->cur_psmode == PS_MODE_ENABLE) in ps_work_func()
405 ps_control(data->hdev, PS_STATE_SLEEP); in ps_work_func()
406 else if (data->ps_cmd == PS_CMD_EXIT_PS) in ps_work_func()
407 ps_control(data->hdev, PS_STATE_AWAKE); in ps_work_func()
413 struct hci_dev *hdev = data->hdev; in ps_timeout_func()
416 if (test_bit(BTNXPUART_TX_STATE_ACTIVE, &nxpdev->tx_state)) { in ps_timeout_func()
419 data->ps_cmd = PS_CMD_ENTER_PS; in ps_timeout_func()
420 schedule_work(&data->work); in ps_timeout_func()
427 struct ps_data *psdata = &nxpdev->psdata; in ps_setup()
429 psdata->hdev = hdev; in ps_setup()
430 INIT_WORK(&psdata->work, ps_work_func); in ps_setup()
431 mutex_init(&psdata->ps_lock); in ps_setup()
432 timer_setup(&psdata->ps_timer, ps_timeout_func, 0); in ps_setup()
437 struct ps_data *psdata = &nxpdev->psdata; in ps_wakeup()
440 mutex_lock(&psdata->ps_lock); in ps_wakeup()
441 ps_state = psdata->ps_state; in ps_wakeup()
442 mutex_unlock(&psdata->ps_lock); in ps_wakeup()
445 psdata->ps_cmd = PS_CMD_EXIT_PS; in ps_wakeup()
446 schedule_work(&psdata->work); in ps_wakeup()
454 struct ps_data *psdata = &nxpdev->psdata; in ps_cleanup()
457 mutex_lock(&psdata->ps_lock); in ps_cleanup()
458 ps_state = psdata->ps_state; in ps_cleanup()
459 mutex_unlock(&psdata->ps_lock); in ps_cleanup()
462 ps_control(psdata->hdev, PS_STATE_AWAKE); in ps_cleanup()
465 cancel_work_sync(&psdata->work); in ps_cleanup()
466 mutex_destroy(&psdata->ps_lock); in ps_cleanup()
472 struct ps_data *psdata = &nxpdev->psdata; in send_ps_cmd()
477 if (psdata->target_ps_mode == PS_MODE_ENABLE) in send_ps_cmd()
481 pcmd.c2h_ps_interval = __cpu_to_le16(psdata->c2h_ps_interval); in send_ps_cmd()
492 psdata->cur_psmode = psdata->target_ps_mode; in send_ps_cmd()
494 psdata->target_ps_mode = psdata->cur_psmode; in send_ps_cmd()
495 if (psdata->cur_psmode == PS_MODE_ENABLE) in send_ps_cmd()
500 *status, psdata->cur_psmode); in send_ps_cmd()
510 struct ps_data *psdata = &nxpdev->psdata; in send_wakeup_method_cmd()
515 pcmd.c2h_wakeupmode = psdata->c2h_wakeupmode; in send_wakeup_method_cmd()
516 pcmd.c2h_wakeup_gpio = psdata->c2h_wakeup_gpio; in send_wakeup_method_cmd()
517 switch (psdata->h2c_wakeupmode) { in send_wakeup_method_cmd()
530 bt_dev_err(hdev, "Setting wake-up method failed (%ld)", PTR_ERR(skb)); in send_wakeup_method_cmd()
537 psdata->cur_h2c_wakeupmode = psdata->h2c_wakeupmode; in send_wakeup_method_cmd()
539 psdata->h2c_wakeupmode = psdata->cur_h2c_wakeupmode; in send_wakeup_method_cmd()
541 *status, psdata->cur_h2c_wakeupmode); in send_wakeup_method_cmd()
551 struct ps_data *psdata = &nxpdev->psdata; in ps_init()
553 serdev_device_set_tiocm(nxpdev->serdev, 0, TIOCM_RTS); in ps_init()
555 serdev_device_set_tiocm(nxpdev->serdev, TIOCM_RTS, 0); in ps_init()
558 psdata->ps_state = PS_STATE_AWAKE; in ps_init()
559 psdata->c2h_wakeupmode = BT_HOST_WAKEUP_METHOD_NONE; in ps_init()
560 psdata->c2h_wakeup_gpio = 0xff; in ps_init()
562 psdata->cur_h2c_wakeupmode = WAKEUP_METHOD_INVALID; in ps_init()
563 psdata->h2c_ps_interval = PS_DEFAULT_TIMEOUT_PERIOD_MS; in ps_init()
566 psdata->h2c_wakeupmode = WAKEUP_METHOD_DTR; in ps_init()
567 serdev_device_set_tiocm(nxpdev->serdev, 0, TIOCM_DTR); in ps_init()
568 serdev_device_set_tiocm(nxpdev->serdev, TIOCM_DTR, 0); in ps_init()
572 psdata->h2c_wakeupmode = WAKEUP_METHOD_BREAK; in ps_init()
573 serdev_device_break_ctl(nxpdev->serdev, -1); in ps_init()
575 serdev_device_break_ctl(nxpdev->serdev, 0); in ps_init()
580 psdata->cur_psmode = PS_MODE_DISABLE; in ps_init()
581 psdata->target_ps_mode = DEFAULT_PS_MODE; in ps_init()
583 if (psdata->cur_h2c_wakeupmode != psdata->h2c_wakeupmode) in ps_init()
585 if (psdata->cur_psmode != psdata->target_ps_mode) in ps_init()
595 nxpdev->fw_dnld_v1_offset = 0; in nxp_download_firmware()
596 nxpdev->fw_v1_sent_bytes = 0; in nxp_download_firmware()
597 nxpdev->fw_v1_expected_len = HDR_LEN; in nxp_download_firmware()
598 nxpdev->boot_reg_offset = 0; in nxp_download_firmware()
599 nxpdev->fw_dnld_v3_offset = 0; in nxp_download_firmware()
600 nxpdev->fw_v3_offset_correction = 0; in nxp_download_firmware()
601 nxpdev->baudrate_changed = false; in nxp_download_firmware()
602 nxpdev->timeout_changed = false; in nxp_download_firmware()
603 nxpdev->helper_downloaded = false; in nxp_download_firmware()
605 serdev_device_set_baudrate(nxpdev->serdev, HCI_NXP_PRI_BAUDRATE); in nxp_download_firmware()
606 serdev_device_set_flow_control(nxpdev->serdev, false); in nxp_download_firmware()
607 nxpdev->current_baudrate = HCI_NXP_PRI_BAUDRATE; in nxp_download_firmware()
610 err = wait_event_interruptible_timeout(nxpdev->fw_dnld_done_wait_q, in nxp_download_firmware()
612 &nxpdev->tx_state), in nxp_download_firmware()
615 release_firmware(nxpdev->fw); in nxp_download_firmware()
616 memset(nxpdev->fw_name, 0, sizeof(nxpdev->fw_name)); in nxp_download_firmware()
620 nxpdev->fw_dnld_v1_offset ? in nxp_download_firmware()
621 nxpdev->fw_dnld_v1_offset : in nxp_download_firmware()
622 nxpdev->fw_dnld_v3_offset); in nxp_download_firmware()
623 return -ETIMEDOUT; in nxp_download_firmware()
625 if (test_bit(BTNXPUART_FW_DOWNLOAD_ABORT, &nxpdev->tx_state)) { in nxp_download_firmware()
627 return -EINTR; in nxp_download_firmware()
630 serdev_device_set_flow_control(nxpdev->serdev, true); in nxp_download_firmware()
649 serdev_device_write_buf(nxpdev->serdev, ack_nak, len); in nxp_send_ack()
657 u32 clkdivaddr = CLKDIVADDR - nxpdev->boot_reg_offset; in nxp_fw_change_baudrate()
658 u32 uartdivaddr = UARTDIVADDR - nxpdev->boot_reg_offset; in nxp_fw_change_baudrate()
659 u32 uartmcraddr = UARTMCRADDR - nxpdev->boot_reg_offset; in nxp_fw_change_baudrate()
660 u32 uartreinitaddr = UARTREINITADDR - nxpdev->boot_reg_offset; in nxp_fw_change_baudrate()
661 u32 uarticraddr = UARTICRADDR - nxpdev->boot_reg_offset; in nxp_fw_change_baudrate()
662 u32 uartfcraddr = UARTFCRADDR - nxpdev->boot_reg_offset; in nxp_fw_change_baudrate()
670 sizeof(nxp_cmd5) - 4)); in nxp_fw_change_baudrate()
672 serdev_device_write_buf(nxpdev->serdev, (u8 *)&nxp_cmd5, sizeof(nxp_cmd5)); in nxp_fw_change_baudrate()
673 nxpdev->fw_v3_offset_correction += req_len; in nxp_fw_change_baudrate()
689 sizeof(uart_config) - 4)); in nxp_fw_change_baudrate()
691 serdev_device_write_buf(nxpdev->serdev, (u8 *)&uart_config, sizeof(uart_config)); in nxp_fw_change_baudrate()
692 serdev_device_wait_until_sent(nxpdev->serdev, 0); in nxp_fw_change_baudrate()
693 nxpdev->fw_v3_offset_correction += req_len; in nxp_fw_change_baudrate()
712 sizeof(nxp_cmd7) - 4)); in nxp_fw_change_timeout()
713 serdev_device_write_buf(nxpdev->serdev, (u8 *)&nxp_cmd7, sizeof(nxp_cmd7)); in nxp_fw_change_timeout()
714 serdev_device_wait_until_sent(nxpdev->serdev, 0); in nxp_fw_change_timeout()
715 nxpdev->fw_v3_offset_correction += req_len; in nxp_fw_change_timeout()
723 return __le32_to_cpu(hdr->payload_len); in nxp_get_data_len()
728 return test_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in is_fw_downloading()
733 if (test_bit(BTNXPUART_CHECK_BOOT_SIGNATURE, &nxpdev->tx_state)) { in process_boot_signature()
734 clear_bit(BTNXPUART_CHECK_BOOT_SIGNATURE, &nxpdev->tx_state); in process_boot_signature()
735 wake_up_interruptible(&nxpdev->check_boot_sign_wait_q); in process_boot_signature()
749 return -ENOENT; in nxp_request_firmware()
751 if (!strlen(nxpdev->fw_name)) { in nxp_request_firmware()
753 !device_property_read_string(&nxpdev->serdev->dev, in nxp_request_firmware()
754 "firmware-name", in nxp_request_firmware()
757 snprintf(nxpdev->fw_name, MAX_FW_FILE_NAME_LEN, "nxp/%s", fw_name); in nxp_request_firmware()
758 err = request_firmware_direct(&nxpdev->fw, nxpdev->fw_name, &hdev->dev); in nxp_request_firmware()
760 snprintf(nxpdev->fw_name, MAX_FW_FILE_NAME_LEN, "nxp/%s", fw_name_old); in nxp_request_firmware()
761 err = request_firmware_direct(&nxpdev->fw, nxpdev->fw_name, &hdev->dev); in nxp_request_firmware()
764 bt_dev_info(hdev, "Request Firmware: %s", nxpdev->fw_name); in nxp_request_firmware()
766 bt_dev_err(hdev, "Firmware file %s not found", nxpdev->fw_name); in nxp_request_firmware()
767 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_request_firmware()
784 chip_id = le16_to_cpu(req->chip_id ^ req->chip_id_comp); in nxp_recv_chip_ver_v1()
785 if (chip_id == 0xffff && nxpdev->fw_dnld_v1_offset) { in nxp_recv_chip_ver_v1()
786 nxpdev->fw_dnld_v1_offset = 0; in nxp_recv_chip_ver_v1()
787 nxpdev->fw_v1_sent_bytes = 0; in nxp_recv_chip_ver_v1()
788 nxpdev->fw_v1_expected_len = HDR_LEN; in nxp_recv_chip_ver_v1()
789 release_firmware(nxpdev->fw); in nxp_recv_chip_ver_v1()
790 memset(nxpdev->fw_name, 0, sizeof(nxpdev->fw_name)); in nxp_recv_chip_ver_v1()
802 struct btnxpuart_data *nxp_data = nxpdev->nxp_data; in nxp_recv_fw_req_v1()
813 len = __le16_to_cpu(req->len ^ req->len_comp); in nxp_recv_fw_req_v1()
821 len = __le16_to_cpu(req->len); in nxp_recv_fw_req_v1()
823 if (!nxp_data->helper_fw_name) { in nxp_recv_fw_req_v1()
824 if (!nxpdev->timeout_changed) { in nxp_recv_fw_req_v1()
825 nxpdev->timeout_changed = nxp_fw_change_timeout(hdev, in nxp_recv_fw_req_v1()
829 if (!nxpdev->baudrate_changed) { in nxp_recv_fw_req_v1()
830 nxpdev->baudrate_changed = nxp_fw_change_baudrate(hdev, in nxp_recv_fw_req_v1()
832 if (nxpdev->baudrate_changed) { in nxp_recv_fw_req_v1()
833 serdev_device_set_baudrate(nxpdev->serdev, in nxp_recv_fw_req_v1()
835 serdev_device_set_flow_control(nxpdev->serdev, true); in nxp_recv_fw_req_v1()
836 nxpdev->current_baudrate = HCI_NXP_SEC_BAUDRATE; in nxp_recv_fw_req_v1()
842 if (!nxp_data->helper_fw_name || nxpdev->helper_downloaded) { in nxp_recv_fw_req_v1()
843 if (nxp_request_firmware(hdev, nxp_data->fw_name, nxp_data->fw_name_old)) in nxp_recv_fw_req_v1()
845 } else if (nxp_data->helper_fw_name && !nxpdev->helper_downloaded) { in nxp_recv_fw_req_v1()
846 if (nxp_request_firmware(hdev, nxp_data->helper_fw_name, NULL)) in nxp_recv_fw_req_v1()
852 nxpdev->fw->size); in nxp_recv_fw_req_v1()
853 if (nxp_data->helper_fw_name && !nxpdev->helper_downloaded) { in nxp_recv_fw_req_v1()
854 nxpdev->helper_downloaded = true; in nxp_recv_fw_req_v1()
855 serdev_device_wait_until_sent(nxpdev->serdev, 0); in nxp_recv_fw_req_v1()
856 serdev_device_set_baudrate(nxpdev->serdev, in nxp_recv_fw_req_v1()
858 serdev_device_set_flow_control(nxpdev->serdev, true); in nxp_recv_fw_req_v1()
860 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_recv_fw_req_v1()
861 wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q); in nxp_recv_fw_req_v1()
869 len = nxpdev->fw_v1_sent_bytes; in nxp_recv_fw_req_v1()
872 nxpdev->fw_dnld_v1_offset += nxpdev->fw_v1_sent_bytes; in nxp_recv_fw_req_v1()
882 * and we need to re-send the previous header again. in nxp_recv_fw_req_v1()
884 if (len == nxpdev->fw_v1_expected_len) { in nxp_recv_fw_req_v1()
886 nxpdev->fw_v1_expected_len = nxp_get_data_len(nxpdev->fw->data + in nxp_recv_fw_req_v1()
887 nxpdev->fw_dnld_v1_offset); in nxp_recv_fw_req_v1()
889 nxpdev->fw_v1_expected_len = HDR_LEN; in nxp_recv_fw_req_v1()
892 nxpdev->fw_dnld_v1_offset -= nxpdev->fw_v1_sent_bytes; in nxp_recv_fw_req_v1()
893 nxpdev->fw_v1_expected_len = HDR_LEN; in nxp_recv_fw_req_v1()
897 if (nxpdev->fw_dnld_v1_offset + len <= nxpdev->fw->size) in nxp_recv_fw_req_v1()
898 serdev_device_write_buf(nxpdev->serdev, nxpdev->fw->data + in nxp_recv_fw_req_v1()
899 nxpdev->fw_dnld_v1_offset, len); in nxp_recv_fw_req_v1()
900 nxpdev->fw_v1_sent_bytes = len; in nxp_recv_fw_req_v1()
925 nxpdev->boot_reg_offset = 1; in nxp_get_fw_name_from_chipid()
990 chip_id = le16_to_cpu(req->chip_id); in nxp_recv_chip_ver_v3()
991 loader_ver = req->loader_ver; in nxp_recv_chip_ver_v3()
1006 __u32 offset = __le32_to_cpu(req->offset); in nxp_handle_fw_download_error()
1007 __u16 err = __le16_to_cpu(req->error); in nxp_handle_fw_download_error()
1017 sizeof(nak_tx_buf) - 1, 0xff); in nxp_handle_fw_download_error()
1018 serdev_device_write_buf(nxpdev->serdev, nak_tx_buf.buf, in nxp_handle_fw_download_error()
1040 if (!req || !nxpdev->fw) in nxp_recv_fw_req_v3()
1043 if (!req->error) { in nxp_recv_fw_req_v3()
1050 len = __le16_to_cpu(req->len); in nxp_recv_fw_req_v3()
1052 if (!nxpdev->timeout_changed) { in nxp_recv_fw_req_v3()
1053 nxpdev->timeout_changed = nxp_fw_change_timeout(hdev, len); in nxp_recv_fw_req_v3()
1057 if (!nxpdev->baudrate_changed) { in nxp_recv_fw_req_v3()
1058 nxpdev->baudrate_changed = nxp_fw_change_baudrate(hdev, len); in nxp_recv_fw_req_v3()
1059 if (nxpdev->baudrate_changed) { in nxp_recv_fw_req_v3()
1060 serdev_device_set_baudrate(nxpdev->serdev, in nxp_recv_fw_req_v3()
1062 serdev_device_set_flow_control(nxpdev->serdev, true); in nxp_recv_fw_req_v3()
1063 nxpdev->current_baudrate = HCI_NXP_SEC_BAUDRATE; in nxp_recv_fw_req_v3()
1068 if (req->len == 0) { in nxp_recv_fw_req_v3()
1070 nxpdev->fw->size); in nxp_recv_fw_req_v3()
1071 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_recv_fw_req_v3()
1072 wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q); in nxp_recv_fw_req_v3()
1076 offset = __le32_to_cpu(req->offset); in nxp_recv_fw_req_v3()
1077 if (offset < nxpdev->fw_v3_offset_correction) { in nxp_recv_fw_req_v3()
1086 nxpdev->fw_dnld_v3_offset = offset - nxpdev->fw_v3_offset_correction; in nxp_recv_fw_req_v3()
1087 serdev_device_write_buf(nxpdev->serdev, nxpdev->fw->data + in nxp_recv_fw_req_v3()
1088 nxpdev->fw_dnld_v3_offset, len); in nxp_recv_fw_req_v3()
1098 __le32 new_baudrate = __cpu_to_le32(nxpdev->new_baudrate); in nxp_set_baudrate_cmd()
1099 struct ps_data *psdata = &nxpdev->psdata; in nxp_set_baudrate_cmd()
1115 serdev_device_set_baudrate(nxpdev->serdev, nxpdev->new_baudrate); in nxp_set_baudrate_cmd()
1116 nxpdev->current_baudrate = nxpdev->new_baudrate; in nxp_set_baudrate_cmd()
1119 *status, nxpdev->new_baudrate); in nxp_set_baudrate_cmd()
1128 serdev_device_set_baudrate(nxpdev->serdev, HCI_NXP_PRI_BAUDRATE); in nxp_check_boot_sign()
1129 if (test_bit(BTNXPUART_IR_IN_PROGRESS, &nxpdev->tx_state)) in nxp_check_boot_sign()
1130 serdev_device_set_flow_control(nxpdev->serdev, false); in nxp_check_boot_sign()
1132 serdev_device_set_flow_control(nxpdev->serdev, true); in nxp_check_boot_sign()
1133 set_bit(BTNXPUART_CHECK_BOOT_SIGNATURE, &nxpdev->tx_state); in nxp_check_boot_sign()
1135 return wait_event_interruptible_timeout(nxpdev->check_boot_sign_wait_q, in nxp_check_boot_sign()
1137 &nxpdev->tx_state), in nxp_check_boot_sign()
1149 return -ENOMEM; in nxp_set_ind_reset()
1171 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_setup()
1174 serdev_device_set_baudrate(nxpdev->serdev, nxpdev->fw_init_baudrate); in nxp_setup()
1175 nxpdev->current_baudrate = nxpdev->fw_init_baudrate; in nxp_setup()
1177 if (nxpdev->current_baudrate != HCI_NXP_SEC_BAUDRATE) { in nxp_setup()
1178 nxpdev->new_baudrate = HCI_NXP_SEC_BAUDRATE; in nxp_setup()
1184 if (test_and_clear_bit(BTNXPUART_IR_IN_PROGRESS, &nxpdev->tx_state)) in nxp_setup()
1196 set_bit(BTNXPUART_IR_IN_PROGRESS, &nxpdev->tx_state); in nxp_hw_err()
1211 if (test_bit(BTNXPUART_IR_IN_PROGRESS, &nxpdev->tx_state)) { in nxp_shutdown()
1218 serdev_device_set_flow_control(nxpdev->serdev, false); in nxp_shutdown()
1219 set_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_shutdown()
1233 skb_queue_tail(&nxpdev->txq, skb); in btnxpuart_queue_skb()
1241 struct ps_data *psdata = &nxpdev->psdata; in nxp_enqueue()
1248 * driver flags accordingly and ask driver to re-send the command to FW. in nxp_enqueue()
1253 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT && !psdata->driver_sent_cmd) { in nxp_enqueue()
1254 hdr = (struct hci_command_hdr *)skb->data; in nxp_enqueue()
1255 if (hdr->plen != (skb->len - HCI_COMMAND_HDR_SIZE)) in nxp_enqueue()
1258 switch (__le16_to_cpu(hdr->opcode)) { in nxp_enqueue()
1260 if (hdr->plen == sizeof(ps_parm)) { in nxp_enqueue()
1261 memcpy(&ps_parm, skb->data + HCI_COMMAND_HDR_SIZE, hdr->plen); in nxp_enqueue()
1263 psdata->target_ps_mode = PS_MODE_ENABLE; in nxp_enqueue()
1265 psdata->target_ps_mode = PS_MODE_DISABLE; in nxp_enqueue()
1266 psdata->c2h_ps_interval = __le16_to_cpu(ps_parm.c2h_ps_interval); in nxp_enqueue()
1272 if (hdr->plen == sizeof(wakeup_parm)) { in nxp_enqueue()
1273 memcpy(&wakeup_parm, skb->data + HCI_COMMAND_HDR_SIZE, hdr->plen); in nxp_enqueue()
1274 psdata->c2h_wakeupmode = wakeup_parm.c2h_wakeupmode; in nxp_enqueue()
1275 psdata->c2h_wakeup_gpio = wakeup_parm.c2h_wakeup_gpio; in nxp_enqueue()
1276 psdata->h2c_wakeup_gpio = wakeup_parm.h2c_wakeup_gpio; in nxp_enqueue()
1279 psdata->h2c_wakeupmode = WAKEUP_METHOD_DTR; in nxp_enqueue()
1283 psdata->h2c_wakeupmode = WAKEUP_METHOD_BREAK; in nxp_enqueue()
1291 if (hdr->plen == sizeof(baudrate_parm)) { in nxp_enqueue()
1292 memcpy(&baudrate_parm, skb->data + HCI_COMMAND_HDR_SIZE, hdr->plen); in nxp_enqueue()
1293 nxpdev->new_baudrate = __le32_to_cpu(baudrate_parm); in nxp_enqueue()
1299 if (hdr->plen == 1) { in nxp_enqueue()
1321 return skb_dequeue(&nxpdev->txq); in nxp_dequeue()
1329 struct serdev_device *serdev = nxpdev->serdev; in btnxpuart_tx_work()
1330 struct hci_dev *hdev = nxpdev->hdev; in btnxpuart_tx_work()
1338 len = serdev_device_write_buf(serdev, skb->data, skb->len); in btnxpuart_tx_work()
1339 hdev->stat.byte_tx += len; in btnxpuart_tx_work()
1342 if (skb->len > 0) { in btnxpuart_tx_work()
1343 skb_queue_head(&nxpdev->txq, skb); in btnxpuart_tx_work()
1349 hdev->stat.cmd_tx++; in btnxpuart_tx_work()
1352 hdev->stat.acl_tx++; in btnxpuart_tx_work()
1355 hdev->stat.sco_tx++; in btnxpuart_tx_work()
1361 clear_bit(BTNXPUART_TX_STATE_ACTIVE, &nxpdev->tx_state); in btnxpuart_tx_work()
1369 err = serdev_device_open(nxpdev->serdev); in btnxpuart_open()
1372 dev_name(&nxpdev->serdev->dev)); in btnxpuart_open()
1374 set_bit(BTNXPUART_SERDEV_OPEN, &nxpdev->tx_state); in btnxpuart_open()
1383 serdev_device_close(nxpdev->serdev); in btnxpuart_close()
1384 skb_queue_purge(&nxpdev->txq); in btnxpuart_close()
1385 if (!IS_ERR_OR_NULL(nxpdev->rx_skb)) { in btnxpuart_close()
1386 kfree_skb(nxpdev->rx_skb); in btnxpuart_close()
1387 nxpdev->rx_skb = NULL; in btnxpuart_close()
1389 clear_bit(BTNXPUART_SERDEV_OPEN, &nxpdev->tx_state); in btnxpuart_close()
1398 serdev_device_write_flush(nxpdev->serdev); in btnxpuart_flush()
1399 skb_queue_purge(&nxpdev->txq); in btnxpuart_flush()
1401 cancel_work_sync(&nxpdev->tx_work); in btnxpuart_flush()
1403 if (!IS_ERR_OR_NULL(nxpdev->rx_skb)) { in btnxpuart_flush()
1404 kfree_skb(nxpdev->rx_skb); in btnxpuart_flush()
1405 nxpdev->rx_skb = NULL; in btnxpuart_flush()
1429 nxpdev->rx_skb = h4_recv_buf(nxpdev->hdev, nxpdev->rx_skb, data, count, in btnxpuart_receive_buf()
1431 if (IS_ERR(nxpdev->rx_skb)) { in btnxpuart_receive_buf()
1432 int err = PTR_ERR(nxpdev->rx_skb); in btnxpuart_receive_buf()
1433 /* Safe to ignore out-of-sync bootloader signatures */ in btnxpuart_receive_buf()
1435 bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err); in btnxpuart_receive_buf()
1439 nxpdev->hdev->stat.byte_rx += count; in btnxpuart_receive_buf()
1458 nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL); in nxp_serdev_probe()
1460 return -ENOMEM; in nxp_serdev_probe()
1462 nxpdev->nxp_data = (struct btnxpuart_data *)device_get_match_data(&serdev->dev); in nxp_serdev_probe()
1464 nxpdev->serdev = serdev; in nxp_serdev_probe()
1469 INIT_WORK(&nxpdev->tx_work, btnxpuart_tx_work); in nxp_serdev_probe()
1470 skb_queue_head_init(&nxpdev->txq); in nxp_serdev_probe()
1472 init_waitqueue_head(&nxpdev->fw_dnld_done_wait_q); in nxp_serdev_probe()
1473 init_waitqueue_head(&nxpdev->check_boot_sign_wait_q); in nxp_serdev_probe()
1475 device_property_read_u32(&nxpdev->serdev->dev, "fw-init-baudrate", in nxp_serdev_probe()
1476 &nxpdev->fw_init_baudrate); in nxp_serdev_probe()
1477 if (!nxpdev->fw_init_baudrate) in nxp_serdev_probe()
1478 nxpdev->fw_init_baudrate = FW_INIT_BAUDRATE; in nxp_serdev_probe()
1480 set_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_serdev_probe()
1487 dev_err(&serdev->dev, "Can't allocate HCI device\n"); in nxp_serdev_probe()
1488 return -ENOMEM; in nxp_serdev_probe()
1491 nxpdev->hdev = hdev; in nxp_serdev_probe()
1493 hdev->bus = HCI_UART; in nxp_serdev_probe()
1496 hdev->manufacturer = MANUFACTURER_NXP; in nxp_serdev_probe()
1497 hdev->open = btnxpuart_open; in nxp_serdev_probe()
1498 hdev->close = btnxpuart_close; in nxp_serdev_probe()
1499 hdev->flush = btnxpuart_flush; in nxp_serdev_probe()
1500 hdev->setup = nxp_setup; in nxp_serdev_probe()
1501 hdev->send = nxp_enqueue; in nxp_serdev_probe()
1502 hdev->hw_error = nxp_hw_err; in nxp_serdev_probe()
1503 hdev->shutdown = nxp_shutdown; in nxp_serdev_probe()
1504 SET_HCIDEV_DEV(hdev, &serdev->dev); in nxp_serdev_probe()
1507 dev_err(&serdev->dev, "Can't register HCI device\n"); in nxp_serdev_probe()
1509 return -ENODEV; in nxp_serdev_probe()
1520 struct hci_dev *hdev = nxpdev->hdev; in nxp_serdev_remove()
1523 set_bit(BTNXPUART_FW_DOWNLOAD_ABORT, &nxpdev->tx_state); in nxp_serdev_remove()
1524 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); in nxp_serdev_remove()
1525 wake_up_interruptible(&nxpdev->check_boot_sign_wait_q); in nxp_serdev_remove()
1526 wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q); in nxp_serdev_remove()
1530 * driver baudrate in case this driver is re-inserted. in nxp_serdev_remove()
1532 if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) { in nxp_serdev_remove()
1533 nxpdev->new_baudrate = nxpdev->fw_init_baudrate; in nxp_serdev_remove()
1546 struct ps_data *psdata = &nxpdev->psdata; in nxp_serdev_suspend()
1548 ps_control(psdata->hdev, PS_STATE_SLEEP); in nxp_serdev_suspend()
1555 struct ps_data *psdata = &nxpdev->psdata; in nxp_serdev_resume()
1557 ps_control(psdata->hdev, PS_STATE_AWAKE); in nxp_serdev_resume()
1575 { .compatible = "nxp,88w8987-bt", .data = &w8987_data },
1576 { .compatible = "nxp,88w8997-bt", .data = &w8997_data },