Lines Matching refs:mbox

68 	struct omap_mbox	*mbox;  member
144 static u32 mbox_fifo_read(struct omap_mbox *mbox) in mbox_fifo_read() argument
146 struct omap_mbox_fifo *fifo = &mbox->rx_fifo; in mbox_fifo_read()
148 return mbox_read_reg(mbox->parent, fifo->msg); in mbox_fifo_read()
151 static void mbox_fifo_write(struct omap_mbox *mbox, u32 msg) in mbox_fifo_write() argument
153 struct omap_mbox_fifo *fifo = &mbox->tx_fifo; in mbox_fifo_write()
155 mbox_write_reg(mbox->parent, msg, fifo->msg); in mbox_fifo_write()
158 static int mbox_fifo_empty(struct omap_mbox *mbox) in mbox_fifo_empty() argument
160 struct omap_mbox_fifo *fifo = &mbox->rx_fifo; in mbox_fifo_empty()
162 return (mbox_read_reg(mbox->parent, fifo->msg_stat) == 0); in mbox_fifo_empty()
165 static int mbox_fifo_full(struct omap_mbox *mbox) in mbox_fifo_full() argument
167 struct omap_mbox_fifo *fifo = &mbox->tx_fifo; in mbox_fifo_full()
169 return mbox_read_reg(mbox->parent, fifo->fifo_stat); in mbox_fifo_full()
173 static void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) in ack_mbox_irq() argument
176 &mbox->tx_fifo : &mbox->rx_fifo; in ack_mbox_irq()
180 mbox_write_reg(mbox->parent, bit, irqstatus); in ack_mbox_irq()
183 mbox_read_reg(mbox->parent, irqstatus); in ack_mbox_irq()
186 static int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) in is_mbox_irq() argument
189 &mbox->tx_fifo : &mbox->rx_fifo; in is_mbox_irq()
194 u32 enable = mbox_read_reg(mbox->parent, irqenable); in is_mbox_irq()
195 u32 status = mbox_read_reg(mbox->parent, irqstatus); in is_mbox_irq()
200 static void _omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) in _omap_mbox_enable_irq() argument
204 &mbox->tx_fifo : &mbox->rx_fifo; in _omap_mbox_enable_irq()
208 l = mbox_read_reg(mbox->parent, irqenable); in _omap_mbox_enable_irq()
210 mbox_write_reg(mbox->parent, l, irqenable); in _omap_mbox_enable_irq()
213 static void _omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) in _omap_mbox_disable_irq() argument
216 &mbox->tx_fifo : &mbox->rx_fifo; in _omap_mbox_disable_irq()
224 if (!mbox->intr_type) in _omap_mbox_disable_irq()
225 bit = mbox_read_reg(mbox->parent, irqdisable) & ~bit; in _omap_mbox_disable_irq()
227 mbox_write_reg(mbox->parent, bit, irqdisable); in _omap_mbox_disable_irq()
232 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); in omap_mbox_enable_irq() local
234 if (WARN_ON(!mbox)) in omap_mbox_enable_irq()
237 _omap_mbox_enable_irq(mbox, irq); in omap_mbox_enable_irq()
243 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); in omap_mbox_disable_irq() local
245 if (WARN_ON(!mbox)) in omap_mbox_disable_irq()
248 _omap_mbox_disable_irq(mbox, irq); in omap_mbox_disable_irq()
268 mbox_chan_received_data(mq->mbox->chan, (void *)data); in mbox_rx_work()
272 _omap_mbox_enable_irq(mq->mbox, IRQ_RX); in mbox_rx_work()
281 static void __mbox_tx_interrupt(struct omap_mbox *mbox) in __mbox_tx_interrupt() argument
283 _omap_mbox_disable_irq(mbox, IRQ_TX); in __mbox_tx_interrupt()
284 ack_mbox_irq(mbox, IRQ_TX); in __mbox_tx_interrupt()
285 mbox_chan_txdone(mbox->chan, 0); in __mbox_tx_interrupt()
288 static void __mbox_rx_interrupt(struct omap_mbox *mbox) in __mbox_rx_interrupt() argument
290 struct omap_mbox_queue *mq = mbox->rxq; in __mbox_rx_interrupt()
294 while (!mbox_fifo_empty(mbox)) { in __mbox_rx_interrupt()
296 _omap_mbox_disable_irq(mbox, IRQ_RX); in __mbox_rx_interrupt()
301 msg = mbox_fifo_read(mbox); in __mbox_rx_interrupt()
308 ack_mbox_irq(mbox, IRQ_RX); in __mbox_rx_interrupt()
310 schedule_work(&mbox->rxq->work); in __mbox_rx_interrupt()
315 struct omap_mbox *mbox = p; in mbox_interrupt() local
317 if (is_mbox_irq(mbox, IRQ_TX)) in mbox_interrupt()
318 __mbox_tx_interrupt(mbox); in mbox_interrupt()
320 if (is_mbox_irq(mbox, IRQ_RX)) in mbox_interrupt()
321 __mbox_rx_interrupt(mbox); in mbox_interrupt()
326 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox, in mbox_queue_alloc() argument
357 static int omap_mbox_startup(struct omap_mbox *mbox) in omap_mbox_startup() argument
362 mq = mbox_queue_alloc(mbox, mbox_rx_work); in omap_mbox_startup()
365 mbox->rxq = mq; in omap_mbox_startup()
366 mq->mbox = mbox; in omap_mbox_startup()
368 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED, in omap_mbox_startup()
369 mbox->name, mbox); in omap_mbox_startup()
375 if (mbox->send_no_irq) in omap_mbox_startup()
376 mbox->chan->txdone_method = TXDONE_BY_ACK; in omap_mbox_startup()
378 _omap_mbox_enable_irq(mbox, IRQ_RX); in omap_mbox_startup()
383 mbox_queue_free(mbox->rxq); in omap_mbox_startup()
387 static void omap_mbox_fini(struct omap_mbox *mbox) in omap_mbox_fini() argument
389 _omap_mbox_disable_irq(mbox, IRQ_RX); in omap_mbox_fini()
390 free_irq(mbox->irq, mbox); in omap_mbox_fini()
391 flush_work(&mbox->rxq->work); in omap_mbox_fini()
392 mbox_queue_free(mbox->rxq); in omap_mbox_fini()
398 struct omap_mbox *_mbox, *mbox = NULL; in omap_mbox_device_find() local
407 mbox = _mbox; in omap_mbox_device_find()
411 return mbox; in omap_mbox_device_find()
418 struct omap_mbox *mbox = NULL; in omap_mbox_request_channel() local
435 mbox = omap_mbox_device_find(mdev, chan_name); in omap_mbox_request_channel()
436 if (mbox) in omap_mbox_request_channel()
441 if (!mbox || !mbox->chan) in omap_mbox_request_channel()
444 chan = mbox->chan; in omap_mbox_request_channel()
453 ret = chan->mbox->ops->startup(chan); in omap_mbox_request_channel()
477 struct omap_mbox *mbox = mboxes[i]; in omap_mbox_register() local
479 mbox->dev = device_create(&omap_mbox_class, mdev->dev, in omap_mbox_register()
480 0, mbox, "%s", mbox->name); in omap_mbox_register()
481 if (IS_ERR(mbox->dev)) { in omap_mbox_register()
482 ret = PTR_ERR(mbox->dev); in omap_mbox_register()
521 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); in omap_mbox_chan_startup() local
522 struct omap_mbox_device *mdev = mbox->parent; in omap_mbox_chan_startup()
527 ret = omap_mbox_startup(mbox); in omap_mbox_chan_startup()
536 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); in omap_mbox_chan_shutdown() local
537 struct omap_mbox_device *mdev = mbox->parent; in omap_mbox_chan_shutdown()
540 omap_mbox_fini(mbox); in omap_mbox_chan_shutdown()
545 static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, u32 msg) in omap_mbox_chan_send_noirq() argument
549 if (!mbox_fifo_full(mbox)) { in omap_mbox_chan_send_noirq()
550 _omap_mbox_enable_irq(mbox, IRQ_RX); in omap_mbox_chan_send_noirq()
551 mbox_fifo_write(mbox, msg); in omap_mbox_chan_send_noirq()
553 _omap_mbox_disable_irq(mbox, IRQ_RX); in omap_mbox_chan_send_noirq()
556 mbox_fifo_read(mbox); in omap_mbox_chan_send_noirq()
557 ack_mbox_irq(mbox, IRQ_RX); in omap_mbox_chan_send_noirq()
563 static int omap_mbox_chan_send(struct omap_mbox *mbox, u32 msg) in omap_mbox_chan_send() argument
567 if (!mbox_fifo_full(mbox)) { in omap_mbox_chan_send()
568 mbox_fifo_write(mbox, msg); in omap_mbox_chan_send()
573 _omap_mbox_enable_irq(mbox, IRQ_TX); in omap_mbox_chan_send()
579 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); in omap_mbox_chan_send_data() local
583 if (!mbox) in omap_mbox_chan_send_data()
586 if (mbox->send_no_irq) in omap_mbox_chan_send_data()
587 ret = omap_mbox_chan_send_noirq(mbox, msg); in omap_mbox_chan_send_data()
589 ret = omap_mbox_chan_send(mbox, msg); in omap_mbox_chan_send_data()
682 struct omap_mbox *mbox; in omap_mbox_of_xlate() local
695 mbox = omap_mbox_device_find(mdev, node->name); in omap_mbox_of_xlate()
697 return mbox ? mbox->chan : ERR_PTR(-ENOENT); in omap_mbox_of_xlate()
704 struct omap_mbox **list, *mbox, *mboxblk; in omap_mbox_probe() local
798 mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox), in omap_mbox_probe()
803 mbox = mboxblk; in omap_mbox_probe()
806 fifo = &mbox->tx_fifo; in omap_mbox_probe()
814 fifo = &mbox->rx_fifo; in omap_mbox_probe()
822 mbox->send_no_irq = finfo->send_no_irq; in omap_mbox_probe()
823 mbox->intr_type = intr_type; in omap_mbox_probe()
825 mbox->parent = mdev; in omap_mbox_probe()
826 mbox->name = finfo->name; in omap_mbox_probe()
827 mbox->irq = platform_get_irq(pdev, finfo->tx_irq); in omap_mbox_probe()
828 if (mbox->irq < 0) in omap_mbox_probe()
829 return mbox->irq; in omap_mbox_probe()
830 mbox->chan = &chnls[i]; in omap_mbox_probe()
831 chnls[i].con_priv = mbox; in omap_mbox_probe()
832 list[i] = mbox++; in omap_mbox_probe()