hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/mailbox/omap-mailbox.c
....@@ -3,7 +3,7 @@
33 * OMAP mailbox driver
44 *
55 * 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 - https://www.ti.com
77 *
88 * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
99 * Suman Anna <s-anna@ti.com>
....@@ -141,14 +141,14 @@
141141 }
142142
143143 /* Mailbox FIFO handle functions */
144
-static mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
144
+static u32 mbox_fifo_read(struct omap_mbox *mbox)
145145 {
146146 struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
147147
148
- return (mbox_msg_t)mbox_read_reg(mbox->parent, fifo->msg);
148
+ return mbox_read_reg(mbox->parent, fifo->msg);
149149 }
150150
151
-static void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
151
+static void mbox_fifo_write(struct omap_mbox *mbox, u32 msg)
152152 {
153153 struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
154154
....@@ -256,14 +256,16 @@
256256 {
257257 struct omap_mbox_queue *mq =
258258 container_of(work, struct omap_mbox_queue, work);
259
- mbox_msg_t msg;
259
+ mbox_msg_t data;
260
+ u32 msg;
260261 int len;
261262
262263 while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
263264 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
264265 WARN_ON(len != sizeof(msg));
266
+ data = msg;
265267
266
- mbox_chan_received_data(mq->mbox->chan, (void *)msg);
268
+ mbox_chan_received_data(mq->mbox->chan, (void *)data);
267269 spin_lock_irq(&mq->lock);
268270 if (mq->full) {
269271 mq->full = false;
....@@ -286,7 +288,7 @@
286288 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
287289 {
288290 struct omap_mbox_queue *mq = mbox->rxq;
289
- mbox_msg_t msg;
291
+ u32 msg;
290292 int len;
291293
292294 while (!mbox_fifo_empty(mbox)) {
....@@ -486,7 +488,7 @@
486488 list_add(&mdev->elem, &omap_mbox_devices);
487489 mutex_unlock(&omap_mbox_devices_lock);
488490
489
- ret = mbox_controller_register(&mdev->controller);
491
+ ret = devm_mbox_controller_register(mdev->dev, &mdev->controller);
490492
491493 err_out:
492494 if (ret) {
....@@ -507,8 +509,6 @@
507509 mutex_lock(&omap_mbox_devices_lock);
508510 list_del(&mdev->elem);
509511 mutex_unlock(&omap_mbox_devices_lock);
510
-
511
- mbox_controller_unregister(&mdev->controller);
512512
513513 mboxes = mdev->mboxes;
514514 for (i = 0; mboxes[i]; i++)
....@@ -542,13 +542,13 @@
542542 mutex_unlock(&mdev->cfg_lock);
543543 }
544544
545
-static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, void *data)
545
+static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, u32 msg)
546546 {
547547 int ret = -EBUSY;
548548
549549 if (!mbox_fifo_full(mbox)) {
550550 _omap_mbox_enable_irq(mbox, IRQ_RX);
551
- mbox_fifo_write(mbox, (mbox_msg_t)data);
551
+ mbox_fifo_write(mbox, msg);
552552 ret = 0;
553553 _omap_mbox_disable_irq(mbox, IRQ_RX);
554554
....@@ -560,12 +560,12 @@
560560 return ret;
561561 }
562562
563
-static int omap_mbox_chan_send(struct omap_mbox *mbox, void *data)
563
+static int omap_mbox_chan_send(struct omap_mbox *mbox, u32 msg)
564564 {
565565 int ret = -EBUSY;
566566
567567 if (!mbox_fifo_full(mbox)) {
568
- mbox_fifo_write(mbox, (mbox_msg_t)data);
568
+ mbox_fifo_write(mbox, msg);
569569 ret = 0;
570570 }
571571
....@@ -578,14 +578,15 @@
578578 {
579579 struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
580580 int ret;
581
+ u32 msg = omap_mbox_message(data);
581582
582583 if (!mbox)
583584 return -EINVAL;
584585
585586 if (mbox->send_no_irq)
586
- ret = omap_mbox_chan_send_noirq(mbox, data);
587
+ ret = omap_mbox_chan_send_noirq(mbox, msg);
587588 else
588
- ret = omap_mbox_chan_send(mbox, data);
589
+ ret = omap_mbox_chan_send(mbox, msg);
589590
590591 return ret;
591592 }
....@@ -656,6 +657,10 @@
656657 },
657658 {
658659 .compatible = "ti,omap4-mailbox",
660
+ .data = &omap4_data,
661
+ },
662
+ {
663
+ .compatible = "ti,am654-mailbox",
659664 .data = &omap4_data,
660665 },
661666 {
....@@ -832,7 +837,10 @@
832837 mdev->intr_type = intr_type;
833838 mdev->mboxes = list;
834839
835
- /* 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
+ */
836844 mdev->controller.txdone_irq = true;
837845 mdev->controller.dev = mdev->dev;
838846 mdev->controller.ops = &omap_mbox_chan_ops;
....@@ -860,7 +868,7 @@
860868 dev_info(mdev->dev, "omap mailbox rev 0x%x\n", l);
861869
862870 ret = pm_runtime_put_sync(mdev->dev);
863
- if (ret < 0)
871
+ if (ret < 0 && ret != -ENOSYS)
864872 goto unregister;
865873
866874 devm_kfree(&pdev->dev, finfoblk);
....@@ -901,9 +909,8 @@
901909 return err;
902910
903911 /* kfifo size sanity check: alignment and minimal size */
904
- mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
905
- mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
906
- sizeof(mbox_msg_t));
912
+ mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(u32));
913
+ mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(u32));
907914
908915 err = platform_driver_register(&omap_mbox_driver);
909916 if (err)