drivers/mmc/host/bcm2835.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/bcm2835.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/bcm2835.c- Extension
.c- Size
- 37943 bytes
- Lines
- 1500
- Domain
- Driver Families
- Bucket
- drivers/mmc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/delay.hlinux/device.hlinux/dmaengine.hlinux/dma-mapping.hlinux/err.hlinux/highmem.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/scatterlist.hlinux/time.hlinux/workqueue.hlinux/string_choices.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sd.h
Detected Declarations
struct bcm2835_hostfunction bcm2835_dumpcmdfunction bcm2835_dumpregsfunction bcm2835_reset_internalfunction bcm2835_resetfunction bcm2835_wait_transfer_completefunction bcm2835_dma_completefunction bcm2835_transfer_block_piofunction bcm2835_transfer_piofunction bcm2835_prepare_dmafunction for_each_sgfunction bcm2835_start_dmafunction bcm2835_set_transfer_irqsfunction bcm2835_prepare_datafunction bcm2835_read_wait_sdcmdfunction bcm2835_finish_requestfunction bcm2835_send_commandfunction bcm2835_transfer_completefunction bcm2835_finish_datafunction bcm2835_finish_commandfunction bcm2835_timeoutfunction bcm2835_check_cmd_errorfunction bcm2835_check_data_errorfunction bcm2835_busy_irqfunction bcm2835_data_irqfunction bcm2835_data_threaded_irqfunction bcm2835_block_irqfunction bcm2835_irqfunction bcm2835_threaded_irqfunction bcm2835_dma_complete_workfunction bcm2835_set_clockfunction automaticfunction bcm2835_requestfunction bcm2835_set_iosfunction bcm2835_add_hostfunction bcm2835_suspendfunction bcm2835_resumefunction bcm2835_probefunction bcm2835_remove
Annotated Snippet
struct bcm2835_host {
spinlock_t lock;
struct mutex mutex;
void __iomem *ioaddr;
u32 phys_addr;
struct clk *clk;
struct platform_device *pdev;
unsigned int clock; /* Current clock speed */
unsigned int max_clk; /* Max possible freq */
struct work_struct dma_work;
struct delayed_work timeout_work; /* Timer for timeouts */
struct sg_mapping_iter sg_miter; /* SG state for PIO */
unsigned int blocks; /* remaining PIO blocks */
int irq; /* Device IRQ */
u32 ns_per_fifo_word;
/* cached registers */
u32 hcfg;
u32 cdiv;
struct mmc_request *mrq; /* Current request */
struct mmc_command *cmd; /* Current command */
struct mmc_data *data; /* Current data request */
bool data_complete:1;/* Data finished before cmd */
bool use_busy:1; /* Wait for busy interrupt */
bool use_sbc:1; /* Send CMD23 */
/* for threaded irq handler */
bool irq_block;
bool irq_busy;
bool irq_data;
/* DMA part */
struct dma_chan *dma_chan_rxtx;
struct dma_chan *dma_chan;
struct dma_slave_config dma_cfg_rx;
struct dma_slave_config dma_cfg_tx;
struct dma_async_tx_descriptor *dma_desc;
u32 dma_dir;
u32 drain_words;
struct page *drain_page;
u32 drain_offset;
bool use_dma;
};
static void bcm2835_dumpcmd(struct bcm2835_host *host, struct mmc_command *cmd,
const char *label)
{
struct device *dev = &host->pdev->dev;
if (!cmd)
return;
dev_dbg(dev, "%c%s op %d arg 0x%x flags 0x%x - resp %08x %08x %08x %08x, err %d\n",
(cmd == host->cmd) ? '>' : ' ',
label, cmd->opcode, cmd->arg, cmd->flags,
cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3],
cmd->error);
}
static void bcm2835_dumpregs(struct bcm2835_host *host)
{
struct mmc_request *mrq = host->mrq;
struct device *dev = &host->pdev->dev;
if (mrq) {
bcm2835_dumpcmd(host, mrq->sbc, "sbc");
bcm2835_dumpcmd(host, mrq->cmd, "cmd");
if (mrq->data) {
dev_dbg(dev, "data blocks %x blksz %x - err %d\n",
mrq->data->blocks,
mrq->data->blksz,
mrq->data->error);
}
bcm2835_dumpcmd(host, mrq->stop, "stop");
}
dev_dbg(dev, "=========== REGISTER DUMP ===========\n");
dev_dbg(dev, "SDCMD 0x%08x\n", readl(host->ioaddr + SDCMD));
dev_dbg(dev, "SDARG 0x%08x\n", readl(host->ioaddr + SDARG));
dev_dbg(dev, "SDTOUT 0x%08x\n", readl(host->ioaddr + SDTOUT));
dev_dbg(dev, "SDCDIV 0x%08x\n", readl(host->ioaddr + SDCDIV));
dev_dbg(dev, "SDRSP0 0x%08x\n", readl(host->ioaddr + SDRSP0));
dev_dbg(dev, "SDRSP1 0x%08x\n", readl(host->ioaddr + SDRSP1));
dev_dbg(dev, "SDRSP2 0x%08x\n", readl(host->ioaddr + SDRSP2));
dev_dbg(dev, "SDRSP3 0x%08x\n", readl(host->ioaddr + SDRSP3));
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/highmem.h`, `linux/interrupt.h`.
- Detected declarations: `struct bcm2835_host`, `function bcm2835_dumpcmd`, `function bcm2835_dumpregs`, `function bcm2835_reset_internal`, `function bcm2835_reset`, `function bcm2835_wait_transfer_complete`, `function bcm2835_dma_complete`, `function bcm2835_transfer_block_pio`, `function bcm2835_transfer_pio`, `function bcm2835_prepare_dma`.
- Atlas domain: Driver Families / drivers/mmc.
- 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.