Lines Matching refs:mhi_chan

133 		      struct mhi_chan *mhi_chan)  in mhi_ring_chan_db()  argument
135 struct mhi_ring *ring = &mhi_chan->tre_ring; in mhi_ring_chan_db()
147 mhi_chan->db_cfg.process_db(mhi_cntrl, &mhi_chan->db_cfg, in mhi_ring_chan_db()
276 struct mhi_chan *ul_chan, *dl_chan; in mhi_destroy_device()
337 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? in mhi_get_free_desc_count() local
339 struct mhi_ring *tre_ring = &mhi_chan->tre_ring; in mhi_get_free_desc_count()
362 struct mhi_chan *mhi_chan; in mhi_create_devices() local
367 mhi_chan = mhi_cntrl->mhi_chan; in mhi_create_devices()
368 for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { in mhi_create_devices()
369 if (!mhi_chan->configured || mhi_chan->mhi_dev || in mhi_create_devices()
370 !(mhi_chan->ee_mask & BIT(mhi_cntrl->ee))) in mhi_create_devices()
377 switch (mhi_chan->dir) { in mhi_create_devices()
379 mhi_dev->ul_chan = mhi_chan; in mhi_create_devices()
380 mhi_dev->ul_chan_id = mhi_chan->chan; in mhi_create_devices()
384 mhi_dev->dl_chan = mhi_chan; in mhi_create_devices()
385 mhi_dev->dl_chan_id = mhi_chan->chan; in mhi_create_devices()
394 mhi_chan->mhi_dev = mhi_dev; in mhi_create_devices()
397 if ((i + 1) < mhi_cntrl->max_chan && mhi_chan[1].configured) { in mhi_create_devices()
398 if (!strcmp(mhi_chan[1].name, mhi_chan->name)) { in mhi_create_devices()
400 mhi_chan++; in mhi_create_devices()
401 if (mhi_chan->dir == DMA_TO_DEVICE) { in mhi_create_devices()
402 mhi_dev->ul_chan = mhi_chan; in mhi_create_devices()
403 mhi_dev->ul_chan_id = mhi_chan->chan; in mhi_create_devices()
405 mhi_dev->dl_chan = mhi_chan; in mhi_create_devices()
406 mhi_dev->dl_chan_id = mhi_chan->chan; in mhi_create_devices()
409 mhi_chan->mhi_dev = mhi_dev; in mhi_create_devices()
414 mhi_dev->name = mhi_chan->name; in mhi_create_devices()
466 struct mhi_chan *mhi_chan = mhi_event->mhi_chan; in mhi_irq_handler() local
467 struct mhi_device *mhi_dev = mhi_chan->mhi_dev; in mhi_irq_handler()
569 struct mhi_chan *mhi_chan) in parse_xfer_event() argument
578 buf_ring = &mhi_chan->buf_ring; in parse_xfer_event()
579 tre_ring = &mhi_chan->tre_ring; in parse_xfer_event()
591 write_lock_irqsave(&mhi_chan->lock, flags); in parse_xfer_event()
593 read_lock_bh(&mhi_chan->lock); in parse_xfer_event()
595 if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) in parse_xfer_event()
621 result.dir = mhi_chan->dir; in parse_xfer_event()
646 mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); in parse_xfer_event()
648 if (mhi_chan->dir == DMA_TO_DEVICE) { in parse_xfer_event()
659 if (mhi_chan->pre_alloc) { in parse_xfer_event()
660 if (mhi_queue_buf(mhi_chan->mhi_dev, in parse_xfer_event()
661 mhi_chan->dir, in parse_xfer_event()
666 mhi_chan->chan); in parse_xfer_event()
678 mhi_chan->db_cfg.db_mode = 1; in parse_xfer_event()
682 mhi_ring_chan_db(mhi_cntrl, mhi_chan); in parse_xfer_event()
695 write_unlock_irqrestore(&mhi_chan->lock, flags); in parse_xfer_event()
697 read_unlock_bh(&mhi_chan->lock); in parse_xfer_event()
704 struct mhi_chan *mhi_chan) in parse_rsc_event() argument
713 buf_ring = &mhi_chan->buf_ring; in parse_rsc_event()
714 tre_ring = &mhi_chan->tre_ring; in parse_rsc_event()
731 result.dir = mhi_chan->dir; in parse_rsc_event()
733 read_lock_bh(&mhi_chan->lock); in parse_rsc_event()
735 if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) in parse_rsc_event()
741 mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); in parse_rsc_event()
761 read_unlock_bh(&mhi_chan->lock); in parse_rsc_event()
773 struct mhi_chan *mhi_chan; in mhi_process_cmd_completion() local
787 mhi_cntrl->mhi_chan[chan].configured) { in mhi_process_cmd_completion()
788 mhi_chan = &mhi_cntrl->mhi_chan[chan]; in mhi_process_cmd_completion()
789 write_lock_bh(&mhi_chan->lock); in mhi_process_cmd_completion()
790 mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); in mhi_process_cmd_completion()
791 complete(&mhi_chan->completion); in mhi_process_cmd_completion()
792 write_unlock_bh(&mhi_chan->lock); in mhi_process_cmd_completion()
809 struct mhi_chan *mhi_chan; in mhi_process_ctrl_ev_ring() local
937 mhi_chan = &mhi_cntrl->mhi_chan[chan]; in mhi_process_ctrl_ev_ring()
938 if (!mhi_chan->configured) in mhi_process_ctrl_ev_ring()
940 parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); in mhi_process_ctrl_ev_ring()
981 struct mhi_chan *mhi_chan; in mhi_process_data_event_ring() local
1008 mhi_cntrl->mhi_chan[chan].configured) { in mhi_process_data_event_ring()
1009 mhi_chan = &mhi_cntrl->mhi_chan[chan]; in mhi_process_data_event_ring()
1012 parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); in mhi_process_data_event_ring()
1015 parse_rsc_event(mhi_cntrl, local_rp, mhi_chan); in mhi_process_data_event_ring()
1113 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : in mhi_queue() local
1115 struct mhi_ring *tre_ring = &mhi_chan->tre_ring; in mhi_queue()
1130 ret = mhi_gen_tre(mhi_cntrl, mhi_chan, buf_info, mflags); in mhi_queue()
1143 if (mhi_chan->dir == DMA_TO_DEVICE) in mhi_queue()
1147 mhi_ring_chan_db(mhi_cntrl, mhi_chan); in mhi_queue()
1161 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : in mhi_queue_skb() local
1169 if (unlikely(mhi_chan->pre_alloc)) in mhi_queue_skb()
1179 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : in mhi_queue_dma() local
1188 if (unlikely(mhi_chan->pre_alloc)) in mhi_queue_dma()
1195 int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, in mhi_gen_tre() argument
1204 buf_ring = &mhi_chan->buf_ring; in mhi_gen_tre()
1205 tre_ring = &mhi_chan->tre_ring; in mhi_gen_tre()
1216 buf_info->dir = mhi_chan->dir; in mhi_gen_tre()
1228 bei = !!(mhi_chan->intmod); in mhi_gen_tre()
1258 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? in mhi_queue_is_full() local
1260 struct mhi_ring *tre_ring = &mhi_chan->tre_ring; in mhi_queue_is_full()
1267 struct mhi_chan *mhi_chan, in mhi_send_cmd() argument
1276 if (mhi_chan) in mhi_send_cmd()
1277 chan = mhi_chan->chan; in mhi_send_cmd()
1320 struct mhi_chan *mhi_chan, in mhi_update_channel_state() argument
1323 struct device *dev = &mhi_chan->mhi_dev->dev; in mhi_update_channel_state()
1327 dev_dbg(dev, "%d: Updating channel state to: %s\n", mhi_chan->chan, in mhi_update_channel_state()
1332 write_lock_irq(&mhi_chan->lock); in mhi_update_channel_state()
1333 if (mhi_chan->ch_state != MHI_CH_STATE_STOP && in mhi_update_channel_state()
1334 mhi_chan->ch_state != MHI_CH_STATE_ENABLED && in mhi_update_channel_state()
1335 mhi_chan->ch_state != MHI_CH_STATE_SUSPENDED) { in mhi_update_channel_state()
1336 write_unlock_irq(&mhi_chan->lock); in mhi_update_channel_state()
1339 mhi_chan->ch_state = MHI_CH_STATE_DISABLED; in mhi_update_channel_state()
1340 write_unlock_irq(&mhi_chan->lock); in mhi_update_channel_state()
1345 if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) in mhi_update_channel_state()
1351 if (mhi_chan->ch_state != MHI_CH_STATE_STOP && in mhi_update_channel_state()
1352 mhi_chan->ch_state != MHI_CH_STATE_DISABLED) in mhi_update_channel_state()
1359 mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); in mhi_update_channel_state()
1369 reinit_completion(&mhi_chan->completion); in mhi_update_channel_state()
1370 ret = mhi_send_cmd(mhi_cntrl, mhi_chan, cmd); in mhi_update_channel_state()
1373 mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); in mhi_update_channel_state()
1377 ret = wait_for_completion_timeout(&mhi_chan->completion, in mhi_update_channel_state()
1379 if (!ret || mhi_chan->ccs != MHI_EV_CC_SUCCESS) { in mhi_update_channel_state()
1382 mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); in mhi_update_channel_state()
1390 write_lock_irq(&mhi_chan->lock); in mhi_update_channel_state()
1391 mhi_chan->ch_state = (to_state == MHI_CH_STATE_TYPE_START) ? in mhi_update_channel_state()
1393 write_unlock_irq(&mhi_chan->lock); in mhi_update_channel_state()
1397 mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); in mhi_update_channel_state()
1407 struct mhi_chan *mhi_chan) in mhi_unprepare_channel() argument
1410 struct device *dev = &mhi_chan->mhi_dev->dev; in mhi_unprepare_channel()
1412 mutex_lock(&mhi_chan->mutex); in mhi_unprepare_channel()
1414 if (!(BIT(mhi_cntrl->ee) & mhi_chan->ee_mask)) { in mhi_unprepare_channel()
1416 TO_MHI_EXEC_STR(mhi_cntrl->ee), mhi_chan->ee_mask); in mhi_unprepare_channel()
1421 ret = mhi_update_channel_state(mhi_cntrl, mhi_chan, in mhi_unprepare_channel()
1425 mhi_chan->chan); in mhi_unprepare_channel()
1428 write_lock_irq(&mhi_chan->lock); in mhi_unprepare_channel()
1429 mhi_chan->ch_state = MHI_CH_STATE_DISABLED; in mhi_unprepare_channel()
1430 write_unlock_irq(&mhi_chan->lock); in mhi_unprepare_channel()
1432 if (!mhi_chan->offload_ch) { in mhi_unprepare_channel()
1433 mhi_reset_chan(mhi_cntrl, mhi_chan); in mhi_unprepare_channel()
1434 mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); in mhi_unprepare_channel()
1436 dev_dbg(dev, "%d: successfully reset\n", mhi_chan->chan); in mhi_unprepare_channel()
1438 mutex_unlock(&mhi_chan->mutex); in mhi_unprepare_channel()
1442 struct mhi_chan *mhi_chan, unsigned int flags) in mhi_prepare_channel() argument
1445 struct device *dev = &mhi_chan->mhi_dev->dev; in mhi_prepare_channel()
1447 if (!(BIT(mhi_cntrl->ee) & mhi_chan->ee_mask)) { in mhi_prepare_channel()
1449 TO_MHI_EXEC_STR(mhi_cntrl->ee), mhi_chan->ee_mask); in mhi_prepare_channel()
1453 mutex_lock(&mhi_chan->mutex); in mhi_prepare_channel()
1456 if (!mhi_chan->offload_ch) { in mhi_prepare_channel()
1457 ret = mhi_init_chan_ctxt(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1462 ret = mhi_update_channel_state(mhi_cntrl, mhi_chan, in mhi_prepare_channel()
1467 if (mhi_chan->dir == DMA_FROM_DEVICE) in mhi_prepare_channel()
1468 mhi_chan->pre_alloc = !!(flags & MHI_CH_INBOUND_ALLOC_BUFS); in mhi_prepare_channel()
1471 if (mhi_chan->pre_alloc) { in mhi_prepare_channel()
1473 &mhi_chan->tre_ring); in mhi_prepare_channel()
1490 ret = mhi_gen_tre(mhi_cntrl, mhi_chan, &info, MHI_EOT); in mhi_prepare_channel()
1499 read_lock_irq(&mhi_chan->lock); in mhi_prepare_channel()
1500 mhi_ring_chan_db(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1501 read_unlock_irq(&mhi_chan->lock); in mhi_prepare_channel()
1506 mutex_unlock(&mhi_chan->mutex); in mhi_prepare_channel()
1511 if (!mhi_chan->offload_ch) in mhi_prepare_channel()
1512 mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1515 mutex_unlock(&mhi_chan->mutex); in mhi_prepare_channel()
1520 mutex_unlock(&mhi_chan->mutex); in mhi_prepare_channel()
1521 mhi_unprepare_channel(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1570 struct mhi_chan *mhi_chan) in mhi_reset_data_chan() argument
1576 buf_ring = &mhi_chan->buf_ring; in mhi_reset_data_chan()
1577 tre_ring = &mhi_chan->tre_ring; in mhi_reset_data_chan()
1583 if (mhi_chan->dir == DMA_TO_DEVICE) { in mhi_reset_data_chan()
1595 if (mhi_chan->pre_alloc) { in mhi_reset_data_chan()
1599 mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); in mhi_reset_data_chan()
1604 void mhi_reset_chan(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan) in mhi_reset_chan() argument
1608 int chan = mhi_chan->chan; in mhi_reset_chan()
1611 if (mhi_chan->offload_ch) in mhi_reset_chan()
1615 mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; in mhi_reset_chan()
1616 er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_chan->er_index]; in mhi_reset_chan()
1620 mhi_reset_data_chan(mhi_cntrl, mhi_chan); in mhi_reset_chan()
1629 struct mhi_chan *mhi_chan; in __mhi_prepare_for_transfer() local
1632 mhi_chan = dir ? mhi_dev->dl_chan : mhi_dev->ul_chan; in __mhi_prepare_for_transfer()
1633 if (!mhi_chan) in __mhi_prepare_for_transfer()
1636 ret = mhi_prepare_channel(mhi_cntrl, mhi_chan, flags); in __mhi_prepare_for_transfer()
1645 mhi_chan = dir ? mhi_dev->dl_chan : mhi_dev->ul_chan; in __mhi_prepare_for_transfer()
1646 if (!mhi_chan) in __mhi_prepare_for_transfer()
1649 mhi_unprepare_channel(mhi_cntrl, mhi_chan); in __mhi_prepare_for_transfer()
1670 struct mhi_chan *mhi_chan; in mhi_unprepare_from_transfer() local
1674 mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; in mhi_unprepare_from_transfer()
1675 if (!mhi_chan) in mhi_unprepare_from_transfer()
1678 mhi_unprepare_channel(mhi_cntrl, mhi_chan); in mhi_unprepare_from_transfer()
1686 struct mhi_chan *mhi_chan = mhi_dev->dl_chan; in mhi_poll() local
1687 struct mhi_event *mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; in mhi_poll()