Lines Matching refs:mhu
206 int (*rx_startup)(struct mhuv2 *mhu, struct mbox_chan *chan);
207 void (*rx_shutdown)(struct mhuv2 *mhu, struct mbox_chan *chan);
208 void *(*read_data)(struct mhuv2 *mhu, struct mbox_chan *chan);
210 void (*tx_startup)(struct mhuv2 *mhu, struct mbox_chan *chan);
211 void (*tx_shutdown)(struct mhuv2 *mhu, struct mbox_chan *chan);
212 int (*last_tx_done)(struct mhuv2 *mhu, struct mbox_chan *chan);
213 int (*send_data)(struct mhuv2 *mhu, struct mbox_chan *chan, void *arg);
260 static int mhuv2_doorbell_rx_startup(struct mhuv2 *mhu, struct mbox_chan *chan) in mhuv2_doorbell_rx_startup() argument
265 &mhu->recv->ch_wn[priv->ch_wn_idx].mask_clear); in mhuv2_doorbell_rx_startup()
269 static void mhuv2_doorbell_rx_shutdown(struct mhuv2 *mhu, in mhuv2_doorbell_rx_shutdown() argument
275 &mhu->recv->ch_wn[priv->ch_wn_idx].mask_set); in mhuv2_doorbell_rx_shutdown()
278 static void *mhuv2_doorbell_read_data(struct mhuv2 *mhu, struct mbox_chan *chan) in mhuv2_doorbell_read_data() argument
283 &mhu->recv->ch_wn[priv->ch_wn_idx].stat_clear); in mhuv2_doorbell_read_data()
287 static int mhuv2_doorbell_last_tx_done(struct mhuv2 *mhu, in mhuv2_doorbell_last_tx_done() argument
292 return !(readl_relaxed(&mhu->send->ch_wn[priv->ch_wn_idx].stat) & in mhuv2_doorbell_last_tx_done()
296 static int mhuv2_doorbell_send_data(struct mhuv2 *mhu, struct mbox_chan *chan, in mhuv2_doorbell_send_data() argument
302 spin_lock_irqsave(&mhu->doorbell_pending_lock, flags); in mhuv2_doorbell_send_data()
306 &mhu->send->ch_wn[priv->ch_wn_idx].stat_set); in mhuv2_doorbell_send_data()
308 spin_unlock_irqrestore(&mhu->doorbell_pending_lock, flags); in mhuv2_doorbell_send_data()
324 static int mhuv2_data_transfer_rx_startup(struct mhuv2 *mhu, in mhuv2_data_transfer_rx_startup() argument
334 writel_relaxed(0xFFFFFFFF, &mhu->recv->ch_wn[i].mask_clear); in mhuv2_data_transfer_rx_startup()
338 static void mhuv2_data_transfer_rx_shutdown(struct mhuv2 *mhu, in mhuv2_data_transfer_rx_shutdown() argument
344 writel_relaxed(0xFFFFFFFF, &mhu->recv->ch_wn[i].mask_set); in mhuv2_data_transfer_rx_shutdown()
347 static void *mhuv2_data_transfer_read_data(struct mhuv2 *mhu, in mhuv2_data_transfer_read_data() argument
377 data[windows - 1 - i] = readl_relaxed(&mhu->recv->ch_wn[idx].stat); in mhuv2_data_transfer_read_data()
378 writel_relaxed(0xFFFFFFFF, &mhu->recv->ch_wn[idx].stat_clear); in mhuv2_data_transfer_read_data()
384 static void mhuv2_data_transfer_tx_startup(struct mhuv2 *mhu, in mhuv2_data_transfer_tx_startup() argument
391 if (mhu->minor) { in mhuv2_data_transfer_tx_startup()
392 writel_relaxed(0x1, &mhu->send->ch_wn[i].int_clr); in mhuv2_data_transfer_tx_startup()
393 writel_relaxed(0x1, &mhu->send->ch_wn[i].int_en); in mhuv2_data_transfer_tx_startup()
397 static void mhuv2_data_transfer_tx_shutdown(struct mhuv2 *mhu, in mhuv2_data_transfer_tx_shutdown() argument
403 if (mhu->minor) in mhuv2_data_transfer_tx_shutdown()
404 writel_relaxed(0x0, &mhu->send->ch_wn[i].int_en); in mhuv2_data_transfer_tx_shutdown()
407 static int mhuv2_data_transfer_last_tx_done(struct mhuv2 *mhu, in mhuv2_data_transfer_last_tx_done() argument
414 return !readl_relaxed(&mhu->send->ch_wn[i].stat); in mhuv2_data_transfer_last_tx_done()
444 static int mhuv2_data_transfer_send_data(struct mhuv2 *mhu, in mhuv2_data_transfer_send_data() argument
455 …dev_err(mhu->mbox.dev, "Data aligned at first window can't be zero to guarantee interrupt generati… in mhuv2_data_transfer_send_data()
459 while(!mhuv2_data_transfer_last_tx_done(mhu, chan)) in mhuv2_data_transfer_send_data()
476 writel_relaxed(word, &mhu->send->ch_wn[priv->ch_wn_idx + windows - 1 - i].stat_set); in mhuv2_data_transfer_send_data()
499 static struct mbox_chan *get_irq_chan_comb(struct mhuv2 *mhu, u32 __iomem *reg) in get_irq_chan_comb() argument
501 struct mbox_chan *chans = mhu->mbox.chans; in get_irq_chan_comb()
512 for (i = 0; i < mhu->length; i += 2) { in get_irq_chan_comb()
513 protocol = mhu->protocols[i]; in get_irq_chan_comb()
514 windows = mhu->protocols[i + 1]; in get_irq_chan_comb()
539 struct mhuv2 *mhu = data; in mhuv2_sender_interrupt() local
540 struct device *dev = mhu->mbox.dev; in mhuv2_sender_interrupt()
547 chan = get_irq_chan_comb(mhu, mhu->send->chcomb_int_st); in mhuv2_sender_interrupt()
555 writel_relaxed(1, &mhu->send->ch_wn[priv->ch_wn_idx + priv->windows - 1].int_clr); in mhuv2_sender_interrupt()
568 writel_relaxed(1, &mhu->send->ch_wn[priv->ch_wn_idx].int_clr); in mhuv2_sender_interrupt()
576 spin_lock_irqsave(&mhu->doorbell_pending_lock, flags); in mhuv2_sender_interrupt()
582 stat = readl_relaxed(&mhu->send->ch_wn[priv->ch_wn_idx].stat); in mhuv2_sender_interrupt()
603 spin_unlock_irqrestore(&mhu->doorbell_pending_lock, flags); in mhuv2_sender_interrupt()
619 static struct mbox_chan *get_irq_chan_comb_rx(struct mhuv2 *mhu) in get_irq_chan_comb_rx() argument
625 chan = get_irq_chan_comb(mhu, mhu->recv->chcomb_int_st); in get_irq_chan_comb_rx()
637 stat = readl_relaxed(&mhu->recv->ch_wn[priv->ch_wn_idx].stat_masked); in get_irq_chan_comb_rx()
643 static struct mbox_chan *get_irq_chan_stat_rx(struct mhuv2 *mhu) in get_irq_chan_stat_rx() argument
645 struct mbox_chan *chans = mhu->mbox.chans; in get_irq_chan_stat_rx()
650 while (i < mhu->mbox.num_chans) { in get_irq_chan_stat_rx()
652 stat = readl_relaxed(&mhu->recv->ch_wn[priv->ch_wn_idx].stat_masked); in get_irq_chan_stat_rx()
666 static struct mbox_chan *get_irq_chan_rx(struct mhuv2 *mhu) in get_irq_chan_rx() argument
668 if (!mhu->minor) in get_irq_chan_rx()
669 return get_irq_chan_stat_rx(mhu); in get_irq_chan_rx()
671 return get_irq_chan_comb_rx(mhu); in get_irq_chan_rx()
676 struct mhuv2 *mhu = arg; in mhuv2_receiver_interrupt() local
677 struct mbox_chan *chan = get_irq_chan_rx(mhu); in mhuv2_receiver_interrupt()
678 struct device *dev = mhu->mbox.dev; in mhuv2_receiver_interrupt()
690 data = priv->ops->read_data(mhu, chan); in mhuv2_receiver_interrupt()
711 struct mhuv2 *mhu = mhu_from_mbox(chan->mbox); in mhuv2_sender_last_tx_done() local
714 return priv->ops->last_tx_done(mhu, chan); in mhuv2_sender_last_tx_done()
719 struct mhuv2 *mhu = mhu_from_mbox(chan->mbox); in mhuv2_sender_send_data() local
722 if (!priv->ops->last_tx_done(mhu, chan)) in mhuv2_sender_send_data()
725 return priv->ops->send_data(mhu, chan, data); in mhuv2_sender_send_data()
730 struct mhuv2 *mhu = mhu_from_mbox(chan->mbox); in mhuv2_sender_startup() local
734 priv->ops->tx_startup(mhu, chan); in mhuv2_sender_startup()
740 struct mhuv2 *mhu = mhu_from_mbox(chan->mbox); in mhuv2_sender_shutdown() local
744 priv->ops->tx_shutdown(mhu, chan); in mhuv2_sender_shutdown()
756 struct mhuv2 *mhu = mhu_from_mbox(chan->mbox); in mhuv2_receiver_startup() local
759 return priv->ops->rx_startup(mhu, chan); in mhuv2_receiver_startup()
764 struct mhuv2 *mhu = mhu_from_mbox(chan->mbox); in mhuv2_receiver_shutdown() local
767 priv->ops->rx_shutdown(mhu, chan); in mhuv2_receiver_shutdown()
793 struct mhuv2 *mhu = mhu_from_mbox(mbox); in mhuv2_mbox_of_xlate() local
805 for (i = 0; i < mhu->length; i += 2) { in mhuv2_mbox_of_xlate()
806 protocol = mhu->protocols[i]; in mhuv2_mbox_of_xlate()
807 windows = mhu->protocols[i + 1]; in mhuv2_mbox_of_xlate()
834 static int mhuv2_verify_protocol(struct mhuv2 *mhu) in mhuv2_verify_protocol() argument
836 struct device *dev = mhu->mbox.dev; in mhuv2_verify_protocol()
839 for (i = 0; i < mhu->length; i += 2) { in mhuv2_verify_protocol()
840 protocol = mhu->protocols[i]; in mhuv2_verify_protocol()
841 windows = mhu->protocols[i + 1]; in mhuv2_verify_protocol()
860 if (total_windows > mhu->windows) { in mhuv2_verify_protocol()
862 total_windows, mhu->windows); in mhuv2_verify_protocol()
866 mhu->mbox.num_chans = channels; in mhuv2_verify_protocol()
870 static int mhuv2_allocate_channels(struct mhuv2 *mhu) in mhuv2_allocate_channels() argument
872 struct mbox_controller *mbox = &mhu->mbox; in mhuv2_allocate_channels()
884 for (i = 0; i < mhu->length; i += 2) { in mhuv2_allocate_channels()
887 protocol = mhu->protocols[i]; in mhuv2_allocate_channels()
888 windows = mhu->protocols[i + 1]; in mhuv2_allocate_channels()
918 if (mhu->frame == SENDER_FRAME && mhu->minor) in mhuv2_allocate_channels()
919 writel_relaxed(0x1, &mhu->send->ch_wn[priv->ch_wn_idx].int_en); in mhuv2_allocate_channels()
929 static int mhuv2_parse_channels(struct mhuv2 *mhu) in mhuv2_parse_channels() argument
931 struct device *dev = mhu->mbox.dev; in mhuv2_parse_channels()
954 mhu->protocols = protocols; in mhuv2_parse_channels()
955 mhu->length = count; in mhuv2_parse_channels()
957 ret = mhuv2_verify_protocol(mhu); in mhuv2_parse_channels()
961 return mhuv2_allocate_channels(mhu); in mhuv2_parse_channels()
964 static int mhuv2_tx_init(struct amba_device *adev, struct mhuv2 *mhu, in mhuv2_tx_init() argument
967 struct device *dev = mhu->mbox.dev; in mhuv2_tx_init()
970 mhu->frame = SENDER_FRAME; in mhuv2_tx_init()
971 mhu->mbox.ops = &mhuv2_sender_ops; in mhuv2_tx_init()
972 mhu->send = reg; in mhuv2_tx_init()
974 mhu->windows = readl_relaxed_bitfield(&mhu->send->mhu_cfg, struct mhu_cfg_t, num_ch); in mhuv2_tx_init()
975 mhu->minor = readl_relaxed_bitfield(&mhu->send->aidr, struct aidr_t, arch_minor_rev); in mhuv2_tx_init()
977 spin_lock_init(&mhu->doorbell_pending_lock); in mhuv2_tx_init()
983 if (mhu->minor && adev->irq[0]) { in mhuv2_tx_init()
986 IRQF_ONESHOT, "mhuv2-tx", mhu); in mhuv2_tx_init()
991 mhu->mbox.txdone_irq = true; in mhuv2_tx_init()
992 mhu->mbox.txdone_poll = false; in mhuv2_tx_init()
993 mhu->irq = adev->irq[0]; in mhuv2_tx_init()
995 writel_relaxed_bitfield(1, &mhu->send->int_en, struct int_en_t, chcomb); in mhuv2_tx_init()
998 for (i = 0; i < mhu->windows; i++) in mhuv2_tx_init()
999 writel_relaxed(0x0, &mhu->send->ch_wn[i].int_en); in mhuv2_tx_init()
1005 mhu->mbox.txdone_irq = false; in mhuv2_tx_init()
1006 mhu->mbox.txdone_poll = true; in mhuv2_tx_init()
1007 mhu->mbox.txpoll_period = 1; in mhuv2_tx_init()
1011 writel_relaxed(0x1, &mhu->send->access_request); in mhuv2_tx_init()
1012 while (!readl_relaxed(&mhu->send->access_ready)) in mhuv2_tx_init()
1018 static int mhuv2_rx_init(struct amba_device *adev, struct mhuv2 *mhu, in mhuv2_rx_init() argument
1021 struct device *dev = mhu->mbox.dev; in mhuv2_rx_init()
1024 mhu->frame = RECEIVER_FRAME; in mhuv2_rx_init()
1025 mhu->mbox.ops = &mhuv2_receiver_ops; in mhuv2_rx_init()
1026 mhu->recv = reg; in mhuv2_rx_init()
1028 mhu->windows = readl_relaxed_bitfield(&mhu->recv->mhu_cfg, struct mhu_cfg_t, num_ch); in mhuv2_rx_init()
1029 mhu->minor = readl_relaxed_bitfield(&mhu->recv->aidr, struct aidr_t, arch_minor_rev); in mhuv2_rx_init()
1031 mhu->irq = adev->irq[0]; in mhuv2_rx_init()
1032 if (!mhu->irq) { in mhuv2_rx_init()
1037 ret = devm_request_threaded_irq(dev, mhu->irq, NULL, in mhuv2_rx_init()
1039 "mhuv2-rx", mhu); in mhuv2_rx_init()
1046 for (i = 0; i < mhu->windows; i++) in mhuv2_rx_init()
1047 writel_relaxed(0xFFFFFFFF, &mhu->recv->ch_wn[i].mask_set); in mhuv2_rx_init()
1049 if (mhu->minor) in mhuv2_rx_init()
1050 writel_relaxed_bitfield(1, &mhu->recv->int_en, struct int_en_t, chcomb); in mhuv2_rx_init()
1059 struct mhuv2 *mhu; in mhuv2_probe() local
1067 mhu = devm_kzalloc(dev, sizeof(*mhu), GFP_KERNEL); in mhuv2_probe()
1068 if (!mhu) in mhuv2_probe()
1071 mhu->mbox.dev = dev; in mhuv2_probe()
1072 mhu->mbox.of_xlate = mhuv2_mbox_of_xlate; in mhuv2_probe()
1075 ret = mhuv2_tx_init(adev, mhu, reg); in mhuv2_probe()
1077 ret = mhuv2_rx_init(adev, mhu, reg); in mhuv2_probe()
1085 BUG_ON(!mhu->windows); in mhuv2_probe()
1087 ret = mhuv2_parse_channels(mhu); in mhuv2_probe()
1091 amba_set_drvdata(adev, mhu); in mhuv2_probe()
1093 ret = devm_mbox_controller_register(dev, &mhu->mbox); in mhuv2_probe()
1102 struct mhuv2 *mhu = amba_get_drvdata(adev); in mhuv2_remove() local
1104 if (mhu->frame == SENDER_FRAME) in mhuv2_remove()
1105 writel_relaxed(0x0, &mhu->send->access_request); in mhuv2_remove()