drivers/mmc/host/dw_mmc-pltfm.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/dw_mmc-pltfm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/dw_mmc-pltfm.c- Extension
.c- Size
- 3717 bytes
- Lines
- 139
- Domain
- Driver Families
- Bucket
- drivers/mmc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/interrupt.hlinux/module.hlinux/io.hlinux/irq.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/of.hlinux/mfd/altera-sysmgr.hlinux/regmap.hdw_mmc.hdw_mmc-pltfm.h
Detected Declarations
function Copyrightfunction dw_mci_socfpga_priv_initfunction dw_mci_pltfm_probefunction dw_mci_pltfm_removeexport dw_mci_pltfm_registerexport dw_mci_pltfm_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Synopsys DesignWare Multimedia Card Interface driver
*
* Copyright (C) 2009 NXP Semiconductors
* Copyright (C) 2009, 2010 Imagination Technologies Ltd.
*/
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/of.h>
#include <linux/mfd/altera-sysmgr.h>
#include <linux/regmap.h>
#include "dw_mmc.h"
#include "dw_mmc-pltfm.h"
#define SOCFPGA_DW_MMC_CLK_PHASE_STEP 45
#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel, reg_shift) \
((((smplsel) & 0x7) << reg_shift) | (((drvsel) & 0x7) << 0))
int dw_mci_pltfm_register(struct platform_device *pdev,
const struct dw_mci_drv_data *drv_data)
{
struct dw_mci *host;
struct resource *regs;
host = dw_mci_alloc_host(&pdev->dev);
if (IS_ERR(host))
return PTR_ERR(host);
host->irq = platform_get_irq(pdev, 0);
if (host->irq < 0)
return host->irq;
host->drv_data = drv_data;
host->irq_flags = 0;
host->regs = devm_platform_get_and_ioremap_resource(pdev, 0, ®s);
if (IS_ERR(host->regs))
return PTR_ERR(host->regs);
/* Get registers' physical base address */
host->phy_regs = regs->start;
platform_set_drvdata(pdev, host);
return dw_mci_probe(host);
}
EXPORT_SYMBOL_GPL(dw_mci_pltfm_register);
static int dw_mci_socfpga_priv_init(struct dw_mci *host)
{
struct device_node *np = host->dev->of_node;
struct mmc_clk_phase phase;
struct regmap *sys_mgr_base_addr;
u32 reg_offset, reg_shift;
int hs_timing;
phase = host->phase_map.phase[MMC_TIMING_SD_HS];
if (!phase.valid)
return 0;
sys_mgr_base_addr = altr_sysmgr_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon");
if (IS_ERR(sys_mgr_base_addr)) {
dev_warn(host->dev, "clk-phase-sd-hs was specified, but failed to find altr,sys-mgr regmap!\n");
return 0;
}
of_property_read_u32_index(np, "altr,sysmgr-syscon", 1, ®_offset);
of_property_read_u32_index(np, "altr,sysmgr-syscon", 2, ®_shift);
phase.in_deg /= SOCFPGA_DW_MMC_CLK_PHASE_STEP;
phase.out_deg /= SOCFPGA_DW_MMC_CLK_PHASE_STEP;
hs_timing = SYSMGR_SDMMC_CTRL_SET(phase.in_deg, phase.out_deg, reg_shift);
regmap_write(sys_mgr_base_addr, reg_offset, hs_timing);
return 0;
}
static const struct dw_mci_drv_data socfpga_drv_data = {
.init = dw_mci_socfpga_priv_init,
Annotation
- Immediate include surface: `linux/err.h`, `linux/interrupt.h`, `linux/module.h`, `linux/io.h`, `linux/irq.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/slab.h`.
- Detected declarations: `function Copyright`, `function dw_mci_socfpga_priv_init`, `function dw_mci_pltfm_probe`, `function dw_mci_pltfm_remove`, `export dw_mci_pltfm_register`, `export dw_mci_pltfm_remove`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: integration 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.