drivers/mfd/atmel-hlcdc.c
Source file repositories/reference/linux-study-clean/drivers/mfd/atmel-hlcdc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/atmel-hlcdc.c- Extension
.c- Size
- 4324 bytes
- Lines
- 170
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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/iopoll.hlinux/mfd/atmel-hlcdc.hlinux/mfd/core.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct atmel_hlcdc_regmapfunction regmap_atmel_hlcdc_reg_writefunction regmap_atmel_hlcdc_reg_readfunction atmel_hlcdc_probe
Annotated Snippet
struct atmel_hlcdc_regmap {
void __iomem *regs;
struct device *dev;
};
static const struct mfd_cell atmel_hlcdc_cells[] = {
{
.name = "atmel-hlcdc-pwm",
.of_compatible = "atmel,hlcdc-pwm",
},
{
.name = "atmel-hlcdc-dc",
.of_compatible = "atmel,hlcdc-display-controller",
},
};
static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg,
unsigned int val)
{
struct atmel_hlcdc_regmap *hregmap = context;
if (reg <= ATMEL_HLCDC_DIS) {
u32 status;
int ret;
ret = readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
status,
!(status & ATMEL_HLCDC_SIP),
1, 100);
if (ret) {
dev_err(hregmap->dev,
"Timeout! Clock domain synchronization is in progress!\n");
return ret;
}
}
writel(val, hregmap->regs + reg);
return 0;
}
static int regmap_atmel_hlcdc_reg_read(void *context, unsigned int reg,
unsigned int *val)
{
struct atmel_hlcdc_regmap *hregmap = context;
*val = readl(hregmap->regs + reg);
return 0;
}
static const struct regmap_config atmel_hlcdc_regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
.max_register = ATMEL_HLCDC_REG_MAX,
.reg_write = regmap_atmel_hlcdc_reg_write,
.reg_read = regmap_atmel_hlcdc_reg_read,
.fast_io = true,
};
static int atmel_hlcdc_probe(struct platform_device *pdev)
{
struct atmel_hlcdc_regmap *hregmap;
struct device *dev = &pdev->dev;
struct atmel_hlcdc *hlcdc;
hregmap = devm_kzalloc(dev, sizeof(*hregmap), GFP_KERNEL);
if (!hregmap)
return -ENOMEM;
hlcdc = devm_kzalloc(dev, sizeof(*hlcdc), GFP_KERNEL);
if (!hlcdc)
return -ENOMEM;
hregmap->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(hregmap->regs))
return PTR_ERR(hregmap->regs);
hregmap->dev = &pdev->dev;
hlcdc->irq = platform_get_irq(pdev, 0);
if (hlcdc->irq < 0)
return hlcdc->irq;
hlcdc->periph_clk = devm_clk_get(dev, "periph_clk");
if (IS_ERR(hlcdc->periph_clk)) {
dev_err(dev, "failed to get peripheral clock\n");
return PTR_ERR(hlcdc->periph_clk);
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/iopoll.h`, `linux/mfd/atmel-hlcdc.h`, `linux/mfd/core.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct atmel_hlcdc_regmap`, `function regmap_atmel_hlcdc_reg_write`, `function regmap_atmel_hlcdc_reg_read`, `function atmel_hlcdc_probe`.
- Atlas domain: Driver Families / drivers/mfd.
- 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.