drivers/mmc/host/meson-mx-sdhc-mmc.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/meson-mx-sdhc-mmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/meson-mx-sdhc-mmc.c- Extension
.c- Size
- 24499 bytes
- Lines
- 909
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/device.hlinux/dma-mapping.hlinux/interrupt.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/types.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sdio.hlinux/mmc/slot-gpio.hmeson-mx-sdhc.h
Detected Declarations
struct meson_mx_sdhc_datastruct meson_mx_sdhc_hostfunction meson_mx_sdhc_resetfunction meson_mx_sdhc_clear_fifofunction meson_mx_sdhc_wait_cmd_readyfunction meson_mx_sdhc_start_cmdfunction meson_mx_sdhc_disable_clksfunction meson_mx_sdhc_enable_clksfunction meson_mx_sdhc_set_clkfunction meson_mx_sdhc_set_iosfunction meson_mx_sdhc_map_dmafunction meson_mx_sdhc_requestfunction meson_mx_sdhc_card_busyfunction meson_mx_sdhc_tuning_point_matchesfunction meson_mx_sdhc_execute_tuningfunction meson_mx_sdhc_request_donefunction meson_mx_sdhc_read_responsefunction meson_mx_sdhc_irqfunction meson_mx_sdhc_irq_threadfunction meson_mx_sdhc_init_hw_meson8function meson_mx_sdhc_set_pdma_meson8function meson_mx_sdhc_wait_before_send_meson8function meson_mx_sdhc_init_hw_meson8m2function meson_mx_sdhc_set_pdma_meson8m2function meson_mx_sdhc_init_hwfunction meson_mx_sdhc_probefunction meson_mx_sdhc_remove
Annotated Snippet
struct meson_mx_sdhc_data {
void (*init_hw)(struct mmc_host *mmc);
void (*set_pdma)(struct mmc_host *mmc);
void (*wait_before_send)(struct mmc_host *mmc);
bool hardware_flush_all_cmds;
};
struct meson_mx_sdhc_host {
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mmc_command *cmd;
int error;
struct regmap *regmap;
struct clk *pclk;
struct clk *sd_clk;
struct clk_bulk_data bulk_clks[MESON_SDHC_NUM_BULK_CLKS];
bool bulk_clks_enabled;
const struct meson_mx_sdhc_data *platform;
};
static const struct regmap_config meson_mx_sdhc_regmap_config = {
.reg_bits = 8,
.val_bits = 32,
.reg_stride = 4,
.max_register = MESON_SDHC_CLK2,
};
static void meson_mx_sdhc_reset(struct meson_mx_sdhc_host *host)
{
regmap_write(host->regmap, MESON_SDHC_SRST, MESON_SDHC_SRST_MAIN_CTRL |
MESON_SDHC_SRST_RXFIFO | MESON_SDHC_SRST_TXFIFO |
MESON_SDHC_SRST_DPHY_RX | MESON_SDHC_SRST_DPHY_TX |
MESON_SDHC_SRST_DMA_IF);
usleep_range(10, 100);
regmap_write(host->regmap, MESON_SDHC_SRST, 0);
usleep_range(10, 100);
}
static void meson_mx_sdhc_clear_fifo(struct mmc_host *mmc)
{
struct meson_mx_sdhc_host *host = mmc_priv(mmc);
u32 stat;
regmap_read(host->regmap, MESON_SDHC_STAT, &stat);
if (!FIELD_GET(MESON_SDHC_STAT_RXFIFO_CNT, stat) &&
!FIELD_GET(MESON_SDHC_STAT_TXFIFO_CNT, stat))
return;
regmap_write(host->regmap, MESON_SDHC_SRST, MESON_SDHC_SRST_RXFIFO |
MESON_SDHC_SRST_TXFIFO | MESON_SDHC_SRST_MAIN_CTRL);
udelay(5);
regmap_read(host->regmap, MESON_SDHC_STAT, &stat);
if (FIELD_GET(MESON_SDHC_STAT_RXFIFO_CNT, stat) ||
FIELD_GET(MESON_SDHC_STAT_TXFIFO_CNT, stat))
dev_warn(mmc_dev(host->mmc),
"Failed to clear FIFOs, RX: %lu, TX: %lu\n",
FIELD_GET(MESON_SDHC_STAT_RXFIFO_CNT, stat),
FIELD_GET(MESON_SDHC_STAT_TXFIFO_CNT, stat));
}
static void meson_mx_sdhc_wait_cmd_ready(struct mmc_host *mmc)
{
struct meson_mx_sdhc_host *host = mmc_priv(mmc);
u32 stat, esta;
int ret;
ret = regmap_read_poll_timeout(host->regmap, MESON_SDHC_STAT, stat,
!(stat & MESON_SDHC_STAT_CMD_BUSY),
MESON_SDHC_WAIT_CMD_READY_SLEEP_US,
MESON_SDHC_WAIT_CMD_READY_TIMEOUT_US);
if (ret) {
dev_warn(mmc_dev(mmc),
"Failed to poll for CMD_BUSY while processing CMD%d\n",
host->cmd->opcode);
meson_mx_sdhc_reset(host);
}
ret = regmap_read_poll_timeout(host->regmap, MESON_SDHC_ESTA, esta,
!(esta & MESON_SDHC_ESTA_11_13),
MESON_SDHC_WAIT_CMD_READY_SLEEP_US,
MESON_SDHC_WAIT_CMD_READY_TIMEOUT_US);
if (ret) {
dev_warn(mmc_dev(mmc),
"Failed to poll for ESTA[13:11] while processing CMD%d\n",
Annotation
- Immediate include surface: `linux/clk.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct meson_mx_sdhc_data`, `struct meson_mx_sdhc_host`, `function meson_mx_sdhc_reset`, `function meson_mx_sdhc_clear_fifo`, `function meson_mx_sdhc_wait_cmd_ready`, `function meson_mx_sdhc_start_cmd`, `function meson_mx_sdhc_disable_clks`, `function meson_mx_sdhc_enable_clks`, `function meson_mx_sdhc_set_clk`, `function meson_mx_sdhc_set_ios`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: source implementation candidate.
- 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.