Lines Matching refs:hu

77 	int			(*rx_func)(struct hci_uart *hu, u8 c);
80 struct hci_uart *hu; /* Parent HCI UART */ member
125 static void h5_link_control(struct hci_uart *hu, const void *data, size_t len) in h5_link_control() argument
127 struct h5 *h5 = hu->priv; in h5_link_control()
152 struct hci_uart *hu = h5->hu; in h5_timed_event() local
156 BT_DBG("%s", hu->hdev->name); in h5_timed_event()
159 h5_link_control(hu, sync_req, sizeof(sync_req)); in h5_timed_event()
163 h5_link_control(hu, conf_req, sizeof(conf_req)); in h5_timed_event()
176 BT_DBG("hu %p retransmitting %u pkts", hu, h5->unack.qlen); in h5_timed_event()
188 hci_uart_tx_wakeup(hu); in h5_timed_event()
191 static void h5_peer_reset(struct hci_uart *hu) in h5_peer_reset() argument
193 struct h5 *h5 = hu->priv; in h5_peer_reset()
195 bt_dev_err(hu->hdev, "Peer device has reset"); in h5_peer_reset()
209 hci_reset_dev(hu->hdev); in h5_peer_reset()
212 static int h5_open(struct hci_uart *hu) in h5_open() argument
217 BT_DBG("hu %p", hu); in h5_open()
219 if (hu->serdev) { in h5_open()
220 h5 = serdev_device_get_drvdata(hu->serdev); in h5_open()
227 hu->priv = h5; in h5_open()
228 h5->hu = hu; in h5_open()
243 set_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags); in h5_open()
246 h5_link_control(hu, sync, sizeof(sync)); in h5_open()
252 static int h5_close(struct hci_uart *hu) in h5_close() argument
254 struct h5 *h5 = hu->priv; in h5_close()
268 if (!hu->serdev) in h5_close()
274 static int h5_setup(struct hci_uart *hu) in h5_setup() argument
276 struct h5 *h5 = hu->priv; in h5_setup()
326 static void h5_handle_internal_rx(struct hci_uart *hu) in h5_handle_internal_rx() argument
328 struct h5 *h5 = hu->priv; in h5_handle_internal_rx()
339 BT_DBG("%s", hu->hdev->name); in h5_handle_internal_rx()
351 h5_peer_reset(hu); in h5_handle_internal_rx()
352 h5_link_control(hu, sync_rsp, 2); in h5_handle_internal_rx()
355 h5_peer_reset(hu); in h5_handle_internal_rx()
357 h5_link_control(hu, conf_req, 3); in h5_handle_internal_rx()
359 h5_link_control(hu, conf_rsp, 2); in h5_handle_internal_rx()
360 h5_link_control(hu, conf_req, 3); in h5_handle_internal_rx()
366 hci_uart_init_ready(hu); in h5_handle_internal_rx()
377 h5_link_control(hu, woken_req, 2); in h5_handle_internal_rx()
384 hci_uart_tx_wakeup(hu); in h5_handle_internal_rx()
387 static void h5_complete_rx_pkt(struct hci_uart *hu) in h5_complete_rx_pkt() argument
389 struct h5 *h5 = hu->priv; in h5_complete_rx_pkt()
395 hci_uart_tx_wakeup(hu); in h5_complete_rx_pkt()
412 hci_recv_frame(hu->hdev, h5->rx_skb); in h5_complete_rx_pkt()
418 h5_handle_internal_rx(hu); in h5_complete_rx_pkt()
425 static int h5_rx_crc(struct hci_uart *hu, unsigned char c) in h5_rx_crc() argument
427 h5_complete_rx_pkt(hu); in h5_rx_crc()
432 static int h5_rx_payload(struct hci_uart *hu, unsigned char c) in h5_rx_payload() argument
434 struct h5 *h5 = hu->priv; in h5_rx_payload()
441 h5_complete_rx_pkt(hu); in h5_rx_payload()
447 static int h5_rx_3wire_hdr(struct hci_uart *hu, unsigned char c) in h5_rx_3wire_hdr() argument
449 struct h5 *h5 = hu->priv; in h5_rx_3wire_hdr()
453 hu->hdev->name, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr), in h5_rx_3wire_hdr()
458 bt_dev_err(hu->hdev, "Invalid header checksum"); in h5_rx_3wire_hdr()
464 bt_dev_err(hu->hdev, "Out-of-order packet arrived (%u != %u)", in h5_rx_3wire_hdr()
467 hci_uart_tx_wakeup(hu); in h5_rx_3wire_hdr()
474 bt_dev_err(hu->hdev, "Non-link packet received in non-active state"); in h5_rx_3wire_hdr()
485 static int h5_rx_pkt_start(struct hci_uart *hu, unsigned char c) in h5_rx_pkt_start() argument
487 struct h5 *h5 = hu->priv; in h5_rx_pkt_start()
497 bt_dev_err(hu->hdev, "Can't allocate mem for new packet"); in h5_rx_pkt_start()
502 h5->rx_skb->dev = (void *)hu->hdev; in h5_rx_pkt_start()
507 static int h5_rx_delimiter(struct hci_uart *hu, unsigned char c) in h5_rx_delimiter() argument
509 struct h5 *h5 = hu->priv; in h5_rx_delimiter()
560 static int h5_recv(struct hci_uart *hu, const void *data, int count) in h5_recv() argument
562 struct h5 *h5 = hu->priv; in h5_recv()
565 BT_DBG("%s pending %zu count %d", hu->hdev->name, h5->rx_pending, in h5_recv()
573 bt_dev_err(hu->hdev, "Too short H5 packet"); in h5_recv()
584 processed = h5->rx_func(hu, *ptr); in h5_recv()
592 if (hu->serdev) { in h5_recv()
593 pm_runtime_get(&hu->serdev->dev); in h5_recv()
594 pm_runtime_mark_last_busy(&hu->serdev->dev); in h5_recv()
595 pm_runtime_put_autosuspend(&hu->serdev->dev); in h5_recv()
601 static int h5_enqueue(struct hci_uart *hu, struct sk_buff *skb) in h5_enqueue() argument
603 struct h5 *h5 = hu->priv; in h5_enqueue()
606 bt_dev_err(hu->hdev, "Packet too long (%u bytes)", skb->len); in h5_enqueue()
612 bt_dev_err(hu->hdev, "Ignoring HCI data in non-active state"); in h5_enqueue()
629 bt_dev_err(hu->hdev, "Unknown packet type %u", hci_skb_pkt_type(skb)); in h5_enqueue()
634 if (hu->serdev) { in h5_enqueue()
635 pm_runtime_get_sync(&hu->serdev->dev); in h5_enqueue()
636 pm_runtime_mark_last_busy(&hu->serdev->dev); in h5_enqueue()
637 pm_runtime_put_autosuspend(&hu->serdev->dev); in h5_enqueue()
682 static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type, in h5_prepare_pkt() argument
685 struct h5 *h5 = hu->priv; in h5_prepare_pkt()
691 bt_dev_err(hu->hdev, "Unknown packet type %u", pkt_type); in h5_prepare_pkt()
724 hu->hdev->name, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr), in h5_prepare_pkt()
739 static struct sk_buff *h5_dequeue(struct hci_uart *hu) in h5_dequeue() argument
741 struct h5 *h5 = hu->priv; in h5_dequeue()
755 return h5_prepare_pkt(hu, HCI_3WIRE_LINK_PKT, wakeup_req, 2); in h5_dequeue()
760 nskb = h5_prepare_pkt(hu, hci_skb_pkt_type(skb), in h5_dequeue()
768 bt_dev_err(hu->hdev, "Could not dequeue pkt because alloc_skb failed"); in h5_dequeue()
778 nskb = h5_prepare_pkt(hu, hci_skb_pkt_type(skb), in h5_dequeue()
788 bt_dev_err(hu->hdev, "Could not dequeue pkt because alloc_skb failed"); in h5_dequeue()
795 return h5_prepare_pkt(hu, HCI_3WIRE_ACK_PKT, NULL, 0); in h5_dequeue()
800 static int h5_flush(struct hci_uart *hu) in h5_flush() argument
802 BT_DBG("hu %p", hu); in h5_flush()
828 h5->hu = &h5->serdev_hu; in h5_serdev_probe()
909 btrtl_dev = btrtl_initialize(h5->hu->hdev, h5->id); in h5_btrtl_setup()
913 err = btrtl_get_uart_settings(h5->hu->hdev, btrtl_dev, in h5_btrtl_setup()
920 skb = __hci_cmd_sync(h5->hu->hdev, 0xfc17, sizeof(baudrate_data), in h5_btrtl_setup()
923 rtl_dev_err(h5->hu->hdev, "set baud rate command failed\n"); in h5_btrtl_setup()
932 serdev_device_set_baudrate(h5->hu->serdev, controller_baudrate); in h5_btrtl_setup()
933 serdev_device_set_flow_control(h5->hu->serdev, flow_control); in h5_btrtl_setup()
938 err = btrtl_download_firmware(h5->hu->hdev, btrtl_dev); in h5_btrtl_setup()
944 btrtl_set_quirks(h5->hu->hdev, btrtl_dev); in h5_btrtl_setup()
960 set_bit(HCI_UART_NO_SUSPEND_NOTIFIER, &h5->hu->flags); in h5_btrtl_open()
963 serdev_device_set_flow_control(h5->hu->serdev, false); in h5_btrtl_open()
964 serdev_device_set_parity(h5->hu->serdev, SERDEV_PARITY_EVEN); in h5_btrtl_open()
965 serdev_device_set_baudrate(h5->hu->serdev, 115200); in h5_btrtl_open()
968 pm_runtime_set_active(&h5->hu->serdev->dev); in h5_btrtl_open()
969 pm_runtime_use_autosuspend(&h5->hu->serdev->dev); in h5_btrtl_open()
970 pm_runtime_set_autosuspend_delay(&h5->hu->serdev->dev, in h5_btrtl_open()
972 pm_runtime_enable(&h5->hu->serdev->dev); in h5_btrtl_open()
989 pm_runtime_disable(&h5->hu->serdev->dev); in h5_btrtl_close()
1003 serdev_device_set_flow_control(h5->hu->serdev, false); in h5_btrtl_suspend()
1044 reprobe->dev = get_device(&h5->hu->serdev->dev); in h5_btrtl_resume()
1050 serdev_device_set_flow_control(h5->hu->serdev, true); in h5_btrtl_resume()