drivers/ufs/host/ufs-mediatek.c
Source file repositories/reference/linux-study-clean/drivers/ufs/host/ufs-mediatek.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ufs/host/ufs-mediatek.c- Extension
.c- Size
- 63451 bytes
- Lines
- 2560
- Domain
- Driver Families
- Bucket
- drivers/ufs
- 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/arm-smccc.hlinux/bitfield.hlinux/clk.hlinux/delay.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_device.hlinux/of_platform.hlinux/phy/phy.hlinux/platform_device.hlinux/regulator/consumer.hlinux/reset.hufs/ufshcd.hufshcd-pltfrm.hufs/ufs_quirks.hufs/unipro.hufs-mediatek.hufs-mediatek-sip.hufs-mediatek-trace.h
Detected Declarations
struct attr_minfunction ufs_mtk_is_boost_crypt_enabledfunction ufs_mtk_is_va09_supportedfunction ufs_mtk_is_broken_vccfunction ufs_mtk_is_pmc_via_fastautofunction ufs_mtk_is_tx_skew_fixfunction ufs_mtk_is_rtff_mtcmosfunction ufs_mtk_is_allow_vccqx_lpmfunction ufs_mtk_is_clk_scale_readyfunction ufs_mtk_cfg_unipro_cgfunction ufs_mtk_crypto_enablefunction ufs_mtk_host_resetfunction ufs_mtk_init_reset_controlfunction ufs_mtk_init_resetfunction ufs_mtk_hce_enable_notifyfunction ufs_mtk_bind_mphyfunction ufs_mtk_setup_ref_clkfunction ufs_mtk_setup_ref_clk_wait_usfunction ufs_mtk_dbg_selfunction ufs_mtk_wait_idle_statefunction ufs_mtk_wait_link_statefunction ufs_mtk_mphy_power_onfunction ufs_mtk_get_host_clkfunction ufs_mtk_boost_cryptfunction ufs_mtk_init_host_clkfunction ufs_mtk_init_boost_cryptfunction ufs_mtk_init_va09_pwr_ctrlfunction ufs_mtk_init_host_capsfunction ufs_mtk_scale_perffunction ufs_mtk_pwr_ctrlfunction ufs_mtk_mcq_disable_irqfunction ufs_mtk_mcq_enable_irqfunction ufs_mtk_setup_clocksfunction ufshcd_is_auto_hibern8_enabledfunction ufs_mtk_mcq_get_irqfunction ufs_mtk_mcq_set_irq_affinityfunction ufs_mtk_is_legacy_chipsetfunction ufs_mtk_get_hw_ip_versionfunction ufs_mtk_get_controller_versionfunction ufs_mtk_get_ufs_hci_versionfunction ufs_mtk_init_clocksfunction list_for_each_entryfunction ufs_mtk_vreg_fix_vccfunction ufs_mtk_vreg_fix_vccqxfunction ufs_mtk_setup_clk_gatingfunction ufs_mtk_fix_ahitfunction ufs_mtk_fix_clock_scalingfunction ufs_mtk_init_mcq_irq
Annotated Snippet
struct attr_min {
u32 attr;
u32 min_value;
} pa_min_sync_length[] = {
{PA_TXHSG1SYNCLENGTH, 0x48},
{PA_TXHSG2SYNCLENGTH, 0x48},
{PA_TXHSG3SYNCLENGTH, 0x48},
{PA_TXHSG4SYNCLENGTH, 0x48},
{PA_TXHSG5SYNCLENGTH, 0x48}
};
cnt = sizeof(pa_min_sync_length) / sizeof(struct attr_min);
for (i = 0; i < cnt; i++) {
att = pa_min_sync_length[i].attr;
min = pa_min_sync_length[i].min_value;
ufshcd_dme_get(hba, UIC_ARG_MIB(att), &value);
if (value < min)
ufshcd_dme_set(hba, UIC_ARG_MIB(att), min);
ufshcd_dme_peer_get(hba, UIC_ARG_MIB(att), &value);
if (value < min)
ufshcd_dme_peer_set(hba, UIC_ARG_MIB(att), min);
}
}
static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
struct ufs_pa_layer_attr *dev_req_params)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
int ret = 0;
if (ufs_mtk_pmc_via_fastauto(hba, dev_req_params)) {
ufs_mtk_adjust_sync_length(hba);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), true);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), UFS_HS_G1);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), true);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXGEAR), UFS_HS_G1);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES),
dev_req_params->lane_tx);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVERXDATALANES),
dev_req_params->lane_rx);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HSSERIES),
dev_req_params->hs_rate);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXHSADAPTTYPE),
PA_NO_ADAPT);
if (!(hba->quirks & UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING)) {
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0),
DL_FC0ProtectionTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1),
DL_TC0ReplayTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA2),
DL_AFC0ReqTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA3),
DL_FC1ProtectionTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA4),
DL_TC1ReplayTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA5),
DL_AFC1ReqTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalFC0ProtectionTimeOutVal),
DL_FC0ProtectionTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalTC0ReplayTimeOutVal),
DL_TC0ReplayTimeOutVal_Default);
ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalAFC0ReqTimeOutVal),
DL_AFC0ReqTimeOutVal_Default);
}
ret = ufshcd_uic_change_pwr_mode(hba,
FASTAUTO_MODE << 4 | FASTAUTO_MODE);
if (ret) {
dev_err(hba->dev, "%s: HSG1B FASTAUTO failed ret=%d\n",
__func__, ret);
}
}
/* if already configured to the requested pwr_mode, skip adapt */
if (dev_req_params->gear_rx == hba->pwr_info.gear_rx &&
dev_req_params->gear_tx == hba->pwr_info.gear_tx &&
dev_req_params->lane_rx == hba->pwr_info.lane_rx &&
dev_req_params->lane_tx == hba->pwr_info.lane_tx &&
dev_req_params->pwr_rx == hba->pwr_info.pwr_rx &&
dev_req_params->pwr_tx == hba->pwr_info.pwr_tx &&
dev_req_params->hs_rate == hba->pwr_info.hs_rate) {
return ret;
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_device.h`.
- Detected declarations: `struct attr_min`, `function ufs_mtk_is_boost_crypt_enabled`, `function ufs_mtk_is_va09_supported`, `function ufs_mtk_is_broken_vcc`, `function ufs_mtk_is_pmc_via_fastauto`, `function ufs_mtk_is_tx_skew_fix`, `function ufs_mtk_is_rtff_mtcmos`, `function ufs_mtk_is_allow_vccqx_lpm`, `function ufs_mtk_is_clk_scale_ready`, `function ufs_mtk_cfg_unipro_cg`.
- Atlas domain: Driver Families / drivers/ufs.
- 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.