u-boot-brain/drivers/mailbox/sandbox-mbox.c
Tom Rini 83d290c56f SPDX: Convert all of our single license tags to Linux Kernel style
When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from.  So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry.  Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents.  There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 09:34:12 -04:00

104 lines
2.0 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2016, NVIDIA CORPORATION.
*/
#include <common.h>
#include <dm.h>
#include <mailbox-uclass.h>
#include <asm/io.h>
#include <asm/mbox.h>
#define SANDBOX_MBOX_CHANNELS 2
struct sandbox_mbox_chan {
bool rx_msg_valid;
uint32_t rx_msg;
};
struct sandbox_mbox {
struct sandbox_mbox_chan chans[SANDBOX_MBOX_CHANNELS];
};
static int sandbox_mbox_request(struct mbox_chan *chan)
{
debug("%s(chan=%p)\n", __func__, chan);
if (chan->id >= SANDBOX_MBOX_CHANNELS)
return -EINVAL;
return 0;
}
static int sandbox_mbox_free(struct mbox_chan *chan)
{
debug("%s(chan=%p)\n", __func__, chan);
return 0;
}
static int sandbox_mbox_send(struct mbox_chan *chan, const void *data)
{
struct sandbox_mbox *sbm = dev_get_priv(chan->dev);
const uint32_t *pmsg = data;
debug("%s(chan=%p, data=%p)\n", __func__, chan, data);
sbm->chans[chan->id].rx_msg = *pmsg ^ SANDBOX_MBOX_PING_XOR;
sbm->chans[chan->id].rx_msg_valid = true;
return 0;
}
static int sandbox_mbox_recv(struct mbox_chan *chan, void *data)
{
struct sandbox_mbox *sbm = dev_get_priv(chan->dev);
uint32_t *pmsg = data;
debug("%s(chan=%p, data=%p)\n", __func__, chan, data);
if (!sbm->chans[chan->id].rx_msg_valid)
return -ENODATA;
*pmsg = sbm->chans[chan->id].rx_msg;
sbm->chans[chan->id].rx_msg_valid = false;
return 0;
}
static int sandbox_mbox_bind(struct udevice *dev)
{
debug("%s(dev=%p)\n", __func__, dev);
return 0;
}
static int sandbox_mbox_probe(struct udevice *dev)
{
debug("%s(dev=%p)\n", __func__, dev);
return 0;
}
static const struct udevice_id sandbox_mbox_ids[] = {
{ .compatible = "sandbox,mbox" },
{ }
};
struct mbox_ops sandbox_mbox_mbox_ops = {
.request = sandbox_mbox_request,
.free = sandbox_mbox_free,
.send = sandbox_mbox_send,
.recv = sandbox_mbox_recv,
};
U_BOOT_DRIVER(sandbox_mbox) = {
.name = "sandbox_mbox",
.id = UCLASS_MAILBOX,
.of_match = sandbox_mbox_ids,
.bind = sandbox_mbox_bind,
.probe = sandbox_mbox_probe,
.priv_auto_alloc_size = sizeof(struct sandbox_mbox),
.ops = &sandbox_mbox_mbox_ops,
};