Skip to content

Commit

Permalink
Merge branch 'mailbox-devel' of git://git.linaro.org/landing-teams/wo…
Browse files Browse the repository at this point in the history
…rking/fujitsu/integration

Pull mailbox framework updates from Jassi Brar.

* 'mailbox-devel' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
  Mailbox: Add support for Platform Communication Channel
  mailbox/omap: adapt to the new mailbox framework
  mailbox: add tx_prepare client callback
  mailbox: Don't unnecessarily re-arm the polling timer
  • Loading branch information
Linus Torvalds committed Dec 11, 2014
2 parents b859e7d + 86c22f8 commit 14ba9a2
Show file tree
Hide file tree
Showing 10 changed files with 701 additions and 188 deletions.
23 changes: 23 additions & 0 deletions Documentation/devicetree/bindings/mailbox/omap-mailbox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Required properties:
device. The format is dependent on which interrupt
controller the OMAP device uses
- ti,hwmods: Name of the hwmod associated with the mailbox
- #mbox-cells: Common mailbox binding property to identify the number
of cells required for the mailbox specifier. Should be
1
- ti,mbox-num-users: Number of targets (processor devices) that the mailbox
device can interrupt
- ti,mbox-num-fifos: Number of h/w fifo queues within the mailbox IP block
Expand Down Expand Up @@ -72,6 +75,18 @@ data that represent the following:
Cell #3 (usr_id) - mailbox user id for identifying the interrupt line
associated with generating a tx/rx fifo interrupt.

Mailbox Users:
==============
A device needing to communicate with a target processor device should specify
them using the common mailbox binding properties, "mboxes" and the optional
"mbox-names" (please see Documentation/devicetree/bindings/mailbox/mailbox.txt
for details). Each value of the mboxes property should contain a phandle to the
mailbox controller device node and an args specifier that will be the phandle to
the intended sub-mailbox child node to be used for communication. The equivalent
"mbox-names" property value can be used to give a name to the communication channel
to be used by the client user.


Example:
--------

Expand All @@ -81,6 +96,7 @@ mailbox: mailbox@4a0f4000 {
reg = <0x4a0f4000 0x200>;
interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
ti,hwmods = "mailbox";
#mbox-cells = <1>;
ti,mbox-num-users = <3>;
ti,mbox-num-fifos = <8>;
mbox_ipu: mbox_ipu {
Expand All @@ -93,12 +109,19 @@ mailbox: mailbox@4a0f4000 {
};
};

dsp {
...
mboxes = <&mailbox &mbox_dsp>;
...
};

/* AM33xx */
mailbox: mailbox@480C8000 {
compatible = "ti,omap4-mailbox";
reg = <0x480C8000 0x200>;
interrupts = <77>;
ti,hwmods = "mailbox";
#mbox-cells = <1>;
ti,mbox-num-users = <4>;
ti,mbox-num-fifos = <8>;
mbox_wkupm3: wkup_m3 {
Expand Down
12 changes: 12 additions & 0 deletions drivers/mailbox/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@ config OMAP_MBOX_KFIFO_SIZE
Specify the default size of mailbox's kfifo buffers (bytes).
This can also be changed at runtime (via the mbox_kfifo_size
module parameter).

config PCC
bool "Platform Communication Channel Driver"
depends on ACPI
help
ACPI 5.0+ spec defines a generic mode of communication
between the OS and a platform such as the BMC. This medium
(PCC) is typically used by CPPC (ACPI CPU Performance management),
RAS (ACPI reliability protocol) and MPST (ACPI Memory power
states). Select this driver if your platform implements the
PCC clients mentioned above.

endif
2 changes: 2 additions & 0 deletions drivers/mailbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ obj-$(CONFIG_MAILBOX) += mailbox.o
obj-$(CONFIG_PL320_MBOX) += pl320-ipc.o

obj-$(CONFIG_OMAP2PLUS_MBOX) += omap-mailbox.o

obj-$(CONFIG_PCC) += pcc.o
19 changes: 11 additions & 8 deletions drivers/mailbox/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#include <linux/mailbox_client.h>
#include <linux/mailbox_controller.h>

#define TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */
#define TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */
#define TXDONE_BY_ACK BIT(2) /* S/W ACK recevied by Client ticks the TX */
#include "mailbox.h"

static LIST_HEAD(mbox_cons);
static DEFINE_MUTEX(con_mutex);

static void poll_txdone(unsigned long data);

static int add_to_rbuf(struct mbox_chan *chan, void *mssg)
{
int idx;
Expand Down Expand Up @@ -60,7 +60,7 @@ static void msg_submit(struct mbox_chan *chan)
unsigned count, idx;
unsigned long flags;
void *data;
int err;
int err = -EBUSY;

spin_lock_irqsave(&chan->lock, flags);

Expand All @@ -76,6 +76,8 @@ static void msg_submit(struct mbox_chan *chan)

data = chan->msg_data[idx];

if (chan->cl->tx_prepare)
chan->cl->tx_prepare(chan->cl, data);
/* Try to submit a message to the MBOX controller */
err = chan->mbox->ops->send_data(chan, data);
if (!err) {
Expand All @@ -84,6 +86,9 @@ static void msg_submit(struct mbox_chan *chan)
}
exit:
spin_unlock_irqrestore(&chan->lock, flags);

if (!err && chan->txdone_method == TXDONE_BY_POLL)
poll_txdone((unsigned long)chan->mbox);
}

static void tx_tick(struct mbox_chan *chan, int r)
Expand Down Expand Up @@ -117,10 +122,11 @@ static void poll_txdone(unsigned long data)
struct mbox_chan *chan = &mbox->chans[i];

if (chan->active_req && chan->cl) {
resched = true;
txdone = chan->mbox->ops->last_tx_done(chan);
if (txdone)
tx_tick(chan, 0);
else
resched = true;
}
}

Expand Down Expand Up @@ -252,9 +258,6 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)

msg_submit(chan);

if (chan->txdone_method == TXDONE_BY_POLL)
poll_txdone((unsigned long)chan->mbox);

if (chan->cl->tx_block && chan->active_req) {
unsigned long wait;
int ret;
Expand Down
14 changes: 14 additions & 0 deletions drivers/mailbox/mailbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#ifndef __MAILBOX_H
#define __MAILBOX_H

#define TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */
#define TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */
#define TXDONE_BY_ACK BIT(2) /* S/W ACK recevied by Client ticks the TX */

#endif /* __MAILBOX_H */
Loading

0 comments on commit 14ba9a2

Please sign in to comment.