#include <linux/regmap.h>
#include <linux/slab.h>
+#include <acpi/qemu-mailbox.h>
+
#define QEMU_MBOX_MAX_CHAN_CNT 8
#define QEMU_MBOX_CFG 0x0
struct mbox_controller mbox;
};
+static struct qemu_mbox *__mbox;
+
static inline struct qemu_mbox *get_qemu_mbox(struct mbox_controller *mbox)
{
return container_of(mbox, struct qemu_mbox, mbox);
return IRQ_HANDLED;
}
+struct mbox_chan *qemu_mbox_request_channel(struct mbox_client *cl)
+{
+ struct qemu_mbox *mbox = __mbox;
+ struct mbox_chan *chan = ERR_PTR(-EBUSY);
+ unsigned int i;
+
+ if (!mbox)
+ return ERR_PTR(-ENOENT);
+
+ for (i = 0; i < mbox->mbox.num_chans; i++) {
+ chan = &mbox->mbox.chans[i];
+ if (mbox_bind_client(chan, cl) == 0)
+ break;
+ }
+
+ return chan;
+}
+EXPORT_SYMBOL_GPL(qemu_mbox_request_channel);
+
static int qemu_mbox_send_data(struct mbox_chan *link, void *data)
{
unsigned long chan = (unsigned long)link->con_priv;
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Mailbox driver for QEMU Virtual PCI
+ */
+
+#ifndef _QEMU_MBOX_H
+#define _QEMU_MBOX_H
+
+#include <linux/mailbox_controller.h>
+#include <linux/mailbox_client.h>
+
+#if defined(CONFIG_QEMU_MBOX) || defined(CONFIG_QEMU_MBOX_MODULE)
+struct mbox_chan *qemu_mbox_request_channel(struct mbox_client *cl);
+#else
+static inline struct mbox_chan *
+qemu_mbox_request_channel(struct mbox_client *cl)
+{
+ return ERR_PTR(-ENODEV);
+}
+#endif
+
+#endif /* _QEMU_MBOX_H */