Permalink
Browse files

mailbox: change OMAP1&2 opened message adaptation

This patch change internal OMAP1&2 mailbox drivers
behavior to use pdata field of mailbox_msg structure
instead of header one which could be confusing.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information...
1 parent cf4279e commit 96e9ef8a08c16d840938fbb56acd8caed2356068 @ydrallap ydrallap committed with Jan 31, 2013
@@ -37,6 +37,7 @@ struct omap_mbox1_fifo {
struct omap_mbox1_priv {
struct omap_mbox1_fifo tx_fifo;
struct omap_mbox1_fifo rx_fifo;
+ unsigned long data;
};
static inline int mbox_read_reg(size_t ofs)
@@ -52,25 +53,26 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
/* msg */
static void omap1_mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
- struct omap_mbox1_fifo *fifo =
- &((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
+ struct omap_mbox1_priv *priv = mbox->priv;
+ struct omap_mbox1_fifo *fifo = &priv->rx_fifo;
- msg->header = mbox_read_reg(fifo->data);
- msg->header |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16;
- MAILBOX_FILL_HEADER_MSG((*msg), msg->header);
+ priv->data = mbox_read_reg(fifo->data);
+ priv->data |= ((unsigned long) mbox_read_reg(fifo->cmd)) << 16;
+ MAILBOX_FILL_MSG((*msg), 0, priv->data, 0);
}
static int
omap1_mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
{
struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->tx_fifo;
+ unsigned long data = (unsigned long)msg->pdata;
if (msg->size != sizeof(u32))
return -EINVAL;
- mbox_write_reg(msg->header & 0xffff, fifo->data);
- mbox_write_reg(msg->header >> 16, fifo->cmd);
+ mbox_write_reg(data & 0xffff, fifo->data);
+ mbox_write_reg(data >> 16, fifo->cmd);
return 0;
}
@@ -60,6 +60,7 @@ struct omap_mbox2_priv {
u32 ctx[OMAP4_MBOX_NR_REGS];
unsigned long irqdisable;
u32 intr_type;
+ unsigned long data;
};
static void omap2_mbox_enable_irq(struct mailbox *mbox,
@@ -98,10 +99,10 @@ static void omap2_mbox_shutdown(struct mailbox *mbox)
/* Mailbox FIFO handle functions */
static void omap2_mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
- struct omap_mbox2_fifo *fifo =
- &((struct omap_mbox2_priv *)mbox->priv)->rx_fifo;
- msg->header = mbox_read_reg(fifo->msg);
- MAILBOX_FILL_HEADER_MSG((*msg), msg->header);
+ struct omap_mbox2_priv *priv = mbox->priv;
+ struct omap_mbox2_fifo *fifo = &priv->rx_fifo;
+ priv->data = mbox_read_reg(fifo->msg);
+ MAILBOX_FILL_MSG((*msg), 0, priv->data, 0);
}
static int omap2_mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
@@ -112,7 +113,7 @@ static int omap2_mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
if (msg->size != sizeof(u32))
return -EINVAL;
- mbox_write_reg(msg->header, fifo->msg);
+ mbox_write_reg((unsigned long)msg->pdata, fifo->msg);
return 0;
}
@@ -68,10 +68,11 @@ static int omap_rproc_mbox_callback(struct notifier_block *this,
struct device *dev = oproc->rproc->dev.parent;
struct mailbox_msg *msg = data;
const char *name = oproc->rproc->name;
+ unsigned long msg_data = (unsigned long)msg->pdata;
- dev_dbg(dev, "mbox msg: 0x%x\n", msg->header);
+ dev_dbg(dev, "mbox msg: 0x%x\n", msg_data);
- switch (msg->header) {
+ switch (msg_data) {
case RP_MBOX_CRASH:
/* just log this for now. later, we'll also do recovery */
dev_err(dev, "omap rproc %s crashed\n", name);
@@ -81,8 +82,8 @@ static int omap_rproc_mbox_callback(struct notifier_block *this,
break;
default:
/* msg contains the index of the triggered vring */
- if (rproc_vq_interrupt(oproc->rproc, msg->header) == IRQ_NONE)
- dev_dbg(dev, "no message was found in vqid %d\n", msg->header);
+ if (rproc_vq_interrupt(oproc->rproc, msg_data) == IRQ_NONE)
+ dev_dbg(dev, "no message was found in vqid %d\n", msg_data);
}
return NOTIFY_DONE;
@@ -97,7 +98,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
int ret;
/* send the index of the triggered virtqueue in the mailbox payload */
- MAILBOX_FILL_HEADER_MSG(msg, vqid);
+ MAILBOX_FILL_MSG(msg, 0, vqid, 0));
ret = mailbox_msg_send(oproc->mbox, &msg);
if (ret)
dev_err(dev, "mailbox_msg_send failed: %d\n", ret);
@@ -139,7 +140,7 @@ static int omap_rproc_start(struct rproc *rproc)
* Note that the reply will _not_ arrive immediately: this message
* will wait in the mailbox fifo until the remote processor is booted.
*/
- MAILBOX_FILL_HEADER_MSG(msg, RP_MBOX_ECHO_REQUEST);
+ MAILBOX_FILL_MSG(msg, 0, RP_MBOX_ECHO_REQUEST, 0);
ret = mailbox_msg_send(oproc->mbox, &msg);
if (ret) {
dev_err(dev, "mailbox_get failed: %d\n", ret);
@@ -912,7 +912,7 @@ int io_mbox_msg(struct notifier_block *self, unsigned long len, void *data)
{
struct io_mgr *pio_mgr;
struct dev_object *dev_obj;
- struct mailbox_msg *msg = data;
+ u32 msg = ((struct mailbox_msg *)data)->pdata;
unsigned long flags;
dev_obj = dev_get_first();
@@ -921,7 +921,7 @@ int io_mbox_msg(struct notifier_block *self, unsigned long len, void *data)
if (!pio_mgr)
return NOTIFY_BAD;
- pio_mgr->intr_val = (u16)(msg->header);
+ pio_mgr->intr_val = (u16)(msg);
if (pio_mgr->intr_val & MBX_PM_CLASS)
io_dispatch_pm(pio_mgr);
@@ -428,7 +428,8 @@ int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val)
dsp_clock_enable_all(dev_context->dsp_per_clks);
}
- MAILBOX_FILL_HEADER_MSG(msg, mb_val);
+ temp = mb_val;
+ MAILBOX_FILL_MSG(msg, 0, temp, 0);
status = mailbox_msg_send(dev_context->mbox, &msg);
if (status) {
View
@@ -28,9 +28,6 @@ struct mailbox_msg {
_msg.size = _size; \
}
-#define MAILBOX_FILL_HEADER_MSG(_msg, _header) \
- MAILBOX_FILL_MSG(_msg, _header, NULL, 0);
-
int mailbox_msg_send(struct mailbox *, struct mailbox_msg *msg);
struct mailbox *mailbox_get(const char *, struct notifier_block *nb);

0 comments on commit 96e9ef8

Please sign in to comment.