drivers/mmc/host/owl-mmc.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/owl-mmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/owl-mmc.c- Extension
.c- Size
- 17966 bytes
- Lines
- 692
- 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/dmaengine.hlinux/dma-direction.hlinux/dma-mapping.hlinux/interrupt.hlinux/mmc/host.hlinux/mmc/slot-gpio.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/reset.hlinux/spinlock.h
Detected Declarations
struct owl_mmc_hostfunction owl_mmc_update_regfunction owl_irq_handlerfunction owl_mmc_finish_requestfunction owl_mmc_send_cmdfunction owl_mmc_dma_completefunction owl_mmc_prepare_datafunction owl_mmc_requestfunction owl_mmc_set_clk_ratefunction owl_mmc_set_clkfunction owl_mmc_set_bus_widthfunction owl_mmc_ctr_resetfunction owl_mmc_power_onfunction owl_mmc_set_iosfunction owl_mmc_start_signal_voltage_switchfunction owl_mmc_probefunction owl_mmc_remove
Annotated Snippet
struct owl_mmc_host {
struct device *dev;
struct reset_control *reset;
void __iomem *base;
struct clk *clk;
struct completion sdc_complete;
spinlock_t lock;
int irq;
u32 clock;
bool ddr_50;
enum dma_data_direction dma_dir;
struct dma_chan *dma;
struct dma_async_tx_descriptor *desc;
struct dma_slave_config dma_cfg;
struct completion dma_complete;
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mmc_command *cmd;
struct mmc_data *data;
};
static void owl_mmc_update_reg(void __iomem *reg, unsigned int val, bool state)
{
unsigned int regval;
regval = readl(reg);
if (state)
regval |= val;
else
regval &= ~val;
writel(regval, reg);
}
static irqreturn_t owl_irq_handler(int irq, void *devid)
{
struct owl_mmc_host *owl_host = devid;
u32 state;
spin_lock(&owl_host->lock);
state = readl(owl_host->base + OWL_REG_SD_STATE);
if (state & OWL_SD_STATE_TEI) {
state = readl(owl_host->base + OWL_REG_SD_STATE);
state |= OWL_SD_STATE_TEI;
writel(state, owl_host->base + OWL_REG_SD_STATE);
complete(&owl_host->sdc_complete);
}
spin_unlock(&owl_host->lock);
return IRQ_HANDLED;
}
static void owl_mmc_finish_request(struct owl_mmc_host *owl_host)
{
struct mmc_request *mrq = owl_host->mrq;
struct mmc_data *data = mrq->data;
/* Should never be NULL */
WARN_ON(!mrq);
owl_host->mrq = NULL;
if (data)
dma_unmap_sg(owl_host->dma->device->dev, data->sg, data->sg_len,
owl_host->dma_dir);
/* Finally finish request */
mmc_request_done(owl_host->mmc, mrq);
}
static void owl_mmc_send_cmd(struct owl_mmc_host *owl_host,
struct mmc_command *cmd,
struct mmc_data *data)
{
unsigned long timeout;
u32 mode, state, resp[2];
u32 cmd_rsp_mask = 0;
init_completion(&owl_host->sdc_complete);
switch (mmc_resp_type(cmd)) {
case MMC_RSP_NONE:
mode = OWL_SD_CTL_TM(0);
break;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-direction.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/mmc/host.h`, `linux/mmc/slot-gpio.h`.
- Detected declarations: `struct owl_mmc_host`, `function owl_mmc_update_reg`, `function owl_irq_handler`, `function owl_mmc_finish_request`, `function owl_mmc_send_cmd`, `function owl_mmc_dma_complete`, `function owl_mmc_prepare_data`, `function owl_mmc_request`, `function owl_mmc_set_clk_rate`, `function owl_mmc_set_clk`.
- 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.