drivers/mmc/host/rtsx_usb_sdmmc.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/rtsx_usb_sdmmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/rtsx_usb_sdmmc.c- Extension
.c- Size
- 38153 bytes
- Lines
- 1504
- 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.
- 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/module.hlinux/slab.hlinux/delay.hlinux/platform_device.hlinux/usb.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sd.hlinux/mmc/card.hlinux/scatterlist.hlinux/pm.hlinux/pm_runtime.hlinux/rtsx_usb.hlinux/unaligned.hlinux/leds.hlinux/workqueue.h
Detected Declarations
struct rtsx_usb_sdmmcfunction sd_clear_errorfunction sd_print_debug_regsfunction sd_read_datafunction sd_write_datafunction sd_send_cmd_get_rspfunction sd_rw_multifunction sd_enable_initial_modefunction sd_disable_initial_modefunction sd_normal_rwfunction sd_change_phasefunction get_phase_pointfunction get_phase_lenfunction sd_search_final_phasefunction sd_wait_data_idlefunction sd_tuning_rx_cmdfunction sd_tuning_phasefunction sd_tuning_rxfunction sdmmc_get_rofunction sdmmc_get_cdfunction sdmmc_requestfunction mmc_op_multifunction sd_set_bus_widthfunction sd_pull_ctl_disable_lqfp48function sd_pull_ctl_disable_qfn24function sd_pull_ctl_enable_lqfp48function sd_pull_ctl_enable_qfn24function sd_power_onfunction sd_power_offfunction sd_set_power_modefunction sd_set_timingfunction sdmmc_set_iosfunction sdmmc_switch_voltagefunction sdmmc_card_busyfunction sdmmc_execute_tuningfunction rtsx_usb_led_controlfunction rtsx_usb_update_ledfunction rtsx_usb_init_hostfunction rtsx_usb_sdmmc_drv_probefunction rtsx_usb_sdmmc_drv_removefunction rtsx_usb_sdmmc_runtime_suspendfunction rtsx_usb_sdmmc_runtime_resume
Annotated Snippet
struct rtsx_usb_sdmmc {
struct platform_device *pdev;
struct rtsx_ucr *ucr;
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mutex host_mutex;
u8 ssc_depth;
unsigned int clock;
bool vpclk;
bool double_clk;
bool host_removal;
bool card_exist;
bool initial_mode;
bool ddr_mode;
unsigned char power_mode;
u16 ocp_stat;
#ifdef RTSX_USB_USE_LEDS_CLASS
struct led_classdev led;
char led_name[32];
struct work_struct led_work;
#endif
};
static inline struct device *sdmmc_dev(struct rtsx_usb_sdmmc *host)
{
return &(host->pdev->dev);
}
static inline void sd_clear_error(struct rtsx_usb_sdmmc *host)
{
struct rtsx_ucr *ucr = host->ucr;
rtsx_usb_ep0_write_register(ucr, CARD_STOP,
SD_STOP | SD_CLR_ERR,
SD_STOP | SD_CLR_ERR);
rtsx_usb_clear_dma_err(ucr);
rtsx_usb_clear_fsm_err(ucr);
}
#ifdef DEBUG
static void sd_print_debug_regs(struct rtsx_usb_sdmmc *host)
{
struct rtsx_ucr *ucr = host->ucr;
u8 val = 0;
rtsx_usb_ep0_read_register(ucr, SD_STAT1, &val);
dev_dbg(sdmmc_dev(host), "SD_STAT1: 0x%x\n", val);
rtsx_usb_ep0_read_register(ucr, SD_STAT2, &val);
dev_dbg(sdmmc_dev(host), "SD_STAT2: 0x%x\n", val);
rtsx_usb_ep0_read_register(ucr, SD_BUS_STAT, &val);
dev_dbg(sdmmc_dev(host), "SD_BUS_STAT: 0x%x\n", val);
}
#else
#define sd_print_debug_regs(host)
#endif /* DEBUG */
static int sd_read_data(struct rtsx_usb_sdmmc *host, struct mmc_command *cmd,
u16 byte_cnt, u8 *buf, int buf_len, int timeout)
{
struct rtsx_ucr *ucr = host->ucr;
int err;
u8 trans_mode;
if (!buf)
buf_len = 0;
rtsx_usb_init_cmd(ucr);
if (cmd != NULL) {
dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD%d\n", __func__
, cmd->opcode);
if (cmd->opcode == MMC_SEND_TUNING_BLOCK)
trans_mode = SD_TM_AUTO_TUNING;
else
trans_mode = SD_TM_NORMAL_READ;
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
SD_CMD0, 0xFF, (u8)(cmd->opcode) | 0x40);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
SD_CMD1, 0xFF, (u8)(cmd->arg >> 24));
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
SD_CMD2, 0xFF, (u8)(cmd->arg >> 16));
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
SD_CMD3, 0xFF, (u8)(cmd->arg >> 8));
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
SD_CMD4, 0xFF, (u8)cmd->arg);
} else {
trans_mode = SD_TM_AUTO_READ_3;
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/delay.h`, `linux/platform_device.h`, `linux/usb.h`, `linux/mmc/host.h`, `linux/mmc/mmc.h`, `linux/mmc/sd.h`.
- Detected declarations: `struct rtsx_usb_sdmmc`, `function sd_clear_error`, `function sd_print_debug_regs`, `function sd_read_data`, `function sd_write_data`, `function sd_send_cmd_get_rsp`, `function sd_rw_multi`, `function sd_enable_initial_mode`, `function sd_disable_initial_mode`, `function sd_normal_rw`.
- 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.