drivers/mmc/host/mxs-mmc.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/mxs-mmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/mxs-mmc.c- Extension
.c- Size
- 18095 bytes
- Lines
- 721
- 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/kernel.hlinux/init.hlinux/ioport.hlinux/of.hlinux/platform_device.hlinux/delay.hlinux/interrupt.hlinux/dma-mapping.hlinux/dmaengine.hlinux/dma/mxs-dma.hlinux/highmem.hlinux/clk.hlinux/err.hlinux/completion.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sdio.hlinux/mmc/slot-gpio.hlinux/regulator/consumer.hlinux/module.hlinux/stmp_device.hlinux/spi/mxs-spi.h
Detected Declarations
struct mxs_mmc_hostfunction mxs_mmc_get_cdfunction mxs_mmc_resetfunction mxs_mmc_request_donefunction mxs_mmc_dma_irq_callbackfunction mxs_mmc_irq_handlerfunction mxs_mmc_bcfunction mxs_mmc_acfunction mxs_ns_to_ssp_ticksfunction mxs_mmc_adtcfunction mxs_mmc_start_cmdfunction mxs_mmc_requestfunction mxs_mmc_set_iosfunction mxs_mmc_enable_sdio_irqfunction mxs_mmc_regulator_disablefunction mxs_mmc_probefunction mxs_mmc_removefunction mxs_mmc_suspendfunction mxs_mmc_resume
Annotated Snippet
struct mxs_mmc_host {
struct mxs_ssp ssp;
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mmc_command *cmd;
struct mmc_data *data;
unsigned char bus_width;
spinlock_t lock;
int sdio_irq_en;
bool broken_cd;
};
static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
struct mxs_ssp *ssp = &host->ssp;
int present, ret;
if (host->broken_cd)
return -ENOSYS;
ret = mmc_gpio_get_cd(mmc);
if (ret >= 0)
return ret;
present = mmc->caps & MMC_CAP_NEEDS_POLL ||
!(readl(ssp->base + HW_SSP_STATUS(ssp)) &
BM_SSP_STATUS_CARD_DETECT);
if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
present = !present;
return present;
}
static int mxs_mmc_reset(struct mxs_mmc_host *host)
{
struct mxs_ssp *ssp = &host->ssp;
u32 ctrl0, ctrl1;
int ret;
ret = stmp_reset_block(ssp->base);
if (ret)
return ret;
ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
BF_SSP(0x7, CTRL1_WORD_LENGTH) |
BM_SSP_CTRL1_DMA_ENABLE |
BM_SSP_CTRL1_POLARITY |
BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN |
BM_SSP_CTRL1_DATA_CRC_IRQ_EN |
BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN |
BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN |
BM_SSP_CTRL1_RESP_ERR_IRQ_EN;
writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
BF_SSP(2, TIMING_CLOCK_DIVIDE) |
BF_SSP(0, TIMING_CLOCK_RATE),
ssp->base + HW_SSP_TIMING(ssp));
if (host->sdio_irq_en) {
ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
ctrl1 |= BM_SSP_CTRL1_SDIO_IRQ_EN;
}
writel(ctrl0, ssp->base + HW_SSP_CTRL0);
writel(ctrl1, ssp->base + HW_SSP_CTRL1(ssp));
return 0;
}
static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
struct mmc_command *cmd);
static void mxs_mmc_request_done(struct mxs_mmc_host *host)
{
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
struct mmc_request *mrq = host->mrq;
struct mxs_ssp *ssp = &host->ssp;
if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
if (mmc_resp_type(cmd) & MMC_RSP_136) {
cmd->resp[3] = readl(ssp->base + HW_SSP_SDRESP0(ssp));
cmd->resp[2] = readl(ssp->base + HW_SSP_SDRESP1(ssp));
cmd->resp[1] = readl(ssp->base + HW_SSP_SDRESP2(ssp));
cmd->resp[0] = readl(ssp->base + HW_SSP_SDRESP3(ssp));
} else {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/ioport.h`, `linux/of.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct mxs_mmc_host`, `function mxs_mmc_get_cd`, `function mxs_mmc_reset`, `function mxs_mmc_request_done`, `function mxs_mmc_dma_irq_callback`, `function mxs_mmc_irq_handler`, `function mxs_mmc_bc`, `function mxs_mmc_ac`, `function mxs_ns_to_ssp_ticks`, `function mxs_mmc_adtc`.
- 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.