drivers/soc/renesas/rcar-mfis.c
Source file repositories/reference/linux-study-clean/drivers/soc/renesas/rcar-mfis.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/renesas/rcar-mfis.c- Extension
.c- Size
- 9910 bytes
- Lines
- 385
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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
dt-bindings/soc/renesas,r8a78000-mfis.hlinux/device.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/mailbox_controller.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/of_platform.hlinux/platform_device.hlinux/spinlock.h
Detected Declarations
struct mfis_privstruct mfis_regstruct mfis_infostruct mfis_chan_privstruct mfis_privfunction mfis_readfunction mfis_writefunction mfis_mb_iicr_interruptfunction mfis_mb_startupfunction mfis_mb_shutdownfunction mfis_mb_iicr_send_datafunction mfis_mb_iicr_last_tx_donefunction mfis_mb_r8a779g0_calc_regfunction mfis_mb_r8a78000_calc_regfunction mfis_mb_probefunction mfis_reg_probefunction mfis_probe
Annotated Snippet
struct mfis_reg {
void __iomem *base;
resource_size_t start;
struct mfis_priv *priv;
};
struct mfis_info {
u32 unprotect_mask;
unsigned int mb_num_channels;
unsigned int mb_reg_comes_from_dt:1;
unsigned int mb_tx_uses_eicr:1;
unsigned int mb_channels_are_unidir:1;
u32 (*mb_calc_reg)(u32 chan_num, bool tx_uses_eicr, bool is_only_rx);
};
struct mfis_chan_priv {
u32 reg;
int irq;
};
struct mfis_priv {
spinlock_t unprotect_lock; /* guards access to the unprotection reg */
struct device *dev;
struct mfis_reg common_reg;
struct mfis_reg mbox_reg;
const struct mfis_info *info;
/* mailbox private data */
struct mbox_controller mbox;
struct mfis_chan_priv *chan_privs;
};
static u32 mfis_read(struct mfis_reg *mreg, unsigned int reg)
{
return ioread32(mreg->base + reg);
}
static void mfis_write(struct mfis_reg *mreg, u32 reg, u32 val)
{
struct mfis_priv *priv = mreg->priv;
u32 unprotect_mask = priv->info->unprotect_mask;
unsigned long flags;
u32 unprotect_code;
/*
* [Gen4] key: 0xACCE0000, mask: 0x0000FFFF
* [Gen5] key: 0xACC00000, mask: 0x000FFFFF
*/
unprotect_code = (MFIS_UNPROTECT_KEY & ~unprotect_mask) |
((mreg->start + reg) & unprotect_mask);
spin_lock_irqsave(&priv->unprotect_lock, flags);
iowrite32(unprotect_code, priv->common_reg.base + MFISWACNTR);
iowrite32(val, mreg->base + reg);
spin_unlock_irqrestore(&priv->unprotect_lock, flags);
}
/********************************************************
* Mailbox *
********************************************************/
#define mfis_mb_mbox_to_priv(_m) container_of((_m), struct mfis_priv, mbox)
static irqreturn_t mfis_mb_iicr_interrupt(int irq, void *data)
{
struct mbox_chan *chan = data;
struct mfis_priv *priv = mfis_mb_mbox_to_priv(chan->mbox);
struct mfis_chan_priv *chan_priv = chan->con_priv;
mbox_chan_received_data(chan, NULL);
/* Stop remote(!) doorbell */
mfis_write(&priv->mbox_reg, chan_priv->reg, 0);
return IRQ_HANDLED;
}
static int mfis_mb_startup(struct mbox_chan *chan)
{
struct mfis_chan_priv *chan_priv = chan->con_priv;
if (!chan_priv->irq)
return 0;
return request_irq(chan_priv->irq, mfis_mb_iicr_interrupt, 0,
dev_name(chan->mbox->dev), chan);
}
static void mfis_mb_shutdown(struct mbox_chan *chan)
{
struct mfis_chan_priv *chan_priv = chan->con_priv;
Annotation
- Immediate include surface: `dt-bindings/soc/renesas,r8a78000-mfis.h`, `linux/device.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/mailbox_controller.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct mfis_priv`, `struct mfis_reg`, `struct mfis_info`, `struct mfis_chan_priv`, `struct mfis_priv`, `function mfis_read`, `function mfis_write`, `function mfis_mb_iicr_interrupt`, `function mfis_mb_startup`, `function mfis_mb_shutdown`.
- Atlas domain: Driver Families / drivers/soc.
- 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.