Lines Matching refs:pio

141 	struct hci_pio_data *pio;
144 pio = kzalloc(sizeof(*pio), GFP_KERNEL);
145 if (!pio)
148 hci->io_data = pio;
149 spin_lock_init(&pio->lock);
174 pio->rx_thresh_size = 2 << rx_thresh;
175 pio->tx_thresh_size = 2 << tx_thresh;
178 pio->rx_thresh_size = 1 << rx_thresh;
179 pio->tx_thresh_size = 1 << tx_thresh;
191 pio->max_ibi_thresh = clamp_val(ibi_val/2, 1, 63);
193 FIELD_PREP(QUEUE_IBI_DATA_THLD, pio->max_ibi_thresh) |
197 pio->reg_queue_thresh = val;
204 pio->enabled_irqs = STAT_ALL_ERRORS;
211 struct hci_pio_data *pio = hci->io_data;
215 if (pio) {
218 BUG_ON(pio->curr_xfer);
219 BUG_ON(pio->curr_rx);
220 BUG_ON(pio->curr_tx);
221 BUG_ON(pio->curr_resp);
222 kfree(pio);
241 static bool hci_pio_do_rx(struct i3c_hci *hci, struct hci_pio_data *pio)
243 struct hci_xfer *xfer = pio->curr_rx;
254 nr_words = min(xfer->data_left / 4, pio->rx_thresh_size);
267 struct hci_pio_data *pio, unsigned int count)
269 struct hci_xfer *xfer = pio->curr_rx;
307 static bool hci_pio_do_tx(struct i3c_hci *hci, struct hci_pio_data *pio)
309 struct hci_xfer *xfer = pio->curr_tx;
321 nr_words = min(xfer->data_left / 4, pio->tx_thresh_size);
347 static bool hci_pio_process_rx(struct i3c_hci *hci, struct hci_pio_data *pio)
349 while (pio->curr_rx && hci_pio_do_rx(hci, pio))
350 pio->curr_rx = pio->curr_rx->next_data;
351 return !pio->curr_rx;
354 static bool hci_pio_process_tx(struct i3c_hci *hci, struct hci_pio_data *pio)
356 while (pio->curr_tx && hci_pio_do_tx(hci, pio))
357 pio->curr_tx = pio->curr_tx->next_data;
358 return !pio->curr_tx;
361 static void hci_pio_queue_data(struct i3c_hci *hci, struct hci_pio_data *pio)
363 struct hci_xfer *xfer = pio->curr_xfer;
372 prev_queue_tail = pio->rx_queue;
373 pio->rx_queue = xfer;
374 if (pio->curr_rx) {
377 pio->curr_rx = xfer;
378 if (!hci_pio_process_rx(hci, pio))
379 pio->enabled_irqs |= STAT_RX_THLD;
382 prev_queue_tail = pio->tx_queue;
383 pio->tx_queue = xfer;
384 if (pio->curr_tx) {
387 pio->curr_tx = xfer;
388 if (!hci_pio_process_tx(hci, pio))
389 pio->enabled_irqs |= STAT_TX_THLD;
473 static void hci_pio_err(struct i3c_hci *hci, struct hci_pio_data *pio,
476 static bool hci_pio_process_resp(struct i3c_hci *hci, struct hci_pio_data *pio)
478 while (pio->curr_resp &&
480 struct hci_xfer *xfer = pio->curr_resp;
490 hci_pio_err(hci, pio, STAT_PROG_ERRORS);
495 if (pio->curr_rx == xfer) {
506 hci_pio_do_trailing_rx(hci, pio,
515 if (hci_pio_process_rx(hci, pio))
516 pio->enabled_irqs &= ~STAT_RX_THLD;
524 if (pio->curr_rx == xfer) {
526 pio->curr_rx = pio->curr_rx->next_data;
527 } else if (pio->curr_tx == xfer) {
529 pio->curr_tx = pio->curr_tx->next_data;
535 pio->curr_resp = xfer->next_resp;
539 return !pio->curr_resp;
542 static void hci_pio_queue_resp(struct i3c_hci *hci, struct hci_pio_data *pio)
544 struct hci_xfer *xfer = pio->curr_xfer;
550 prev_queue_tail = pio->resp_queue;
551 pio->resp_queue = xfer;
552 if (pio->curr_resp) {
555 pio->curr_resp = xfer;
556 if (!hci_pio_process_resp(hci, pio))
557 pio->enabled_irqs |= STAT_RESP_READY;
561 static bool hci_pio_process_cmd(struct i3c_hci *hci, struct hci_pio_data *pio)
563 while (pio->curr_xfer &&
569 hci_pio_queue_data(hci, pio);
575 hci_pio_queue_resp(hci, pio);
579 hci_pio_write_cmd(hci, pio->curr_xfer);
583 pio->curr_xfer = pio->curr_xfer->next_xfer;
585 return !pio->curr_xfer;
590 struct hci_pio_data *pio = hci->io_data;
604 spin_lock_irq(&pio->lock);
605 prev_queue_tail = pio->xfer_queue;
606 pio->xfer_queue = &xfer[n - 1];
607 if (pio->curr_xfer) {
610 pio->curr_xfer = xfer;
611 if (!hci_pio_process_cmd(hci, pio))
612 pio->enabled_irqs |= STAT_CMD_QUEUE_READY;
613 pio_reg_write(INTR_SIGNAL_ENABLE, pio->enabled_irqs);
617 spin_unlock_irq(&pio->lock);
622 struct hci_pio_data *pio,
634 for (p = pio->curr_resp; p; p = p->next_resp)
638 for (p = pio->curr_rx; p; p = p->next_data)
642 for (p = pio->curr_tx; p; p = p->next_data)
651 p_prev_next = &pio->curr_xfer;
652 for (p = pio->curr_xfer; p; p = p->next_xfer) {
668 for (p = pio->curr_resp; p; p = p->next_resp) {
673 for (p = pio->curr_xfer; p; p = p->next_xfer) {
678 pio->curr_xfer = pio->curr_rx = pio->curr_tx = pio->curr_resp = NULL;
685 struct hci_pio_data *pio = hci->io_data;
688 spin_lock_irq(&pio->lock);
694 ret = hci_pio_dequeue_xfer_common(hci, pio, xfer, n);
695 spin_unlock_irq(&pio->lock);
699 static void hci_pio_err(struct i3c_hci *hci, struct hci_pio_data *pio,
728 hci_pio_dequeue_xfer_common(hci, pio, pio->curr_resp, 1);
730 if (pio->curr_tx && pio->curr_tx->data_left != pio->curr_tx->data_len)
731 hci_pio_dequeue_xfer_common(hci, pio, pio->curr_tx, 1);
741 struct hci_pio_data *pio,
744 u32 regval = pio->reg_queue_thresh;
749 if (regval != pio->reg_queue_thresh) {
751 pio->reg_queue_thresh = regval;
757 struct hci_pio_data *pio)
759 struct hci_pio_ibi_data *ibi = &pio->ibi;
768 thresh_val = min(nr_words, pio->max_ibi_thresh);
769 hci_pio_set_ibi_thresh(hci, pio, thresh_val);
791 hci_pio_set_ibi_thresh(hci, pio, 1);
806 static bool hci_pio_prep_new_ibi(struct i3c_hci *hci, struct hci_pio_data *pio)
808 struct hci_pio_ibi_data *ibi = &pio->ibi;
861 static void hci_pio_free_ibi_slot(struct i3c_hci *hci, struct hci_pio_data *pio)
863 struct hci_pio_ibi_data *ibi = &pio->ibi;
873 static bool hci_pio_process_ibi(struct i3c_hci *hci, struct hci_pio_data *pio)
875 struct hci_pio_ibi_data *ibi = &pio->ibi;
878 if (!hci_pio_prep_new_ibi(hci, pio))
886 if (!hci_pio_get_ibi_segment(hci, pio))
894 hci_pio_set_ibi_thresh(hci, pio, 1);
904 hci_pio_set_ibi_thresh(hci, pio, 1);
915 hci_pio_set_ibi_thresh(hci, pio, 1);
925 hci_pio_free_ibi_slot(hci, pio);
934 hci_pio_free_ibi_slot(hci, pio);
984 struct hci_pio_data *pio = hci->io_data;
987 spin_lock(&pio->lock);
989 DBG("(in) status: %#x/%#x", status, pio->enabled_irqs);
990 status &= pio->enabled_irqs | STAT_LATENCY_WARNINGS;
992 spin_unlock(&pio->lock);
997 hci_pio_process_ibi(hci, pio);
1000 if (hci_pio_process_rx(hci, pio))
1001 pio->enabled_irqs &= ~STAT_RX_THLD;
1003 if (hci_pio_process_tx(hci, pio))
1004 pio->enabled_irqs &= ~STAT_TX_THLD;
1006 if (hci_pio_process_resp(hci, pio))
1007 pio->enabled_irqs &= ~STAT_RESP_READY;
1018 hci_pio_err(hci, pio, status & STAT_ALL_ERRORS);
1022 if (hci_pio_process_cmd(hci, pio))
1023 pio->enabled_irqs &= ~STAT_CMD_QUEUE_READY;
1025 pio_reg_write(INTR_SIGNAL_ENABLE, pio->enabled_irqs);
1028 spin_unlock(&pio->lock);