drivers/mmc/core/sdio.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/sdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/sdio.c- Extension
.c- Size
- 30658 bytes
- Lines
- 1337
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/pm_runtime.hlinux/sysfs.hlinux/mmc/host.hlinux/mmc/card.hlinux/mmc/mmc.hlinux/mmc/sdio.hlinux/mmc/sdio_func.hlinux/mmc/sdio_ids.hcore.hcard.hhost.hbus.hquirks.hsd.hsdio_bus.hmmc_ops.hsd_ops.hsdio_ops.hsdio_cis.h
Detected Declarations
function sdio_read_fbrfunction sdio_init_funcfunction sdio_read_cccrfunction sdio_enable_widefunction sdio_disable_cdfunction sdio_disable_widefunction sdio_disable_4bit_busfunction sdio_enable_4bit_busfunction mmc_sdio_switch_hsfunction sdio_enable_hsfunction mmc_sdio_get_max_clockfunction host_drive_to_sdio_drivefunction sdio_select_driver_typefunction sdio_set_bus_speed_modefunction mmc_sdio_init_uhs_cardfunction mmc_sdio_pre_initfunction mmc_sdio_init_cardfunction mmc_sdio_reinit_cardfunction mmc_sdio_removefunction mmc_sdio_alivefunction mmc_sdio_detectfunction mmc_sdio_pre_suspendfunction mmc_sdio_suspendfunction mmc_sdio_resumefunction mmc_sdio_runtime_suspendfunction mmc_sdio_runtime_resumefunction mmc_sdio_hw_resetfunction mmc_sdio_sw_resetfunction mmc_attach_sdiofunction voltage
Annotated Snippet
if (cccr_vsn >= SDIO_CCCR_REV_3_00 && uhs) {
card->scr.sda_spec3 = 1;
ret = mmc_io_rw_direct(card, 0, 0,
SDIO_CCCR_UHS, 0, &data);
if (ret)
goto out;
if (mmc_host_can_uhs(card->host)) {
if (data & SDIO_UHS_DDR50)
card->sw_caps.sd3_bus_mode
|= SD_MODE_UHS_DDR50 | SD_MODE_UHS_SDR50
| SD_MODE_UHS_SDR25 | SD_MODE_UHS_SDR12;
if (data & SDIO_UHS_SDR50)
card->sw_caps.sd3_bus_mode
|= SD_MODE_UHS_SDR50 | SD_MODE_UHS_SDR25
| SD_MODE_UHS_SDR12;
if (data & SDIO_UHS_SDR104)
card->sw_caps.sd3_bus_mode
|= SD_MODE_UHS_SDR104 | SD_MODE_UHS_SDR50
| SD_MODE_UHS_SDR25 | SD_MODE_UHS_SDR12;
}
ret = mmc_io_rw_direct(card, 0, 0,
SDIO_CCCR_DRIVE_STRENGTH, 0, &data);
if (ret)
goto out;
if (data & SDIO_DRIVE_SDTA)
card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_A;
if (data & SDIO_DRIVE_SDTC)
card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_C;
if (data & SDIO_DRIVE_SDTD)
card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_D;
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTERRUPT_EXT, 0, &data);
if (ret)
goto out;
if (data & SDIO_INTERRUPT_EXT_SAI) {
data |= SDIO_INTERRUPT_EXT_EAI;
ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_INTERRUPT_EXT,
data, NULL);
if (ret)
goto out;
card->cccr.enable_async_irq = 1;
}
}
/* if no uhs mode ensure we check for high speed */
if (!card->sw_caps.sd3_bus_mode) {
if (speed & SDIO_SPEED_SHS) {
card->cccr.high_speed = 1;
card->sw_caps.hs_max_dtr = 50000000;
} else {
card->cccr.high_speed = 0;
card->sw_caps.hs_max_dtr = 25000000;
}
}
}
out:
return ret;
}
static int sdio_enable_wide(struct mmc_card *card)
{
int ret;
u8 ctrl;
if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
return 0;
if (card->cccr.low_speed && !card->cccr.wide_bus)
return 0;
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl);
if (ret)
return ret;
if ((ctrl & SDIO_BUS_WIDTH_MASK) == SDIO_BUS_WIDTH_RESERVED)
pr_warn("%s: SDIO_CCCR_IF is invalid: 0x%02x\n",
mmc_hostname(card->host), ctrl);
/* set as 4-bit bus width */
ctrl &= ~SDIO_BUS_WIDTH_MASK;
ctrl |= SDIO_BUS_WIDTH_4BIT;
Annotation
- Immediate include surface: `linux/err.h`, `linux/pm_runtime.h`, `linux/sysfs.h`, `linux/mmc/host.h`, `linux/mmc/card.h`, `linux/mmc/mmc.h`, `linux/mmc/sdio.h`, `linux/mmc/sdio_func.h`.
- Detected declarations: `function sdio_read_fbr`, `function sdio_init_func`, `function sdio_read_cccr`, `function sdio_enable_wide`, `function sdio_disable_cd`, `function sdio_disable_wide`, `function sdio_disable_4bit_bus`, `function sdio_enable_4bit_bus`, `function mmc_sdio_switch_hs`, `function sdio_enable_hs`.
- 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.
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.