drivers/mmc/host/meson-mx-sdio.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/meson-mx-sdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/meson-mx-sdio.c- Extension
.c- Size
- 21596 bytes
- Lines
- 771
- 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.
- 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/bitfield.hlinux/clk.hlinux/clk-provider.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/module.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/platform_device.hlinux/of_platform.hlinux/regmap.hlinux/timer.hlinux/types.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sdio.hlinux/mmc/slot-gpio.h
Detected Declarations
struct meson_mx_mmc_host_clkcstruct meson_mx_mmc_hostfunction meson_mx_mmc_soft_resetfunction meson_mx_mmc_start_cmdfunction meson_mx_mmc_request_donefunction meson_mx_mmc_set_iosfunction meson_mx_mmc_map_dmafunction meson_mx_mmc_requestfunction meson_mx_mmc_read_responsefunction meson_mx_mmc_process_cmd_irqfunction meson_mx_mmc_irqfunction meson_mx_mmc_irq_threadfunction meson_mx_mmc_timeoutfunction for_each_available_child_of_node_scopedfunction meson_mx_mmc_add_hostfunction meson_mx_mmc_probefunction meson_mx_mmc_remove
Annotated Snippet
struct meson_mx_mmc_host_clkc {
struct clk_divider cfg_div;
struct clk_fixed_factor fixed_div2;
};
struct meson_mx_mmc_host {
struct device *controller_dev;
struct clk *cfg_div_clk;
struct regmap *regmap;
int irq;
spinlock_t irq_lock;
struct timer_list cmd_timeout;
unsigned int slot_id;
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mmc_command *cmd;
int error;
};
static void meson_mx_mmc_soft_reset(struct meson_mx_mmc_host *host)
{
regmap_write(host->regmap, MESON_MX_SDIO_IRQC,
MESON_MX_SDIO_IRQC_SOFT_RESET);
udelay(2);
}
static struct mmc_command *meson_mx_mmc_get_next_cmd(struct mmc_command *cmd)
{
if (cmd->opcode == MMC_SET_BLOCK_COUNT && !cmd->error)
return cmd->mrq->cmd;
else if (mmc_op_multi(cmd->opcode) &&
(!cmd->mrq->sbc || cmd->error || cmd->data->error))
return cmd->mrq->stop;
else
return NULL;
}
static void meson_mx_mmc_start_cmd(struct mmc_host *mmc,
struct mmc_command *cmd)
{
struct meson_mx_mmc_host *host = mmc_priv(mmc);
unsigned int pack_size;
unsigned long irqflags, timeout;
u32 send = 0, ext = 0;
host->cmd = cmd;
if (cmd->busy_timeout)
timeout = msecs_to_jiffies(cmd->busy_timeout);
else
timeout = msecs_to_jiffies(1000);
switch (mmc_resp_type(cmd)) {
case MMC_RSP_R1:
case MMC_RSP_R1B:
case MMC_RSP_R3:
/* 7 (CMD) + 32 (response) + 7 (CRC) -1 */
send |= FIELD_PREP(MESON_MX_SDIO_SEND_CMD_RESP_BITS_MASK, 45);
break;
case MMC_RSP_R2:
/* 7 (CMD) + 120 (response) + 7 (CRC) -1 */
send |= FIELD_PREP(MESON_MX_SDIO_SEND_CMD_RESP_BITS_MASK, 133);
send |= MESON_MX_SDIO_SEND_RESP_CRC7_FROM_8;
break;
default:
break;
}
if (!(cmd->flags & MMC_RSP_CRC))
send |= MESON_MX_SDIO_SEND_RESP_WITHOUT_CRC7;
if (cmd->flags & MMC_RSP_BUSY)
send |= MESON_MX_SDIO_SEND_CHECK_DAT0_BUSY;
if (cmd->data) {
send |= FIELD_PREP(MESON_MX_SDIO_SEND_REPEAT_PACKAGE_TIMES_MASK,
(cmd->data->blocks - 1));
pack_size = cmd->data->blksz * BITS_PER_BYTE;
if (mmc->ios.bus_width == MMC_BUS_WIDTH_4)
pack_size += MESON_MX_SDIO_RESPONSE_CRC16_BITS * 4;
else
pack_size += MESON_MX_SDIO_RESPONSE_CRC16_BITS * 1;
ext |= FIELD_PREP(MESON_MX_SDIO_EXT_DATA_RW_NUMBER_MASK,
pack_size);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/module.h`, `linux/interrupt.h`.
- Detected declarations: `struct meson_mx_mmc_host_clkc`, `struct meson_mx_mmc_host`, `function meson_mx_mmc_soft_reset`, `function meson_mx_mmc_start_cmd`, `function meson_mx_mmc_request_done`, `function meson_mx_mmc_set_ios`, `function meson_mx_mmc_map_dma`, `function meson_mx_mmc_request`, `function meson_mx_mmc_read_response`, `function meson_mx_mmc_process_cmd_irq`.
- 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.
- 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.