drivers/mmc/host/sdhci-esdhc-mcf.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/sdhci-esdhc-mcf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/sdhci-esdhc-mcf.c- Extension
.c- Size
- 12353 bytes
- Lines
- 512
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/delay.hlinux/platform_data/mmc-esdhc-mcf.hlinux/mmc/mmc.hsdhci-pltfm.hsdhci-esdhc.h
Detected Declarations
struct pltfm_mcf_datafunction esdhc_mcf_buffer_swap32function esdhc_clrset_befunction esdhc_mcf_writeb_befunction esdhc_mcf_writew_befunction esdhc_mcf_writel_befunction esdhc_mcf_readb_befunction esdhc_mcf_readw_befunction esdhc_mcf_readl_befunction esdhc_mcf_get_max_timeout_countfunction esdhc_mcf_set_timeoutfunction esdhc_mcf_resetfunction esdhc_mcf_pltfm_get_max_clockfunction esdhc_mcf_pltfm_get_min_clockfunction esdhc_mcf_pltfm_set_clockfunction esdhc_mcf_pltfm_set_bus_widthfunction esdhc_mcf_request_donefunction esdhc_mcf_copy_to_bounce_bufferfunction esdhc_mcf_plat_initfunction sdhci_esdhc_mcf_probefunction sdhci_esdhc_mcf_remove
Annotated Snippet
struct pltfm_mcf_data {
struct clk *clk_ipg;
struct clk *clk_ahb;
struct clk *clk_per;
int aside;
int current_bus_width;
};
static inline void esdhc_mcf_buffer_swap32(u32 *buf, int len)
{
int i;
u32 temp;
len = (len + 3) >> 2;
for (i = 0; i < len; i++) {
temp = swab32(*buf);
*buf++ = temp;
}
}
static inline void esdhc_clrset_be(struct sdhci_host *host,
u32 mask, u32 val, int reg)
{
void __iomem *base = host->ioaddr + (reg & ~3);
u8 shift = (reg & 3) << 3;
mask <<= shift;
val <<= shift;
if (reg == SDHCI_HOST_CONTROL)
val |= ESDHC_PROCTL_D3CD;
writel((readl(base) & ~mask) | val, base);
}
/*
* Note: mcf is big-endian, single bytes need to be accessed at big endian
* offsets.
*/
static void esdhc_mcf_writeb_be(struct sdhci_host *host, u8 val, int reg)
{
void __iomem *base = host->ioaddr + (reg & ~3);
u8 shift = (reg & 3) << 3;
u32 mask = ~(0xff << shift);
if (reg == SDHCI_HOST_CONTROL) {
u32 host_ctrl = ESDHC_DEFAULT_HOST_CONTROL;
u8 dma_bits = (val & SDHCI_CTRL_DMA_MASK) >> 3;
u8 tmp = readb(host->ioaddr + SDHCI_HOST_CONTROL + 1);
tmp &= ~0x03;
tmp |= dma_bits;
/*
* Recomposition needed, restore always endianness and
* keep D3CD and AI, just setting bus width.
*/
host_ctrl |= val;
host_ctrl |= (dma_bits << 8);
writel(host_ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
return;
}
writel((readl(base) & mask) | (val << shift), base);
}
static void esdhc_mcf_writew_be(struct sdhci_host *host, u16 val, int reg)
{
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct pltfm_mcf_data *mcf_data = sdhci_pltfm_priv(pltfm_host);
void __iomem *base = host->ioaddr + (reg & ~3);
u8 shift = (reg & 3) << 3;
u32 mask = ~(0xffff << shift);
switch (reg) {
case SDHCI_TRANSFER_MODE:
mcf_data->aside = val;
return;
case SDHCI_COMMAND:
if (host->cmd->opcode == MMC_STOP_TRANSMISSION)
val |= SDHCI_CMD_ABORTCMD;
/*
* As for the fsl driver,
* we have to set the mode in a single write here.
*/
writel(val << 16 | mcf_data->aside,
host->ioaddr + SDHCI_TRANSFER_MODE);
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/platform_data/mmc-esdhc-mcf.h`, `linux/mmc/mmc.h`, `sdhci-pltfm.h`, `sdhci-esdhc.h`.
- Detected declarations: `struct pltfm_mcf_data`, `function esdhc_mcf_buffer_swap32`, `function esdhc_clrset_be`, `function esdhc_mcf_writeb_be`, `function esdhc_mcf_writew_be`, `function esdhc_mcf_writel_be`, `function esdhc_mcf_readb_be`, `function esdhc_mcf_readw_be`, `function esdhc_mcf_readl_be`, `function esdhc_mcf_get_max_timeout_count`.
- 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.