| .. | .. |
|---|
| 3 | 3 | * OMAP mailbox driver |
|---|
| 4 | 4 | * |
|---|
| 5 | 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 - https://www.ti.com |
|---|
| 7 | 7 | * |
|---|
| 8 | 8 | * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com> |
|---|
| 9 | 9 | * Suman Anna <s-anna@ti.com> |
|---|
| .. | .. |
|---|
| 141 | 141 | } |
|---|
| 142 | 142 | |
|---|
| 143 | 143 | /* 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) |
|---|
| 145 | 145 | { |
|---|
| 146 | 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 | |
|---|
| 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) |
|---|
| 152 | 152 | { |
|---|
| 153 | 153 | struct omap_mbox_fifo *fifo = &mbox->tx_fifo; |
|---|
| 154 | 154 | |
|---|
| .. | .. |
|---|
| 256 | 256 | { |
|---|
| 257 | 257 | struct omap_mbox_queue *mq = |
|---|
| 258 | 258 | container_of(work, struct omap_mbox_queue, work); |
|---|
| 259 | | - mbox_msg_t msg; |
|---|
| 259 | + mbox_msg_t data; |
|---|
| 260 | + u32 msg; |
|---|
| 260 | 261 | int len; |
|---|
| 261 | 262 | |
|---|
| 262 | 263 | while (kfifo_len(&mq->fifo) >= sizeof(msg)) { |
|---|
| 263 | 264 | len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); |
|---|
| 264 | 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 | 269 | spin_lock_irq(&mq->lock); |
|---|
| 268 | 270 | if (mq->full) { |
|---|
| 269 | 271 | mq->full = false; |
|---|
| .. | .. |
|---|
| 286 | 288 | static void __mbox_rx_interrupt(struct omap_mbox *mbox) |
|---|
| 287 | 289 | { |
|---|
| 288 | 290 | struct omap_mbox_queue *mq = mbox->rxq; |
|---|
| 289 | | - mbox_msg_t msg; |
|---|
| 291 | + u32 msg; |
|---|
| 290 | 292 | int len; |
|---|
| 291 | 293 | |
|---|
| 292 | 294 | while (!mbox_fifo_empty(mbox)) { |
|---|
| .. | .. |
|---|
| 486 | 488 | list_add(&mdev->elem, &omap_mbox_devices); |
|---|
| 487 | 489 | mutex_unlock(&omap_mbox_devices_lock); |
|---|
| 488 | 490 | |
|---|
| 489 | | - ret = mbox_controller_register(&mdev->controller); |
|---|
| 491 | + ret = devm_mbox_controller_register(mdev->dev, &mdev->controller); |
|---|
| 490 | 492 | |
|---|
| 491 | 493 | err_out: |
|---|
| 492 | 494 | if (ret) { |
|---|
| .. | .. |
|---|
| 507 | 509 | mutex_lock(&omap_mbox_devices_lock); |
|---|
| 508 | 510 | list_del(&mdev->elem); |
|---|
| 509 | 511 | mutex_unlock(&omap_mbox_devices_lock); |
|---|
| 510 | | - |
|---|
| 511 | | - mbox_controller_unregister(&mdev->controller); |
|---|
| 512 | 512 | |
|---|
| 513 | 513 | mboxes = mdev->mboxes; |
|---|
| 514 | 514 | for (i = 0; mboxes[i]; i++) |
|---|
| .. | .. |
|---|
| 542 | 542 | mutex_unlock(&mdev->cfg_lock); |
|---|
| 543 | 543 | } |
|---|
| 544 | 544 | |
|---|
| 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) |
|---|
| 546 | 546 | { |
|---|
| 547 | 547 | int ret = -EBUSY; |
|---|
| 548 | 548 | |
|---|
| 549 | 549 | if (!mbox_fifo_full(mbox)) { |
|---|
| 550 | 550 | _omap_mbox_enable_irq(mbox, IRQ_RX); |
|---|
| 551 | | - mbox_fifo_write(mbox, (mbox_msg_t)data); |
|---|
| 551 | + mbox_fifo_write(mbox, msg); |
|---|
| 552 | 552 | ret = 0; |
|---|
| 553 | 553 | _omap_mbox_disable_irq(mbox, IRQ_RX); |
|---|
| 554 | 554 | |
|---|
| .. | .. |
|---|
| 560 | 560 | return ret; |
|---|
| 561 | 561 | } |
|---|
| 562 | 562 | |
|---|
| 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) |
|---|
| 564 | 564 | { |
|---|
| 565 | 565 | int ret = -EBUSY; |
|---|
| 566 | 566 | |
|---|
| 567 | 567 | if (!mbox_fifo_full(mbox)) { |
|---|
| 568 | | - mbox_fifo_write(mbox, (mbox_msg_t)data); |
|---|
| 568 | + mbox_fifo_write(mbox, msg); |
|---|
| 569 | 569 | ret = 0; |
|---|
| 570 | 570 | } |
|---|
| 571 | 571 | |
|---|
| .. | .. |
|---|
| 578 | 578 | { |
|---|
| 579 | 579 | struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan); |
|---|
| 580 | 580 | int ret; |
|---|
| 581 | + u32 msg = omap_mbox_message(data); |
|---|
| 581 | 582 | |
|---|
| 582 | 583 | if (!mbox) |
|---|
| 583 | 584 | return -EINVAL; |
|---|
| 584 | 585 | |
|---|
| 585 | 586 | if (mbox->send_no_irq) |
|---|
| 586 | | - ret = omap_mbox_chan_send_noirq(mbox, data); |
|---|
| 587 | + ret = omap_mbox_chan_send_noirq(mbox, msg); |
|---|
| 587 | 588 | else |
|---|
| 588 | | - ret = omap_mbox_chan_send(mbox, data); |
|---|
| 589 | + ret = omap_mbox_chan_send(mbox, msg); |
|---|
| 589 | 590 | |
|---|
| 590 | 591 | return ret; |
|---|
| 591 | 592 | } |
|---|
| .. | .. |
|---|
| 656 | 657 | }, |
|---|
| 657 | 658 | { |
|---|
| 658 | 659 | .compatible = "ti,omap4-mailbox", |
|---|
| 660 | + .data = &omap4_data, |
|---|
| 661 | + }, |
|---|
| 662 | + { |
|---|
| 663 | + .compatible = "ti,am654-mailbox", |
|---|
| 659 | 664 | .data = &omap4_data, |
|---|
| 660 | 665 | }, |
|---|
| 661 | 666 | { |
|---|
| .. | .. |
|---|
| 832 | 837 | mdev->intr_type = intr_type; |
|---|
| 833 | 838 | mdev->mboxes = list; |
|---|
| 834 | 839 | |
|---|
| 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 | + */ |
|---|
| 836 | 844 | mdev->controller.txdone_irq = true; |
|---|
| 837 | 845 | mdev->controller.dev = mdev->dev; |
|---|
| 838 | 846 | mdev->controller.ops = &omap_mbox_chan_ops; |
|---|
| .. | .. |
|---|
| 860 | 868 | dev_info(mdev->dev, "omap mailbox rev 0x%x\n", l); |
|---|
| 861 | 869 | |
|---|
| 862 | 870 | ret = pm_runtime_put_sync(mdev->dev); |
|---|
| 863 | | - if (ret < 0) |
|---|
| 871 | + if (ret < 0 && ret != -ENOSYS) |
|---|
| 864 | 872 | goto unregister; |
|---|
| 865 | 873 | |
|---|
| 866 | 874 | devm_kfree(&pdev->dev, finfoblk); |
|---|
| .. | .. |
|---|
| 901 | 909 | return err; |
|---|
| 902 | 910 | |
|---|
| 903 | 911 | /* 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)); |
|---|
| 907 | 914 | |
|---|
| 908 | 915 | err = platform_driver_register(&omap_mbox_driver); |
|---|
| 909 | 916 | if (err) |
|---|