Lines Matching refs:mhi_chan
131 struct mhi_chan *mhi_chan) in mhi_ring_chan_db() argument
133 struct mhi_ring *ring = &mhi_chan->tre_ring; in mhi_ring_chan_db()
145 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()
453 struct mhi_chan *mhi_chan = mhi_event->mhi_chan; in mhi_irq_handler() local
454 struct mhi_device *mhi_dev = mhi_chan->mhi_dev; in mhi_irq_handler()
561 struct mhi_chan *mhi_chan) in parse_xfer_event() argument
570 buf_ring = &mhi_chan->buf_ring; in parse_xfer_event()
571 tre_ring = &mhi_chan->tre_ring; in parse_xfer_event()
583 write_lock_irqsave(&mhi_chan->lock, flags); in parse_xfer_event()
585 read_lock_bh(&mhi_chan->lock); in parse_xfer_event()
587 if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) in parse_xfer_event()
613 result.dir = mhi_chan->dir; in parse_xfer_event()
637 read_unlock_bh(&mhi_chan->lock); in parse_xfer_event()
640 mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); in parse_xfer_event()
642 if (mhi_chan->dir == DMA_TO_DEVICE) { in parse_xfer_event()
653 if (mhi_chan->pre_alloc) { in parse_xfer_event()
654 if (mhi_queue_buf(mhi_chan->mhi_dev, in parse_xfer_event()
655 mhi_chan->dir, in parse_xfer_event()
660 mhi_chan->chan); in parse_xfer_event()
665 read_lock_bh(&mhi_chan->lock); in parse_xfer_event()
674 mhi_chan->db_cfg.db_mode = 1; in parse_xfer_event()
678 mhi_ring_chan_db(mhi_cntrl, mhi_chan); in parse_xfer_event()
691 write_unlock_irqrestore(&mhi_chan->lock, flags); in parse_xfer_event()
693 read_unlock_bh(&mhi_chan->lock); in parse_xfer_event()
700 struct mhi_chan *mhi_chan) in parse_rsc_event() argument
709 buf_ring = &mhi_chan->buf_ring; in parse_rsc_event()
710 tre_ring = &mhi_chan->tre_ring; in parse_rsc_event()
727 result.dir = mhi_chan->dir; in parse_rsc_event()
729 read_lock_bh(&mhi_chan->lock); in parse_rsc_event()
731 if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) in parse_rsc_event()
737 mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); in parse_rsc_event()
757 read_unlock_bh(&mhi_chan->lock); in parse_rsc_event()
769 struct mhi_chan *mhi_chan; in mhi_process_cmd_completion() local
783 mhi_cntrl->mhi_chan[chan].configured) { in mhi_process_cmd_completion()
784 mhi_chan = &mhi_cntrl->mhi_chan[chan]; in mhi_process_cmd_completion()
785 write_lock_bh(&mhi_chan->lock); in mhi_process_cmd_completion()
786 mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); in mhi_process_cmd_completion()
787 complete(&mhi_chan->completion); in mhi_process_cmd_completion()
788 write_unlock_bh(&mhi_chan->lock); in mhi_process_cmd_completion()
805 struct mhi_chan *mhi_chan; in mhi_process_ctrl_ev_ring() local
933 mhi_chan = &mhi_cntrl->mhi_chan[chan]; in mhi_process_ctrl_ev_ring()
934 if (!mhi_chan->configured) in mhi_process_ctrl_ev_ring()
936 parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); in mhi_process_ctrl_ev_ring()
977 struct mhi_chan *mhi_chan; in mhi_process_data_event_ring() local
1004 mhi_cntrl->mhi_chan[chan].configured) { in mhi_process_data_event_ring()
1005 mhi_chan = &mhi_cntrl->mhi_chan[chan]; in mhi_process_data_event_ring()
1008 parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); in mhi_process_data_event_ring()
1011 parse_rsc_event(mhi_cntrl, local_rp, mhi_chan); in mhi_process_data_event_ring()
1109 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : in mhi_queue() local
1111 struct mhi_ring *tre_ring = &mhi_chan->tre_ring; in mhi_queue()
1122 ret = mhi_gen_tre(mhi_cntrl, mhi_chan, buf_info, mflags); in mhi_queue()
1137 if (mhi_chan->dir == DMA_TO_DEVICE) in mhi_queue()
1141 mhi_ring_chan_db(mhi_cntrl, mhi_chan); in mhi_queue()
1154 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : in mhi_queue_skb() local
1162 if (unlikely(mhi_chan->pre_alloc)) in mhi_queue_skb()
1172 struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : in mhi_queue_dma() local
1181 if (unlikely(mhi_chan->pre_alloc)) in mhi_queue_dma()
1188 int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, in mhi_gen_tre() argument
1198 write_lock_bh(&mhi_chan->lock); in mhi_gen_tre()
1200 buf_ring = &mhi_chan->buf_ring; in mhi_gen_tre()
1201 tre_ring = &mhi_chan->tre_ring; in mhi_gen_tre()
1212 buf_info->dir = mhi_chan->dir; in mhi_gen_tre()
1218 write_unlock_bh(&mhi_chan->lock); in mhi_gen_tre()
1226 bei = !!(mhi_chan->intmod); in mhi_gen_tre()
1237 write_unlock_bh(&mhi_chan->lock); 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) 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()
1468 if (mhi_chan->pre_alloc) { in mhi_prepare_channel()
1470 &mhi_chan->tre_ring); in mhi_prepare_channel()
1486 ret = mhi_gen_tre(mhi_cntrl, mhi_chan, &info, MHI_EOT); in mhi_prepare_channel()
1495 read_lock_irq(&mhi_chan->lock); in mhi_prepare_channel()
1496 mhi_ring_chan_db(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1497 read_unlock_irq(&mhi_chan->lock); in mhi_prepare_channel()
1502 mutex_unlock(&mhi_chan->mutex); in mhi_prepare_channel()
1507 if (!mhi_chan->offload_ch) in mhi_prepare_channel()
1508 mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1511 mutex_unlock(&mhi_chan->mutex); in mhi_prepare_channel()
1516 mutex_unlock(&mhi_chan->mutex); in mhi_prepare_channel()
1517 mhi_unprepare_channel(mhi_cntrl, mhi_chan); in mhi_prepare_channel()
1566 struct mhi_chan *mhi_chan) in mhi_reset_data_chan() argument
1572 buf_ring = &mhi_chan->buf_ring; in mhi_reset_data_chan()
1573 tre_ring = &mhi_chan->tre_ring; in mhi_reset_data_chan()
1579 if (mhi_chan->dir == DMA_TO_DEVICE) { in mhi_reset_data_chan()
1591 if (mhi_chan->pre_alloc) { in mhi_reset_data_chan()
1595 mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); in mhi_reset_data_chan()
1600 void mhi_reset_chan(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan) in mhi_reset_chan() argument
1604 int chan = mhi_chan->chan; in mhi_reset_chan()
1607 if (mhi_chan->offload_ch) in mhi_reset_chan()
1611 mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; in mhi_reset_chan()
1612 er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_chan->er_index]; in mhi_reset_chan()
1616 mhi_reset_data_chan(mhi_cntrl, mhi_chan); in mhi_reset_chan()
1626 struct mhi_chan *mhi_chan; in mhi_prepare_for_transfer() local
1629 mhi_chan = dir ? mhi_dev->dl_chan : mhi_dev->ul_chan; in mhi_prepare_for_transfer()
1630 if (!mhi_chan) in mhi_prepare_for_transfer()
1633 ret = mhi_prepare_channel(mhi_cntrl, mhi_chan); in mhi_prepare_for_transfer()
1642 mhi_chan = dir ? mhi_dev->dl_chan : mhi_dev->ul_chan; in mhi_prepare_for_transfer()
1643 if (!mhi_chan) in mhi_prepare_for_transfer()
1646 mhi_unprepare_channel(mhi_cntrl, mhi_chan); in mhi_prepare_for_transfer()
1656 struct mhi_chan *mhi_chan; in mhi_unprepare_from_transfer() local
1660 mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; in mhi_unprepare_from_transfer()
1661 if (!mhi_chan) in mhi_unprepare_from_transfer()
1664 mhi_unprepare_channel(mhi_cntrl, mhi_chan); in mhi_unprepare_from_transfer()
1672 struct mhi_chan *mhi_chan = mhi_dev->dl_chan; in mhi_poll() local
1673 struct mhi_event *mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; in mhi_poll()