drivers/mmc/host/tmio_mmc_core.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/tmio_mmc_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/tmio_mmc_core.c- Extension
.c- Size
- 34455 bytes
- Lines
- 1338
- Domain
- Driver Families
- Bucket
- drivers/mmc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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/delay.hlinux/device.hlinux/dma-mapping.hlinux/highmem.hlinux/interrupt.hlinux/io.hlinux/irq.hlinux/mmc/card.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/slot-gpio.hlinux/module.hlinux/of.hlinux/pagemap.hlinux/platform_data/tmio.hlinux/platform_device.hlinux/pm_qos.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/mmc/sdio.hlinux/scatterlist.hlinux/sizes.hlinux/spinlock.hlinux/workqueue.htmio_mmc.h
Detected Declarations
function Copyrightfunction tmio_mmc_end_dmafunction tmio_mmc_enable_dmafunction tmio_mmc_request_dmafunction tmio_mmc_release_dmafunction tmio_mmc_abort_dmafunction tmio_mmc_dataend_dmafunction tmio_mmc_enable_mmc_irqsfunction tmio_mmc_disable_mmc_irqsfunction tmio_mmc_ack_mmc_irqsfunction tmio_mmc_init_sgfunction tmio_mmc_next_sgfunction tmio_mmc_enable_sdio_irqfunction tmio_mmc_set_bus_widthfunction tmio_mmc_resetfunction tmio_mmc_reset_workfunction cancel_delayed_workfunction tmio_mmc_start_commandfunction tmio_mmc_transfer_datafunction returnsfunction tmio_mmc_check_bounce_bufferfunction tmio_mmc_do_data_irqfunction tmio_mmc_data_irqfunction tmio_mmc_cmd_irqfunction __tmio_mmc_card_detect_irqfunction __tmio_mmc_sdcard_irqfunction __tmio_mmc_sdio_irqfunction tmio_mmc_irqfunction tmio_mmc_start_datafunction tmio_process_mrqfunction tmio_mmc_requestfunction tmio_mmc_finish_requestfunction tmio_mmc_done_workfunction tmio_mmc_power_onfunction tmio_mmc_power_offfunction tmio_mmc_get_timeout_cyclesfunction tmio_mmc_max_busy_timeoutfunction speedfunction tmio_mmc_get_rofunction tmio_mmc_get_cdfunction tmio_multi_io_quirkfunction tmio_mmc_init_ocrfunction tmio_mmc_of_parsefunction tmio_mmc_host_probefunction tmio_mmc_host_removefunction tmio_mmc_clk_enablefunction tmio_mmc_clk_disablefunction tmio_mmc_host_runtime_suspend
Annotated Snippet
msecs_to_jiffies(CMDREQ_TIMEOUT))) {
spin_unlock_irqrestore(&host->lock, flags);
return;
}
dev_warn(&host->pdev->dev,
"timeout waiting for hardware interrupt (CMD%u)\n",
mrq->cmd->opcode);
if (host->data)
host->data->error = -ETIMEDOUT;
else if (host->cmd)
host->cmd->error = -ETIMEDOUT;
else
mrq->cmd->error = -ETIMEDOUT;
/* No new calls yet, but disallow concurrent tmio_mmc_done_work() */
host->mrq = ERR_PTR(-EBUSY);
host->cmd = NULL;
host->data = NULL;
spin_unlock_irqrestore(&host->lock, flags);
tmio_mmc_reset(host, true);
/* Ready for new calls */
host->mrq = NULL;
mmc_request_done(host->mmc, mrq);
}
/* These are the bitmasks the tmio chip requires to implement the MMC response
* types. Note that R1 and R6 are the same in this scheme. */
#define APP_CMD 0x0040
#define RESP_NONE 0x0300
#define RESP_R1 0x0400
#define RESP_R1B 0x0500
#define RESP_R2 0x0600
#define RESP_R3 0x0700
#define DATA_PRESENT 0x0800
#define TRANSFER_READ 0x1000
#define TRANSFER_MULTI 0x2000
#define SECURITY_CMD 0x4000
#define NO_CMD12_ISSUE 0x4000 /* TMIO_MMC_HAVE_CMD12_CTRL */
static int tmio_mmc_start_command(struct tmio_mmc_host *host,
struct mmc_command *cmd)
{
struct mmc_data *data = host->data;
int c = cmd->opcode;
switch (mmc_resp_type(cmd)) {
case MMC_RSP_NONE: c |= RESP_NONE; break;
case MMC_RSP_R1:
c |= RESP_R1; break;
case MMC_RSP_R1B: c |= RESP_R1B; break;
case MMC_RSP_R2: c |= RESP_R2; break;
case MMC_RSP_R3: c |= RESP_R3; break;
default:
pr_debug("Unknown response type %d\n", mmc_resp_type(cmd));
return -EINVAL;
}
host->cmd = cmd;
/* FIXME - this seems to be ok commented out but the spec suggest this bit
* should be set when issuing app commands.
* if(cmd->flags & MMC_FLAG_ACMD)
* c |= APP_CMD;
*/
if (data) {
c |= DATA_PRESENT;
if (data->blocks > 1) {
sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, TMIO_STOP_SEC);
c |= TRANSFER_MULTI;
/*
* Disable auto CMD12 at IO_RW_EXTENDED and
* SET_BLOCK_COUNT when doing multiple block transfer
*/
if ((host->pdata->flags & TMIO_MMC_HAVE_CMD12_CTRL) &&
(cmd->opcode == SD_IO_RW_EXTENDED || host->mrq->sbc))
c |= NO_CMD12_ISSUE;
}
if (data->flags & MMC_DATA_READ)
c |= TRANSFER_READ;
}
tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_CMD);
/* Fire off the command */
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/highmem.h`, `linux/interrupt.h`, `linux/io.h`, `linux/irq.h`, `linux/mmc/card.h`.
- Detected declarations: `function Copyright`, `function tmio_mmc_end_dma`, `function tmio_mmc_enable_dma`, `function tmio_mmc_request_dma`, `function tmio_mmc_release_dma`, `function tmio_mmc_abort_dma`, `function tmio_mmc_dataend_dma`, `function tmio_mmc_enable_mmc_irqs`, `function tmio_mmc_disable_mmc_irqs`, `function tmio_mmc_ack_mmc_irqs`.
- Atlas domain: Driver Families / drivers/mmc.
- 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.