drivers/mmc/host/dw_mmc-k3.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/dw_mmc-k3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/dw_mmc-k3.c- Extension
.c- Size
- 11131 bytes
- Lines
- 467
- 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/bitops.hlinux/bitfield.hlinux/clk.hlinux/mfd/syscon.hlinux/mmc/host.hlinux/module.hlinux/of_address.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/regulator/consumer.hdw_mmc.hdw_mmc-pltfm.h
Detected Declarations
struct k3_privstruct hs_timingfunction dw_mci_k3_set_iosfunction dw_mci_hi6220_parse_dtfunction dw_mci_hi6220_switch_voltagefunction dw_mci_hi6220_set_iosfunction dw_mci_hi6220_execute_tuningfunction dw_mci_hs_set_timingfunction dw_mci_hi3660_initfunction dw_mci_set_sel18function dw_mci_hi3660_set_iosfunction dw_mci_get_best_clksmplfunction dw_mci_hi3660_execute_tuningfunction dw_mci_hi3660_switch_voltagefunction dw_mci_k3_probe
Annotated Snippet
struct k3_priv {
u32 cur_speed;
struct regmap *reg;
};
static unsigned long dw_mci_hi6220_caps[] = {
MMC_CAP_CMD23,
MMC_CAP_CMD23,
0
};
struct hs_timing {
u32 drv_phase;
u32 smpl_dly;
u32 smpl_phase_max;
u32 smpl_phase_min;
};
static struct hs_timing hs_timing_cfg[TIMING_MODE][TIMING_CFG_NUM] = {
{ /* reserved */ },
{ /* SD */
{7, 0, 15, 15,}, /* 0: LEGACY 400k */
{6, 0, 4, 4,}, /* 1: MMC_HS */
{6, 0, 3, 3,}, /* 2: SD_HS */
{6, 0, 15, 15,}, /* 3: SDR12 */
{6, 0, 2, 2,}, /* 4: SDR25 */
{4, 0, 11, 0,}, /* 5: SDR50 */
{6, 4, 15, 0,}, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
},
{ /* SDIO */
{7, 0, 15, 15,}, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{6, 0, 15, 15,}, /* 2: SD_HS */
{6, 0, 15, 15,}, /* 3: SDR12 */
{6, 0, 0, 0,}, /* 4: SDR25 */
{4, 0, 12, 0,}, /* 5: SDR50 */
{5, 4, 15, 0,}, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static void dw_mci_k3_set_ios(struct dw_mci *host, struct mmc_ios *ios)
{
int ret;
ret = clk_set_rate(host->ciu_clk, ios->clock);
if (ret)
dev_warn(host->dev, "failed to set rate %uHz\n", ios->clock);
host->bus_hz = clk_get_rate(host->ciu_clk);
}
static const struct dw_mci_drv_data k3_drv_data = {
.set_ios = dw_mci_k3_set_ios,
};
static int dw_mci_hi6220_parse_dt(struct dw_mci *host)
{
struct k3_priv *priv;
priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->reg = syscon_regmap_lookup_by_phandle(host->dev->of_node,
"hisilicon,peripheral-syscon");
if (IS_ERR(priv->reg))
priv->reg = NULL;
host->priv = priv;
return 0;
}
static int dw_mci_hi6220_switch_voltage(struct dw_mci *host, struct mmc_ios *ios)
{
struct k3_priv *priv;
struct mmc_host *mmc = host->mmc;
int min_uv, max_uv;
int ret;
priv = host->priv;
if (!priv || !priv->reg)
return 0;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/mfd/syscon.h`, `linux/mmc/host.h`, `linux/module.h`, `linux/of_address.h`, `linux/platform_device.h`.
- Detected declarations: `struct k3_priv`, `struct hs_timing`, `function dw_mci_k3_set_ios`, `function dw_mci_hi6220_parse_dt`, `function dw_mci_hi6220_switch_voltage`, `function dw_mci_hi6220_set_ios`, `function dw_mci_hi6220_execute_tuning`, `function dw_mci_hs_set_timing`, `function dw_mci_hi3660_init`, `function dw_mci_set_sel18`.
- 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.