Skip to content

Commit

Permalink
firmware: bcm2835: Support legacy mailbox API
Browse files Browse the repository at this point in the history
Add support for the bcm_mailbox_*() functions.
This is temporary until all drivers have been converted to the
firmware API (rpi_firmware_property*()).

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
  • Loading branch information
notro authored and popcornmix committed Jul 13, 2015
1 parent d72c334 commit be083fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/firmware/raspberrypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
#define MBOX_MSG(chan, data28) (((data28) & ~0xf) | ((chan) & 0xf))
#define MBOX_CHAN(msg) ((msg) & 0xf)
#define MBOX_DATA28(msg) ((msg) & ~0xf)
#define MBOX_CHAN_VCHIQ 3
#define MBOX_CHAN_PROPERTY 8

struct rpi_firmware {
struct mbox_client cl;
struct mbox_chan *chan; /* The property channel. */
struct completion c;
u32 enabled;
u32 received;
};

static struct platform_device *g_pdev;
Expand All @@ -35,14 +37,15 @@ static DEFINE_MUTEX(transaction_lock);
static void response_callback(struct mbox_client *cl, void *msg)
{
struct rpi_firmware *fw = container_of(cl, struct rpi_firmware, cl);
fw->received = *(u32 *)msg;
complete(&fw->c);
}

/*
* Sends a request to the firmware through the BCM2835 mailbox driver,
* and synchronously waits for the reply.
*/
static int
int
rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
{
u32 message = MBOX_MSG(chan, data);
Expand All @@ -54,7 +57,8 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
reinit_completion(&fw->c);
ret = mbox_send_message(fw->chan, &message);
if (ret >= 0) {
wait_for_completion(&fw->c);
if (chan != MBOX_CHAN_VCHIQ)
wait_for_completion(&fw->c);
ret = 0;
} else {
dev_err(fw->cl.dev, "mbox_send_message returned %d\n", ret);
Expand All @@ -63,6 +67,13 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)

return ret;
}
EXPORT_SYMBOL(rpi_firmware_transaction);

u32 rpi_firmware_transaction_received(struct rpi_firmware *fw)
{
return MBOX_DATA28(fw->received);
}
EXPORT_SYMBOL(rpi_firmware_transaction_received);

/**
* rpi_firmware_property_list - Submit firmware property list
Expand Down
2 changes: 2 additions & 0 deletions include/soc/bcm2835/raspberrypi-firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ enum rpi_firmware_property_tag {
RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001,
};

int rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data);
u32 rpi_firmware_transaction_received(struct rpi_firmware *fw);
int rpi_firmware_property(struct rpi_firmware *fw,
u32 tag, void *data, size_t len);
int rpi_firmware_property_list(struct rpi_firmware *fw,
Expand Down

0 comments on commit be083fb

Please sign in to comment.