drivers/mailbox/imx-mailbox.c
Source file repositories/reference/linux-study-clean/drivers/mailbox/imx-mailbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mailbox/imx-mailbox.c- Extension
.c- Size
- 29420 bytes
- Lines
- 1146
- 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/bitfield.hlinux/clk.hlinux/firmware/imx/ipc.hlinux/firmware/imx/s4.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/jiffies.hlinux/kernel.hlinux/mailbox_controller.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/suspend.hlinux/slab.hlinux/workqueue.h
Detected Declarations
struct imx_sc_rpc_msg_maxstruct imx_s4_rpc_msg_maxstruct imx_mu_con_privstruct imx_mu_privstruct imx_mu_dcfgenum imx_mu_chan_typeenum imx_mu_xcrenum imx_mu_xsrenum imx_mu_typefunction imx_mu_writefunction imx_mu_readfunction imx_mu_tx_waiting_writefunction imx_mu_rx_waiting_readfunction imx_mu_xcr_rmwfunction imx_mu_generic_txfunction imx_mu_generic_rxfunction imx_mu_generic_rxdbfunction imx_mu_specific_txfunction imx_mu_specific_rxfunction imx_mu_seco_txfunction imx_mu_seco_rxdbfunction imx_mu_txdb_workfunction imx_mu_isrfunction imx_mu_send_datafunction imx_mu_startupfunction imx_mu_shutdownfunction imx_mu_xlatefunction imx_mu_get_tr_rrfunction imx_mu_init_genericfunction imx_mu_init_specificfunction imx_mu_init_secofunction imx_mu_probefunction imx_mu_removefunction imx_mu_suspend_noirqfunction imx_mu_resume_noirqfunction imx_mu_runtime_suspendfunction imx_mu_runtime_resume
Annotated Snippet
struct imx_sc_rpc_msg_max {
struct imx_sc_rpc_msg hdr;
u32 data[30];
};
struct imx_s4_rpc_msg_max {
struct imx_s4_rpc_msg hdr;
u32 data[254];
};
struct imx_mu_con_priv {
unsigned int idx;
char irq_desc[IMX_MU_CHAN_NAME_SIZE];
enum imx_mu_chan_type type;
struct mbox_chan *chan;
struct work_struct txdb_work;
};
struct imx_mu_priv {
struct device *dev;
void __iomem *base;
void *msg;
spinlock_t xcr_lock; /* control register lock */
struct mbox_controller mbox;
struct mbox_chan mbox_chans[IMX_MU_CHANS];
struct imx_mu_con_priv con_priv[IMX_MU_CHANS];
const struct imx_mu_dcfg *dcfg;
struct clk *clk;
int irq[IMX_MU_CHANS];
bool suspend;
bool side_b;
u32 xcr[IMX_MU_xCR_MAX];
u32 num_tr;
u32 num_rr;
};
enum imx_mu_type {
IMX_MU_V1,
IMX_MU_V2 = BIT(1),
IMX_MU_V2_S4 = BIT(15),
IMX_MU_V2_IRQ = BIT(16),
};
struct imx_mu_dcfg {
int (*tx)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp, void *data);
int (*rx)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp);
int (*rxdb)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp);
int (*init)(struct imx_mu_priv *priv);
enum imx_mu_type type;
u32 xTR; /* Transmit Register0 */
u32 xRR; /* Receive Register0 */
u32 xSR[IMX_MU_xSR_MAX]; /* Status Registers */
u32 xCR[IMX_MU_xCR_MAX]; /* Control Registers */
bool skip_suspend_flag;
};
#define IMX_MU_xSR_GIPn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(28 + (3 - (x))))
#define IMX_MU_xSR_RFn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x))))
#define IMX_MU_xSR_TEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(20 + (3 - (x))))
/* General Purpose Interrupt Enable */
#define IMX_MU_xCR_GIEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(28 + (3 - (x))))
/* Receive Interrupt Enable */
#define IMX_MU_xCR_RIEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x))))
/* Transmit Interrupt Enable */
#define IMX_MU_xCR_TIEn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(20 + (3 - (x))))
/* General Purpose Interrupt Request */
#define IMX_MU_xCR_GIRn(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(16 + (3 - (x))))
/* MU reset */
#define IMX_MU_xCR_RST(type) (type & IMX_MU_V2 ? BIT(0) : BIT(5))
#define IMX_MU_xSR_RST(type) (type & IMX_MU_V2 ? BIT(0) : BIT(7))
static struct imx_mu_priv *to_imx_mu_priv(struct mbox_controller *mbox)
{
return container_of(mbox, struct imx_mu_priv, mbox);
}
static void imx_mu_write(struct imx_mu_priv *priv, u32 val, u32 offs)
{
iowrite32(val, priv->base + offs);
}
static u32 imx_mu_read(struct imx_mu_priv *priv, u32 offs)
{
return ioread32(priv->base + offs);
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/firmware/imx/ipc.h`, `linux/firmware/imx/s4.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/jiffies.h`.
- Detected declarations: `struct imx_sc_rpc_msg_max`, `struct imx_s4_rpc_msg_max`, `struct imx_mu_con_priv`, `struct imx_mu_priv`, `struct imx_mu_dcfg`, `enum imx_mu_chan_type`, `enum imx_mu_xcr`, `enum imx_mu_xsr`, `enum imx_mu_type`, `function imx_mu_write`.
- 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.