drivers/mmc/core/sd_uhs2.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/sd_uhs2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/sd_uhs2.c- Extension
.c- Size
- 35297 bytes
- Lines
- 1305
- 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.
- 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/err.hlinux/pm_runtime.hlinux/mmc/host.hlinux/mmc/card.hlinux/mmc/mmc.hlinux/mmc/sd.hlinux/mmc/sd_uhs2.hcard.hcore.hbus.hsd.hsd_ops.hmmc_ops.h
Detected Declarations
struct sd_uhs2_wait_active_state_datafunction sd_uhs2_power_upfunction sd_uhs2_power_offfunction sd_uhs2_phy_initfunction sd_uhs2_cmd_assemblefunction sd_uhs2_dev_initfunction sd_uhs2_enumfunction sd_uhs2_config_readfunction sd_uhs2_config_writefunction sd_uhs2_go_dormantfunction sd_uhs2_wait_active_state_cbfunction sd_uhs2_go_dormant_statefunction sd_uhs2_init_cardfunction sd_uhs2_legacy_initfunction sd_uhs2_reinitfunction sd_uhs2_removefunction sd_uhs2_alivefunction sd_uhs2_detectfunction _sd_uhs2_suspendfunction sd_uhs2_suspendfunction _mmc_sd_uhs2_resumefunction sd_uhs2_resumefunction sd_uhs2_runtime_suspendfunction sd_uhs2_runtime_resumefunction sd_uhs2_hw_resetfunction sd_uhs2_attachfunction mmc_attach_sd_uhs2function mmc_uhs2_prepare_cmd
Annotated Snippet
struct sd_uhs2_wait_active_state_data {
struct mmc_host *host;
struct mmc_command *cmd;
};
static int sd_uhs2_power_up(struct mmc_host *host)
{
if (host->ios.power_mode == MMC_POWER_ON)
return 0;
host->ios.vdd = fls(host->ocr_avail) - 1;
host->ios.clock = host->f_init;
host->ios.timing = MMC_TIMING_UHS2_SPEED_A;
host->ios.power_mode = MMC_POWER_ON;
return host->ops->uhs2_control(host, UHS2_SET_IOS);
}
static int sd_uhs2_power_off(struct mmc_host *host)
{
int err;
if (host->ios.power_mode == MMC_POWER_OFF)
return 0;
host->ios.vdd = 0;
host->ios.clock = 0;
host->ios.power_mode = MMC_POWER_OFF;
host->uhs2_sd_tran = false;
err = host->ops->uhs2_control(host, UHS2_SET_IOS);
if (err)
return err;
/* For consistency, let's restore the initial timing. */
host->ios.timing = MMC_TIMING_LEGACY;
return 0;
}
/*
* Run the phy initialization sequence, which mainly relies on the UHS-II host
* to check that we reach the expected electrical state, between the host and
* the card.
*/
static int sd_uhs2_phy_init(struct mmc_host *host)
{
int err;
err = host->ops->uhs2_control(host, UHS2_PHY_INIT);
if (err) {
pr_debug("%s: failed to initial phy for UHS-II!\n",
mmc_hostname(host));
}
return err;
}
/*
* sd_uhs2_cmd_assemble() - build up UHS-II command packet which is embedded in
* mmc_command structure
* @cmd: MMC command to executed
* @uhs2_cmd: UHS2 command corresponded to MMC command
* @header: Header field of UHS-II command cxpacket
* @arg: Argument field of UHS-II command packet
* @payload: Payload field of UHS-II command packet
* @plen: Payload length
* @resp: Response buffer is allocated by caller and it is used to keep
* the response of CM-TRAN command. For SD-TRAN command, uhs2_resp
* should be null and SD-TRAN command response should be stored in
* resp of mmc_command.
* @resp_len: Response buffer length
*
* The uhs2_command structure contains message packets which are transmited/
* received on UHS-II bus. This function fills in the contents of uhs2_command
* structure and embededs UHS2 command into mmc_command structure, which is used
* in legacy SD operation functions.
*
*/
static void sd_uhs2_cmd_assemble(struct mmc_command *cmd,
struct uhs2_command *uhs2_cmd,
u8 plen, u8 resp_len)
{
uhs2_cmd->payload_len = plen * sizeof(u32);
uhs2_cmd->packet_len = uhs2_cmd->payload_len + 4;
cmd->uhs2_cmd = uhs2_cmd;
cmd->uhs2_cmd->uhs2_resp_len = resp_len;
}
/*
Annotation
- Immediate include surface: `linux/err.h`, `linux/pm_runtime.h`, `linux/mmc/host.h`, `linux/mmc/card.h`, `linux/mmc/mmc.h`, `linux/mmc/sd.h`, `linux/mmc/sd_uhs2.h`, `card.h`.
- Detected declarations: `struct sd_uhs2_wait_active_state_data`, `function sd_uhs2_power_up`, `function sd_uhs2_power_off`, `function sd_uhs2_phy_init`, `function sd_uhs2_cmd_assemble`, `function sd_uhs2_dev_init`, `function sd_uhs2_enum`, `function sd_uhs2_config_read`, `function sd_uhs2_config_write`, `function sd_uhs2_go_dormant`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: source implementation candidate.
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.