Lines Matching full:mhu

268 	int (*rx_startup)(struct mhuv3 *mhu, struct mbox_chan *chan);
269 void (*rx_shutdown)(struct mhuv3 *mhu, struct mbox_chan *chan);
270 void *(*read_data)(struct mhuv3 *mhu, struct mbox_chan *chan);
271 void (*rx_complete)(struct mhuv3 *mhu, struct mbox_chan *chan);
272 void (*tx_startup)(struct mhuv3 *mhu, struct mbox_chan *chan);
273 void (*tx_shutdown)(struct mhuv3 *mhu, struct mbox_chan *chan);
274 int (*last_tx_done)(struct mhuv3 *mhu, struct mbox_chan *chan);
275 int (*send_data)(struct mhuv3 *mhu, struct mbox_chan *chan, void *arg);
314 struct mbox_chan *(*mbox_of_xlate)(struct mhuv3 *mhu,
317 void (*combined_irq_setup)(struct mhuv3 *mhu);
318 int (*channels_init)(struct mhuv3 *mhu);
319 struct mbox_chan *(*chan_from_comb_irq_get)(struct mhuv3 *mhu);
329 * @auto_op_full: Flag to indicate if the MHU supports AutoOp full mode.
342 * @mbox: Mailbox controller belonging to the MHU frame.
366 typedef int (*mhuv3_extension_initializer)(struct mhuv3 *mhu);
370 static void mhuv3_doorbell_tx_startup(struct mhuv3 *mhu, struct mbox_chan *chan) in mhuv3_doorbell_tx_startup() argument
375 writel_relaxed_bitmask(0x1, &mhu->pbx->dbcw[priv->ch_idx].int_en, tfr_ack); in mhuv3_doorbell_tx_startup()
378 static void mhuv3_doorbell_tx_shutdown(struct mhuv3 *mhu, struct mbox_chan *chan) in mhuv3_doorbell_tx_shutdown() argument
381 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_doorbell_tx_shutdown()
385 writel_relaxed_bitmask(0x0, &mhu->pbx->dbcw[priv->ch_idx].int_en, tfr_ack); in mhuv3_doorbell_tx_shutdown()
388 writel_relaxed_bitmask(0x1, &mhu->pbx->dbcw[priv->ch_idx].int_clr, tfr_ack); in mhuv3_doorbell_tx_shutdown()
394 static int mhuv3_doorbell_rx_startup(struct mhuv3 *mhu, struct mbox_chan *chan) in mhuv3_doorbell_rx_startup() argument
399 writel_relaxed(BIT(priv->doorbell), &mhu->mbx->dbcw[priv->ch_idx].msk_clr); in mhuv3_doorbell_rx_startup()
404 static void mhuv3_doorbell_rx_shutdown(struct mhuv3 *mhu, in mhuv3_doorbell_rx_shutdown() argument
410 writel_relaxed(BIT(priv->doorbell), &mhu->mbx->dbcw[priv->ch_idx].msk_set); in mhuv3_doorbell_rx_shutdown()
413 static void mhuv3_doorbell_rx_complete(struct mhuv3 *mhu, struct mbox_chan *chan) in mhuv3_doorbell_rx_complete() argument
418 writel_relaxed(BIT(priv->doorbell), &mhu->mbx->dbcw[priv->ch_idx].clr); in mhuv3_doorbell_rx_complete()
421 static int mhuv3_doorbell_last_tx_done(struct mhuv3 *mhu, in mhuv3_doorbell_last_tx_done() argument
427 done = !(readl_relaxed(&mhu->pbx->dbcw[priv->ch_idx].st) & in mhuv3_doorbell_last_tx_done()
430 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_doorbell_last_tx_done()
442 static int mhuv3_doorbell_send_data(struct mhuv3 *mhu, struct mbox_chan *chan, in mhuv3_doorbell_send_data() argument
446 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_doorbell_send_data()
456 writel_relaxed(BIT(priv->doorbell), &mhu->pbx->dbcw[priv->ch_idx].set); in mhuv3_doorbell_send_data()
475 struct mhuv3 *mhu = mhu_from_mbox(chan->mbox); in mhuv3_sender_last_tx_done() local
477 return priv->ops->last_tx_done(mhu, chan); in mhuv3_sender_last_tx_done()
483 struct mhuv3 *mhu = mhu_from_mbox(chan->mbox); in mhuv3_sender_send_data() local
485 if (!priv->ops->last_tx_done(mhu, chan)) in mhuv3_sender_send_data()
488 return priv->ops->send_data(mhu, chan, data); in mhuv3_sender_send_data()
494 struct mhuv3 *mhu = mhu_from_mbox(chan->mbox); in mhuv3_sender_startup() local
497 priv->ops->tx_startup(mhu, chan); in mhuv3_sender_startup()
505 struct mhuv3 *mhu = mhu_from_mbox(chan->mbox); in mhuv3_sender_shutdown() local
508 priv->ops->tx_shutdown(mhu, chan); in mhuv3_sender_shutdown()
521 struct mhuv3 *mhu = mhu_from_mbox(chan->mbox); in mhuv3_receiver_startup() local
523 return priv->ops->rx_startup(mhu, chan); in mhuv3_receiver_startup()
529 struct mhuv3 *mhu = mhu_from_mbox(chan->mbox); in mhuv3_receiver_shutdown() local
531 priv->ops->rx_shutdown(mhu, chan); in mhuv3_receiver_shutdown()
554 static struct mbox_chan *mhuv3_dbe_mbox_of_xlate(struct mhuv3 *mhu, in mhuv3_dbe_mbox_of_xlate() argument
558 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_dbe_mbox_of_xlate()
559 struct mbox_controller *mbox = &mhu->mbox; in mhuv3_dbe_mbox_of_xlate()
571 static void mhuv3_dbe_combined_irq_setup(struct mhuv3 *mhu) in mhuv3_dbe_combined_irq_setup() argument
573 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_dbe_combined_irq_setup()
576 if (mhu->frame == PBX_FRAME) { in mhuv3_dbe_combined_irq_setup()
577 struct pdbcw_page __iomem *dbcw = mhu->pbx->dbcw; in mhuv3_dbe_combined_irq_setup()
585 struct mdbcw_page __iomem *dbcw = mhu->mbx->dbcw; in mhuv3_dbe_combined_irq_setup()
595 static int mhuv3_dbe_channels_init(struct mhuv3 *mhu) in mhuv3_dbe_channels_init() argument
597 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_dbe_channels_init()
598 struct mbox_controller *mbox = &mhu->mbox; in mhuv3_dbe_channels_init()
626 static bool mhuv3_dbe_doorbell_lookup(struct mhuv3 *mhu, unsigned int channel, in mhuv3_dbe_doorbell_lookup() argument
629 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_dbe_doorbell_lookup()
630 struct device *dev = mhu->mbox.dev; in mhuv3_dbe_doorbell_lookup()
633 if (mhu->frame == PBX_FRAME) { in mhuv3_dbe_doorbell_lookup()
636 st = readl_relaxed_bitmask(&mhu->pbx->dbcw[channel].int_st, in mhuv3_dbe_doorbell_lookup()
641 active_dbs = readl_relaxed(&mhu->pbx->dbcw[channel].st); in mhuv3_dbe_doorbell_lookup()
654 &mhu->pbx->dbcw[channel].int_clr, in mhuv3_dbe_doorbell_lookup()
657 st = readl_relaxed(&mhu->mbx->dbcw[channel].st_msk); in mhuv3_dbe_doorbell_lookup()
668 mhuv3_str[mhu->frame], channel); in mhuv3_dbe_doorbell_lookup()
673 static struct mbox_chan *mhuv3_dbe_chan_from_comb_irq_get(struct mhuv3 *mhu) in mhuv3_dbe_chan_from_comb_irq_get() argument
675 struct mhuv3_extension *e = mhu->ext[DBE_EXT]; in mhuv3_dbe_chan_from_comb_irq_get()
676 struct device *dev = mhu->mbox.dev; in mhuv3_dbe_chan_from_comb_irq_get()
683 cmb_st = readl_relaxed(&mhu->ctrl->dbch_int_st[i]); in mhuv3_dbe_chan_from_comb_irq_get()
690 mhuv3_str[mhu->frame], channel); in mhuv3_dbe_chan_from_comb_irq_get()
694 if (!mhuv3_dbe_doorbell_lookup(mhu, channel, &db)) in mhuv3_dbe_chan_from_comb_irq_get()
698 mhuv3_str[mhu->frame], channel, db); in mhuv3_dbe_chan_from_comb_irq_get()
700 return &mhu->mbox.chans[channel * MHUV3_FLAG_BITS + db]; in mhuv3_dbe_chan_from_comb_irq_get()
706 static int mhuv3_dbe_init(struct mhuv3 *mhu) in mhuv3_dbe_init() argument
708 struct device *dev = mhu->mbox.dev; in mhuv3_dbe_init()
711 if (!readl_relaxed_bitmask(&mhu->ctrl->feat_spt0, dbe_spt)) in mhuv3_dbe_init()
714 dev_dbg(dev, "%s: Initializing DBE Extension.\n", mhuv3_str[mhu->frame]); in mhuv3_dbe_init()
723 readl_relaxed_bitmask(&mhu->ctrl->dbch_cfg0, num_dbch) + 1; in mhuv3_dbe_init()
729 mhu->num_chans += e->num_chans * MHUV3_FLAG_BITS; in mhuv3_dbe_init()
730 mhu->ext[DBE_EXT] = e; in mhuv3_dbe_init()
733 mhuv3_str[mhu->frame], e->num_chans); in mhuv3_dbe_init()
738 static int mhuv3_fce_init(struct mhuv3 *mhu) in mhuv3_fce_init() argument
740 struct device *dev = mhu->mbox.dev; in mhuv3_fce_init()
742 if (!readl_relaxed_bitmask(&mhu->ctrl->feat_spt0, fce_spt)) in mhuv3_fce_init()
746 mhuv3_str[mhu->frame]); in mhuv3_fce_init()
751 static int mhuv3_fe_init(struct mhuv3 *mhu) in mhuv3_fe_init() argument
753 struct device *dev = mhu->mbox.dev; in mhuv3_fe_init()
755 if (!readl_relaxed_bitmask(&mhu->ctrl->feat_spt0, fe_spt)) in mhuv3_fe_init()
759 mhuv3_str[mhu->frame]); in mhuv3_fe_init()
770 static int mhuv3_initialize_channels(struct device *dev, struct mhuv3 *mhu) in mhuv3_initialize_channels() argument
772 struct mbox_controller *mbox = &mhu->mbox; in mhuv3_initialize_channels()
775 mbox->chans = devm_kcalloc(dev, mhu->num_chans, in mhuv3_initialize_channels()
782 if (mhu->ext[i]) in mhuv3_initialize_channels()
783 ret = mhu->ext[i]->channels_init(mhu); in mhuv3_initialize_channels()
791 struct mhuv3 *mhu = mhu_from_mbox(mbox); in mhuv3_mbox_of_xlate() local
804 return mhu->ext[type]->mbox_of_xlate(mhu, channel, param); in mhuv3_mbox_of_xlate()
809 struct mhuv3 *mhu = data; in mhu_frame_cleanup_actions() local
811 writel_relaxed_bitmask(0x0, &mhu->ctrl->x_ctrl, op_req); in mhu_frame_cleanup_actions()
814 static int mhuv3_frame_init(struct mhuv3 *mhu, void __iomem *regs) in mhuv3_frame_init() argument
816 struct device *dev = mhu->mbox.dev; in mhuv3_frame_init()
819 mhu->ctrl = regs; in mhuv3_frame_init()
820 mhu->frame = readl_relaxed_bitmask(&mhu->ctrl->blk_id, id); in mhuv3_frame_init()
821 if (mhu->frame > MBX_FRAME) in mhuv3_frame_init()
823 "Invalid Frame type- %d\n", mhu->frame); in mhuv3_frame_init()
825 mhu->major = readl_relaxed_bitmask(&mhu->ctrl->aidr, arch_major_rev); in mhuv3_frame_init()
826 mhu->minor = readl_relaxed_bitmask(&mhu->ctrl->aidr, arch_minor_rev); in mhuv3_frame_init()
827 mhu->implem = readl_relaxed_bitmask(&mhu->ctrl->iidr, implementer); in mhuv3_frame_init()
828 mhu->rev = readl_relaxed_bitmask(&mhu->ctrl->iidr, revision); in mhuv3_frame_init()
829 mhu->var = readl_relaxed_bitmask(&mhu->ctrl->iidr, variant); in mhuv3_frame_init()
830 mhu->prod_id = readl_relaxed_bitmask(&mhu->ctrl->iidr, product_id); in mhuv3_frame_init()
831 if (mhu->major != MHUV3_MAJOR_VERSION) in mhuv3_frame_init()
833 "Unsupported MHU %s block - major:%d minor:%d\n", in mhuv3_frame_init()
834 mhuv3_str[mhu->frame], mhu->major, in mhuv3_frame_init()
835 mhu->minor); in mhuv3_frame_init()
837 mhu->auto_op_full = in mhuv3_frame_init()
838 !!readl_relaxed_bitmask(&mhu->ctrl->feat_spt1, auto_op_spt); in mhuv3_frame_init()
840 if (mhu->auto_op_full) { in mhuv3_frame_init()
841 writel_relaxed_bitmask(0x1, &mhu->ctrl->x_ctrl, op_req); in mhuv3_frame_init()
842 devm_add_action_or_reset(dev, mhu_frame_cleanup_actions, mhu); in mhuv3_frame_init()
846 "Found MHU %s block - major:%d minor:%d\n implem:0x%X rev:0x%X var:0x%X prod_id:0x%X", in mhuv3_frame_init()
847 mhuv3_str[mhu->frame], mhu->major, mhu->minor, in mhuv3_frame_init()
848 mhu->implem, mhu->rev, mhu->var, mhu->prod_id); in mhuv3_frame_init()
850 if (mhu->frame == PBX_FRAME) in mhuv3_frame_init()
851 mhu->pbx = regs; in mhuv3_frame_init()
853 mhu->mbx = regs; in mhuv3_frame_init()
863 ret = mhuv3_extension_init[i](mhu); in mhuv3_frame_init()
867 mhuv3_str[mhu->frame], in mhuv3_frame_init()
877 struct mhuv3 *mhu = arg; in mhuv3_pbx_comb_interrupt() local
882 dev = mhu->mbox.dev; in mhuv3_pbx_comb_interrupt()
887 if (i == FCE_EXT || !mhu->ext[i]) in mhuv3_pbx_comb_interrupt()
890 chan = mhu->ext[i]->chan_from_comb_irq_get(mhu); in mhuv3_pbx_comb_interrupt()
915 struct mhuv3 *mhu = arg; in mhuv3_mbx_comb_interrupt() local
920 dev = mhu->mbox.dev; in mhuv3_mbx_comb_interrupt()
925 if (!mhu->ext[i]) in mhuv3_mbx_comb_interrupt()
929 chan = mhu->ext[i]->chan_from_comb_irq_get(mhu); in mhuv3_mbx_comb_interrupt()
944 data = priv->ops->read_data(mhu, chan); in mhuv3_mbx_comb_interrupt()
963 priv->ops->rx_complete(mhu, chan); in mhuv3_mbx_comb_interrupt()
972 static int mhuv3_setup_pbx(struct mhuv3 *mhu) in mhuv3_setup_pbx() argument
974 struct device *dev = mhu->mbox.dev; in mhuv3_setup_pbx()
976 mhu->mbox.ops = &mhuv3_sender_ops; in mhuv3_setup_pbx()
978 if (mhu->cmb_irq > 0) { in mhuv3_setup_pbx()
981 ret = devm_request_threaded_irq(dev, mhu->cmb_irq, NULL, in mhuv3_setup_pbx()
983 IRQF_ONESHOT, "mhuv3-pbx", mhu); in mhuv3_setup_pbx()
988 mhu->mbox.txdone_irq = true; in mhuv3_setup_pbx()
989 mhu->mbox.txdone_poll = false; in mhuv3_setup_pbx()
992 if (mhu->ext[i]) in mhuv3_setup_pbx()
993 mhu->ext[i]->combined_irq_setup(mhu); in mhuv3_setup_pbx()
1001 mhu->mbox.txdone_irq = false; in mhuv3_setup_pbx()
1002 mhu->mbox.txdone_poll = true; in mhuv3_setup_pbx()
1003 mhu->mbox.txpoll_period = 1; in mhuv3_setup_pbx()
1008 static int mhuv3_setup_mbx(struct mhuv3 *mhu) in mhuv3_setup_mbx() argument
1010 struct device *dev = mhu->mbox.dev; in mhuv3_setup_mbx()
1013 mhu->mbox.ops = &mhuv3_receiver_ops; in mhuv3_setup_mbx()
1015 if (mhu->cmb_irq <= 0) in mhuv3_setup_mbx()
1019 ret = devm_request_threaded_irq(dev, mhu->cmb_irq, NULL, in mhuv3_setup_mbx()
1021 "mhuv3-mbx", mhu); in mhuv3_setup_mbx()
1026 if (mhu->ext[i]) in mhuv3_setup_mbx()
1027 mhu->ext[i]->combined_irq_setup(mhu); in mhuv3_setup_mbx()
1034 static int mhuv3_irqs_init(struct mhuv3 *mhu, struct platform_device *pdev) in mhuv3_irqs_init() argument
1036 dev_dbg(mhu->mbox.dev, "Initializing %s block.\n", in mhuv3_irqs_init()
1037 mhuv3_str[mhu->frame]); in mhuv3_irqs_init()
1039 if (mhu->frame == PBX_FRAME) { in mhuv3_irqs_init()
1040 mhu->cmb_irq = in mhuv3_irqs_init()
1042 return mhuv3_setup_pbx(mhu); in mhuv3_irqs_init()
1045 mhu->cmb_irq = platform_get_irq_byname(pdev, "combined"); in mhuv3_irqs_init()
1046 return mhuv3_setup_mbx(mhu); in mhuv3_irqs_init()
1053 struct mhuv3 *mhu; in mhuv3_probe() local
1056 mhu = devm_kzalloc(dev, sizeof(*mhu), GFP_KERNEL); in mhuv3_probe()
1057 if (!mhu) in mhuv3_probe()
1064 mhu->mbox.dev = dev; in mhuv3_probe()
1065 ret = mhuv3_frame_init(mhu, regs); in mhuv3_probe()
1069 ret = mhuv3_irqs_init(mhu, pdev); in mhuv3_probe()
1073 mhu->mbox.of_xlate = mhuv3_mbox_of_xlate; in mhuv3_probe()
1074 ret = mhuv3_initialize_channels(dev, mhu); in mhuv3_probe()
1078 ret = devm_mbox_controller_register(dev, &mhu->mbox); in mhuv3_probe()