summaryrefslogtreecommitdiffstats
path: root/drivers/mailbox/omap-mailbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mailbox/omap-mailbox.c')
-rw-r--r--drivers/mailbox/omap-mailbox.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
index ca50177a33f2..a3cd63583cf7 100644
--- a/drivers/mailbox/omap-mailbox.c
+++ b/drivers/mailbox/omap-mailbox.c
@@ -3,7 +3,7 @@
3 * OMAP mailbox driver 3 * OMAP mailbox driver
4 * 4 *
5 * Copyright (C) 2006-2009 Nokia Corporation. All rights reserved. 5 * Copyright (C) 2006-2009 Nokia Corporation. All rights reserved.
6 * Copyright (C) 2013-2016 Texas Instruments Incorporated - http://www.ti.com 6 * Copyright (C) 2013-2019 Texas Instruments Incorporated - http://www.ti.com
7 * 7 *
8 * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com> 8 * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
9 * Suman Anna <s-anna@ti.com> 9 * Suman Anna <s-anna@ti.com>
@@ -141,14 +141,14 @@ void mbox_write_reg(struct omap_mbox_device *mdev, u32 val, size_t ofs)
141} 141}
142 142
143/* Mailbox FIFO handle functions */ 143/* Mailbox FIFO handle functions */
144static mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox) 144static u32 mbox_fifo_read(struct omap_mbox *mbox)
145{ 145{
146 struct omap_mbox_fifo *fifo = &mbox->rx_fifo; 146 struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
147 147
148 return (mbox_msg_t)mbox_read_reg(mbox->parent, fifo->msg); 148 return mbox_read_reg(mbox->parent, fifo->msg);
149} 149}
150 150
151static void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg) 151static void mbox_fifo_write(struct omap_mbox *mbox, u32 msg)
152{ 152{
153 struct omap_mbox_fifo *fifo = &mbox->tx_fifo; 153 struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
154 154
@@ -256,14 +256,16 @@ static void mbox_rx_work(struct work_struct *work)
256{ 256{
257 struct omap_mbox_queue *mq = 257 struct omap_mbox_queue *mq =
258 container_of(work, struct omap_mbox_queue, work); 258 container_of(work, struct omap_mbox_queue, work);
259 mbox_msg_t msg; 259 mbox_msg_t data;
260 u32 msg;
260 int len; 261 int len;
261 262
262 while (kfifo_len(&mq->fifo) >= sizeof(msg)) { 263 while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
263 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); 264 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
264 WARN_ON(len != sizeof(msg)); 265 WARN_ON(len != sizeof(msg));
266 data = msg;
265 267
266 mbox_chan_received_data(mq->mbox->chan, (void *)msg); 268 mbox_chan_received_data(mq->mbox->chan, (void *)data);
267 spin_lock_irq(&mq->lock); 269 spin_lock_irq(&mq->lock);
268 if (mq->full) { 270 if (mq->full) {
269 mq->full = false; 271 mq->full = false;
@@ -286,7 +288,7 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
286static void __mbox_rx_interrupt(struct omap_mbox *mbox) 288static void __mbox_rx_interrupt(struct omap_mbox *mbox)
287{ 289{
288 struct omap_mbox_queue *mq = mbox->rxq; 290 struct omap_mbox_queue *mq = mbox->rxq;
289 mbox_msg_t msg; 291 u32 msg;
290 int len; 292 int len;
291 293
292 while (!mbox_fifo_empty(mbox)) { 294 while (!mbox_fifo_empty(mbox)) {
@@ -540,13 +542,13 @@ static void omap_mbox_chan_shutdown(struct mbox_chan *chan)
540 mutex_unlock(&mdev->cfg_lock); 542 mutex_unlock(&mdev->cfg_lock);
541} 543}
542 544
543static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, void *data) 545static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, u32 msg)
544{ 546{
545 int ret = -EBUSY; 547 int ret = -EBUSY;
546 548
547 if (!mbox_fifo_full(mbox)) { 549 if (!mbox_fifo_full(mbox)) {
548 _omap_mbox_enable_irq(mbox, IRQ_RX); 550 _omap_mbox_enable_irq(mbox, IRQ_RX);
549 mbox_fifo_write(mbox, (mbox_msg_t)data); 551 mbox_fifo_write(mbox, msg);
550 ret = 0; 552 ret = 0;
551 _omap_mbox_disable_irq(mbox, IRQ_RX); 553 _omap_mbox_disable_irq(mbox, IRQ_RX);
552 554
@@ -558,12 +560,12 @@ static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, void *data)
558 return ret; 560 return ret;
559} 561}
560 562
561static int omap_mbox_chan_send(struct omap_mbox *mbox, void *data) 563static int omap_mbox_chan_send(struct omap_mbox *mbox, u32 msg)
562{ 564{
563 int ret = -EBUSY; 565 int ret = -EBUSY;
564 566
565 if (!mbox_fifo_full(mbox)) { 567 if (!mbox_fifo_full(mbox)) {
566 mbox_fifo_write(mbox, (mbox_msg_t)data); 568 mbox_fifo_write(mbox, msg);
567 ret = 0; 569 ret = 0;
568 } 570 }
569 571
@@ -576,14 +578,15 @@ static int omap_mbox_chan_send_data(struct mbox_chan *chan, void *data)
576{ 578{
577 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); 579 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
578 int ret; 580 int ret;
581 u32 msg = omap_mbox_message(data);
579 582
580 if (!mbox) 583 if (!mbox)
581 return -EINVAL; 584 return -EINVAL;
582 585
583 if (mbox->send_no_irq) 586 if (mbox->send_no_irq)
584 ret = omap_mbox_chan_send_noirq(mbox, data); 587 ret = omap_mbox_chan_send_noirq(mbox, msg);
585 else 588 else
586 ret = omap_mbox_chan_send(mbox, data); 589 ret = omap_mbox_chan_send(mbox, msg);
587 590
588 return ret; 591 return ret;
589} 592}
@@ -657,6 +660,10 @@ static const struct of_device_id omap_mailbox_of_match[] = {
657 .data = &omap4_data, 660 .data = &omap4_data,
658 }, 661 },
659 { 662 {
663 .compatible = "ti,am654-mailbox",
664 .data = &omap4_data,
665 },
666 {
660 /* end */ 667 /* end */
661 }, 668 },
662}; 669};
@@ -830,7 +837,10 @@ static int omap_mbox_probe(struct platform_device *pdev)
830 mdev->intr_type = intr_type; 837 mdev->intr_type = intr_type;
831 mdev->mboxes = list; 838 mdev->mboxes = list;
832 839
833 /* OMAP does not have a Tx-Done IRQ, but rather a Tx-Ready IRQ */ 840 /*
841 * OMAP/K3 Mailbox IP does not have a Tx-Done IRQ, but rather a Tx-Ready
842 * IRQ and is needed to run the Tx state machine
843 */
834 mdev->controller.txdone_irq = true; 844 mdev->controller.txdone_irq = true;
835 mdev->controller.dev = mdev->dev; 845 mdev->controller.dev = mdev->dev;
836 mdev->controller.ops = &omap_mbox_chan_ops; 846 mdev->controller.ops = &omap_mbox_chan_ops;
@@ -899,9 +909,8 @@ static int __init omap_mbox_init(void)
899 return err; 909 return err;
900 910
901 /* kfifo size sanity check: alignment and minimal size */ 911 /* kfifo size sanity check: alignment and minimal size */
902 mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t)); 912 mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(u32));
903 mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, 913 mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(u32));
904 sizeof(mbox_msg_t));
905 914
906 err = platform_driver_register(&omap_mbox_driver); 915 err = platform_driver_register(&omap_mbox_driver);
907 if (err) 916 if (err)