drivers/mailbox/mtk-adsp-mailbox.c
Source file repositories/reference/linux-study-clean/drivers/mailbox/mtk-adsp-mailbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mailbox/mtk-adsp-mailbox.c- Extension
.c- Size
- 4703 bytes
- Lines
- 186
- Domain
- Driver Families
- Bucket
- drivers/mailbox
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/io.hlinux/iopoll.hlinux/kernel.hlinux/mailbox_controller.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct mtk_adsp_mbox_privstruct mtk_adsp_mbox_cfgfunction mtk_adsp_mbox_irqfunction mtk_adsp_mbox_isrfunction mtk_adsp_mbox_startupfunction mtk_adsp_mbox_shutdownfunction mtk_adsp_mbox_send_datafunction mtk_adsp_mbox_last_tx_donefunction mtk_adsp_mbox_probe
Annotated Snippet
struct mtk_adsp_mbox_priv {
struct device *dev;
struct mbox_controller mbox;
void __iomem *va_mboxreg;
const struct mtk_adsp_mbox_cfg *cfg;
};
struct mtk_adsp_mbox_cfg {
u32 set_in;
u32 set_out;
u32 clr_in;
u32 clr_out;
};
static inline struct mtk_adsp_mbox_priv *get_mtk_adsp_mbox_priv(struct mbox_controller *mbox)
{
return container_of(mbox, struct mtk_adsp_mbox_priv, mbox);
}
static irqreturn_t mtk_adsp_mbox_irq(int irq, void *data)
{
struct mbox_chan *chan = data;
struct mtk_adsp_mbox_priv *priv = get_mtk_adsp_mbox_priv(chan->mbox);
u32 op = readl(priv->va_mboxreg + priv->cfg->set_out);
writel(op, priv->va_mboxreg + priv->cfg->clr_out);
return IRQ_WAKE_THREAD;
}
static irqreturn_t mtk_adsp_mbox_isr(int irq, void *data)
{
struct mbox_chan *chan = data;
mbox_chan_received_data(chan, NULL);
return IRQ_HANDLED;
}
static struct mbox_chan *mtk_adsp_mbox_xlate(struct mbox_controller *mbox,
const struct of_phandle_args *sp)
{
return mbox->chans;
}
static int mtk_adsp_mbox_startup(struct mbox_chan *chan)
{
struct mtk_adsp_mbox_priv *priv = get_mtk_adsp_mbox_priv(chan->mbox);
/* Clear ADSP mbox command */
writel(0xFFFFFFFF, priv->va_mboxreg + priv->cfg->clr_in);
writel(0xFFFFFFFF, priv->va_mboxreg + priv->cfg->clr_out);
return 0;
}
static void mtk_adsp_mbox_shutdown(struct mbox_chan *chan)
{
struct mtk_adsp_mbox_priv *priv = get_mtk_adsp_mbox_priv(chan->mbox);
/* Clear ADSP mbox command */
writel(0xFFFFFFFF, priv->va_mboxreg + priv->cfg->clr_in);
writel(0xFFFFFFFF, priv->va_mboxreg + priv->cfg->clr_out);
}
static int mtk_adsp_mbox_send_data(struct mbox_chan *chan, void *data)
{
struct mtk_adsp_mbox_priv *priv = get_mtk_adsp_mbox_priv(chan->mbox);
u32 *msg = data;
writel(*msg, priv->va_mboxreg + priv->cfg->set_in);
return 0;
}
static bool mtk_adsp_mbox_last_tx_done(struct mbox_chan *chan)
{
struct mtk_adsp_mbox_priv *priv = get_mtk_adsp_mbox_priv(chan->mbox);
return readl(priv->va_mboxreg + priv->cfg->set_in) == 0;
}
static const struct mbox_chan_ops mtk_adsp_mbox_chan_ops = {
.send_data = mtk_adsp_mbox_send_data,
.startup = mtk_adsp_mbox_startup,
.shutdown = mtk_adsp_mbox_shutdown,
.last_tx_done = mtk_adsp_mbox_last_tx_done,
};
static int mtk_adsp_mbox_probe(struct platform_device *pdev)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/mailbox_controller.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct mtk_adsp_mbox_priv`, `struct mtk_adsp_mbox_cfg`, `function mtk_adsp_mbox_irq`, `function mtk_adsp_mbox_isr`, `function mtk_adsp_mbox_startup`, `function mtk_adsp_mbox_shutdown`, `function mtk_adsp_mbox_send_data`, `function mtk_adsp_mbox_last_tx_done`, `function mtk_adsp_mbox_probe`.
- Atlas domain: Driver Families / drivers/mailbox.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.