drivers/mmc/host/pxamci.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/pxamci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/pxamci.c- Extension
.c- Size
- 18917 bytes
- Lines
- 794
- 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/module.hlinux/init.hlinux/ioport.hlinux/platform_device.hlinux/delay.hlinux/interrupt.hlinux/dmaengine.hlinux/dma-mapping.hlinux/clk.hlinux/err.hlinux/mmc/host.hlinux/mmc/slot-gpio.hlinux/io.hlinux/regulator/consumer.hlinux/gpio/consumer.hlinux/gfp.hlinux/of.hlinux/soc/pxa/cpu.hlinux/sizes.hlinux/platform_data/mmc-pxamci.hpxamci.h
Detected Declarations
struct pxamci_hostfunction pxamci_init_ocrfunction pxamci_set_powerfunction pxamci_stop_clockfunction pxamci_enable_irqfunction pxamci_disable_irqfunction pxamci_setup_datafunction pxamci_start_cmdfunction pxamci_finish_requestfunction pxamci_cmd_donefunction pxamci_data_donefunction pxamci_irqfunction pxamci_requestfunction pxamci_get_rofunction pxamci_set_iosfunction pxamci_enable_sdio_irqfunction pxamci_dma_irqfunction pxamci_detect_irqfunction pxamci_of_initfunction pxamci_of_initfunction pxamci_probefunction pxamci_remove
Annotated Snippet
struct pxamci_host {
struct mmc_host *mmc;
spinlock_t lock;
struct resource *res;
void __iomem *base;
struct clk *clk;
unsigned long clkrate;
unsigned int clkrt;
unsigned int cmdat;
unsigned int imask;
unsigned int power_mode;
unsigned long detect_delay_ms;
bool use_ro_gpio;
struct gpio_desc *power;
struct pxamci_platform_data *pdata;
struct mmc_request *mrq;
struct mmc_command *cmd;
struct mmc_data *data;
struct dma_chan *dma_chan_rx;
struct dma_chan *dma_chan_tx;
dma_cookie_t dma_cookie;
unsigned int dma_len;
unsigned int dma_dir;
};
static int pxamci_init_ocr(struct pxamci_host *host)
{
struct mmc_host *mmc = host->mmc;
int ret;
ret = mmc_regulator_get_supply(mmc);
if (ret < 0)
return ret;
if (IS_ERR(mmc->supply.vmmc)) {
/* fall-back to platform data */
mmc->ocr_avail = host->pdata ?
host->pdata->ocr_mask :
MMC_VDD_32_33 | MMC_VDD_33_34;
}
return 0;
}
static inline int pxamci_set_power(struct pxamci_host *host,
unsigned char power_mode,
unsigned int vdd)
{
struct mmc_host *mmc = host->mmc;
struct regulator *supply = mmc->supply.vmmc;
if (!IS_ERR(supply))
return mmc_regulator_set_ocr(mmc, supply, vdd);
if (host->power) {
bool on = !!((1 << vdd) & host->pdata->ocr_mask);
gpiod_set_value(host->power, on);
}
if (host->pdata && host->pdata->setpower)
return host->pdata->setpower(mmc_dev(host->mmc), vdd);
return 0;
}
static void pxamci_stop_clock(struct pxamci_host *host)
{
if (readl(host->base + MMC_STAT) & STAT_CLK_EN) {
unsigned long timeout = 10000;
unsigned int v;
writel(STOP_CLOCK, host->base + MMC_STRPCL);
do {
v = readl(host->base + MMC_STAT);
if (!(v & STAT_CLK_EN))
break;
udelay(1);
} while (timeout--);
if (v & STAT_CLK_EN)
dev_err(mmc_dev(host->mmc), "unable to stop clock\n");
}
}
static void pxamci_enable_irq(struct pxamci_host *host, unsigned int mask)
{
unsigned long flags;
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/ioport.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct pxamci_host`, `function pxamci_init_ocr`, `function pxamci_set_power`, `function pxamci_stop_clock`, `function pxamci_enable_irq`, `function pxamci_disable_irq`, `function pxamci_setup_data`, `function pxamci_start_cmd`, `function pxamci_finish_request`, `function pxamci_cmd_done`.
- 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.