drivers/mmc/host/sdhci.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/sdhci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/sdhci.c- Extension
.c- Size
- 134153 bytes
- Lines
- 5024
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/dmaengine.hlinux/ktime.hlinux/highmem.hlinux/io.hlinux/module.hlinux/dma-mapping.hlinux/slab.hlinux/scatterlist.hlinux/sizes.hlinux/regulator/consumer.hlinux/pm_runtime.hlinux/of.hlinux/bug.hlinux/leds.hlinux/mmc/mmc.hlinux/mmc/host.hlinux/mmc/card.hlinux/mmc/sdio.hlinux/mmc/slot-gpio.hsdhci.h
Detected Declarations
enum sdhci_reset_reasonfunction sdhci_dumpregsfunction sdhci_do_enable_v4_modefunction sdhci_add_hostfunction sdhci_data_line_cmdfunction sdhci_set_card_detectionfunction sdhci_enable_card_detectionfunction sdhci_disable_card_detectionfunction sdhci_runtime_pm_bus_onfunction sdhci_runtime_pm_bus_offfunction sdhci_resetfunction sdhci_do_resetfunction sdhci_reset_for_allfunction sdhci_reset_for_reasonfunction sdhci_set_default_irqsfunction sdhci_config_dmafunction sdhci_initfunction sdhci_reinitfunction __sdhci_led_activatefunction __sdhci_led_deactivatefunction sdhci_led_controlfunction sdhci_led_registerfunction sdhci_led_unregisterfunction sdhci_led_activatefunction sdhci_led_unregisterfunction sdhci_led_deactivatefunction sdhci_mod_timerfunction sdhci_del_timerfunction sdhci_has_requestsfunction sdhci_read_block_piofunction sdhci_write_block_piofunction sdhci_transfer_piofunction sdhci_pre_dma_transferfunction sdhci_kunmap_atomicfunction sdhci_adma_write_descfunction __sdhci_adma_write_descfunction sdhci_adma_mark_endfunction sdhci_adma_table_prefunction for_each_sgfunction sdhci_adma_table_postfunction for_each_sgfunction for_each_sgfunction sdhci_set_adma_addrfunction sdhci_sdma_addressfunction sdhci_set_sdma_addrfunction sdhci_target_timeoutfunction sdhci_calc_sw_timeoutfunction sdhci_calc_timeout
Annotated Snippet
if (host->flags & SDHCI_USE_64_BIT_DMA) {
SDHCI_DUMP("ADMA Err: 0x%08x | ADMA Ptr: 0x%08x%08x\n",
sdhci_readl(host, SDHCI_ADMA_ERROR),
sdhci_readl(host, SDHCI_ADMA_ADDRESS_HI),
sdhci_readl(host, SDHCI_ADMA_ADDRESS));
} else {
SDHCI_DUMP("ADMA Err: 0x%08x | ADMA Ptr: 0x%08x\n",
sdhci_readl(host, SDHCI_ADMA_ERROR),
sdhci_readl(host, SDHCI_ADMA_ADDRESS));
}
}
if (host->ops->dump_uhs2_regs)
host->ops->dump_uhs2_regs(host);
if (host->ops->dump_vendor_regs)
host->ops->dump_vendor_regs(host);
SDHCI_DUMP("============================================\n");
}
EXPORT_SYMBOL_GPL(sdhci_dumpregs);
/*****************************************************************************\
* *
* Low level functions *
* *
\*****************************************************************************/
static void sdhci_do_enable_v4_mode(struct sdhci_host *host)
{
u16 ctrl2;
ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
if (ctrl2 & SDHCI_CTRL_V4_MODE)
return;
ctrl2 |= SDHCI_CTRL_V4_MODE;
sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2);
}
/*
* This can be called before sdhci_add_host() by Vendor's host controller
* driver to enable v4 mode if supported.
*/
void sdhci_enable_v4_mode(struct sdhci_host *host)
{
host->v4_mode = true;
sdhci_do_enable_v4_mode(host);
}
EXPORT_SYMBOL_GPL(sdhci_enable_v4_mode);
bool sdhci_data_line_cmd(struct mmc_command *cmd)
{
return cmd->data || cmd->flags & MMC_RSP_BUSY;
}
EXPORT_SYMBOL_GPL(sdhci_data_line_cmd);
static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
{
u32 present;
if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
!mmc_card_is_removable(host->mmc) || mmc_host_can_gpio_cd(host->mmc))
return;
if (enable) {
present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
SDHCI_CARD_PRESENT;
host->ier |= present ? SDHCI_INT_CARD_REMOVE :
SDHCI_INT_CARD_INSERT;
} else {
host->ier &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
}
sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
}
static void sdhci_enable_card_detection(struct sdhci_host *host)
{
sdhci_set_card_detection(host, true);
}
static void sdhci_disable_card_detection(struct sdhci_host *host)
{
sdhci_set_card_detection(host, false);
}
static void sdhci_runtime_pm_bus_on(struct sdhci_host *host)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/ktime.h`, `linux/highmem.h`, `linux/io.h`, `linux/module.h`, `linux/dma-mapping.h`.
- Detected declarations: `enum sdhci_reset_reason`, `function sdhci_dumpregs`, `function sdhci_do_enable_v4_mode`, `function sdhci_add_host`, `function sdhci_data_line_cmd`, `function sdhci_set_card_detection`, `function sdhci_enable_card_detection`, `function sdhci_disable_card_detection`, `function sdhci_runtime_pm_bus_on`, `function sdhci_runtime_pm_bus_off`.
- 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.