drivers/ufs/host/ti-j721e-ufs.c
Source file repositories/reference/linux-study-clean/drivers/ufs/host/ti-j721e-ufs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ufs/host/ti-j721e-ufs.c- Extension
.c- Size
- 2680 bytes
- Lines
- 118
- Domain
- Driver Families
- Bucket
- drivers/ufs
- 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/clk.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.h
Detected Declarations
struct ti_j721e_ufsfunction ti_j721e_ufs_probefunction ti_j721e_ufs_removefunction ti_j721e_ufs_resume
Annotated Snippet
struct ti_j721e_ufs {
void __iomem *regbase;
u32 reg;
};
static int ti_j721e_ufs_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct ti_j721e_ufs *ufs;
unsigned long clk_rate;
struct clk *clk;
int ret;
ufs = devm_kzalloc(dev, sizeof(*ufs), GFP_KERNEL);
if (!ufs)
return -ENOMEM;
ufs->regbase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ufs->regbase))
return PTR_ERR(ufs->regbase);
pm_runtime_enable(dev);
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
goto disable_pm;
/* Select MPHY refclk frequency */
clk = devm_clk_get(dev, NULL);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
dev_err(dev, "Cannot claim MPHY clock.\n");
goto clk_err;
}
clk_rate = clk_get_rate(clk);
if (clk_rate == 26000000)
ufs->reg |= TI_UFS_SS_CLK_26MHZ;
devm_clk_put(dev, clk);
/* Take UFS slave device out of reset */
ufs->reg |= TI_UFS_SS_RST_N_PCS;
writel(ufs->reg, ufs->regbase + TI_UFS_SS_CTRL);
dev_set_drvdata(dev, ufs);
ret = of_platform_populate(pdev->dev.of_node, NULL, NULL,
dev);
if (ret) {
dev_err(dev, "failed to populate child nodes %d\n", ret);
goto clk_err;
}
return ret;
clk_err:
pm_runtime_put_sync(dev);
disable_pm:
pm_runtime_disable(dev);
return ret;
}
static void ti_j721e_ufs_remove(struct platform_device *pdev)
{
of_platform_depopulate(&pdev->dev);
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
static int ti_j721e_ufs_resume(struct device *dev)
{
struct ti_j721e_ufs *ufs = dev_get_drvdata(dev);
writel(ufs->reg, ufs->regbase + TI_UFS_SS_CTRL);
return 0;
}
static DEFINE_SIMPLE_DEV_PM_OPS(ti_j721e_ufs_pm_ops, NULL, ti_j721e_ufs_resume);
static const struct of_device_id ti_j721e_ufs_of_match[] = {
{
.compatible = "ti,j721e-ufs",
},
{ },
};
MODULE_DEVICE_TABLE(of, ti_j721e_ufs_of_match);
static struct platform_driver ti_j721e_ufs_driver = {
.probe = ti_j721e_ufs_probe,
.remove = ti_j721e_ufs_remove,
.driver = {
Annotation
- Immediate include surface: `linux/clk.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct ti_j721e_ufs`, `function ti_j721e_ufs_probe`, `function ti_j721e_ufs_remove`, `function ti_j721e_ufs_resume`.
- Atlas domain: Driver Families / drivers/ufs.
- 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.