Lines Matching refs:mbox

68 	struct omap_mbox	*mbox;
144 static u32 mbox_fifo_read(struct omap_mbox *mbox)
146 struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
148 return mbox_read_reg(mbox->parent, fifo->msg);
151 static void mbox_fifo_write(struct omap_mbox *mbox, u32 msg)
153 struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
155 mbox_write_reg(mbox->parent, msg, fifo->msg);
158 static int mbox_fifo_empty(struct omap_mbox *mbox)
160 struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
162 return (mbox_read_reg(mbox->parent, fifo->msg_stat) == 0);
165 static int mbox_fifo_full(struct omap_mbox *mbox)
167 struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
169 return mbox_read_reg(mbox->parent, fifo->fifo_stat);
173 static void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
176 &mbox->tx_fifo : &mbox->rx_fifo;
180 mbox_write_reg(mbox->parent, bit, irqstatus);
183 mbox_read_reg(mbox->parent, irqstatus);
186 static int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
189 &mbox->tx_fifo : &mbox->rx_fifo;
194 u32 enable = mbox_read_reg(mbox->parent, irqenable);
195 u32 status = mbox_read_reg(mbox->parent, irqstatus);
200 static void _omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
204 &mbox->tx_fifo : &mbox->rx_fifo;
208 l = mbox_read_reg(mbox->parent, irqenable);
210 mbox_write_reg(mbox->parent, l, irqenable);
213 static void _omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
216 &mbox->tx_fifo : &mbox->rx_fifo;
224 if (!mbox->intr_type)
225 bit = mbox_read_reg(mbox->parent, irqdisable) & ~bit;
227 mbox_write_reg(mbox->parent, bit, irqdisable);
232 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
234 if (WARN_ON(!mbox))
237 _omap_mbox_enable_irq(mbox, irq);
243 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
245 if (WARN_ON(!mbox))
248 _omap_mbox_disable_irq(mbox, irq);
268 mbox_chan_received_data(mq->mbox->chan, (void *)data);
272 _omap_mbox_enable_irq(mq->mbox, IRQ_RX);
281 static void __mbox_tx_interrupt(struct omap_mbox *mbox)
283 _omap_mbox_disable_irq(mbox, IRQ_TX);
284 ack_mbox_irq(mbox, IRQ_TX);
285 mbox_chan_txdone(mbox->chan, 0);
288 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
290 struct omap_mbox_queue *mq = mbox->rxq;
294 while (!mbox_fifo_empty(mbox)) {
296 _omap_mbox_disable_irq(mbox, IRQ_RX);
301 msg = mbox_fifo_read(mbox);
308 ack_mbox_irq(mbox, IRQ_RX);
310 schedule_work(&mbox->rxq->work);
315 struct omap_mbox *mbox = p;
317 if (is_mbox_irq(mbox, IRQ_TX))
318 __mbox_tx_interrupt(mbox);
320 if (is_mbox_irq(mbox, IRQ_RX))
321 __mbox_rx_interrupt(mbox);
326 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
357 static int omap_mbox_startup(struct omap_mbox *mbox)
362 mq = mbox_queue_alloc(mbox, mbox_rx_work);
365 mbox->rxq = mq;
366 mq->mbox = mbox;
368 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
369 mbox->name, mbox);
375 if (mbox->send_no_irq)
376 mbox->chan->txdone_method = TXDONE_BY_ACK;
378 _omap_mbox_enable_irq(mbox, IRQ_RX);
383 mbox_queue_free(mbox->rxq);
387 static void omap_mbox_fini(struct omap_mbox *mbox)
389 _omap_mbox_disable_irq(mbox, IRQ_RX);
390 free_irq(mbox->irq, mbox);
391 flush_work(&mbox->rxq->work);
392 mbox_queue_free(mbox->rxq);
398 struct omap_mbox *_mbox, *mbox = NULL;
407 mbox = _mbox;
411 return mbox;
418 struct omap_mbox *mbox = NULL;
435 mbox = omap_mbox_device_find(mdev, chan_name);
436 if (mbox)
441 if (!mbox || !mbox->chan)
444 chan = mbox->chan;
453 ret = chan->mbox->ops->startup(chan);
464 static struct class omap_mbox_class = { .name = "mbox", };
477 struct omap_mbox *mbox = mboxes[i];
479 mbox->dev = device_create(&omap_mbox_class, mdev->dev,
480 0, mbox, "%s", mbox->name);
481 if (IS_ERR(mbox->dev)) {
482 ret = PTR_ERR(mbox->dev);
521 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
522 struct omap_mbox_device *mdev = mbox->parent;
527 ret = omap_mbox_startup(mbox);
536 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
537 struct omap_mbox_device *mdev = mbox->parent;
540 omap_mbox_fini(mbox);
545 static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, u32 msg)
549 if (!mbox_fifo_full(mbox)) {
550 _omap_mbox_enable_irq(mbox, IRQ_RX);
551 mbox_fifo_write(mbox, msg);
553 _omap_mbox_disable_irq(mbox, IRQ_RX);
556 mbox_fifo_read(mbox);
557 ack_mbox_irq(mbox, IRQ_RX);
563 static int omap_mbox_chan_send(struct omap_mbox *mbox, u32 msg)
567 if (!mbox_fifo_full(mbox)) {
568 mbox_fifo_write(mbox, msg);
573 _omap_mbox_enable_irq(mbox, IRQ_TX);
579 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
583 if (!mbox)
586 if (mbox->send_no_irq)
587 ret = omap_mbox_chan_send_noirq(mbox, msg);
589 ret = omap_mbox_chan_send(mbox, msg);
678 struct omap_mbox *mbox;
691 mbox = omap_mbox_device_find(mdev, node->name);
693 return mbox ? mbox->chan : ERR_PTR(-ENOENT);
701 struct omap_mbox **list, *mbox, *mboxblk;
724 if (of_property_read_u32(node, "ti,mbox-num-users", &num_users))
727 if (of_property_read_u32(node, "ti,mbox-num-fifos", &num_fifos))
732 dev_err(&pdev->dev, "no available mbox devices found\n");
745 ret = of_property_read_u32_array(child, "ti,mbox-tx", tmp,
753 ret = of_property_read_u32_array(child, "ti,mbox-rx", tmp,
763 if (of_find_property(child, "ti,mbox-send-noirq", NULL))
796 mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox),
801 mbox = mboxblk;
804 fifo = &mbox->tx_fifo;
812 fifo = &mbox->rx_fifo;
820 mbox->send_no_irq = finfo->send_no_irq;
821 mbox->intr_type = intr_type;
823 mbox->parent = mdev;
824 mbox->name = finfo->name;
825 mbox->irq = platform_get_irq(pdev, finfo->tx_irq);
826 if (mbox->irq < 0)
827 return mbox->irq;
828 mbox->chan = &chnls[i];
829 chnls[i].con_priv = mbox;
830 list[i] = mbox++;