drivers/mailbox/omap-mailbox.c
Source file repositories/reference/linux-study-clean/drivers/mailbox/omap-mailbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mailbox/omap-mailbox.c- Extension
.c- Size
- 15190 bytes
- Lines
- 618
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/spinlock.hlinux/mutex.hlinux/slab.hlinux/kfifo.hlinux/err.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/mailbox_controller.h
Detected Declarations
struct omap_mbox_fifostruct omap_mbox_match_datastruct omap_mbox_devicestruct omap_mboxfunction mbox_read_regfunction mbox_write_regfunction mbox_fifo_readfunction mbox_fifo_writefunction mbox_fifo_emptyfunction mbox_fifo_fullfunction ack_mbox_irqfunction is_mbox_irqfunction omap_mbox_enable_irqfunction omap_mbox_disable_irqfunction __mbox_tx_interruptfunction __mbox_rx_interruptfunction mbox_interruptfunction omap_mbox_startupfunction omap_mbox_finifunction omap_mbox_chan_startupfunction omap_mbox_chan_shutdownfunction omap_mbox_chan_send_noirqfunction omap_mbox_chan_sendfunction omap_mbox_chan_send_datafunction omap_mbox_suspendfunction omap_mbox_resumefunction omap_mbox_probe
Annotated Snippet
struct omap_mbox_fifo {
unsigned long msg;
unsigned long fifo_stat;
unsigned long msg_stat;
unsigned long irqenable;
unsigned long irqstatus;
unsigned long irqdisable;
u32 intr_bit;
};
struct omap_mbox_match_data {
u32 intr_type;
bool is_exclusive;
};
struct omap_mbox_device {
struct device *dev;
struct mutex cfg_lock;
void __iomem *mbox_base;
u32 *irq_ctx;
u32 num_users;
u32 num_fifos;
u32 intr_type;
const struct omap_mbox_match_data *mbox_data;
};
struct omap_mbox {
const char *name;
int irq;
struct omap_mbox_device *parent;
struct omap_mbox_fifo tx_fifo;
struct omap_mbox_fifo rx_fifo;
u32 intr_type;
struct mbox_chan *chan;
bool send_no_irq;
};
static inline
unsigned int mbox_read_reg(struct omap_mbox_device *mdev, size_t ofs)
{
return __raw_readl(mdev->mbox_base + ofs);
}
static inline
void mbox_write_reg(struct omap_mbox_device *mdev, u32 val, size_t ofs)
{
__raw_writel(val, mdev->mbox_base + ofs);
}
/* Mailbox FIFO handle functions */
static u32 mbox_fifo_read(struct omap_mbox *mbox)
{
struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
return mbox_read_reg(mbox->parent, fifo->msg);
}
static void mbox_fifo_write(struct omap_mbox *mbox, u32 msg)
{
struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
mbox_write_reg(mbox->parent, msg, fifo->msg);
}
static int mbox_fifo_empty(struct omap_mbox *mbox)
{
struct omap_mbox_fifo *fifo = &mbox->rx_fifo;
return (mbox_read_reg(mbox->parent, fifo->msg_stat) == 0);
}
static int mbox_fifo_full(struct omap_mbox *mbox)
{
struct omap_mbox_fifo *fifo = &mbox->tx_fifo;
return mbox_read_reg(mbox->parent, fifo->fifo_stat);
}
/* Mailbox IRQ handle functions */
static void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
{
struct omap_mbox_fifo *fifo = (irq == IRQ_TX) ?
&mbox->tx_fifo : &mbox->rx_fifo;
u32 bit = fifo->intr_bit;
u32 irqstatus = fifo->irqstatus;
mbox_write_reg(mbox->parent, bit, irqstatus);
/* Flush posted write for irq status to avoid spurious interrupts */
mbox_read_reg(mbox->parent, irqstatus);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/spinlock.h`, `linux/mutex.h`, `linux/slab.h`, `linux/kfifo.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct omap_mbox_fifo`, `struct omap_mbox_match_data`, `struct omap_mbox_device`, `struct omap_mbox`, `function mbox_read_reg`, `function mbox_write_reg`, `function mbox_fifo_read`, `function mbox_fifo_write`, `function mbox_fifo_empty`, `function mbox_fifo_full`.
- Atlas domain: Driver Families / drivers/mailbox.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.