arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c- Extension
.c- Size
- 13622 bytes
- Lines
- 517
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hasm/mpc5121.hasm/io.hlinux/spinlock.hlinux/slab.hlinux/dmaengine.hlinux/dma-direction.hlinux/dma-mapping.h
Detected Declarations
struct cs_rangefunction mpc512x_lpbfifo_irqfunction mpc512x_lpbfifo_callbackfunction mpc512x_lpbfifo_kickfunction mpc512x_lpbfifo_submit_lockedfunction mpc512x_lpbfifo_submitfunction get_cs_rangesfunction for_each_of_rangefunction mpc512x_lpbfifo_probefunction mpc512x_lpbfifo_removeexport mpc512x_lpbfifo_submit
Annotated Snippet
struct cs_range {
u32 csnum;
u32 base; /* must be zero */
u32 addr;
u32 size;
};
static struct lpbfifo_data {
spinlock_t lock; /* for protecting lpbfifo_data */
phys_addr_t regs_phys;
resource_size_t regs_size;
struct mpc512x_lpbfifo __iomem *regs;
int irq;
struct cs_range *cs_ranges;
size_t cs_n;
struct dma_chan *chan;
struct mpc512x_lpbfifo_request *req;
dma_addr_t ram_bus_addr;
bool wait_lpbfifo_irq;
bool wait_lpbfifo_callback;
} lpbfifo;
/*
* A data transfer from RAM to some device on LPB is finished
* when both mpc512x_lpbfifo_irq() and mpc512x_lpbfifo_callback()
* have been called. We execute the callback registered in
* mpc512x_lpbfifo_request just after that.
* But for a data transfer from some device on LPB to RAM we don't enable
* LPBFIFO interrupt because clearing MPC512X_SCLPC_SUCCESS interrupt flag
* automatically disables LPBFIFO reading request to the DMA controller
* and the data transfer hangs. So the callback registered in
* mpc512x_lpbfifo_request is executed at the end of mpc512x_lpbfifo_callback().
*/
/*
* mpc512x_lpbfifo_irq - IRQ handler for LPB FIFO
*/
static irqreturn_t mpc512x_lpbfifo_irq(int irq, void *param)
{
struct device *dev = (struct device *)param;
struct mpc512x_lpbfifo_request *req = NULL;
unsigned long flags;
u32 status;
spin_lock_irqsave(&lpbfifo.lock, flags);
if (!lpbfifo.regs)
goto end;
req = lpbfifo.req;
if (!req || req->dir == MPC512X_LPBFIFO_REQ_DIR_READ) {
dev_err(dev, "bogus LPBFIFO IRQ\n");
goto end;
}
status = in_be32(&lpbfifo.regs->status);
if (status != MPC512X_SCLPC_SUCCESS) {
dev_err(dev, "DMA transfer from RAM to peripheral failed\n");
out_be32(&lpbfifo.regs->enable,
MPC512X_SCLPC_RESET | MPC512X_SCLPC_FIFO_RESET);
goto end;
}
/* Clear the interrupt flag */
out_be32(&lpbfifo.regs->status, MPC512X_SCLPC_SUCCESS);
lpbfifo.wait_lpbfifo_irq = false;
if (lpbfifo.wait_lpbfifo_callback)
goto end;
/* Transfer is finished, set the FIFO as idle */
lpbfifo.req = NULL;
spin_unlock_irqrestore(&lpbfifo.lock, flags);
if (req->callback)
req->callback(req);
return IRQ_HANDLED;
end:
spin_unlock_irqrestore(&lpbfifo.lock, flags);
return IRQ_HANDLED;
}
/*
* mpc512x_lpbfifo_callback is called by DMA driver when
* DMA transaction is finished.
*/
static void mpc512x_lpbfifo_callback(void *param)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/platform_device.h`, `asm/mpc5121.h`.
- Detected declarations: `struct cs_range`, `function mpc512x_lpbfifo_irq`, `function mpc512x_lpbfifo_callback`, `function mpc512x_lpbfifo_kick`, `function mpc512x_lpbfifo_submit_locked`, `function mpc512x_lpbfifo_submit`, `function get_cs_ranges`, `function for_each_of_range`, `function mpc512x_lpbfifo_probe`, `function mpc512x_lpbfifo_remove`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.