drivers/mmc/host/rtsx_pci_sdmmc.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/rtsx_pci_sdmmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/rtsx_pci_sdmmc.c- Extension
.c- Size
- 39479 bytes
- Lines
- 1566
- 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.
- 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/pci.hlinux/module.hlinux/slab.hlinux/highmem.hlinux/delay.hlinux/platform_device.hlinux/workqueue.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sd.hlinux/mmc/sdio.hlinux/mmc/card.hlinux/rtsx_pci.hlinux/unaligned.hlinux/pm_runtime.h
Detected Declarations
struct realtek_pci_sdmmcfunction sd_clear_errorfunction dump_reg_rangefunction sd_print_debug_regsfunction sd_get_cd_intfunction sd_cmd_set_sd_cmdfunction sd_cmd_set_data_lenfunction sd_response_typefunction sd_status_indexfunction sd_pre_dma_transferfunction sdmmc_pre_reqfunction sdmmc_post_reqfunction sd_send_cmd_get_rspfunction sd_read_datafunction sd_write_datafunction sd_read_long_datafunction sd_write_long_datafunction sd_enable_initial_modefunction sd_disable_initial_modefunction sd_rw_multifunction sd_normal_rwfunction sd_change_phasefunction test_phase_bitfunction sd_get_phase_lenfunction sd_search_final_phasefunction sd_wait_data_idlefunction sd_tuning_rx_cmdfunction sd_tuning_phasefunction sd_tuning_rxfunction sdio_extblock_cmdfunction sd_rw_cmdfunction sd_requestfunction sdmmc_requestfunction sd_set_bus_widthfunction sd_power_onfunction sd_power_offfunction sd_set_power_modefunction sd_set_timingfunction sdmmc_set_iosfunction sdmmc_get_rofunction sdmmc_get_cdfunction sdmmc_switch_voltagefunction sdmmc_card_busyfunction sdmmc_execute_tuningfunction sdmmc_init_sd_expressfunction init_extra_capsfunction realtek_init_hostfunction rtsx_pci_sdmmc_card_event
Annotated Snippet
struct realtek_pci_sdmmc {
struct platform_device *pdev;
struct rtsx_pcr *pcr;
struct mmc_host *mmc;
struct mmc_request *mrq;
#define SDMMC_WORKQ_NAME "rtsx_pci_sdmmc_workq"
struct work_struct work;
struct mutex host_mutex;
u8 ssc_depth;
unsigned int clock;
bool vpclk;
bool double_clk;
bool eject;
bool initial_mode;
int prev_power_state;
int sg_count;
s32 cookie;
int cookie_sg_count;
bool using_cookie;
};
static int sdmmc_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios);
static inline struct device *sdmmc_dev(struct realtek_pci_sdmmc *host)
{
return &(host->pdev->dev);
}
static inline void sd_clear_error(struct realtek_pci_sdmmc *host)
{
rtsx_pci_write_register(host->pcr, CARD_STOP,
SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR);
}
#ifdef DEBUG
static void dump_reg_range(struct realtek_pci_sdmmc *host, u16 start, u16 end)
{
u16 len = end - start + 1;
int i;
u8 data[8];
for (i = 0; i < len; i += 8) {
int j;
int n = min(8, len - i);
memset(&data, 0, sizeof(data));
for (j = 0; j < n; j++)
rtsx_pci_read_register(host->pcr, start + i + j,
data + j);
dev_dbg(sdmmc_dev(host), "0x%04X(%d): %8ph\n",
start + i, n, data);
}
}
static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
{
dump_reg_range(host, 0xFDA0, 0xFDB3);
dump_reg_range(host, 0xFD52, 0xFD69);
}
#else
#define sd_print_debug_regs(host)
#endif /* DEBUG */
static inline int sd_get_cd_int(struct realtek_pci_sdmmc *host)
{
return rtsx_pci_readl(host->pcr, RTSX_BIPR) & SD_EXIST;
}
static void sd_cmd_set_sd_cmd(struct rtsx_pcr *pcr, struct mmc_command *cmd)
{
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD0, 0xFF,
SD_CMD_START | cmd->opcode);
rtsx_pci_write_be32(pcr, SD_CMD1, cmd->arg);
}
static void sd_cmd_set_data_len(struct rtsx_pcr *pcr, u16 blocks, u16 blksz)
{
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, blocks);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, blocks >> 8);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, blksz);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, blksz >> 8);
}
static int sd_response_type(struct mmc_command *cmd)
{
switch (mmc_resp_type(cmd)) {
case MMC_RSP_NONE:
return SD_RSP_TYPE_R0;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/module.h`, `linux/slab.h`, `linux/highmem.h`, `linux/delay.h`, `linux/platform_device.h`, `linux/workqueue.h`, `linux/mmc/host.h`.
- Detected declarations: `struct realtek_pci_sdmmc`, `function sd_clear_error`, `function dump_reg_range`, `function sd_print_debug_regs`, `function sd_get_cd_int`, `function sd_cmd_set_sd_cmd`, `function sd_cmd_set_data_len`, `function sd_response_type`, `function sd_status_index`, `function sd_pre_dma_transfer`.
- 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.