drivers/mailbox/mailbox-sti.c
Source file repositories/reference/linux-study-clean/drivers/mailbox/mailbox-sti.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mailbox/mailbox-sti.c- Extension
.c- Size
- 13122 bytes
- Lines
- 494
- 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/err.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/mailbox_controller.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/slab.h
Detected Declarations
struct sti_mbox_devicestruct sti_mbox_pdatastruct sti_channelfunction sti_mbox_channel_is_enabledfunction sti_mbox_enable_channelfunction sti_mbox_disable_channelfunction sti_mbox_clear_irqfunction sti_mbox_thread_handlerfunction sti_mbox_irq_handlerfunction sti_mbox_tx_is_readyfunction sti_mbox_send_datafunction sti_mbox_startup_chanfunction sti_mbox_shutdown_chanfunction sti_mbox_probe
Annotated Snippet
struct sti_mbox_device {
struct device *dev;
struct mbox_controller *mbox;
void __iomem *base;
const char *name;
u32 enabled[STI_MBOX_INST_MAX];
spinlock_t lock;
};
/**
* struct sti_mbox_pdata - STi Mailbox platform specific configuration
*
* @num_inst: Maximum number of instances in one HW Mailbox
* @num_chan: Maximum number of channel per instance
*/
struct sti_mbox_pdata {
unsigned int num_inst;
unsigned int num_chan;
};
/**
* struct sti_channel - STi Mailbox allocated channel information
*
* @mdev: Pointer to parent Mailbox device
* @instance: Instance number channel resides in
* @channel: Channel number pertaining to this container
*/
struct sti_channel {
struct sti_mbox_device *mdev;
unsigned int instance;
unsigned int channel;
};
static inline bool sti_mbox_channel_is_enabled(struct mbox_chan *chan)
{
struct sti_channel *chan_info = chan->con_priv;
struct sti_mbox_device *mdev = chan_info->mdev;
unsigned int instance = chan_info->instance;
unsigned int channel = chan_info->channel;
return mdev->enabled[instance] & BIT(channel);
}
static inline
struct mbox_chan *sti_mbox_to_channel(struct mbox_controller *mbox,
unsigned int instance,
unsigned int channel)
{
struct sti_channel *chan_info;
int i;
for (i = 0; i < mbox->num_chans; i++) {
chan_info = mbox->chans[i].con_priv;
if (chan_info &&
chan_info->instance == instance &&
chan_info->channel == channel)
return &mbox->chans[i];
}
dev_err(mbox->dev,
"Channel not registered: instance: %d channel: %d\n",
instance, channel);
return NULL;
}
static void sti_mbox_enable_channel(struct mbox_chan *chan)
{
struct sti_channel *chan_info = chan->con_priv;
struct sti_mbox_device *mdev = chan_info->mdev;
unsigned int instance = chan_info->instance;
unsigned int channel = chan_info->channel;
unsigned long flags;
void __iomem *base = MBOX_BASE(mdev, instance);
spin_lock_irqsave(&mdev->lock, flags);
mdev->enabled[instance] |= BIT(channel);
writel_relaxed(BIT(channel), base + STI_ENA_SET_OFFSET);
spin_unlock_irqrestore(&mdev->lock, flags);
}
static void sti_mbox_disable_channel(struct mbox_chan *chan)
{
struct sti_channel *chan_info = chan->con_priv;
struct sti_mbox_device *mdev = chan_info->mdev;
unsigned int instance = chan_info->instance;
unsigned int channel = chan_info->channel;
unsigned long flags;
void __iomem *base = MBOX_BASE(mdev, instance);
Annotation
- Immediate include surface: `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/mailbox_controller.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct sti_mbox_device`, `struct sti_mbox_pdata`, `struct sti_channel`, `function sti_mbox_channel_is_enabled`, `function sti_mbox_enable_channel`, `function sti_mbox_disable_channel`, `function sti_mbox_clear_irq`, `function sti_mbox_thread_handler`, `function sti_mbox_irq_handler`, `function sti_mbox_tx_is_ready`.
- 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.